Skip to content

Tokens

Tokenize a credit card.

POST /v2/token/card

Sample

json
POST /v2/token/card
{
  "nameOnCard": "Sandbox Test Card",
  "cardNumber": "5200000000000007",
  "expiryMonth": 9,
  "expiryYear": 2022
}

Auth: Access token (Bearer).

Request body

FieldTypeRequiredDescription
cardNumberstringYesThe full primary account number (PAN) of the card to be tokenized.
nameOnCardstringYesThe cardholder name as it appears on the card.
expiryMonth1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12YesThe month in which the card expires.
expiryYearintegerYesThe four-digit expiry year (e.g. 2027).
json
{
  "cardNumber": "string",
  "nameOnCard": "string",
  "expiryMonth": 1,
  "expiryYear": 0
}

Responses

StatusDescription
200The request was successful and the card was tokenized.
400The request failed validation, the error object will contain further information.
401The authorization information provided is not valid, authentication is required to access this resource.
403The authorization header does not contain the correct type or you do not have access to this resource.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
resultobjectNoA model to hold the details of a card response that is returned to a caller when they tokenize a card or verify a tokenized card.
json
{
  "success": true,
  "result": {
    "token": "string",
    "requiresPayment": true,
    "requiresVerification": true,
    "verificationAttemptsRemaining": 0,
    "paymentCurrency": "None",
    "paymentAmountInCents": 0
  }
}

Code samples

ts
// @vantagepay/vantagepay
const cardToken = await client.payments.createCardToken({
  cardNumber: '5200000000000114',
  nameOnCard: 'Jane Doe',
  expiryMonth: 9,
  expiryYear: 2028,
})
csharp
// VantagePay.SDK
using VantagePay.Models.Lookups;
using VantagePay.Models.Tokens;

var cardToken = await client.Payments.CreateCardTokenAsync(new CardRequest
{
    CardNumber = "5200000000000114",
    NameOnCard = "Jane Doe",
    ExpiryMonth = Month.September,
    ExpiryYear = 2028,
});

Tokenize a bank account.

POST /v2/token/bank-account

Sample

json
POST /v2/token/bank-account
{
  "accountNumber": "1111000333777888",
  "bank": "ADB"
}

Auth: Access token (Bearer).

Request body

FieldTypeRequiredDescription
accountNumberstringYesThe bank account number to tokenize.
bankone of 106 values (e.g. None, ABD, ACB, ...)YesThe bank at which the account is held.
json
{
  "accountNumber": "string",
  "bank": "None"
}

Responses

StatusDescription
200The request was successful and the bank account was tokenized.
400The request failed validation, the error object will contain further information.
401The authorization information provided is not valid, authentication is required to access this resource.
403The authorization header does not contain the correct type or you do not have access to this resource.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
resultobjectNoThe result of a bank account tokenization request, containing the token that represents the account for future use.
json
{
  "success": true,
  "result": {
    "token": "string"
  }
}

Code samples

ts
// @vantagepay/vantagepay
// Tokenizes a bank account. Not wrapped by the JavaScript SDK.
// Not wrapped by the JavaScript SDK - call the endpoint directly with the active token.
const response = await fetch(baseUrl + '/v2/token/bank-account', {
  method: 'POST',
  headers: { Authorization: 'Bearer ' + ApiTokens.accessToken },
})
const result = await response.json()
csharp
// VantagePay.SDK
using VantagePay.Models.Lookups;
using VantagePay.Models.Tokens;

var bankToken = await client.Payments.CreateBankAccountTokenAsync(new BankAccountRequest
{
    AccountNumber = "1234567890",
    Bank = Bank.GCB,
});

Activate a card token.

POST /v2/token/card/activate/{cardToken}

Sample

json
POST /v2/token/card/activate/FF5B3EF7CCDE40A4911CAE63ABF2416537FB49DEF0B14E2B8BFAB59B7F43A15E

Auth: Access token (Bearer).

Parameters

NameInRequiredDescription
cardTokenpathYesThe card token to be activated.

Responses

StatusDescription
200The request was successful and the card token was activated.
400The request failed validation, the error object will contain further information.
401The authorization information provided is not valid, authentication is required to access this resource.
403The authorization header does not contain the correct type or you do not have access to this resource.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
json
{
  "success": true
}

Code samples

ts
// @vantagepay/vantagepay
// Activates a card token. Not wrapped by the JavaScript SDK.
// Not wrapped by the JavaScript SDK - call the endpoint directly with the active token.
const response = await fetch(baseUrl + '/v2/token/card/activate/' + cardToken, {
  method: 'POST',
  headers: { Authorization: 'Bearer ' + ApiTokens.accessToken },
})
const result = await response.json()
csharp
// VantagePay.SDK
await client.Payments.ActivateCardTokenAsync(cardToken);

Verify a card with a verification code obtained from the credit card statement.

POST /v2/token/card/verify

Sample

json
POST /v2/token/card/verify
{
  "token": "FF5B3EF7CCDE40A4911CAE63ABF2416537FB49DEF0B14E2B8BFAB59B7F43A15E",
  "verificationCode": "VC-1534"
}

