> ## Documentation Index
> Fetch the complete documentation index at: https://adyen-preview.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Auto Rescue for Card Payments

> Automatically retry shopper-not-present card transactions when they are refused.

On this page, you will learn how to:

1. [Enable Auto Rescue](#step-1-enable-auto-rescue) for card payments.
2. [Receive updates on the Auto Rescue process](#step-2-receive-auto-rescue-updates).

We also explain how you can:

* [Send a payment link](#send-a-payment-link) when the Auto Rescue process ends unsuccessfully.
* [Cancel the Auto Rescue process](#cancel-auto-rescue-process) for a payment.
* [Test how your integration handles Auto Rescue updates](#test-auto-rescue).
* [Reconcile retry attempts in Adyen-generated reports](#auto-rescue-reports).

## How it works

![](https://docs.adyen.com/user/pages/docs/02.online-payments/23.auto-rescue/01.cards/autorescue-cards.svg)

## Step 1: Enable Auto Rescue

You can enable Auto Rescue at either:

* [Account level](#enable-at-account-level): Auto Rescue is used on all eligible payments.
* [Transaction level](#enable-at-transaction-level): You choose when Auto Rescue can be used for a payment, using the `autoRescue` flag.

### Enable at account level

To enable Auto Rescue for all payments, contact our [Support Team](https://ca-test.adyen.com/ca/ca/contactUs/support.shtml?form=other) or your Adyen Account Manager.

When enabled, Auto Rescue works for payments that have:

* The `shopperInteraction` **ContAuth**.
* A `value` greater than **0**.

If you enable Auto Rescue at account level, a rescue window of one calendar month is used. If you prefer to use another rescue window you need to [enable Auto Rescue at the transaction level](#enable-at-transaction-level).

You [receive updates to the Auto Rescue process](#step-2-receive-auto-rescue-updates) in webhook events.

### Enable at transaction level

To enable Auto Rescue on a transaction level, you need to:

1. Contact our [Support Team](https://ca-test.adyen.com/ca/ca/contactUs/support.shtml?form=other) or your Adyen Account Manager to configure this for you.
2. Add the `autoRescue` flag to your payment request to enable Auto Rescue for that transaction.
3. In the payment request, provide a unique `merchantOrderReference`. This should represent a specific billing cycle or subscription, and will appear in any [Auto Rescue updates](#step-2-receive-auto-rescue-updates) or [reports](#auto-rescue-reports).

With `merchantOrderReference` you can connect any Auto Rescue retry attempts to a payment request.

To enable Auto Rescue for a transaction:

1. Make a payment request, and additionally specify:

   * [shopperInteraction](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-shopperInteraction): **ContAuth**
   * `autoRescue`: **true**
   * `maxDaysToRescue`: The rescue window, in days. You can specify between **1** and **48** days. We recommend using a rescue window of one calendar month (**30** days).
   * [reference](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-reference): Your unique reference for this payment request.
   * [merchantOrderReference](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-merchantOrderReference): Your unique order reference. For example, a concatenation of a unique shopper reference and the transaction date.

   The example below shows how to enable Auto Rescue for a shopper-not-present payment submitted to the [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) endpoint. If this payment is **Refused**, Auto Rescue will automatically retry this payment for a maximum of **40** days.

   **Enable Auto Rescue in a payments request**

   #### curl

   ```bash theme={null}
   curl https://checkout-test.adyen.com/v68/payments \
   -H 'x-api-key: ADYEN_API_KEY' \
   -H 'content-type: application/json' \
   -d '{
    "paymentMethod":{
       "type":"scheme",
       "storedPaymentMethodId":"7218395820498475"
    },
    "amount":{
       "currency":"USD",
       "value":1000
    },
    "returnUrl":"https://your-company.example.com/...",
    "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
    "recurringProcessingModel":"Subscription",
    "shopperInteraction":"ContAuth",
    "reference":"Trans987654321",
      "shopperReference":"YOUR_UNIQUE_SHOPPER_ID",
    "merchantOrderReference":"Cust12345_Nov19",
    "additionalData":{
       "autoRescue":"true",
       "maxDaysToRescue":"40"
    }
   }'
   ```

   #### Java

   ```java theme={null}
   // Adyen Java API Library v25.0.0
   import com.adyen.Client;
   import com.adyen.enums.Environment;
   import com.adyen.model.checkout.*;
   import java.time.OffsetDateTime;
   import java.util.*;
   import com.adyen.model.RequestOptions;
   import com.adyen.service.checkout.*;

   // For the live environment, additionally include your liveEndpointUrlPrefix.
   Client client = new Client("ADYEN_API_KEY", Environment.TEST);

   // Create the request object(s)
   Amount amount = new Amount()
     .currency("USD")
     .value(1000L);

   CardDetails cardDetails = new CardDetails()
     .storedPaymentMethodId("7218395820498475")
     .type(CardDetails.TypeEnum.SCHEME);

   PaymentRequest paymentRequest = new PaymentRequest()
     .reference("Trans987654321")
     .merchantOrderReference("Cust12345_Nov19")
     .amount(amount)
     .merchantAccount("YOUR_MERCHANT_ACCOUNT")
     .recurringProcessingModel(PaymentRequest.RecurringProcessingModelEnum.SUBSCRIPTION)
     .paymentMethod(new CheckoutPaymentMethod(cardDetails))
     .shopperInteraction(PaymentRequest.ShopperInteractionEnum.CONTAUTH)
     .additionalData(new HashMap<String, String>(Map.of(
       "autoRescue", "true",
       "maxDaysToRescue", "40"
     )))
     .returnUrl("https://your-company.example.com/...")
     .shopperReference("YOUR_UNIQUE_SHOPPER_ID");

   // Make the API call
   PaymentsApi service = new PaymentsApi(client);
   PaymentResponse response = service.payments(paymentRequest, new RequestOptions().idempotencyKey("UUID"));
   ```

   #### PHP

   ```php theme={null}
   // Adyen PHP API Library v17.4.0
   use Adyen\Client;
   use Adyen\Environment;
   use Adyen\Model\Checkout\Amount;
   use Adyen\Model\Checkout\CheckoutPaymentMethod;
   use Adyen\Model\Checkout\PaymentRequest;
   use Adyen\Service\Checkout\PaymentsApi;

   $client = new Client();
   $client->setXApiKey("ADYEN_API_KEY");
   // For the live environment, additionally include your liveEndpointUrlPrefix.
   $client->setEnvironment(Environment::TEST);


   // Create the request object(s)
   $amount = new Amount();
   $amount
     ->setCurrency("USD")
     ->setValue(1000);

   $checkoutPaymentMethod = new CheckoutPaymentMethod();
   $checkoutPaymentMethod
     ->setStoredPaymentMethodId("7218395820498475")
     ->setType("scheme");

   $paymentRequest = new PaymentRequest();
   $paymentRequest
     ->setReference("Trans987654321")
     ->setMerchantOrderReference("Cust12345_Nov19")
     ->setAmount($amount)
     ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT")
     ->setRecurringProcessingModel("Subscription")
     ->setPaymentMethod($checkoutPaymentMethod)
     ->setShopperInteraction("ContAuth")
     ->setAdditionalData(
       array(
         "autoRescue" => "true",
         "maxDaysToRescue" => "40"
       )
     )
     ->setReturnUrl("https://your-company.example.com/...")
     ->setShopperReference("YOUR_UNIQUE_SHOPPER_ID");

   $requestOptions['idempotencyKey'] = 'UUID';

   // Make the API call
   $service = new PaymentsApi($client);
   $response = $service->payments($paymentRequest, $requestOptions);
   ```

   #### C\#

   ```cs theme={null}
   // Adyen .net API Library v14.4.0
   using Adyen;
   using Environment = Adyen.Model.Environment;
   using Adyen.Model;
   using Adyen.Model.Checkout;
   using Adyen.Service.Checkout;

   // For the live environment, additionally include your liveEndpointUrlPrefix.
   var config = new Config()
   {
       XApiKey = "ADYEN_API_KEY",
       Environment = Environment.Test
   };
   var client = new Client(config);

   // Create the request object(s)
   Amount amount = new Amount
   {
     Currency = "USD",
     Value = 1000
   };

   CardDetails cardDetails = new CardDetails
   {
     StoredPaymentMethodId = "7218395820498475",
     Type = CardDetails.TypeEnum.Scheme
   };

   PaymentRequest paymentRequest = new PaymentRequest
   {
     Reference = "Trans987654321",
     MerchantOrderReference = "Cust12345_Nov19",
     Amount = amount,
     MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
     RecurringProcessingModel = PaymentRequest.RecurringProcessingModelEnum.Subscription,
     PaymentMethod = new CheckoutPaymentMethod(cardDetails),
     ShopperInteraction = PaymentRequest.ShopperInteractionEnum.ContAuth,
     AdditionalData = new Dictionary<string, string>
     {

       { "autoRescue", "true" },
       { "maxDaysToRescue", "40" }
     },
     ReturnUrl = "https://your-company.example.com/...",
     ShopperReference = "YOUR_UNIQUE_SHOPPER_ID"
   };

   // Make the API call
   var service = new PaymentsService(client);
   var response = service.Payments(paymentRequest, requestOptions: new RequestOptions { IdempotencyKey = "UUID"});
   ```

   #### NodeJS (JavaScript)

   ```js theme={null}
   // Adyen Node API Library v16.2.0
   // Require the parts of the module you want to use
   const { Client, CheckoutAPI } = require('@adyen/api-library');
   // Initialize the client object
   // For the live environment, additionally include your liveEndpointUrlPrefix.
   const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"});

   // Create the request object(s)
   const paymentRequest = {
     paymentMethod: {
       type: "scheme",
       storedPaymentMethodId: "7218395820498475"
     },
     amount: {
       currency: "USD",
       value: 1000
     },
     returnUrl: "https://your-company.example.com/...",
     merchantAccount: "YOUR_MERCHANT_ACCOUNT",
     recurringProcessingModel: "Subscription",
     shopperInteraction: "ContAuth",
     reference: "Trans987654321",
     shopperReference: "YOUR_UNIQUE_SHOPPER_ID",
     merchantOrderReference: "Cust12345_Nov19",
     additionalData: {
       autoRescue: "true",
       maxDaysToRescue: "40"
     }
   }

   // Make the API call
   const checkoutAPI = new CheckoutAPI(client);
   const response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: "UUID" });
   ```

   #### Go

   ```go theme={null}
   // Adyen Go API Library v9.3.0
   import (
     "context"
     "github.com/adyen/adyen-go-api-library/v9/src/common"
     "github.com/adyen/adyen-go-api-library/v9/src/adyen"
     "github.com/adyen/adyen-go-api-library/v9/src/checkout"
   )
   // For the live environment, additionally include your liveEndpointUrlPrefix.
   client := adyen.NewClient(&common.Config{
     ApiKey:      "ADYEN_API_KEY",
     Environment: common.TestEnv,
   })

   // Create the request object(s)
   amount := checkout.Amount{
     Currency: "USD",
     Value: 1000,
   }

   cardDetails := checkout.CardDetails{
     StoredPaymentMethodId: common.PtrString("7218395820498475"),
     Type: common.PtrString("scheme"),
   }

   paymentRequest := checkout.PaymentRequest{
     Reference: "Trans987654321",
     MerchantOrderReference: common.PtrString("Cust12345_Nov19"),
     Amount: amount,
     MerchantAccount: "YOUR_MERCHANT_ACCOUNT",
     RecurringProcessingModel: common.PtrString("Subscription"),
     PaymentMethod: checkout.CardDetailsAsCheckoutPaymentMethod(&cardDetails),
     ShopperInteraction: common.PtrString("ContAuth"),
     AdditionalData: &map[string]string{
       "autoRescue": "true",
       "maxDaysToRescue": "40",
     },
     ReturnUrl: "https://your-company.example.com/...",
     ShopperReference: common.PtrString("YOUR_UNIQUE_SHOPPER_ID"),
   }

   // Make the API call
   service := client.Checkout()
   req := service.PaymentsApi.PaymentsInput().IdempotencyKey("UUID").PaymentRequest(paymentRequest)
   res, httpRes, err := service.PaymentsApi.Payments(context.Background(), req)
   ```

   #### Python

   ```py theme={null}
   # Adyen Python API Library v12.2.0
   import Adyen

   adyen = Adyen.Adyen()
   adyen.client.xapikey = "ADYEN_API_KEY"
   # For the live environment, additionally include your liveEndpointUrlPrefix.
   adyen.client.platform = "test" # The environment to use library in.

   # Create the request object(s)
   json_request = {
     "paymentMethod": {
       "type": "scheme",
       "storedPaymentMethodId": "7218395820498475"
     },
     "amount": {
       "currency": "USD",
       "value": 1000
     },
     "returnUrl": "https://your-company.example.com/...",
     "merchantAccount": "YOUR_MERCHANT_ACCOUNT",
     "recurringProcessingModel": "Subscription",
     "shopperInteraction": "ContAuth",
     "reference": "Trans987654321",
     "shopperReference": "YOUR_UNIQUE_SHOPPER_ID",
     "merchantOrderReference": "Cust12345_Nov19",
     "additionalData": {
       "autoRescue": "True",
       "maxDaysToRescue": "40"
     }
   }

   # Make the API call
   result = adyen.checkout.payments_api.payments(request=json_request, idempotency_key="UUID")
   ```

   #### Ruby

   ```rb theme={null}
   # Adyen Ruby API Library v9.3.0
   require "adyen-ruby-api-library"

   adyen = Adyen::Client.new
   adyen.api_key = 'ADYEN_API_KEY'
   # For the live environment, additionally include your liveEndpointUrlPrefix.
   adyen.env = :test # Set to "live" for live environment

   # Create the request object(s)
   request_body = {
     :paymentMethod => {
       :type => 'scheme',
       :storedPaymentMethodId => '7218395820498475'
     },
     :amount => {
       :currency => 'USD',
       :value => 1000
     },
     :returnUrl => 'https://your-company.example.com/...',
     :merchantAccount => 'YOUR_MERCHANT_ACCOUNT',
     :recurringProcessingModel => 'Subscription',
     :shopperInteraction => 'ContAuth',
     :reference => 'Trans987654321',
     :shopperReference => 'YOUR_UNIQUE_SHOPPER_ID',
     :merchantOrderReference => 'Cust12345_Nov19',
     :additionalData => {
       :autoRescue => 'true',
       :maxDaysToRescue => '40'
     }
   }

   # Make the API call
   result = adyen.checkout.payments_api.payments(request_body, headers: { 'Idempotency-Key' => 'UUID' })
   ```

   #### NodeJS (TypeScript)

   ```ts theme={null}
   // Adyen Node API Library v16.2.0
   // Require the parts of the module you want to use
   import { Client, CheckoutAPI, Types } from "@adyen/api-library";
   // Initialize the client object
   // For the live environment, additionally include your liveEndpointUrlPrefix.
   const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"});

   // Create the request object(s)
   const amount: Types.checkout.Amount = {
     currency: "USD",
     value: 1000
   };

   const cardDetails: Types.checkout.CardDetails = {
     storedPaymentMethodId: "7218395820498475",
     type: Types.checkout.CardDetails.TypeEnum.Scheme
   };

   const paymentRequest: Types.checkout.PaymentRequest = {
     reference: "Trans987654321",
     merchantOrderReference: "Cust12345_Nov19",
     amount: amount,
     merchantAccount: "YOUR_MERCHANT_ACCOUNT",
     recurringProcessingModel: Types.checkout.PaymentRequest.RecurringProcessingModelEnum.Subscription,
     paymentMethod: cardDetails,
     shopperInteraction: Types.checkout.PaymentRequest.ShopperInteractionEnum.ContAuth,
     additionalData: {
       "autoRescue": "true",
       "maxDaysToRescue": "40"
     },
     returnUrl: "https://your-company.example.com/...",
     shopperReference: "YOUR_UNIQUE_SHOPPER_ID"
   };

   // Make the API call
   const checkoutAPI = new CheckoutAPI(client);
   const response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: "UUID" });
   ```

[]()

2. You receive a payment response. If the payment is refused, this contains:

   * `resultCode`: **Refused**

   * `refusalReason`: The reason the payment was refused. For more information, see [Refusal reasons](https://adyen-preview.mintlify.site/development-resources/refusal-reasons.md).

   * `retry.rescueScheduled`: Indicates whether Auto Rescue will try to rescue the payment:

     * **true**: Auto Rescue *will* try to rescue the payment. You receive [updates on the rescue process](#step-2-receive-auto-rescue-updates) in webhook events.
     * **false**: Auto Rescue *will not* try to rescue the payment. This happens when a payment cannot be rescued. For example, because of account closure or fraud.

   * `retry.rescueReference`: Unique Auto Rescue reference for this payment.\
     You can use this to [cancel the Auto Rescue process](#cancel-auto-rescue-process) if, for example, the shopper provides you with a new payment details, or cancels their subscription.

   The example response below is for a payment that was **Refused**. In this response, `retry.rescueScheduled` is set to **true**, indicating that Auto Rescue *will* attempt to rescue this payment.

   **Response**

   ```json theme={null}
   	{
   		"pspReference":"HWL5D5BDLSGLNK82",
   		"resultCode":"Refused",
   		"refusalReason":"NOT_ENOUGH_BALANCE",
   		"additionalData":{
   	 		"retry.rescueScheduled":"true",
   			"retry.rescueReference":"865497581465325B"
   		}
   	}
   ```

You [receive updates to the Auto Rescue process](#step-2-receive-auto-rescue-updates) in webhook events.

## Step 2: Receive Auto Rescue updates

To update you on the Auto Rescue process, we send you [webhook events](https://adyen-preview.mintlify.site/development-resources/webhooks.md). We send you a webhook event when:

* A retry attempt was made, and it was:

  * [Successful](#retry-attempt-successful).
  * [Unsuccessful](#retry-attempt-unsuccessful).

* The [rescue process ended](#rescue-process-ended), either because the payment was rescued, or the Auto Rescue process was unsuccessful.

Before using Auto Rescue for live payments, we recommend that you [test how your integration handles these webhook events](#test-auto-rescue).

### Retry attempt successful

If a retry attempt is successful, you receive a webhook event with:

* `eventCode`: **AUTHORISATION**
* `eventDate`: The date of the retry attempt.
* `success`: **true**
* `pspReference`: Adyen's unique reference for the successful retry attempt.
* `merchantOrderReference`: Unique order reference that you provided in the [payment request](#enable-at-transaction-level).

The example below is for a retry attempt that was successful.

**AUTHORISATION webhook for a successful retry**

```json theme={null}
{
   "live":"false",
   "notificationItems":[
      {
         "NotificationRequestItem":{
            "additionalData":{
               "retry.rescueScheduled":"false",
               "retry.rescueReference":"88HH88HH88HH88HH",
               "retry.orderAttemptNumber":3,
               "merchantOrderReference":"Cust12345_Nov19",
               ...
            },
            "pspReference":"PPKFQ89R6QRXGN82",
            "eventCode":"AUTHORISATION",
            "eventDate":"2019-11-12T12:00:01+01:00",
            "reason": "035450:2909:10/2020",
            "success":"true",
            ...
         }
      }
   ]
}
```

You can view how much revenue has been recovered with Auto Rescue in your [Customer Area](https://ca-live.adyen.com/), under **Reports**. Search for the **RevenueAccelerate** report.

If you use manual capture, you need to [capture](https://adyen-preview.mintlify.site/online-payments/capture#manual-capture) each rescued payment to transfer it to your account.

### Retry attempt unsuccessful

If a retry attempt is unsuccessful, you receive a webhook event with:

* `eventCode`: **AUTHORISATION**

* `eventDate`: The date of the retry attempt.

* `success`: **false**

* `merchantOrderReference`: Unique order reference that you provided in the [payment request](#enable-at-transaction-level).

* `retry.rescueScheduled`: Indicates whether Auto Rescue will attempt the payment again:

  * **true**: Another retry attempt has been scheduled. 
  * **false**: We are [unable to schedule another retry attempt](#rescue-process-ended).\
    This usually happens when you have reached the maximum number of retries.

The example below is for a retry attempt that was unsuccessful (`success` is **false**). Another retry attempt has been scheduled (`retry.rescueScheduled` is **true**).

**AUTHORISATION webhook an unsuccessful retry attempt**

```json theme={null}
{
   "live":"false",
   "notificationItems": [
      {
         "NotificationRequestItem":{
            "additionalData":{
               "retry.rescueScheduled":"true",
               "retry.rescueReference": "88HH88HH88HH88HH",
               "retry.orderAttemptNumber": 1,
               "merchantOrderReference":"Cust12345_Nov19",
               ...
            },
            "pspReference":"R8QTPCQ8HXSKGK82",
            "eventDate":"2019-11-12T12:00:01+01:00",
            "eventCode":"AUTHORISATION",
            "reason": "Refused",
            "success":"false",
            ...
         }
      }
   ]
}
```

### Rescue process ended

When the Auto Rescue process ends we send you a webhook event with:

* `eventCode`: **AUTORESCUE**.

* `eventDate`: The date that the rescue process started.

* `success`: Indicates whether the rescue process was successful:

  * **true**: The rescue process was successful.
  * **false**: The rescue process was unsuccessful.

* `merchantOrderReference`: Unique order reference you provided in the payment request.

* `reason`: If the rescue process was unsuccessful, this indicates why the payment could not be rescued:

  * `retryWindowHasElapsed`: The rescue window expired.
  * `maxRetryAttemptsReached`: The maximum number of retry attempts was made.
  * `fraudDecline`: The retry was rejected due to fraud.
  * `internalError`: An internal error occurred while retrying the payment.

The example below is a webhook event indicating that a payment could not be rescued. This is because the maximum number of retries has been reached (`reason` is **maxRetryAttemptsReached**).

**AUTORESCUE webhook an unsuccessful retry attempt**

```json theme={null}
{
   "live":"false",
   "notificationItems":[
      {
         "NotificationRequestItem":{
            "additionalData":{
               "retry.rescueReference":"88HH88HH88HH88HH",
               "merchantOrderReference":"Cust12345_Nov19"
            },
            "amount":{
               "currency":"USD",
               "value":1000
            },
            "eventCode":"AUTORESCUE",
            "eventDate":"2019-11-11T12:00:01+01:00",
            "merchantAccountCode":"YOUR_MERCHANT_ACCOUNT",
            "success":"false",
            "originalReference":"812872049382471H",
            "pspReference":"V4HZ4RBFJGXXGN82",
            "reason":"maxRetryAttemptsReached",
            ...
         }
      }
   ]
}
```

## Send a payment link

In case the Auto Rescue process ended unsuccessfully, you can optionally use [Pay by Link](https://adyen-preview.mintlify.site/unified-commerce/pay-by-link) to send the shopper a payment link so they can still proceed with the payment, for example, using other payment method.

To activate Pay by Link for Auto Rescue, contact our [Support Team](https://ca-test.adyen.com/ca/ca/contactUs/support.shtml?form=other).

After we activate the feature, you will receive additional data fields in the Auto Rescue process end webhook:

* [paymentLink.url](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks) — The URL where the shopper can complete the payment. Valid for 5 days.
* [paymentLink.expiresAt](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks) — The date when the payment link expires, in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. For example, `2019-11-23T12:25:28Z` or `2020-05-27T20:25:28+08:00`.

**AUTORESCUE webhook with payment link**

```json theme={null}
{
   "live":"false",
   "notificationItems":[
      {
         "NotificationRequestItem":{
            "additionalData":{
               "retry.rescueReference":"88HH88HH88HH88HH",
               "merchantOrderReference":"Cust12345_Nov19",
               "paymentLink.url": "https://test.adyen.link/PL8F7CCDDCCB904770",
               "paymentLink.expiresAt": "2021-05-26T12:51:14Z"
            },
            "amount":{
               "currency":"USD",
               "value":1000
            },
            "eventCode":"AUTORESCUE",
            "eventDate":"2019-11-11T12:00:01+01:00",
            "merchantAccountCode":"YOUR_MERCHANT_ACCOUNT",
            "success":"false",
            "originalReference":"812872049382471H",
            "pspReference":"GH4R4RBFJGXXGN82",
            "reason":"maxRetryAttemptsReached"
         }
      }
   ]
}
```

When the shopper has paid with Pay by Link, you receive an [AUTHORISATION](https://docs.adyen.com/api-explorer/MockNotificationService/latest/post/AUTHORISATION) webhook event with:

* `shopperReference`: The payment details used by the shopper.
* `storedPaymentMethodId`: The token you can use for the next subscription renewal. For more information, refer to [Tokenization](https://adyen-preview.mintlify.site/online-payments/tokenization).

## Cancel Auto Rescue

While a payment is in the Auto Rescue process, your shopper may provide you with a new payment method, or cancel their subscription. In these scenarios, you should cancel the Auto Rescue process for the refused payment.

To cancel the Auto Rescue process:

1. Make a [/cancel](https://docs.adyen.com/api-explorer/Payment/cancel) request, specifying: 

   * `originalReference`: The `rescueReference` that you received in the [payment response](#payment-response).
   * `cancellationType`: **autoRescue**

   The following example shows how to cancel the Auto Rescue process for a payment with a `rescueReference` of **865497581465325B**.

   **Cancel Auto Rescue**

   ```bash theme={null}
   curl https://pal-test.adyen.com/pal/servlet/Payment/v68/cancel \
   -H 'x-api-key: YOUR_COMPANY_ACCOUNT_API_KEY' \
   -H 'content-type: application/json' \
   -d '{
   		"merchantAccount":"YOUR_MERCHANT_ACCOUNT",
   		"originalReference":"865497581465325B",
   		"additionalData":{
   			"cancellationType":"autoRescue"
   		}
   	}'
   ```

2. You receive a [/cancel](https://docs.adyen.com/api-explorer/Payment/cancel) response containing:

   * `response`: **\[cancel-received]**
   * `pspReference`: The PSP reference associated with this `/cancel` request. This is different from the PSP reference associated with the original payment request.

   **Response**

   ```json theme={null}
   	{
   	    "response":"[cancel-received]",
   		"pspReference":"XB7XNCQ8HXSKGK82"
   	}
   ```

   After we have processed your cancel request, you receive a webhook event with:

   * `eventCode`: [CANCEL\_AUTORESCUE](https://docs.adyen.com/api-explorer/Webhooks/latest/post/CANCEL_AUTORESCUE)
   * `success`: Indicates whether your request to cancel the rescue process was successful.
   * `merchantOrderReference`: Unique order reference that you provided in the payment request.

   **CANCEL\_AUTORESCUE webhook**

   ```json theme={null}
   	{
   	   "live":"false",
   	   "notificationItems":[
   	      {
   	         "NotificationRequestItem":{
                  "additionalData":{
                     "merchantOrderReference":"Cust12345_Nov19"
                  },
   	            "amount":{
   	               "currency":"USD",
   	               "value":1000
   	            },
   	            "eventCode":"CANCEL_AUTORESCUE",
   	            "eventDate": "2019-04-05T09:08:05+01:00",
   	            "merchantAccountCode":"YOUR_MERCHANT_ACCOUNT",
   	            "success":"true",
   	            "originalReference":"88HH88HH88HH88HH",
   	            "pspReference":"BB7XNCQ8HXSKGK82",
   	            ...
   	         }
   	      }
   	   ]
   	}
   ```

## Test Auto Rescue and go live

Before flagging live payments for Auto Rescue, we recommend that you test how your integration handles scenarios involving [Auto Rescue updates](#step-2-receive-auto-rescue-updates).

To simulate scenarios involving Auto Rescue updates:

1. Make a test [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request that is [flagged for Auto Rescue](#step-1-enable-auto-rescue). In the request, additionally provide:

   * `autoRescueScenario`: Set this to the scenario you want to test:

     * **AutoRescueSuccessfulFirst**: The payment is refused; the first retry attempt is successful.
     * **AutoRescueSuccessfulSecond**: The payment and first retry attempt are refused; the second retry attempt is successful.
     * **AutoRescueFailed**: The payment and all retry attempts are refused.
     * **AutoRescueFraud**: The payment is refused because of fraud; there will be no retry attempts.

2. The example below shows how to test a scenario, with the [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) endpoint, where the second retry attempt is successful:

   **Test successful second retry attempt**

   ```bash theme={null}
   curl https://checkout-test.adyen.com/v72/payments \
   -H 'x-api-key: YOUR_COMPANY_ACCOUNT_API_KEY' \
   -H 'content-type: application/json' \
   -d '{
         "paymentMethod":{
             "type":"scheme",
             "storedPaymentMethodId":"7218395820498476"
         },
         "amount":{
             "currency":"USD",
             "value":1000
         },
         "returnUrl":"https://your-company.example.com/...",
         "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
         "recurringProcessingModel":"Subscription",
         "shopperInteraction":"ContAuth",
         "reference":"Trans987654321",
         "shopperReference":"YOUR_UNIQUE_SHOPPER_ID",
         "merchantOrderReference":"SecondRetryTest",
         "additionalData":{
             "autoRescue":"true",
             "maxDaysToRescue":"40",
             "autoRescueScenario":"AutoRescueSuccessfulSecond"
       }
     }'
   ```

   You receive [Auto Rescue updates](#step-2-receive-auto-rescue-updates) corresponding to the scenario you are testing. If this scenario involves multiple retry attempts, these Auto Rescue updates will occur several minutes apart.

## Auto Rescue reports

Each Auto Rescue retry attempt is a separate transaction, and thus generates a unique `pspReference`. If you want to see all payments initiated by Auto Rescue, we can add the **Payment Requester Type** column to your [Received payment details report](https://adyen-preview.mintlify.site/reporting/received-payment-details-report.md). Contact our [Support Team](https://ca-test.adyen.com/ca/ca/contactUs/support.shtml?form=other) or your Adyen Account Manager to configure this for you.

To connect an Auto Rescue retry attempt to a payment request, use the value in the **Merchant Order Reference** column. This corresponds to `merchantOrderReference` you provided in the payment request. We can add **Merchant Order Reference** to the following reports:

* [Received payment details report](https://adyen-preview.mintlify.site/reporting/received-payment-details-report.md)
* [Settlement Detail Report](https://adyen-preview.mintlify.site/reporting/settlement-reconciliation/transaction-level/settlement-details-report.md)
* [Payments Accounting Report](https://adyen-preview.mintlify.site/reporting/invoice-reconciliation/payment-accounting-report.md)

Contact our [Support Team](https://ca-test.adyen.com/ca/ca/contactUs/support.shtml?form=other) or your Adyen Account Manager to configure this for you.

If you did not provide `merchantOrderReference` in the payment request, we automatically populate the **Merchant Order Reference** column with `pspReference` of the payment request.

### Example

The following example represents two payment requests. One has the `merchantOrderReference` **A1**, and the other **A2**.

* **A1**: The payment was rescued on the first retry attempt.
* **A2**: The payment was rescued on the third retry attempt.

| Transaction | PSP Reference | Merchant Order Reference | Record Type |
| - | - | - | - |
| November monthly subscription payment | 812872049382471H | A1 | Refused |
| 1st retry attempt | 814987049386784P | A1 | Authorised |
| December monthly subscription payment | 812872049382471H | A2 | Refused |
| 1st retry attempt | 804938149876784D | A2 | Refused |
| 2nd retry attempt | 804938149950514L | A2 | Refused |
| 3rd retry attempt | 814987049986784P | A2 | Authorised |

## See also

* [Refusal reasons](https://adyen-preview.mintlify.site/development-resources/refusal-reasons.md)
* [Webhooks](https://adyen-preview.mintlify.site/development-resources/webhooks.md)
* [Capture](https://adyen-preview.mintlify.site/online-payments/capture)
* [Cancel](https://adyen-preview.mintlify.site/online-payments/cancel.md)
* [Received payment details report](https://adyen-preview.mintlify.site/reporting/received-payment-details-report.md)
* [Pay by Link](https://adyen-preview.mintlify.site/unified-commerce/pay-by-link)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.