- Tokenize the card by securely exchanging raw card details for tokens.
- Create the payment using the tokens in place of the card details in your payment request.
Security Benefits of TokenizationSince raw card data never touches your servers, your PCI DSS compliance burden is significantly reduced. Tokens are useless to attackers if intercepted, as they can only be used through Tonder’s secure environment. You can safely store these tokens in your database for recurring payments or “saved card” features.
How Tokenization WorksTonder tokenizes each card field individually (card number, CVV, expiration month, etc.) rather than creating a single token for the entire card. This means you’ll receive separate tokens for each sensitive field, which you then use in place of the original values when making payment requests.
Step 1: Get an Access Token
Before you can use the tokenization service, you must get a short-lived access token using the Get Tokenization Access Token endpoint with your standard Tonder API key. This request obtains a JWT access token required for card tokenization:Request
Request
Make sure to include your Tonder API key in the Authorization header.
Response
Response
The server will respond with a JWT access token, as shown in the example below.
access_token
from the response to authorize your request to the tokenization service in the next step.
Step 2: Tokenize the Card Data
Now, send the raw card details to the Tokenize Card Data endpoint. This request must be authorized with the access token you just obtained and will return individual tokens for each sensitive field. These are the required parameters for the tokenization service:Field | Type | Description |
---|---|---|
card_number | string | The full card number (e.g., “4242424242424242”) |
cardholder_name | string | The name on the card |
cvv | string | Card security code (3-4 digits) |
expiration_month | string | Card expiration month (e.g., “07”) |
expiration_year | string | Card expiration year (e.g., “2025”) |
Request
Request
Include the access token from Step 1 in the authorization header and send the card data in the request body:
Response
Response
The service will respond with a JSON object where each sensitive field has been replaced with a unique individual token. Notice that each original field now contains a separate token value:
Tokenization Response
Each field is tokenized separately. You must use each individual token in the corresponding field when making payment requests. The tokens are not interchangeable between fields.
Due to PCI DSS requirements, your company must share relevant attestation documents with Tonder before we can activate production access to the tokenization endpoint.
Step 3: Create the Payment Using Tokens
Finally, make a standard payment request to the Process Transaction endpoint. In thepayment_method
object, use the individual token values you received from the tokenization service instead of the raw card details.
This request processes the payment using the tokenized card data:
Payment Request
Payment Response
status
field in your response and implement appropriate logic based on the status value received.
The table below details the fields that are returned in the response:
Field | Type | Description |
---|---|---|
id | string | Unique transaction identifier |
operation_type | string | Always "payment" |
status | string | Transaction status |
amount | decimal | Transaction amount |
currency | string | Currency code |
client_reference | string | Your reference identifier |
payment_id | integer | Internal payment ID |
transaction_id | string | Provider transaction ID |
provider | string | Payment provider used |
created_at | string | ISO 8601 timestamp |
status_code | integer | HTTP status code |
next_action | object | Required actions (3DS, redirects) |
Step 4: Check the Transaction Status
For asynchronous payments, or if you need to confirm the final status of any transaction, you can query the transaction status using the Get Transaction Status endpoint with theid
from the payment response:
cURL
success
, failed
, expired
).
Critical: Always validate both
id
and status
fieldsFor proper payment validation, you must check:id
is the unique transaction identifier - store this for future reference.status
is the current payment state - determines next actions.
Next Steps
After successfully tokenizing card data and processing payments:- Try creating payments with 3D Secure for enhanced card security when using tokens.
- Set up webhooks to receive real-time notifications when payment statuses change.