Generate Adyen payment token
This walkthrough shows you how to generate Adyen payment tokens.
Prerequisites
A test account on the Adyen.
Enable recurring details for your Adyen account.
Generate tokens
Generate a new API key for your Adyen web service user.
noteEnsure that you use the API key as a
X-Api-Key
HTTP header for all outgoing requests to Adyen API.Use one of the Adyen UI widgets to encrypt card information and store it as a payment method.
The goal is to produce a request to Adyen API similar to the following example:
cautionAlways use zero amount at this point. You do not want to charge money before order processing starts.
POST https://checkout-test.adyen.com/v52/payments
{
"merchantAccount": "MyCompanyECOM",
"shopperReference": "MyShopper12345",
"reference": "MyShopper12345_Card_Registration",
"storePaymentMethod": true,
"shopperInteraction": "Ecommerce",
"recurringProcessingModel": "CardOnFile",
"amount": {
"value": 0,
"currency": "EUR"
},
"paymentMethod": {
"type": "scheme",
"encryptedCardNumber": "adyenjs_0_1_25ABCDEFG=",
"encryptedExpiryMonth": "adyenjs_0_1_25$ABCDEFG=",
"encryptedExpiryYear": "adyenjs_0_1_25$$ABCDEFG=",
"encryptedSecurityCode": "adyenjs_0_1_25$$ABCDEFG="
}
}For more information and examples about how to integrate Adyen UI widgets on the frontend, see the Web Components integration guide.
Parse the response for
recurringDetailReference
value to be used as a payment token.For examples about how to integrate Adyen UI widgets on the frontend, see the Web Components integration guide.
{
"additionalData": {
"recurringProcessingModel": "CardOnFile",
"recurring.shopperReference": "MyShopper12345",
"recurring.recurringDetailReference": "8415934712150237"
},
"pspReference": "882593471214138J",
"resultCode": "Authorised",
"amount": {
"currency": "EUR",
"value": 0
},
"merchantReference": "MyShopper12345_Card_Registration"
}:::note When you enable recurring details, by default, the
recurringDetailReference
API response is only included during the first call to the payments endpoint, when the details get stored. Additionally, Adyen Support can enable a setting on your account to always retrieve therecurringDetailReference
in the API response, for each call. :::Copy the token value and prefix it with two
(#)
hashes. For example,##8315932173953405
.You can now use it as a
payment
value when paying through Composable Commerce Adyen gateway.