Authorizing the payment source

How to authorize the payment before placing the order

Problem

Your order has reached the final step of the payment flow and you need to perform the last action required by Adyen — an explicit authorization before placing it.

Solution

To authorize the payment, send a PATCH request to the /api/adyen_payments/:id endpoint, setting the _authorize attribute to true. You can check the output of the authorization in the payment_response attribute of the response.

Example

Request
Response
Request

The following request authorizes the Adyen payment source identified by the "emdEKhoOMA" ID:

curl -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": {
"_authorize": true
}
}
}'
Response

On success, the API responds with a 200 OK status code, returning the updated Adyen payment object with the payment response information:

{
"data": {
"id": "emdEKhoOMA",
"type": "adyen_payments",
"links": {
"self": "https://yourdomain.commercelayer.io/api/adyen_payments/emdEKhoOMA"
},
"attributes": {
"payment_methods": {...},
"payment_request_data": {
"origin": "https://checkout.yourdomain.com",
"return_url": "https://checkout.yourdomain.com/eNoKkhzjyN",
"browser_info": {
"language": "it-IT",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:81.0) Gecko/20100101 Firefox/81.0",
"colorDepth": 24,
"javaEnabled": false,
"screenWidth": 2560,
"acceptHeader": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"screenHeight": 1440,
"timeZoneOffset": -120
},
"payment_method": {
"type": "scheme",
"encryptedCardNumber": "adyenjs_0_1_25$0lrKNd0vXuwsvfBiXZRAxe5li79agWcLwvwAKEK9wCEUTjWiPqm35ECE26fOcnulKQZu4zshvqO5m0sTXZiBGu/+a+fgXvH2LoeLUk1HFu1eCfOjywm7sJEp2BqDwBntdeJdGzn+NQ5wjIfqnhnE3mkjrHo2e5Qv8i4KC9w45SF8hCyPAORNhZ8hH/Omw/89E9+x/LEe4JzA6/jnzlkacgC6Xkrn4mXHKDL69RACIP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N4z3laI/XdQJPw4zyFhfB1ECszreIZxnt9mdZloiiJluSY7cqUEJ+JaAK2no6Y0S8i/CMaW3gbUq1qb92YNwMizi3q0oomQSfx3aWXtIoIR2feB6lDZ3KA24ljDJIxTG5ggF436g58E8ACTUqI0NGfWULLsWsSY5rsAnl6GH+kpcXTfd6GIK/5eE38LhDGRlcYUHMq0jwc9sTjeYTTnTctk4gEt84Dj2TtgHFBWjGeGqT1/jdVIStu3S4y/zhRTqrTux8JfmgMkCd0pGtlbKWl0q1V+xC/XHsI8zvEJfMxMYeMntwNR1Yx+wc6hLCbnKKaDmaKPSTNL8Z8dnLULc3HbVJYsD8OxNyR/d80apHLzBTL2yCoNhg3AtGuXZEvo+7UTiJJoDWeAhAdoExjFMxA=="
}
},
"payment_request_details": {},
"payment_response": {
"pspReference": "883602840460986E",
"resultCode": "Authorised",
"merchantReference": "Order #16842"
},
"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": {
"self": "https://yourdomain.commercelayer.io/api/adyen_payments/emdEKhoOMA/relationships/order",
"related": "https://yourdomain.commercelayer.io/api/adyen_payments/emdEKhoOMA/order"
}
}
},
"meta": {
"mode": "test"
}
}
}

More to read

See our API reference 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.