Are you looking for test card numbers?

Would you like to contact support?

Default icon

Cancel

Cancel the authorisation on a payment that has not yet been captured.

Cancel in Customer Area

You can also cancel payments in your Customer Area. For more information, refer to Manage payments.

For some payment methods, the payment is completed in two steps:

  1. Authorisation – The payment details of the shopper are verified, and the funds are reserved.
  2. Capture –  The reserved funds are transferred from the shopper to your account. 

If you have authorised a payment but do not want to capture it, for example because an item is out of stock, you need to cancel the payment. To specify the payment that you want to cancel, use the pspReference of this payment.

If you don't have the pspReference available, for example because of a timeout error, you can also cancel without the pspReference.

Cancel a payment

To cancel a payment that has been authorised but not captured yet:

  1. From the AUTHORISATION webhook, get the pspReference of the authorisation you want to cancel.
  2. Make a POST request to the /payments/{paymentPspReference}/cancels endpoint, where paymentPspReference is the PSP reference of the authorisation you want to cancel.
    If you're not sure whether the authorisation has been captured, use the /payments/{paymentPspReference}/reversals endpoint instead.
    In your request, include:
    Parameter Required Description
    merchantAccount -white_check_mark- The name of your merchant account that is used to process the payment.
    reference Your reference for the cancel request.
    The next example shows how to cancel an authorisation that has the pspReference 8836183819713023.
    curl https://checkout-test.adyen.com/checkout/v68/payments/8836183819713023/cancels \
    -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 paymentCancelRequest = new CreatePaymentCancelRequest();
    paymentCancelRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
    paymentCancelRequest.setReference("YOUR_UNIQUE_REFERENCE");
    String paymentPspReference = "8836183819713023";
    var response = checkout.paymentsCancels(paymentPspReference, paymentCancelRequest);
  3. When you receive the /payments/{paymentPspReference}/cancels response, note:
    • paymentPspReference: the PSP reference of the authorisation you want to cancel.
    • pspReference: Adyen's unique reference associated with this cancel request.
    {
        "merchantAccount": "YOUR_MERCHANT_ACCOUNT",
        "paymentPspReference": "8836183819713023",
        "pspReference" : "8412534564722331",
        "reference": "YOUR_UNIQUE_REFERENCE",
        "status" : "received"
    }
  4. Wait for the CANCELLATION notification webhook to learn the outcome of the cancel request.

CANCELLATION webhook

You receive the outcome of the cancel request asynchronously, in a notification webhook that includes :

  • eventCode: CANCELLATION.
  • originalReference: the PSP reference of the authorisation.
  • pspReference: same as the pspReference in the /payments/{paymentPspReference}/cancels response.
  • success: indicates whether the cancel request was successful. Possible values:
    • true: the cancel request was successful.
    • false: the cancel 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 cancel request.
{
   "live":"false",
   "notificationItems":[
      {
         "NotificationRequestItem":{
            "amount":{
               "currency":"EUR",
               "value":500
            },
            "eventCode":"CANCELLATION",
            "eventDate":"2021-03-05T09:08:05+01:00",
            "merchantAccountCode":"YOUR_MERCHANT_ACCOUNT",
            "originalReference":"8836183819713023",
            "paymentMethod":"mc",
            "pspReference":"8412534564722331",
            "reason":"",
            "success":"true"
         }
      }
   ]
}

For more information about the included fields, see the CANCELLATION notification reference.

Cancel without the pspReference

The /cancels endpoint allows you to cancel a payment using the reference from your /payments request. Cancelling a payment using the reference is only possible for 24 hours after authorisation.

We recommend that you only cancel using the reference if you are generating unique references for payment requests, and don't have the pspReference available.

To cancel a payment using your reference, make a POST /cancels request, and specify:

  • paymentReference: The reference of the payment that you want to cancel.
  • merchantAccount: The name of your merchant account that is used to process the payment.
  • reference: Optionally, you can specify your own reference for this cancel request.
curl https://checkout-test.adyen.com/checkout/v68/cancels \
-H 'X-API-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
    "paymentReference": "Payment123",
    "merchantAccount": "YOUR_MERCHANT_ACCOUNT",
    "reference": "YOUR_UNIQUE_REFERENCE",
}'
String xApiKey = "YOUR_X-API-KEY";
Client client = new Client(xApiKey,Environment.TEST);
Checkout checkout = new Checkout(client);
var standalonePaymentCancelRequest = new CreateStandalonePaymentCancelRequest();
standalonePaymentCancelRequest.setPaymentReference("Payment123");
standalonePaymentCancelRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
standalonePaymentCancelRequest.setReference("YOUR_UNIQUE_REFERENCE");
var response = checkout.cancels(standalonePaymentCancelRequest);

The /cancels response includes a pspReference, Adyen's unique reference associated with this cancel request.

{
    "merchantAccount": "YOUR_MERCHANT_ACCOUNT",
    "paymentReference": "Payment123",
    "pspReference" : "8412534564722331",
    "reference": "YOUR_UNIQUE_REFERENCE",
    "status" : "received"
}

TECHNICAL_CANCEL webhook

If you cancel a payment using the reference instead of the pspReference, you get the outcome of the request in a TECHNICAL_CANCEL webhook. The webhook contains:

  • eventCodeTECHNICAL_CANCEL
  • pspReference: The pspReferencefrom the /cancels response. 
  • originalReference: The pspReference of the payment that you requested to cancel.
  • success: Indicates whether the cancel request was successful. 
{
   "live":"false",
   "notificationItems":[
      {
         "NotificationRequestItem":{
            "additionalData":{
               "paymentMethodVariant":"visa"
            },
            "amount":{
               "currency":"EUR",
               "value":5000
            },
            "eventCode":"TECHNICAL_CANCEL",
            "eventDate":"2021-07-18T22:35:14+02:00",
            "merchantAccountCode":"YOUR_MERCHANT_ACCOUNT",
            "merchantReference":"Payment123",
            "originalReference":"8313547924770610",
            "paymentMethod":"visa",
            "pspReference":"8412534564722331",
            "reason":"",
            "success":"true"
         }
      }
   ]
}

For more information about the included fields, see the TECHNICAL_CANCEL notification reference.

See also