With our API, you can securely store card data with us and receive a token representation of the card. This token can be stored with no increased PCI DSS compliance requirements. Tokens can be used for recurring billing or to enable one-click checkout. You can add, delete, and update stored cards.
This guide focuses on how to store cards (tokenization) and charge them. We also show you how to enable our Payment Method Alias solution in the request.
Before starting the steps in this guide, you must do the following:
We highly recommend processing an authorization or verification against a card before storing it. This allows you to check that the card data provided is valid. For more information, see Transactions and Verifications in the API Explorer.
In this example, we send a request to store a card. For more information, see Payment Methods - Tokenization in the API Explorer.
curl --location --request POST 'https://apis.sandbox.globalpay.com/ucp/payment-methods' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer 19MKWmKalkNz241ECHPH2VTpx9Uc' \
--header 'Accept: application/json' \
--header 'X-GP-Version: 2021-03-22' \
--data-raw '{
"reference": "99388961",
"card": {
"number": "4012001037141112",
"expiry_month": "12",
"expiry_year": "25"
}
}'The id value returned in the response is the token to use to reference the stored card when processing payments. It begins with the three letters PMT_.
{
"id": "PMT_815adaf8-4f8b-43bd-934d-d9fd086897f2",
"time_created": "2021-01-18T12:06:17.227Z",
"status": "ACTIVE",
"merchant_id": "MER_c4c0df11039c48a9b63701adeaa296c3",
"merchant_name": "Sandbox_merchant_2",
"account_id": "TKA_eba30a1b5c4a468d90ceeef2ffff7f5e",
"account_name": "Tokenization",
"reference": "99388961",
"card": {
"masked_number_last4": "XXXXXXXXXXXX1112",
"brand": "VISA",
"expiry_month": "12",
"expiry_year": "25"
},
"action": {
"id": "ACT_KfF9omT2vg3bl8s8uqFsimo2416yv5",
"type": "PAYMENT_METHOD_CREATE",
"time_created": "2021-01-18T12:06:17.227Z",
"result_code": "SUCCESS",
"app_id": "jrYHwMdYRBDGmFwwAVmi5WufYzxuQIQj",
"app_name": "cathal_sandbox"
}
}Creating a transaction from a stored card works the same as a standard authorization, except instead of collecting card data you simply send the id in the payment_method object in the request. We obtain the securely stored card data and build the authorization message.
Under PCI DSS compliance rules, the security code (CVN, CVV) cannot be stored. However, if in your application you let the customer use a card they previously saved, you can prompt them for their security code again. Then include the code in the request.
curl --location --request POST 'https://apis.sandbox.globalpay.com/ucp/transactions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer 19MKWmKalkNz241ECHPH2VTpx9Uc' \
--header 'Accept: application/json' \
--header 'X-GP-Version: 2021-03-22' \
--data-raw '{
"account_name": "Transaction_Processing",
"channel": "CNP",
"type": "SALE",
"amount": "4500",
"currency": "USD",
"reference": "56938151",
"country": "US",
"payment_method": {
"id": "PMT_815adaf8-4f8b-43bd-934d-d9fd086897f2",
"entry_mode": "ECOM"
}
}'With Payment Method Alias, you can link customer data among various payment-processing channels. We provide a unique reference that helps you recognize a customer’s payment interactions no matter where they occur, without exposing sensitive information.
To enable this solution, add the following field to the payment_method object in the sample request for Step 2.
For more information, see Payment Method Alias.
curl --location --request POST 'https://apis.sandbox.globalpay.com/ucp/transactions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer 19MKWmKalkNz241ECHPH2VTpx9Uc' \
--header 'Accept: application/json' \
--header 'X-GP-Version: 2021-03-22' \
--data-raw '{
"account_name": "Transaction_Processing",
"channel": "CNP",
"type": "SALE",
"amount": "4500",
"currency": "USD",
"reference": "56938151",
"country": "US",
"payment_method": {
"id": "PMT_815adaf8-4f8b-43bd-934d-d9fd086897f2",
"entry_mode": "ECOM",
"fingerprint_mode": "ALWAYS"
}
}'