Sending back the payment details
How to submit a payment request to Adyen
Problem
Your customer has submitted credit card information to Adyen — i.e. through one of its UI components integrated into your client. You need to submit a payment request with the data returned by the component to proceed with the payment flow.
Solution
To submit the payment request to Adyen you have to update the Adyen payment object first. To do that, send a PATCH
request to the /api/adyen_payments/:id
endpoint, filling the payment_request_data
attribute with the encrypted credit card details contained in the state.data
object of the UI component.
Example
The following request updates the Adyen payment source identified by the "emdEKhoOMA" ID with the payment details received from the client:
curl -g -X PATCH \
'http://yourdomain.commercelayer.io/api/adyen_payments/emdEKhoOMA' \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer your-access-token' \
-H 'Content-Type: application/vnd.api+json' \
-d '{
"data": {
"type": "adyen_payments",
"id": "emdEKhoOMA",
"attributes": {
"payment_request_data": {
"payment_method": {
"type": "scheme",
"encryptedCardNumber": "adyenjs_0_1_25$0lrKNd0vXuwsvfBiXZRAxe5li79agWcLwvwAKEK9wCEUTjWiPqm35ECE26fOcnulKQZu4zshvqO5m0sTXZiBGu/+a+fgXvH2LoeLUk1HFu1eCfOjywm7sJEp2BqDwBntdeJdGzn+NQ5wjIfqnhnE3mkjrHo2e5Qv8i4KC9w45SF8hCyPAORNhZ8hH/Omw/89E9+x/LEe4JzA6/jnzlkacgC6Xkrn4mXHKDL69RACIPsellPx8qrD5Ek83AFwraVq1XdsBwKgUZjGyFUqBBQMuYITL9MJmt/xmhsmxTJtq0nzSZfcUArNrbXN/6nHiVwgdY+++D6mV5L/GCFy1fQ9vg==$Iz/USqzZJDVMOnwZIfuqlPr7LASrqi0lfsNpFCiXoztORu9JOyC+96tBZwGduXEzi5ICJ4REH6SE5R2DLfnFGiXYXKmZl9dgtHQ6KWg8krzqeB6GVs0zvpS+jiKzc41XmIwdoq26vCNEBH//zNRei2wCJfMhNvclAfQt1cALoT/KeJ5Bxyg0AEMHI6SA7E3m8wjiAOqWFoGao6VI+69jM7KKUB4wyd+KBB17JdqUxUcgor2avVb8tSzvxQAB4f/T3u7PwZENQq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AtGuXZEvo+7UTiJJoDWeAhAdoExjFMxA=="
},
"origin": "https://checkout.yourdomain.com",
"return_url": "https://checkout.yourdomain.com/eNoKkhzjyN",
"browser_info": {
"acceptHeader": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"colorDepth": 24,
"javaEnabled": false,
"language": "it-IT",
"screenHeight": 1440,
"screenWidth": 2560,
"timeZoneOffset": -120,
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:81.0) Gecko/20100101 Firefox/81.0"
}
}
}
}
}'
On success, the API responds with a 200 OK
status code, returning the updated Adyen payment object:
{
"data": {
"id": "emdEKhoOMA",
"type": "adyen_payments",
"links": {
"self": "https://yourdomain.commercelayer.io/api/adyen_payments/emdEKhoOMA"
},
"attributes": {
"payment_methods": {...},
"payment_request_data": {
"payment_method": {
"type": "scheme",
"encryptedCardNumber": "adyenjs_0_1_25$0lrKNd0vXuwsvfBiXZRAxe5li79agWcLwvwAKEK9wCEUTjWiPqm35ECE26fOcnulKQZu4zshvqO5m0sTXZiBGu/+a+fgXvH2LoeLUk1HFu1eCfOjywm7sJEp2BqDwBntdeJdGzn+NQ5wjIfqnhnE3mkjrHo2e5Qv8i4KC9w45SF8hCyPAORNhZ8hH/Omw/89E9+x/LEe4JzA6/jnzlkacgC6Xkrn4mXHKDL69RACIPsellPx8qrD5Ek83AFwraVq1XdsBwKgUZjGyFUqBBQMuYITL9MJmt/xmhsmxTJtq0nzSZfcUArNrbXN/6nHiVwgdY+++D6mV5L/GCFy1fQ9vg==$Iz/USqzZJDVMOnwZIfuqlPr7LASrqi0lfsNpFCiXoztORu9JOyC+96tBZwGduXEzi5ICJ4REH6SE5R2DLfnFGiXYXKmZl9dgtHQ6KWg8krzqeB6GVs0zvpS+jiKzc41XmIwdoq26vCNEBH//zNRei2wCJfMhNvclAfQt1cALoT/KeJ5Bxyg0AEMHI6SA7E3m8wjiAOqWFoGao6VI+69jM7KKUB4wyd+KBB17Jd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c3HbVJYsD8OxNyR/d80apHLzBTL2yCoNhg3AtGuXZEvo+7UTiJJoDWeAhAdoExjFMxA=="
},
"origin": "https://checkout.yourdomain.com",
"return_url": "https://checkout.yourdomain.com/eNoKkhzjyN",
"browser_info": {
"acceptHeader": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"colorDepth": 24,
"javaEnabled": false,
"language": "it-IT",
"screenHeight": 1440,
"screenWidth": 2560,
"timeZoneOffset": -120,
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:81.0) Gecko/20100101 Firefox/81.0"
}
},
"payment_request_details": {},
"payment_response": {},
"payment_instrument":{...},
"created_at": "2018-01-01T12:00:00.000Z",
"updated_at": "2018-01-01T12:00:00.000Z",
"reference": null,
"reference_origin": null,
"metadata": {}
},
"relationships": {
"order": {
"links": {...}
}
},
"meta": {
"mode": "test"
}
}
}
Additional notes
3D Secure authentication
In case of specific features enabled in the transaction – e.g. 3DS – you need to get from the client some additional information – such as browserInfo
, returnUrl
, etc. – and send them back together with the credit card details at the moment of the payment request submission, as shown in the example above — see Adyen documentation for any reference.
Live URL prefix
When using Adyen's for live transactions, you need to pass the live URL prefix to their library.
More to read
See our documentation if you need more information on how to update an Adyen payment. See our Checkout guide for more details on how to place an order.
Placing the orderLast updated