Use the /payments/paymentPspReference/reversals endpoint if you want to return the funds to your shopper, but are not certain whether the payment has been captured or not.
This will either:
- Cancel the payment – in case it has not yet been captured.
- Refund the payment – in case it has already been captured.
You get the outcome of the reversal request asynchronously, in a CANCEL_OR_REFUND webhook.
Do not use the /payments/paymentPspReference/reversals endpoint for payments that involve
- Multiple partial captures.
- Split data either at time of payment or capture for Adyen for Platforms.
Instead, check if the payment has been captured and make a corresponding /payments/paymentPspReference/cancels or /payments/paymentPspReference/refunds call.
Reverse a payment
Make a POST /payments/paymentPspReference/reversals request, where paymentPspReference
is the
pspReference
of the payment that you want to reverse. You can find the pspReference
in the AUTHORISATION webhook.
In your request, include:
merchantAccount
: The name of your merchant account that is used to process the payment.reference
: You can optionally include a reference reversal request. Thereference
field is useful to tag a partial cancel or refund for reconciliation.
curl https://checkout-test.adyen.com/checkout/v69/payments/VK9DRSLLRCQ2WN82/reversals \
-H 'X-API-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"reference": "YOUR_UNIQUE_REFERENCE",
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
}'
String xApiKey = "YOUR_X-API-KEY";
Client client = new Client(xApiKey,Environment.TEST);
Checkout checkout = new Checkout(client);
var paymentReversalRequest = new CreatePaymentReversalRequest();
paymentReversalRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
paymentReversalRequest.setReference("YOUR_UNIQUE_REFERENCE");
String paymentPspReference = "VK9DRSLLRCQ2WN82";
var response = checkout.paymentsReversals(paymentPspReference, paymentReversalRequest);
The /payments/paymentPspReference/reversals response includes a pspReference
, Adyen's unique reference associated with this reversal request.
{
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
"paymentPspReference": "VK9DRSLLRCQ2WN82",
"pspReference" : "TF995R5G6L2GWR82",
"reference": "YOUR_UNIQUE_REFERENCE",
"status" : "received"
}
CANCEL_OR_REFUND webhook
You receive the outcome of the reversal request asynchronously, in a notification webhook that includes :
eventCode
: CANCEL_OR_REFUND.originalReference
: the PSP reference of the original payment.pspReference
: thepspReference
from the reversal response.-
success
: indicates whether the request to reverse the payment was successful. Possible values:- true: your request was successful. The
modification.action
field shows whether the request produced a cancel or a refund. This depends on whether the original payment has already been captured. -
false: your request failed. The notification includes a
reason
field with a short description of the problem. Review the reason, fix the issue if possible, and resubmit the reversal request.
- true: your request was successful. The
{
"live":"false",
"notificationItems":[
{
"NotificationRequestItem":{
"additionalData":{
"modification.action": "refund"
},
"amount":{
"currency": "EUR",
"value": 1025
},
"eventCode":"CANCEL_OR_REFUND",
"eventDate":"2022-02-03T15:14:15.004Z",
"merchantAccountCode":"YOUR_MERCHANT_ACCOUNT",
"originalReference":"VK9DRSLLRCQ2WN82",
"paymentMethod":"mc",
"pspReference":"TF995R5G6L2GWR82",
"reason":"",
"success":"true"
}
}
]
}
For more information about the included fields, see the CANCEL_OR_REFUND notification reference.