Search

Are you looking for test card numbers?

Would you like to contact support?

Online-payment icon

Handling redirects

Learn how you can handle different redirect flows.

For some payment methods, you need to redirect the shopper to another website to complete the payment. For card payments, if the issuer requires 3D Secure authentication and you are using redirect authentication, you also need to redirect the shopper to another website to complete the authentication before the payment can be processed.

If a shopper completed the payment but failed to return to your website or app, you will receive the outcome of the payment in a notification webhook.

Checking redirect parameters

Get the redirect information from the action object in the /payments response.

  • url: Link to where you should redirect your shopper.
  • data: For the POST method, this object contains the parameters that you should send as form data.
  • details.key: Contains the parameters that you should expect when the shopper returns back to your website. If other parameters are appended to the returnURL or sent in the request body but are not included in the details object, ignore them.
  • method: GET or POST. The HTTP request method that you should use. After the shopper completes the payment, the shopper will also be redirected back to your returnURL using the same method.

The redirect method depends on your payment method configuration and the length of the data included in the request, so make sure that your integration can handle both HTTP GET and HTTP POST methods.

For example, for an iDEAL payment, you will receive the following response:

{
  "action": {
    "method": "GET",
    "paymentData": "Ab02b4c0!B..=",
    "paymentMethodType": "ideal",
    "type": "redirect",
    "url": "https://test.adyen.com/hpp/redirectIdeal.shtml?brandCode=ideal&currencyCode=EUR..."
    },
  "details": [
    {
      "key": "payload",
      "type": "text"
    }
  ]
  ...
}

HTTP GET redirect

  1. Get the action.url from the /payments response:

    {
    ...
      "action": {
        "method": "GET",
        "paymentData": "Ab02b4c0!BQ..",
        "paymentMethodType": "ideal",
        "type": "redirect",
        "url": "https://test.adyen.com/hpp/redirectIdeal.shtml?brandCode=ideal&currencyCode=EUR&issuerId=1121..."
      }
    ...
    }
  2. Redirect the shopper to the action.url with an HTTP GET request. For example:

    curl https://test.adyen.com/hpp/redirectIdeal.shtml?brandCode=ideal&currencyCode=EUR&issuerId=1121... \
  3. After the shopper is redirected back to your returnUrl with an HTTP GET request, URL-decode the parameters appended to the returnURL.

    For example, a payload parameter can be appended to the return URL:

    GET /?shopperOrder=12xy..&&payload=Ab02b4c0!BQABF... HTTP/1.1
    Host: www.your-company.com/checkout
  4. Pass the parameters to your back end. You will need the parameters to get the payment result.

  5. From your server, make a /payments/details request, specifying:

    • paymentData: Value you received in the /payments response.
    • details: Object that contains the URL-decoded parameters appended to the returnURL. For example, payload.
    curl https://checkout-test.adyen.com/v50/payments/details \
    -H "x-API-key: YOUR_X-API-KEY" \
    -H "content-type: application/json" \
    -d '{
         "paymentData":"Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...",
         "details":{
           "payload":"Ab02b4c0!BQABAgCW5sxB4e/=="
         }
    }'
    # Set your X-API-KEY with the API key from the Customer Area.
    adyen = Adyen::Client.new
    adyen.api_key = "YOUR_X-API-KEY"
    
    response = adyen.checkout.payments.details({
      :paymentData => 'Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...',
      :details => {
        :payload => 'Ab02b4c0!BQABAgCW5sxB4e/=='
      }
    })
    // Set your X-API-KEY with the API key from the Customer Area.
    Client client = new Client(xApiKey,Environment.TEST);
    
    Checkout checkout = new Checkout(client);
    PaymentDetailsRequest paymentDetailsRequest = new PaymentDetailsRequest();
    HashMap<String, String> details = new HashMap<>();
    details.put("payload", "Ab02b4c0!BQABAgCW5sxB4e/==...");
    paymentsDetailsRequest.setDetails(details);
    paymentsDetailsRequest.setPaymentData("Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...");
    PaymentsResponse paymentsResponse = checkout.paymentDetails(PaymentDetailsRequest);
    // Set your X-API-KEY with the API key from the Customer Area.
    $client = new \Adyen\Client();
    $client->setXApiKey("YOUR_X-API-KEY");
    $service = new \Adyen\Service\Checkout($client);
    
    $params = array(
      "paymentData" => "Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...",
      "details" => array(
        "payload" => "Ab02b4c0!BQABAgCW5sxB4e/==..."
      )
    );
    $result = $service->paymentDetails($params);
    #Set your X-API-KEY with the API key from the Customer Area.
    adyen = Adyen.Adyen()
    adyen.client.xapikey = 'YOUR_X-API-KEY'
    
    result = adyen.checkout.payments_details({
       'paymentData' : 'Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...',
       'details': {
          'payload': 'Ab02b4c0!BQABAgCW5sxB4e/=='
       }
    })
    // Set your X-API-KEY with the API key from the Customer Area.
    var client = new Client ("YOUR_X-API-KEY", Environment.Test);
    var checkout = new Checkout(client);
    string paymentData = "Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...";
    var details = new Dictionary<string, string>
    {
      { "payload", "Ab02b4c0!BQABAgCW5sxB4e/==..." }
    };
    var paymentsDetailsRequest = new Model.Checkout.PaymentsDetailsRequest(Details: details, PaymentData: paymentData);
    var paymentResponse = checkout.PaymentDetails(paymentsDetailsRequest);
    // Set your X-API-KEY with the API key from the Customer Area.
    const {Client, Config, CheckoutAPI} = require('@adyen/api-library');
    const config = new Config();
    // Set your X-API-KEY with the API key from the Customer Area.
    config.apiKey = '[API_KEY]';
    config.merchantAccount = '[MERCHANT_ACCOUNT]';
    const client = new Client({ config });
    client.setEnvironment("TEST");
    const checkout = new CheckoutAPI(client);
    checkout.paymentsDetails({
        details: { payload: "Ab02b4c0!BQABAgCW5sxB4e/==" },
        paymentData: "Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...",
    }).then(res => res);

    The response contains:

      {
       "resultCode": "Authorised",
       "pspReference": "88154795347618C"
     }