Auth: Access token (Bearer).

Request body

FieldTypeRequiredDescription
tokenstring?NoA card token.
verificationCodestringYesThe verification code that appeared on the credit card statement after the verification test payment was made.
json
{
  "token": "string",
  "verificationCode": "string"
}

Responses

StatusDescription
200A verification attempt was successfully made.
400The request failed validation, the error object will contain further information.
401The authorization information provided is not valid, authentication is required to access this resource.
403The authorization header does not contain the correct type or you do not have access to this resource.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
resultobjectNoA model to hold the details of a card response that is returned to a caller when they tokenize a card or verify a tokenized card.
json
{
  "success": true,
  "result": {
    "token": "string",
    "requiresPayment": true,
    "requiresVerification": true,
    "verificationAttemptsRemaining": 0,
    "paymentCurrency": "None",
    "paymentAmountInCents": 0
  }
}

Code samples

ts
// @vantagepay/vantagepay
const card = await client.payments.verifyCardToken({ token: cardToken, verificationCode: '123' })
csharp
// VantagePay.SDK
using VantagePay.Models.Tokens;

var card = await client.Payments.VerifyCardTokenAsync(new VerifyCardRequest { Token = cardToken, VerificationCode = "123" });

Initiate a test payment to verify the ownership of a credit card.

POST /v2/token/card/verify/payment

Sample

json
POST /v2/token/card/verify/payment
{
  "yourReference": "{{$guid}}",
  "token": "FF5B3EF7CCDE40A4911CAE63ABF2416537FB49DEF0B14E2B8BFAB59B7F43A15E",
  "cvv": 123,
  "cardHolder": {
    "firstName": "John",
    "lastName": "Wick",
    "emailAddress": "demo@vantagepay.com",
    "phoneNumber": "233111222333",
    "countryIsoCode": "GHA"
   }
}

Auth: Access token (Bearer).

Request body

FieldTypeRequiredDescription
yourReferencestring?NoAn external reference supplied by the caller.
consumerobjectNoCore identity and contact details for a consumer (end user).
tokenstringYesA card token.
cvvstring?NoThe CVV for the card.
billingAddressobjectNoA physical address associated with a consumer, merchant, or other entity.
cardHolderobjectNoContact and billing details for the card holder, required by card-present and online card payment processors.
locationobjectNoA geographic coordinate with an optional time zone and description. Used to pin an address or entity on a map.
paymentStatusWebhookobjectNoA model to hold the details of a web hook that a caller of this API would like to be called back on.
json
{
  "yourReference": "string",
  "consumer": {
    "reference": "00000000-0000-0000-0000-000000000000",
    "yourReference": "string",
    "source": "string",
    "userReference": "00000000-0000-0000-0000-000000000000",
    "firstName": "string",
    "lastName": "string",
    "middleName": "string",
    "emailAddress": "string",
    "mobileNumber": "string",
    "countryIsoCode": "None",
    "dateOfBirth": "string",
    "gender": "Male",
    "preferredLanguage": "None",
    "kycStatusSummary": "Unverified",
    "isActive": true
  },
  "token": "string",
  "cvv": "string",
  "billingAddress": {
    "reference": "00000000-0000-0000-0000-000000000000",
    "yourReference": "string",
    "addressType": "MAIN",
    "addressLine1": "string",
    "addressLine2": "string",
    "addressLine3": "string",
    "postalCode": "string",
    "countryIsoCode": "None",
    "city": "string",
    "state": "string",
    "location": {},
    "description": "string",
    "formatted": "string",
    "isActive": true
  },
  "cardHolder": {
    "firstName": "string",
    "lastName": "string",
    "emailAddress": "string",
    "phoneNumber": "string",
    "countryIsoCode": "None",
    "shippingAddress": {}
  },
  "location": {
    "latitude": 0,
    "longitude": 0,
    "timeZone": "string",
    "description": "string"
  },
  "paymentStatusWebhook": {
    "callbackUrl": "string",
    "onPaymentCompleteOnly": true
  }
}

Responses

StatusDescription
200The request to initiate a card verification test payment was accepted and processed successfully.
202The request was successful but does not return any results.
400The request failed validation, the error object will contain further information.
401The authorization information provided is not valid, authentication is required to access this resource.
403The authorization header does not contain the correct type or you do not have access to this resource.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
resultobjectNoModel to hold details of a response to a payment request.
json
{
  "success": true,
  "result": {
    "reference": "00000000-0000-0000-0000-000000000000",
    "paymentStatusUrls": {}
  }
}

Code samples

ts
// @vantagepay/vantagepay
const status = await client.payments.createCardVerificationPayment({ token: cardToken, cvv: '123' })
csharp
// VantagePay.SDK
using VantagePay.Models.Payments.Requests;

var status = await client.Payments.CreateCardVerificationPaymentAsync(new CardVerificationPaymentRequest
{
    Token = cardToken,
    Cvv = "123",
});

Payments for Africa