HMAC Card Token Callback:
Outcome - Understand how to calculate the hmac value for the card token callback
Last Updated Date - November 16, 2026
Step 1: Sort the Data Lexicographically by Key
Sort the parameters received in the callback in lexicographical order based on their keys. The keys/parameters should be in the same order as shown in the list below.
Shape of data received:
- POST callbacks: data is received as a JSON object
HMAC String Keys:
card_subtype
created_at
email
id
masked_pan
merchant_id
order_id
tokenStep 2: Concatenate the Values
Concatenate the values of the keys/parameters into a single string in the same order as they are listed. This string will be used to calculate the HMAC in the next step. For example, if we consider the sample card token callback, the resultant string would look like this:
HMAC Concatenated String:
MasterCard2026-11-16T10:44:52.523591example.test@example.com17233884xxxx-xxxx-xxxx-23461642956556087850c045bd5330aa3d666d72830d4bcf0e60e10902df9fb2340af978bbf
Step 3: Calculate the HMAC
Use your HMAC secret and the SHA-512 hashing algorithm to generate an HMAC from the concatenated string.
To know how to get your hmac secret, please check the Getting Integration Credentials page.
HMAC Calculated Sample:
57982fed57b47d82ddaf9b104a6b75acb35fed1bb629ed29959b88db2699dda5dc7845423a5f58f8dc6dd794b3727e5fb28b95d896dfce5dd9d3b2845c4a04e4Step 4: Compare the Calculated HMAC
Compare the HMAC value you calculated with the hmac value received in the callback’s query parameters (e.g., ...?hmac=generated_hash) to verify the integrity and authenticity of the data.
Card Token Callback Sample
Show child attributes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
"type": "TOKEN",
"obj": {
"id": 17233884,
"token": "0c045bd5330aa3d666d72830d4bcf0e60e10902df9fb2340af978bbf",
"masked_pan": "xxxx-xxxx-xxxx-2346",
"merchant_id": 164295,
"card_subtype": "MasterCard",
"created_at": "2026-11-16T10:44:52.523591",
"email": "example.test@example.com",
"order_id": "655608785",
"user_added": false,
"next_payment_intention": "pi_test_243ec1d9c065458e8f61adad564d3d10",
"cardholder_name": "TEST ACCOUNT",
"expiry_month": "01",
"expiry_year": "39",
"card_funding_type": "CREDIT"
}
}