> ## 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 SEPA Payments

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

Besides Auto Rescue for [card transactions](https://adyen-preview.mintlify.site/online-payments/auto-rescue/cards.md), we support rescuing SEPA transactions. Because SEPA transactions always have `eventCode` **AUTHORISED** in the response, these require a different rescue logic compared to card transactions.

We apply our rescue logic on two chargeback reasons for SEPA.

* **AM04**: Insufficient funds
* **MS03**: No reason specified. This code is used in some countries/regions instead of AM04.

Also note that for SEPA payments, we have a maximum of two rescue attempts within the rescue window. The reasons for that are:

* The period between the initial transaction and the first decline message is longer than for card transactions. This means we have fewer days left to rescue the transaction.
* Because chargebacks are typically fined by the issuing bank, it is important to keep the number of rescue attempts low.

On this page, you will learn how to:

1. [Enable Auto Rescue](#step-1-enable-auto-rescue) for SEPA transactions.
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/02.sepa/autorescue-sepa.svg)

## Step 1: Enable Auto Rescue

You can enable Auto Rescue for SEPA payments at:

* [Account level](#enable-auto-rescue-account-level)
* [Transaction level](#enable-auto-rescue-transaction-level).

### Enable at account level

To enable Auto Rescue for all qualifying SEPA payments, 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.

The rescue window is set to 42 days. If you want to use a different rescue window, enable Auto Rescue for SEPA payments at transaction level.

### Enable at transaction level

To enable Auto Rescue for SEPA payments on transaction level, 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.

When configured, to enable Auto Rescue for a SEPA transaction in your payment request:

* Add the `autoRescue` flag.
* Submit a unique `merchantOrderReference`. This reference represents 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). You can connect any Auto Rescue retry attempt to the original [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request using this reference.

For example:

* Make a [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request, and 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 **42** 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.
  * `paymentMethod.type`: **sepadirectdebit**
  * `paymentMethod.sepa.ownerName`: The name on the SEPA bank account. For testing, use a concatenation of `chargeback` and `reasonCode`. See the example below.
  * `paymentMethod.sepa.ibanNumber`: The IBAN of the bank account. Make sure to not encrypt this value.

  The following example shows how to enable Auto Rescue for a SEPA shopper-not-present transaction submitted to the [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) endpoint. In case of a chargeback, Auto Rescue will automatically retry this payment for a maximum of 30 days.

  **Enable Auto Rescue in 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 '{
     "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
     "reference":"YOUR_MERCHANT_REFERENCE",
     "merchantOrderReference":"YOUR_MERCHANT_ORDER_REFERENCE",
     "shopperInteraction":"ContAuth",
     "amount":{
       "currency":"EUR",
       "value":1000
     },
     "paymentMethod":{
       "type":"sepadirectdebit",
       "sepa.ownerName":"chargeback:MS03",
       "sepa.ibanNumber":"DE87123456781234567890"
     },
     "additionalData":{
       "autoRescue":"true",
       "maxDaysToRescue":"30"
     }
  }'
  ```

  #### 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("EUR")
    .value(1000L);

  SepaDirectDebitDetails sepaDirectDebitDetails = new SepaDirectDebitDetails()
    .type(SepaDirectDebitDetails.TypeEnum.SEPADIRECTDEBIT);

  PaymentRequest paymentRequest = new PaymentRequest()
    .reference("YOUR_MERCHANT_REFERENCE")
    .merchantOrderReference("YOUR_MERCHANT_ORDER_REFERENCE")
    .amount(amount)
    .merchantAccount("YOUR_MERCHANT_ACCOUNT")
    .shopperInteraction(PaymentRequest.ShopperInteractionEnum.CONTAUTH)
    .paymentMethod(new CheckoutPaymentMethod(sepaDirectDebitDetails))
    .additionalData(new HashMap<String, String>(Map.of(
      "autoRescue", "true",
      "maxDaysToRescue", "30"
    )));

  // 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("EUR")
    ->setValue(1000);

  $checkoutPaymentMethod = new CheckoutPaymentMethod();
  $checkoutPaymentMethod
    ->setType("sepadirectdebit");

  $paymentRequest = new PaymentRequest();
  $paymentRequest
    ->setReference("YOUR_MERCHANT_REFERENCE")
    ->setMerchantOrderReference("YOUR_MERCHANT_ORDER_REFERENCE")
    ->setAmount($amount)
    ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT")
    ->setShopperInteraction("ContAuth")
    ->setPaymentMethod($checkoutPaymentMethod)
    ->setAdditionalData(
      array(
        "autoRescue" => "true",
        "maxDaysToRescue" => "30"
      )
    );

  $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 = "EUR",
    Value = 1000
  };

  SepaDirectDebitDetails sepaDirectDebitDetails = new SepaDirectDebitDetails
  {
    Type = SepaDirectDebitDetails.TypeEnum.Sepadirectdebit
  };

  PaymentRequest paymentRequest = new PaymentRequest
  {
    Reference = "YOUR_MERCHANT_REFERENCE",
    MerchantOrderReference = "YOUR_MERCHANT_ORDER_REFERENCE",
    Amount = amount,
    MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
    ShopperInteraction = PaymentRequest.ShopperInteractionEnum.ContAuth,
    PaymentMethod = new CheckoutPaymentMethod(sepaDirectDebitDetails),
    AdditionalData = new Dictionary<string, string>
    {

      { "autoRescue", "true" },
      { "maxDaysToRescue", "30" }
    }
  };

  // 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 = {
    merchantAccount: "YOUR_MERCHANT_ACCOUNT",
    reference: "YOUR_MERCHANT_REFERENCE",
    merchantOrderReference: "YOUR_MERCHANT_ORDER_REFERENCE",
    shopperInteraction: "ContAuth",
    amount: {
      currency: "EUR",
      value: 1000
    },
    paymentMethod: {
      type: "sepadirectdebit",
      "sepa.ownerName" : "chargeback:MS03",
      "sepa.ibanNumber" : "DE87123456781234567890"
    },
    additionalData: {
      autoRescue: "true",
      maxDaysToRescue: "30"
    }
  }

  // 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: "EUR",
    Value: 1000,
  }

  sepaDirectDebitDetails := checkout.SepaDirectDebitDetails{
    Type: common.PtrString("sepadirectdebit"),
  }

  paymentRequest := checkout.PaymentRequest{
    Reference: "YOUR_MERCHANT_REFERENCE",
    MerchantOrderReference: common.PtrString("YOUR_MERCHANT_ORDER_REFERENCE"),
    Amount: amount,
    MerchantAccount: "YOUR_MERCHANT_ACCOUNT",
    ShopperInteraction: common.PtrString("ContAuth"),
    PaymentMethod: checkout.SepaDirectDebitDetailsAsCheckoutPaymentMethod(&sepaDirectDebitDetails),
    AdditionalData: &map[string]string{
      "autoRescue": "true",
      "maxDaysToRescue": "30",
    },
  }

  // 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 = {
    "merchantAccount": "YOUR_MERCHANT_ACCOUNT",
    "reference": "YOUR_MERCHANT_REFERENCE",
    "merchantOrderReference": "YOUR_MERCHANT_ORDER_REFERENCE",
    "shopperInteraction": "ContAuth",
    "amount": {
      "currency": "EUR",
      "value": 1000
    },
    "paymentMethod": {
      "type": "sepadirectdebit",
      "sepa.ownerName" : "chargeback:MS03",
      "sepa.ibanNumber" : "DE87123456781234567890"
    },
    "additionalData": {
      "autoRescue": "True",
      "maxDaysToRescue": "30"
    }
  }

  # 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 = {
    :merchantAccount => 'YOUR_MERCHANT_ACCOUNT',
    :reference => 'YOUR_MERCHANT_REFERENCE',
    :merchantOrderReference => 'YOUR_MERCHANT_ORDER_REFERENCE',
    :shopperInteraction => 'ContAuth',
    :amount => {
      :currency => 'EUR',
      :value => 1000
    },
    :paymentMethod => {
      :type => 'sepadirectdebit',
      :sepa.ownerName => 'chargeback:MS03',
      :sepa.ibanNumber => 'DE87123456781234567890'
    },
    :additionalData => {
      :autoRescue => 'true',
      :maxDaysToRescue => '30'
    }
  }

  # 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: "EUR",
    value: 1000
  };

  const sepaDirectDebitDetails: Types.checkout.SepaDirectDebitDetails = {
    type: Types.checkout.SepaDirectDebitDetails.TypeEnum.Sepadirectdebit
  };

  const paymentRequest: Types.checkout.PaymentRequest = {
    reference: "YOUR_MERCHANT_REFERENCE",
    merchantOrderReference: "YOUR_MERCHANT_ORDER_REFERENCE",
    amount: amount,
    merchantAccount: "YOUR_MERCHANT_ACCOUNT",
    shopperInteraction: Types.checkout.PaymentRequest.ShopperInteractionEnum.ContAuth,
    paymentMethod: sepaDirectDebitDetails,
    additionalData: {
      "autoRescue": "true",
      "maxDaysToRescue": "30"
    }
  };

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

  You will receive a response containing:

  * `resultCode`: **Authorised**

  []()

  **Response**

  ```json theme={null}
  {
      "additionalData": {
          "merchantOrderReference": "YOUR_MERCHANT_ORDER_REFERENCE",
          "retry.rescueReference": "8815658961765250",
          ...
      },
      "resultCode": "Authorised",
      "amount": {
          "currency": "EUR",
          "value": 1000
      },
      "merchantReference": "YOUR_MERCHANT_REFERENCE"
  }
  ```

  In case the transaction is charged back, you will receive a webhook event containing:

  * `eventCode`: [CHARGEBACK](https://docs.adyen.com/api-explorer/Webhooks/latest/post/CHARGEBACK)

  **CHARGEBACK webhook**

  ```json theme={null}
  {
      "notificationItems": [
        {
          "NotificationRequestItem": {
              "additionalData": {
                  "chargebackReasonCode": "MS03",
                  "modificationMerchantReferences":"",
                  "retry.rescueReference": "8515659468351660",
                  "merchantOrderReference": "YOUR_MERCHANT_ORDER_REFERENCE",
                  "retry.rescueScheduled": "true",
                  "chargebackSchemeCode": "sepadirectdebit",
                  "defensePeriodEndsAt":"2021-03-05T02:59:46+01:00",
                  "defendable": "false",
                  "disputeStatus": "Lost"
              },
              "amount": {
                  "currency": "EUR",
                  "value": 1000
              },
              "eventCode": "CHARGEBACK",
              "eventDate": "2021-03-05T02:59:46+01:00",
              "merchantAccountCode": "YOUR_MERCHANT_ACCOUNT",
              "merchantReference": "YOUR_REFERENCE",
              "originalReference": "8515659468351660",
              "paymentMethod": "sepadirectdebit",
              "pspReference": "PPKFQ89R6QRXGN82",
              "reason": "MS03:NotSpecifiedReasonAgentGenerated",
              "success": "true"
          }
       }
     ]
  }
  ```

  The Auto Rescue process will attempt to rescue this transaction.

## Step 2: Receive Auto Rescue updates

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

* A rescue attempt was made, and it was:

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

* The rescue process ended either because the payment was rescued, or the process was unsuccessful.

You will receive the webhook 16 days after the rescue attempt.

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

### Retry attempt successful

If a retry attempt was successful, this means we didn't receive another chargeback within the specified rescue window and the Auto Rescue process ended, you will receive a webhook event with:

* `eventCode`: **AUTORESCUE**
* `eventDate`: The date of the retry attempt.
* `success`: **true**
* `reason`: **retryWindowHasElapsed**

Here's an example of the Auto Rescue process end webhook event.

**AUTORESCUE webhook event for a successful retry**

```json theme={null}
{
  "notificationItems": [
    {
        "NotificationRequestItem": {
            "additionalData": {
                "retry.rescueReference": "8815658961765250",
                "merchantOrderReference": "YOUR_MERCHANT_ORDER_REFERENCE"
            },
            "amount": {
                "currency": "EUR",
                "value": 1000
            },
            "eventCode": "AUTORESCUE",
            "eventDate": "2021-03-06T05:00:46+01:00",
            "merchantAccountCode": "YOUR_MERCHANT_ACCOUNT",
            "merchantReference": "YOUR_REFERENCE",
            "originalReference": "8815658961765250",
            "pspReference": "R8QTPCQ8HXSKGK82",
            "reason": "retryWindowHasElapsed",
            "success": "true"
        }
    }
  ]
}
```

If we received another chargeback but the second retry was successful, the process ends and you will receive a webhook event with:

* `eventCode`: **AUTORESCUE**
* `eventDate`: The date of the retry attempt.
* `success`: **true**
* `reason`: **maxRetryAttemptsReached**

Here's an example of the Auto Rescue process end webhook event.

**AUTORESCUE webhook event for a successful second retry**

```json theme={null}
{
  "notificationItems": [
    {
        "NotificationRequestItem": {
            "additionalData": {
                "retry.rescueReference": "8515572949781132",
                "merchantOrderReference": "YOUR_MERCHANT_ORDER_REFERENCE"
            },
            "amount": {
                "currency": "EUR",
                "value": 1000
            },
            "eventCode": "AUTORESCUE",
            "eventDate": "2021-03-07T04:57:38+01:00",
            "merchantAccountCode": "YOUR_MERCHANT_ACCOUNT",
            "merchantReference": "YOUR_REFERENCE",
            "originalReference": "8515572949781132",
            "pspReference": "QJCMPCQ8HXSKGK82",
            "reason": "maxRetryAttemptsReached",
            "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.

### Retry attempt unsuccessful

If a retry attempt was unsuccessful, this means we received chargebacks after each of the two retry attempts. You will receive a webhook event with:

* `eventCode`: **AUTORESCUE**
* `eventDate`: The date of the retry attempt.
* `success`: **false**
* `reason`: **maxRetryAttemptsReached**

Here's an example of the Auto Rescue process end webhook event.

**AUTORESCUE webhook event for an unsuccessful retry attempt**

```json theme={null}
{
  "notificationItems": [
    {
        "NotificationRequestItem": {
            "additionalData": {
                "retry.rescueReference": "8515659468351668",
                "merchantOrderReference": "YOUR_MERCHANT_ORDER_REFERENCE"
            },
            "amount": {
                "currency": "EUR",
                "value": 1000
            },
            "eventCode": "AUTORESCUE",
            "eventDate": "2021-03-07T04:57:38+01:00",
            "merchantAccountCode": "YOUR_MERCHANT_ACCOUNT",
            "merchantReference": "YOUR_REFERENCE",
            "originalReference": "8515659468351668",
            "pspReference": "HWL5D5BDLSGLNK82",
            "reason": "maxRetryAttemptsReached",
            "success": "false"
        }
    }
  ]
}
```

## 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 charged back 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:

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

     * **AutoRescueSuccessfulFirst**: The payment is authorized but we received a chargeback. The first retry attempt is successful because we received no chargeback after this attempt within 30 days.
     * **AutoRescueSuccessfulSecond**: The payment is authorized but we received a chargeback. The first retry attempt is authorized but we received a second chargeback. The second retry attempt is successful because we received no chargeback after this attempt within 30 days.
     * **AutoRescueFailed**: The payment and all retry attempts are authorized, but we received chargebacks after each attempt.

   - `ownerName`: Set this to the type of chargeback that you want to simulate. Use a concatenation of `chargeback` and the reason code. For example, **chargeback:MS03** or **chargeback:AM04**.

   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 '{
        "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
        "reference":"YOUR_MERCHANT_REFERENCE",
        "merchantOrderReference":"YOUR_MERCHANT_ORDER_REFERENCE",
        "shopperInteraction":"ContAuth",
        "amount":{
           "currency":"EUR",
           "value":1000
        },
        "paymentMethod":{
           "type":"sepadirectdebit",
           "sepa.ownerName":"chargeback:MS03",
           "sepa.ibanNumber":"DE87123456781234567890"
        },
        "additionalData":{
           "autoRescue":"true",
           "maxDaysToRescue":"30",
           "autoRescueSepaScenario":"AutoRescueSuccessfulSecond"
       }
   }'
   ```

2. 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 with `merchantOrderReference` **A1** and **A2**.

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

| Transaction | PSP Reference | Merchant Order Reference | Record Type |
| - | - | - | - |
| November monthly subscription payment | 812872049382471H | A1 | Chargeback |
| 1st retry attempt | 814987049386784P | A1 | Authorised |
| December monthly subscription payment | 812872049382471H | A2 | Chargeback |
| 1st retry attempt | 804938149876784D | A2 | Chargeback |
| 2nd retry attempt | 804938149950514L | 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)
* [Understanding disputes](https://adyen-preview.mintlify.site/risk-management/understanding-disputes)
* [SEPA chargebacks](https://adyen-preview.mintlify.site/risk-management/chargeback-guidelines/sepa-chargebacks.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.