Create a card token
A card token is a unique, single-use code that represents a customer’s credit card details. It securely processes payments without exposing the actual card information.
Tokenization in ecommerce requires encrypting a customer card as a token. Encryption conceals the content of card data to protect it from unauthorized access, while tokenization replaces sensitive data with a non-sensitive equivalent or token. Clover uses this token as the source to process secure payments using the Ecommerce APIs.
Clover supports the following card tokenization services:
- Clover token—Learn more in this topic.
 - TransArmor token—See Use TransArmor tokens with Clover Ecommerce APIs.
 
Prerequisites
- Create a global developer account and select the API checkbox in the Ecommerce Settings.
 - Do one of the following:
- If you are using the tokenization services for a single merchant or to run test scenarios, generate Ecommerce API tokens (public and private keys). Use the keys as follows:
- Public key—Use as the Ecommerce API key or 
apiAccessKeyfor a card, gift card, or ACH tokenization without the need to generate a separate PAKMS key. - Private key—Set as the Bearer token in the Authorization header to use Ecommerce APIs.
 
 - Public key—Use as the Ecommerce API key or 
 - If you are using tokenization services to build an app for multiple businesses, you need to generate OAuth 
access_tokenandrefresh_tokenpair to initiate the OAuth flow. 
 - If you are using the tokenization services for a single merchant or to run test scenarios, generate Ecommerce API tokens (public and private keys). Use the keys as follows:
 
Step 1: Encrypt card data
- Retrieve the public encryption keys from JSON file. These keys generally do not change and should be cached by your application. The endpoint returns:
 
TA_PUBLIC_KEY_DEVfor use in the sandbox environment, andTA_PUBLIC_KEY_PRODfor use in the production environment
{
  "TA_PUBLIC_KEY_DEV": "...",
  "TA_PUBLIC_KEY_PROD": "..."
}
- Do the following to encrypt the card information. See the following code: Java example.
- Parse the Base64 public key string from the JSON file.
 - Get the 
modulusandexponent. - Generate an RSA public key using the 
modulusandexponentvalues. - Prepend the 
prefixvalue to the card number. - Using the public key, encrypt the combined prefix and card number.
 - Base64 encode the resulting encrypted data into a string. This string is optional 
encrypted_panvalue in the/v1/tokensrequest.NOTE
To minimize your app's payment card industry (PCI) compliance burden, use
encrypted_paninstead ofnumberin your POST request. 
 
Step 2: Tokenize encrypted card data
- Use the OAuth API token or 
access_tokento generate an Ecommerce API key (PAKMS key) orapiAccessKey. - Send a POST request to the /v1/tokens endpoint.
 - Enter card-related information in the required fields for the 
cardobject:numberorencrypted_panexp_monthexp_yearcvvlast4first6brand
 - In the 
apikeyheader, enter theapiAccessKeyfrom the PAKMS endpoint. 
The server returns a single-pay token that begins with clv_. Example: clv_1ABCDefgHI23jKL4m5nOPqR. Use this token as the source to  create a charge or pay for an order, accept tips, and save customer cards for future transactions.
Request and Response example—Generate a card token
curl --request POST \
     --url https://token-sandbox.dev.clover.com/v1/tokens \
     --header 'accept: application/json' \
     --header 'apikey: 7aacxxxx-xxxx-xxxx-xxxx-xxxxxxxxcae2' \
     --header 'content-type: application/json' \
     --data '{
       "card": {
         "encrypted_pan": "{encrypted_card_number}",
         "first6": "601136",
         "last4": "6668",
         "exp_month": "12",
         "exp_year": "2035",
         "cvv": "123",
         "brand": "DISCOVER"
       }
     }'
{
  "id": "clv_1ABCDefgHI23jKL4m5nOPqR",
  "object": "token",
  "card": {
    "exp_month": "12",
    "exp_year": "2035",
    "first6": "601136",
    "last4": "6668",
    "brand": "DISCOVER"
  }
}
Test cards
Clover provides several sandbox test cards that you can use when developing your app.
Related topics
Updated 7 months ago
