Are you looking for test card numbers?

Would you like to contact support?

Atenção, esta página não se encontra disponível em Português
Default icon

Handling redirects

Learn how you can handle different redirect flows on Checkout API.

Choose your API version:

If you get a redirect action.type:

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

    /payments response
    {
      "action": {
        "method": "GET",
        "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 method from action.method.

    • For redirect payment methods, theaction.method is GET:

      curl https://test.adyen.com/hpp/redirectIdeal.shtml?brandCode=ideal&currencyCode=EUR&issuerId=1121... \
    • For 3D Secure redirect, the action.method is POST:

      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 a page where they need to take additional action, depending on the payment method.

    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 HTTP GET. The returnUrl is appended with a Base64-encoded redirectResult:

    GET /?shopperOrder=12xy..&&redirectResult=X6XtfGC3%21Y... HTTP/1.1
    Host: www.your-company.com/checkout
  3. Get the redirectResult appended to the URL and pass it to your back end to verify the payment result in the next step.

    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.

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

    • details: Object that contains the URL-decoded redirectResult.
    /payments/details request
    curl https://checkout-test.adyen.com/v67/payments/details \
    -H "x-API-key: YOUR_X-API-KEY" \
    -H "content-type: application/json" \
    -d '{
        "details": {
          "redirectResult": "eyJ0cmFuc1N0YXR1cyI6IlkifQ=="
      }
    }'

    The response contains:

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

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 in the next step.

    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.

The response contains:

  • resultCode: Use this to present the result to your shopper.
  • pspReference: Our unique identifier for the transaction.

    /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.."
     }
}'
require 'adyen-ruby-api-library'

# Set your X-API-KEY with the API key from the Customer Area.
adyen = Adyen::Client.new
adyen.env = :test
adyen.api_key = "YOUR_X-API-KEY"

request = adyen.checkout.payments.details({ 
    :paymentData => 'Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...',
    :details => {
        :MD => 'Ab02b4c0!BQABAgCW5sxB4e/==..',
        :PaRes => 'eNrNV0mTo7gS..'
  }
})
response = adyen.checkout.payments.details(request)
// Set your X-API-KEY with the API key from the Customer Area.
String xApiKey = "YOUR_X-API-KEY";
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 paymentsDetailsResponse = checkout.paymentsDetails(paymentsDetailsRequest);
// Set your X-API-KEY with the API key from the Customer Area.
$client = new \Adyen\Client();
$client->setEnvironment(\Adyen\Environment::TEST);
$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.payment.client.platform = "test"
adyen.client.xapikey = 'YOUR_X-API-KEY'

request = {
    'paymentData' : 'Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...',
    'details': {
        'MD': 'Ab02b4c0!BQABAgCW5sxB4e/==..',
        'PaRes': 'eNrNV0mTo7gS..'
    }
}
result = adyen.checkout.payments_details(request)
// Set your X-API-KEY with the API key from the Customer Area.
string apiKey = "YOUR_X-API-KEY";
var client = new Client (apiKey, 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 paymentsDetailsResponse = checkout.PaymentsDetails(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 = '[YOUR_X-API-KEY]';
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: Use this to present the result to your shopper.
  • pspReference: Our unique identifier for the transaction.

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