Menu

Creating a token

Creating a Token

Example Card Token Request

Copied!
curl https://api.worldpay.com/v1/tokens 
-H "Content-type: application/json" 
-X POST 
-d '{
    "reusable": true/false,
    "paymentMethod": {
        "name": "name",
        "expiryMonth": 2,
        "expiryYear": 2015,
        "issueNumber": 1,
        "startMonth": 2,
        "startYear": 2013,
        "cardNumber": "4444 3333 2222 1111",
        "type": "Card",
        "cvc": "123"
    },
    "clientKey": "T_C_client_key"
}'

Example Card Token Response

Copied!
{
    "token": "UUID of token",
    "reusable": true/false,
    "paymentMethod": {
        "type" : "ObfuscatedCard",        "name": "name",
        "expiryMonth": 2,
        "expiryYear": 2015,
        "issueNumber": 1,
        "startMonth": 2,
        "startYear": 2013,
        "cardType": "VISA_CREDIT",
        "maskedCardNumber": "xxxx xxxx xxxx 1111",
        "cardSchemeType": "consumer",
        "cardSchemeName": "VISA CREDIT",
        "cardProductTypeDescNonContactless": "Visa Credit Personal",
        "cardProductTypeDescContactless": "CL Visa Credit Pers",
        "cardIssuer": "LLOYDS BANK PLC",
        "countryCode": "GBR",
        "cardClass": "credit",
        "prepaid": "false"
    }
}

Example APM Token Request

Copied!
curl https://api.worldpay.com/v1/tokens 
-H "Content-type: application/json" 
-X POST 
-d '{
    "paymentMethod": {
        "type": "APM",
        "apmName": "apm-identifier",
        "shopperCountryCode": "GB",
        "apmFields": {
          "attribute1": "value1"
        }
    },    "reusable": true/false,
    "shopperLanguageCode": "en",
    "clientKey": "T_C_client_key"
}

Example APM Token Response

Copied!
{
    "token": "UUID of token",
    "paymentMethod": {
        "type": "APM",
        "apmName": "apm-identifier",
        "shopperCountryCode": "GB",
        "apmFields": {
          "attribute1": "value1"
        }
    },
    "reusable": true/false,
    "shopperLanguageCode": "en"
}

Note: In most cases do not invoke this API directly. Create your Card token using theCard Token Templateform or by ouriOSorAndroidlibraries when using mobile apps. You should only call this API directly if you need to obtain sensitive card details and your e-commerce platform is appropriatelyPCI compliant.

Create a new token through a POST on the Tokens API, specifying paymentMethod's type as Card.

Creating a World / Alternative Payment Method (WPM/APM) Token

Create a new token through a POST on the Tokens API, specifying paymentMethod's type as APM.

Additionally you must specify paymentMethod's apmName and the shopperCountryCode, or define defaults in your Order Settings page.

Test and Live tokens

Live tokens are created using theLive Client Keyand test tokens are created using theTest Client Key. When using yourLive Client Key, any card number will be accepted for Card tokens. When using yourTest Client Key, only a specific set oftest card numberswill be accepted.