Skip to main content
Version: v2.0.4 latest

Tokenization Reference

Every tokenization request uses the Basic Auth or Signature-based authentication and the X-Terminal-Id header, like all Payment Gateway API calls.

Endpoints​

OperationMethod and pathGuide
Save a card (tokenize)POST /api/v1/paymentEnable & Save a Card
Pay with a saved tokenPOST /api/v1/paymentPay with a Saved Token
Block a tokenPOST /api/v1/token/{token}/blockBlock a Token

Request fields​

These fields are added to the standard Create Payment request body, except token, which is a path parameter of the block call.

FieldTypeUsed inDescription
needPaymentTokenbooleanSave a cardSet to true to ask the Payment Gateway to generate a payment token (a reusable reference to the payer's card) from this operation. It must be true when nonPaymentOperation is true.
tokenTypestringSave a card The type of token requested, in descending order of capability: AUTH - an authenticated token that can be used for any operation, including recurring payments. NON_RECUR - an authenticated token that can be used for any operation except recurring payments. UNAUTH - an unauthenticated token that can only be used in operations where the payer authenticates. You never receive a more capable token than the one you request, but you can receive a less capable one depending on how the payer was authenticated, so always check the type of the returned token.
nonPaymentOperationbooleanSave a card without a chargeSet to true to save (tokenize) the payer's card without charging it. The operation is processed as a 0 IQD payment, so amount must not be sent, and needPaymentToken must be true.
recurrentbooleanPay with a tokenSet to true when you charge a saved token as a recurring, merchant-initiated payment (for example a subscription renewal) without the payer present. Recurring payments require an AUTH token. Omit it or set it to false for payments the payer starts.
paymentDataobjectPay with a tokenThe payment method to use. To charge a saved card, set paymentType to PAYMENT_TOKEN and paymentToken to the token value.
paymentData.paymentTypestringPay with a tokenThe payment method. Use PAYMENT_TOKEN to pay with a previously saved token.
paymentData.paymentTokenstringPay with a tokenThe token value you received when the payer's card was tokenized. Maximum 100 characters.
token (path)stringBlock a tokenThe payment token to block: the same value you send as paymentData.paymentToken when paying with the token.

Token types​

Token typeAuthenticatedCustomer-initiated paymentsRecurring payments (recurrent: true)
AUTHYesYesYes
NON_RECURYesYesNo
UNAUTHNoYes, the customer must authenticate each paymentNo

The token you receive is never more capable than the tokenType you request, but it can be less capable, depending on how the customer was authenticated. Always check paymentToken.type.

The paymentToken object​

After a successful tokenization, the payment object sent to your notificationUrl and returned by Get Payment Status includes a paymentToken object:

"paymentToken": {
"token": "48b85aa5-e7a6-5ccc-9466-703472aa7541",
"type": "AUTH",
"validTo": "2032-01-31",
"blocked": false
}
FieldTypeDescription
tokenstringThe token value. Store it against your customer and send it as paymentData.paymentToken to charge the card later.
typestringThe type of the issued token: AUTH, NON_RECUR or UNAUTH. It can be lower than the tokenType you requested, so check it before using the token.
validTostringThe date until which the token can be used.
blockedbooleantrue if the token has been blocked and can no longer be used for payments.

Token error codes​

When a token request fails, the response's error object contains one of the standard API Error Codes. These codes are specific to tokens:

CodeError nameWhat to check
31TOKEN_NOT_FOUNDThe gateway has no token with this value. Send the token exactly as you received it in paymentToken.token, to the same terminal and environment (sandbox or production) that issued it.
32TOKEN_PROCESS_NOT_ALLOWEDThe token's type does not allow this operation, for example a recurring payment (recurrent: true) with a token that is not AUTH. Check paymentToken.type before you charge a token.
35INVALID_TOKEN_TYPEThe tokenType value is not one of AUTH, NON_RECUR, or UNAUTH. Check the spelling and use upper case.
Terminal permissions

If tokenization requests fail even though the request matches this guide, check with the Payment Gateway team that tokenization is enabled on your terminal. See Step 1 — Enable tokenization on your terminal.