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:
-
Get the
action.url
from the /payments response: -
Redirect the shopper to the
action.url
with the HTTP GET method. For example:curl https://test.adyen.com/hpp/redirectIdeal.shtml?brandCode=ideal¤cyCode=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. ThereturnUrl
is appended with aredirectResult
: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.
-
From your server, make a /payments/details request, specifying:
paymentData
: Value you received in the /payments response.details
: Object that contains the URL-decodedredirectResult
.
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:
resultCode
: Use this to present the result to your shopper.pspReference
: Our unique identifier for the transaction.
3D Secure redirect
To redirect the shopper for 3D Secure authentication:
-
Get the
action.url
and theaction.method
from the /payments response. -
Redirect the shopper to the specified
url
using the HTTP POST, and include the contents of thedata
object in the request. For example:
The shopper is redirected to the issuer page to complete the 3D Secure authentication. In the test environment, this is the page: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...'
https://test.adyen.com/hpp/3d/validate.shtml
, and you perform the authentication using the 3D Secure test credentials:- Username: user
- Password: password
returnUrl
with the same HTTP method. This will be appended with theMD
andPaRes
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..
-
URL-decode the
MD
andPaRes
parameters, and pass the parameters to your server. -
From your server, make a /payments/details request, specifying:
-
paymentData
: Value that you received in the /payments response. -
details
: Object that contains the URL-decodedMD
andPaRes
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..", }, })
-
resultCode
: Use this to present the result to your shopper. -
pspReference
: Our unique identifier for the transaction.
-