# Create a Virtual Card to pay an invoice
source: https://developer.mastercard.com/iccp/documentation/03_use-cases/create-a-virtual-card-for-a-b2b-payment/index.md

> A corporate buyer creates virtual card numbers (VCN) to make invoice payments and to cover ad-hoc business expenses.

## Scenario {#scenario}

A company has an accounts payable function that needs to make fast, secure payments on invoices, whether for the received goods or for the incurred expenses. They want to take advantage of an early payment discount available from suppliers, while availing of the credit benefits of card payments.

Using the ICCP API, a company can dynamically generate a virtual credit card for each payment. The buyer can set controls on each virtual card created to ensure that it's used only for that payment amount and the purpose it was intended.

## Onboarding {#onboarding}

Before using the ICCP API, an administrator will configure the company, funding cards and templates from which virtual cards will be created.

## Process to Generate Virtual Card {#process-to-generate-virtual-card}

Once your administrator completes the preliminary steps, you can perform the following sequence of activities to create a virtual card and make a payment:

### 1. Determine Resources to Use {#1-determine-resources-to-use}

Use the ICCP API to find the resources available to be used in creating VCNs.

The sequence of API calls to collect resource information is as follows:

1. Call [getRealCards](https://developer.mastercard.com/iccp/documentation/05_api_reference/soap_api/configuration-details/getrealcards/index.md) to get real card details, which funds the virtual card payments.
2. Call [getCompanyPurchaseTemplates](https://developer.mastercard.com/iccp/documentation/05_api_reference/soap_api/configuration-details/getcompanypurchasetemplates/index.md) to get template and spend control details.
3. Call [getSuppliers](https://developer.mastercard.com/iccp/documentation/05_api_reference/soap_api/configuration-details/getsuppliers/index.md) to get a list of suppliers registered in ICCP for virtual card payments.

Diagram UseCaseGatherDetails

### 2. Submit a Purchase Request {#2submit-a-purchase-request}

Capture the payment details in a purchase request, by making a `submit purchase request` call to the ICCP API, which generates a VCN with the spending limits that you set.

To submit a purchase request, follow these steps:

* Select the real card, purchase template and supplier to be used, based on the information gathered in the previous step.
* Specify the controls in the purchase request to apply to the virtual card. For invoice payments, create a single-use virtual card and set the limit equal to the net invoice amount.
* Make a [submitPurchaseRequest](https://developer.mastercard.com/iccp/documentation/05_api_reference/soap_api/purchaserequest/submitpurchaserequest/index.md) call and confirm via the API response that the virtual card is created (steps 1 and 2 in the diagram below). On successful creation, ICCP will pass the VCN details to the Mastercard Network, so that the card will be recognised (step 3 below).
* Optionally, provide the invoice details as additional data in the purchase request (steps 4 and 5 below).
* Optionally, elect to have the VCN details and invoice details automatically sent to the supplier by secure email (step 6 below)

Once you receive a successful response to the API call, the virtual card is live in the network and can be used immediately.

The following diagram shows the information flow:

Diagram UseCaseCreateVCN

### 3. Complete the Payment {#3complete-the-payment}

To complete the payment using the virtual card, proceed as follows:

* If you have configured ICCP to automatically send the virtual card details to the supplier, no further action is needed and the supplier will use those details to request payment.
* If you have not configured automatic sending of card details, you can provide the card and payment details to the supplier via another means of your choosing.
* Alternatively you can make the card payment using a Mastercard's [Straight Through Processing](https://developer.mastercard.com/product/straight-through-processing-stp/) service.
