Search

Are you looking for test card numbers?

Would you like to contact support?

Default 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.

There are two different redirect flows:

Redirect payment method

To redirect the shopper:

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

    /payments response for a payment method redirect
    {
    ...
      "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 the HTTP GET method. For example:

    curl https://test.adyen.com/hpp/redirectIdeal.shtml?brandCode=ideal&currencyCode=EUR&issuerId=1121... \

    The shopper is redirected to a page where they need to take additional action, depending on the payment method. When they are done, they are redirected back to your returnUrl.

    For security reasons, when displaying the redirect in the app, we recommend that you use SFSafariViewController for iOS or Chrome Custom Tabs for Android, instead of WebView objects. Also refer to the security best practices for WebView.

    After the shopper completes the payment, they are redirected back to your returnUrl with the same HTTP method. The returnUrl is appended with a redirectResult:

    GET /?shopperOrder=12xy..&&redirectResult=X6XtfGC3%21Y... HTTP/1.1
    Host: www.your-company.com/checkout

    URL-decode the redirectResult appended to the URL and pass it to your back end to verify the payment result.

    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.

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

    • paymentData: Value you received in the /payments response.
    • details: Object that contains the URL-decoded redirectResult.
    curl https://checkout-test.adyen.com/v66/payments/details \
    -H "x-API-key: YOUR_X-API-KEY" \
    -H "content-type: application/json" \
    -d '{
         "paymentData":"Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...",
         "details":{
           "redirectResult":"X6XtfGC3!Y..."
         }
    }'
    # 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 => {
        :redirectResult => '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);
    PaymentsDetailsRequest paymentsDetailsRequest = new PaymentsDetailsRequest();
    HashMap<String, String> details = new HashMap<>();
    details.put("redirectResult", "X6XtfGC3!Y...");
    paymentsDetailsRequest.setDetails(details);
    paymentsDetailsRequest.setPaymentData("Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...");
    PaymentsResponse paymentsResponse = checkout.paymentsDetails(paymentsDetailsRequest);
    // 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(
        "redirectResult" => "X6XtfGC3!Y..."
      )
    );
    $result = $service->paymentsDetails($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': {
          'redirectResult': 'X6XtfGC3!Y...'
       }
    })
    // 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>
    {
      { "redirectResult", "X6XtfGC3!Y..." }
    };
    var paymentsDetailsRequest = new Model.Checkout.PaymentsDetailsRequest(Details: details, PaymentData: paymentData);
    var paymentResponse = checkout.PaymentDetails(paymentsDetailsRequest);
    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: { redirectResult: "X6XtfGC3!Y..." },
        paymentData: "Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...",
    }).then(res => res);
    import (
        "github.com/adyen/adyen-go-api-library/v2/src/checkout"
        "github.com/adyen/adyen-go-api-library/v2/src/common"
        "github.com/adyen/adyen-go-api-library/v2/src/adyen"
    )
    
    // Set your X-API-KEY with the API key from the Customer Area.
    client := adyen.NewClient(&common.Config{
        ApiKey:      "[API_KEY]",
        Environment: common.TestEnv,
    })
    
    res, httpRes, err := client.Checkout.PaymentsDetails(&checkout.DetailsRequest{
        PaymentData: "Ab02b4c0!BQABAgAKspbjN8+5...",
        Details: map[string]interface{}{
            "redirectResult":    "X6XtfGC3!Y...",
        },
    })

    The response contains:

    /payments/details response
      {
       "resultCode": "Authorised",
       "pspReference": "88154795347618C"
     }

3D Secure redirect

To redirect the shopper for 3D Secure authentication:

  1. Get the action.url and the action.method from the /payments response.
  2. Redirect the shopper to the specified url using the HTTP POST, and include the contents of the data object in the request. For example:
    curl https://test.adyen.com/hpp/3d/validate.shtml \
    --data-urlencode 'PaReq=eNpVUttygjAQ/RXbDyAXBYRZ00HpTH3wUosPfe...' \
    --data-urlencode 'TermUrl=https://example.com/checkout?shopperOrder=12xy..' \
    --data-urlencode 'MD=OEVudmZVMUlkWjd0MDNwUWs2bmhSdz09...'
    The shopper is redirected to the issuer page to complete the 3D Secure authentication. In the test environment, this is the page: https://test.adyen.com/hpp/3d/validate.shtml, and you perform the authentication using the 3D Secure test credentials:
    • Username: user
    • Password: password
    After completing the 3D Secure authentication, the shopper is redirected back to your returnUrl with the same HTTP method. This will be appended with the MD and PaRes variables.
        POST / HTTP/1.1
        Host: www.your-company.com/checkout?shopperOrder=12xy..
        Content-Type: application/x-www-form-urlencoded
        MD=Ab02b4c0%21BQABAgCW5sxB4e%2F%3D%3D..&PaRes=eNrNV0mTo7gS..
  3. URL-decode the MD and PaRes parameters, and pass the parameters to your server.
  4. From your server, make a /payments/details request, specifying:
    • paymentData: Value that you received in the /payments response.
    • details: Object that contains the URL-decoded MD and PaRes parameters.
    curl https://checkout-test.adyen.com/v66/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 => {
            :MD => 'Ab02b4c0!BQABAgCW5sxB4e/==..',
            :PaRes => 'eNrNV0mTo7gS..'
      }
    })
    // 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);
    PaymentsDetailsRequest paymentsDetailsRequest = new PaymentsDetailsRequest();
    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.paymentsDetails(paymentsDetailsRequest);
    // 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->paymentsDetails($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);
    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);
    import (
        "github.com/adyen/adyen-go-api-library/v2/src/checkout"
        "github.com/adyen/adyen-go-api-library/v2/src/common"
        "github.com/adyen/adyen-go-api-library/v2/src/adyen"
    )
    
    // Set your X-API-KEY with the API key from the Customer Area.
    client := adyen.NewClient(&common.Config{
        ApiKey:      "[API_KEY]",
        Environment: common.TestEnv,
    })
    
    res, httpRes, err := client.Checkout.PaymentsDetails(&checkout.DetailsRequest{
        PaymentData: "Ab02b4c0!BQABAgAKspbjN8+5...",
        Details: map[string]interface{}{
            "MD": "Ab02b4c0!BQABAgCW5sxB4e/==",
            "PaRes": "eNrNV0mTo7gS..",
        },
    })
    The response contains:
    /payments/details response
      {
       "resultCode": "Authorised",
       "pspReference": "88154795347618C"
     }