HTTP POST redirect

  1. Get the action.url from the /payments response:

    {
    ...
    "action": {
           "data": {
               "MD": "OEVudmZVMUlkWjd0MDNwUWs2bmhSdz09...",
               "PaReq": "eNpVUttygjAQ/RXbDyAXBYRZ00HpTH3wUosPfe...",
               "TermUrl": "https://your-company.com/checkout?shopperOrder=12xy.."
           },
           "method": "POST",
           "paymentData": "Ab02b4c0!BQA...",
           "paymentMethodType": "scheme",
           "type": "redirect",
           "url": "https://test.adyen.com/hpp/3d/validate.shtml"
       }
       ...
    }
  2. Redirect the shopper to the specified url with an HTTP POST request and include the contents of the data object in the request body. For example:

    curl https://test.adyen.com/hpp/3d/validate.shtml \
    --data-urlencode 'PaReq=eNpVUttygjAQ/RXbDyAXBYRZ00HpTH3wUosPfe...' \
    --data-urlencode 'TermUrl=https://your-company.com/checkout?shopperOrder=12xy..' \
    --data-urlencode 'MD=OEVudmZVMUlkWjd0MDNwUWs2bmhSdz09...'
  3. After the shopper is redirected back to your returnUrl with an HTTP POST request, URL-decode the parameters from the form data.

    For example, the MD and PaRes parameters are returned after a 3D Secure authentication.

    POST / HTTP/1.1
    Host: www.your-company.com/checkout?shopperOrder=12xy..
    Content-Type: application/x-www-form-urlencoded
    MD=dXlER3BhTEVCazlLd1..&PaRes=eNrNV0mTo7gS..
  4. Pass the parameters to your back end. You will need the parameters to get the payment result.

  5. From your server, make a /payments/details request, specifying:

    • paymentData: Value you received in the /payments response.
    • details: Object that contains the URL-decoded parameters. For example, MD and PaRes.
    curl https://checkout-test.adyen.com/v50/payments/details \
    -H "x-API-key: YOUR_X-API-KEY" \
    -H "content-type: application/json" \
    -d '{
         "paymentData":"Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...",
         "details":{
           "MD":"Ab02b4c0!BQABAgCW5sxB4e/==",
           "PaRes":"eNrNV0mTo7gS.."
         }
    }'
    # Set your X-API-KEY with the API key from the Customer Area.
    adyen = Adyen::Client.new
    adyen.api_key = "YOUR_X-API-KEY"
    
    response = adyen.checkout.payments.details({
      :paymentData => 'Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...',
      :details => {
        :payload => 'Ab02b4c0!BQABAgCW5sxB4e/=='
      }
    })
    // Set your X-API-KEY with the API key from the Customer Area.
    Client client = new Client(xApiKey,Environment.TEST);
    
    Checkout checkout = new Checkout(client);
    PaymentDetailsRequest paymentDetailsRequest = new PaymentDetailsRequest();
    HashMap<String, String> details = new HashMap<>();
    details.put("MD", "Ab02b4c0!BQABAgCW5sxB4e/==");
    details.put("PaRes", "eNrNV0mTo7gS..");
    paymentsDetailsRequest.setDetails(details);
    paymentsDetailsRequest.setPaymentData("Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...");
    PaymentsResponse paymentsResponse = checkout.paymentDetails(PaymentDetailsRequest);
    // Set your X-API-KEY with the API key from the Customer Area.
    $client = new \Adyen\Client();
    $client->setXApiKey("YOUR_X-API-KEY");
    $service = new \Adyen\Service\Checkout($client);
    
    $params = array(
      "paymentData" => "Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...",
      "details" => array(
        "MD" => "Ab02b4c0!BQABAgCW5sxB4e/==",
        "PaRes" => "eNrNV0mTo7gS.."
      )
    );
    $result = $service->paymentDetails($params);
    #Set your X-API-KEY with the API key from the Customer Area.
    adyen = Adyen.Adyen()
    adyen.client.xapikey = 'YOUR_X-API-KEY'
    
    result = adyen.checkout.payments_details({
       'paymentData' : 'Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...',
       'details': {
          'MD': 'Ab02b4c0!BQABAgCW5sxB4e/==',
          'PaRes': "eNrNV0mTo7gS.."
       }
    })
    // Set your X-API-KEY with the API key from the Customer Area.
    var client = new Client ("YOUR_X-API-KEY", Environment.Test);
    var checkout = new Checkout(client);
    string paymentData = "Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...";
    var details = new Dictionary<string, string>
    {
      { "MD", "Ab02b4c0!BQABAgCW5sxB4e/==" },
      {"PaRes", "eNrNV0mTo7gS.."}
    };
    var paymentsDetailsRequest = new Model.Checkout.PaymentsDetailsRequest(Details: details, PaymentData: paymentData);
    var paymentResponse = checkout.PaymentDetails(paymentsDetailsRequest);
    // Set your X-API-KEY with the API key from the Customer Area.
    const {Client, Config, CheckoutAPI} = require('@adyen/api-library');
    const config = new Config();
    // Set your X-API-KEY with the API key from the Customer Area.
    config.apiKey = '[API_KEY]';
    config.merchantAccount = '[MERCHANT_ACCOUNT]';
    const client = new Client({ config });
    client.setEnvironment("TEST");
    const checkout = new CheckoutAPI(client);
    checkout.paymentsDetails({
        details: { MD: "Ab02b4c0!BQABAgCW5sxB4e/==", PaRes: "eNrNV0mTo7gS.." },
        paymentData: "Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...",
    }).then(res => res);

    The response contains:

      {
       "resultCode": "Authorised",
       "pspReference": "88154795347618C"
     }