Search

Are you looking for test card numbers?

Would you like to contact support?

Online-payment icon

Web Components integration guide

Build your web payments form with our JavaScript Components.

See sample codes

  Explore our GitHub repositories here and here.

Components are building blocks that you can use to render UI for individual payment methods: from collecting payment details to handling additional shopper interaction. We recommend that you integrate Components if you want some degree of customization and flexibility on your payments form.

Components are also available on iOS and Android. For an overview of all integration options and available features, refer to Online payments.

Supported payment methods

Components are available for cards, wallets, and most local payment methods. For a list of all payment methods with an available component, refer to Supported payment methods.

To see which payment methods are available in a country, you can also visit our demo store, and select the country at the bottom of the page.

We're actively building Components for more payment methods. To check the latest on Components, see our release notes.

How it works

On this page we describe both server-side and client-side integration steps:

  1. From your server, submit a request to get a list of payment methods available to the shopper.
  2. Add the specific payment method Component to your payments form.
  3. From your server, submit a payment request with the data returned by the Component.
  4. Determine from the response if you need to perform additional actions on your front end, such as to redirect the shopper.
  5. From your server, submit additional payment details.
  6. Present the payment result to the shopper.

Before you begin

Before you start integrating with our online payments API, make sure that you have performed the following steps:

  1. Sign up for an Adyen test account
  2. Get your API Key. Save a copy as you need it for API calls you make to the Adyen payments platform.
  3. Install one of our Libraries to connect with the Adyen APIs.
  4. Use the latest version of our APIs.
  5. If you're building for multiple merchants, provide some basic information so that we can offer you better support.
  6. If you are accepting card payments, learn what you need to do to assess your PCI DSS compliance. Depending on your integration, Adyen may require that you submit PCI DSS documents before you can accept card payments in the live environment.

For more information on these steps, refer to Get started with Adyen.

Step 1: Get available payment methods

First, present a list of available payment methods to your shopper:

  1. Make a POST /paymentMethods request, providing:

    • merchantAccount: Your merchant account name. 
    • countryCode: The shopper's country.
    • amount: The currency and value of the payment (in minor units). For more information, see Currency codes.
    • channel: The platform of the shopper's device. Use Web.

    We use the countryCodeamount, and channel to tailor the list of payment methods to your shopper.

    curl https://checkout-test.adyen.com/v51/paymentMethods \
    -H "x-API-key: YOUR_X-API-KEY" \
    -H "content-type: application/json" \
    -d '{
      "merchantAccount": "YOUR_MERCHANT_ACCOUNT",
      "countryCode": "NL",
      "amount": {
        "currency": "EUR",
        "value": 1000
      },
      "channel": "Web"
    }'
    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"
    
    response = adyen.checkout.payment_methods({
      :merchantAccount => 'YOUR_MERCHANT_ACCOUNT',
      :countryCode => 'NL',
      :amount => {
        :currency => 'EUR',
        :value => 1000
      },
      :channel => 'Web'
    })
    # Pass the response to your front end
    // 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);
    PaymentMethodsRequest paymentMethodsRequest = new PaymentMethodsRequest();
    paymentMethodsRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
    paymentMethodsRequest.setCountryCode("NL");
    Amount amount = new Amount();
    amount.setCurrency("EUR");
    amount.setValue(1000L);
    paymentMethodsRequest.setAmount(amount);
    paymentMethodsRequest.setChannel(PaymentMethodsRequest.ChannelEnum.WEB);
    PaymentMethodsResponse response = checkout.paymentMethods(paymentMethodsRequest);
    // 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(
      "merchantAccount" => "YOUR_MERCHANT_ACCOUNT",
      "countryCode" => "NL",
      "amount" => array(
        "currency" => "EUR",
        "value" => 1000
      ),
      "channel" => "Web"
    );
    
    $result = $service->paymentMethods($params);
    // Pass the response to your front end
    # Set your X-API-KEY with the API key from the Customer Area.
    adyen = Adyen.Adyen()
    adyen.client.xapikey = 'YOUR_X-API-KEY'
    
    request = {
      'merchantAccount': 'YOUR_MERCHANT_ACCOUNT',
      'countryCode': 'NL',
      'amount': {
        'value': 1000,
        'currency': 'EUR'
      },
      'channel': 'Web'
    }
    
    response = adyen.checkout.payment_methods(request)
    # Pass the response to your front end
    // 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);
    var amount = new Model.Checkout.Amount("EUR", 1000);
    var paymentMethodsRequest = new Model.Checkout.PaymentMethodsRequest(MerchantAccount: "YOUR_MERCHANT_ACCOUNT")
    {
       CountryCode = "NL",
       Amount = amount,
       Channel = "Web"
    };
    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 = '[YOUR_MERCHANT_ACCOUNT]';
    const client = new Client({ config });
    client.setEnvironment("TEST");
    const checkout = new CheckoutAPI(client);
    const paymentsResponse = checkout.paymentMethods({
        amount: {
            currency: "EUR",
            value: 1000,
        },
        countryCode: "NL",
        channel: "Web",
        merchantAccount: config.merchantAccount
    }).then(res => res);

    A list of available paymentMethods is returned in the response. Each payment method has a:

    • name: Name of the payment method.
    • type: Unique payment method code.
    /paymentMethods response
    {
      "paymentMethods":[
        {
          "details":[...],
          "name":"Credit Card",
          "type":"scheme"
          ...
        },
        {
          "details":[...],
          "name":"SEPA Direct Debit",
          "type":"sepadirectdebit"
        },
        ...
      ]
    }

    If you want to know more about the properties returned in the response, see the response parameters on API Explorer.

  2. Pass the response to your front end. You will use this in the next step to specify which payment methods are available for the shopper.

Step 2: Add Components to your payments form

To learn how SRI hashes help ensure the integrity of the files that you are loading from Adyen, refer to Subresource Integrity.

To use Components on your payments form, you need to:

  1. Include the following script in the <body> above any other JavaScript in your checkout page: 

    We recommend that you also validate the Subresource Integrity (SRI) hash, which we provide for our JavaScript and CSS files.

    <script src="https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.5.0/adyen.js"
    integrity="sha384-MpcW2OFcC1/y5nwF6UmvRfDXGISpg1rowHVybiS+wJObkUwgFpvbdpJxR2/bwmeA"
    crossorigin="anonymous"></script>
    <!-- Adyen provides the SRI hash that you include as the integrity attribute. Refer to our release notes to get the SRI hash for the specific version. https://docs.adyen.com/checkout/components-drop-in-release-notes -->
  2. Use the following CSS file:

    <link rel="stylesheet" href="https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.5.0/adyen.css"
    integrity="sha384-aWycvW8Dygg+6QHTq56FJMi4CJBjQt4LbRO3zWUuyfbv0A8g3rb5FR/vHyHKfiY0"
    crossorigin="anonymous">
    <!-- Adyen provides the SRI hash that you include as the integrity attribute. Refer to our release notes to get the SRI hash for the specific version. https://docs.adyen.com/checkout/components-drop-in-release-notes -->

    You can add your own styling by overriding the rules of this CSS file.

  3. Create functions to handle the following events:
    • onChange: Event that Components call after the shopper provides the required payment details for the specific payment method.

      Alternatively, you can use our pre-built Pay button, together with the onSubmit event. Refer to the showPayButton configuration in Configuring Components.

    • onAdditionalDetails: An event that a Component calls when you need to provide additional payment details in your request.

  4. Create an instance of AdyenCheckout, specifying the following parameters:

    • locale: The shopper's locale. This is used to set the language rendered in the Components. For a list of supported locales, see Localization.
    • originKey: The Origin Key of your website. To find out how to generate one, see How to get an Origin Key.
    • environment: Use test. When you're ready to accept live payments, change the value to one of our live environments.  
    • paymentMethodsResponse: The full paymentMethods response, returned in step 1. We recommend that you pass this on the AdyenCheckout instance. Otherwise, you need to pass the specific payment method details separately for each Component.
    • onChange: Specify the function that you created in step 3 above, for example, handleOnChange. If you wish to override this function, you can also define an onChange event on the Component level.
    • onAdditionalDetails: Specify the function that you created in step 3 above, for example, handleOnAdditionalDetails.
       function handleOnChange(state, component) {
           state.isValid // True or false. Specifies if all the information that the shopper provided is valid.
           state.data // Provides the data that you need to pass in the `/payments` call.
           component // Provides the active component instance that called this event.
       }
    
       function handleOnAdditionalDetails(state, component) {
           state.data // Provides the data that you need to pass in the `/payments/details` call.
           component // Provides the active component instance that called this event.
       }
    
       const configuration = {
           locale: "en_US", // The shopper's locale. For a list of supported locales, see https://docs.adyen.com/checkout/components-web/localization-components.
           environment: "test", // When you're ready to accept live payments, change the value to one of our live environments https://docs.adyen.com/checkout/components-web#testing-your-integration.  
           originKey: "YOUR_ORIGIN_KEY", // Your website's Origin Key. To find out how to generate one, see https://docs.adyen.com/user-management/how-to-get-an-origin-key.
           paymentMethodsResponse: paymentMethodsResponse, // The payment methods response returned in step 1.
           onChange: handleOnChange, // Your function for handling onChange event
           onAdditionalDetails: handleOnAdditionalDetails // Your function for handling onAdditionalDetails event
       };
    
       const checkout = new AdyenCheckout(configuration);
  5. Next, add Components for the payment methods that you'll be accepting.

    The steps for adding Components are the same for each payment method, however, some may require additional configuration. For information on the required configuration, refer to the payment method integration guides.
    • Create a DOM element, placing it where you want the payment method form to be rendered.

      <div id="component-container"></div>

      If you are using JavaScript frameworks such as Vue or React, make sure that you use references instead of selectors and that you don't re-render the DOM element.

    • Use the checkout.create method to create and mount an instance of a payment method Component. For example, to add the Cards Component to your payments form:

      const card = checkout.create("card").mount("#component-container");

      You can also include optional Card Component configuration.

  6. When the shopper enters the payment details, the Component will call the onChange event. If state.isValid is true, collect the values passed in state.data. These are the shopper details that you will need to make the payment.

  7. Pass state.data values to your server.

    state from onChange event for Card Component
    {
      isValid: true,
      data: {
        paymentMethod: {
          type: "scheme",
          encryptedCardNumber: "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
          encryptedExpiryMonth: "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
          encryptedExpiryYear: "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
          encryptedSecurityCode: "adyenjs_0_1_18$MT6ppy0FAMVMLH..."
        }
      }
    }

Step 3: Make a payment

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

    • amount
    • reference: Your unique reference for this payment.
    • paymentMethod: The state.data.paymentMethod from the onChange event from your front end.
    • returnUrl: URL to where the shopper should be taken back to after a redirection. The URL should include the protocol: http:// or https://. You can also include your own additional query parameters, for example, shopper ID or order reference number.
    • merchantAccount: Your merchant account name.
      Additional parameters are required for some payment methods, native 3D Secure 2 authentication, and recurring payments. For information on the required fields, refer to the payment method integration guides.

    The example below shows how you would make a card payment using encrypted values generated by the Card Component.

    curl https://checkout-test.adyen.com/v51/payments \
    -H "x-API-key: YOUR_X-API-KEY" \
    -H "content-type: application/json" \
    -d '{
      "amount":{
        "currency":"EUR",
        "value":1000
      },
      "reference":"YOUR_ORDER_NUMBER",
      "paymentMethod":{hint:state.data.paymentMethod from onChange or OnSubmit}state.data.paymentMethod{/hint},
      "returnUrl":"https://your-company.com/checkout?shopperOrder=12xy..",
      "merchantAccount":"YOUR_MERCHANT_ACCOUNT"
    }'
    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"
     
    paymentMethod = "COMPONENT_DATA"
    # Data object passed from OnChange event of the front end, parsed from JSON to a Hash.
    
    response = adyen.checkout.payments({
      :amount => {
        :currency => "EUR",
        :value => 1000
      },
      :reference => "YOUR_ORDER_NUMBER",
      :paymentMethod => paymentMethod,
      :returnUrl => "https://your-company.com/checkout?shopperOrder=12xy..",
      :merchantAccount => "YOUR_MERCHANT_ACCOUNT"
    })
    
    # Check if further action is needed.
    if response.body.has_key(:action)
       # Pass the action object to your front end
       # response.body[:action]
    else
       # No further action needed, pass the resultCode object to your front end
       # response.body[:resultCode]
    // 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);
    PaymentsRequest paymentsRequest = new PaymentsRequest();
    paymentsRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
    Amount amount = new Amount();
    amount.setCurrency("EUR");
    amount.setValue(15000L);
    paymentsRequest.setAmount(amount);
    String encryptedCardNumber = "adyenjs_0_1_18$...encryptedCardNumber";
    String encryptedExpiryMonth = "adyenjs_0_1_18$...encryptedExpiryMonth";
    String encryptedExpiryYear = "adyenjs_0_1_18$...encryptedExpiryYear";
    String encryptedSecurityCode = "adyenjs_0_1_18$...encryptedSecurityCode";
    paymentsRequest.setReference("Your order number");
    paymentsRequest.addEncryptedCardData(encryptedCardNumber,encryptedExpiryMonth, encryptedExpiryYear, encryptedSecurityCode, "John Smith");
    paymentsRequest.setReturnUrl("https://your-company.com/checkout?shopperOrder=12xy..");
    PaymentsResponse paymentsResponse = checkout.payments(paymentsRequest);
    // 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);
    
    $paymentMethod = "COMPONENT_DATA";
    // Data object passed from onChange event of the front end parsed from JSON to an array
    
    $params = array(
      "amount" => array(
        "currency" => "EUR",
        "value" => 1000
      ),
      "reference" => "YOUR_ORDER_NUMBER",
      "paymentMethod" => $paymentMethod,
      "returnUrl" => "https://your-company.com/checkout?shopperOrder=12xy..",
      "merchantAccount" => "YOUR_MERCHANT_ACCOUNT"
    );
    
    $result = $service->payments($params);
    
    // Check if further action is needed.
    if (array_key_exists("action", $result){
       // Pass the action object to your front end
       // $result["action"]
    }
    else {
       // No further action needed, pass the resultCode to your front end
       // $result['resultCode']
    }
    # Set your X-API-KEY with the API key from the Customer Area.
    adyen = Adyen.Adyen()
    adyen.client.xapikey = 'YOUR_X-API-KEY'
    
    paymentMethod = "COMPONENT_DATA"
    # Data object passed from onChange event of the front end, parsed from JSON to a dictionary
    
    result = adyen.checkout.payments({
       'amount': {
          'value': 1000,
          'currency': 'EUR'
       },
       'reference': 'YOUR_ORDER_NUMBER',
       'paymentMethod': paymentMethod,
       'returnUrl': 'https://your-company.com/checkout?shopperOrder=12xy..',
       'merchantAccount': 'YOUR_MERCHANT_ACCOUNT'
    })
    
    # Check if further action is needed
    if 'action' in result.message:
       # Pass the action object to your front end
       # result.message['action']
    else:
       # No further action needed, pass the resultCode to your front end
       # result.message['resultCode']
    // 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);
    
    var amount = new Model.Checkout.Amount("EUR", 1000);
    var details = new Model.Checkout.DefaultPaymentMethodDetails{
      Type = "scheme",
      EncryptedCardNumber = "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
      EncryptedExpiryMonth = "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
      EncryptedExpiryYear = "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
      EncryptedSecurityCode = "adyenjs_0_1_18$MT6ppy0FAMVMLH..."
    };
    var paymentRequest = new Adyen.Model.Checkout.PaymentRequest
    {
      Reference = "YOUR_ORDER_NUMBER",
      Amount = amount,
      ReturnUrl = @"https://your-company.com/checkout?shopperOrder=12xy..",
      MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
      PaymentMethod = details
    };
    
    var paymentResponse = checkout.Payments(paymentsRequest);
    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 = '[YOUR_MERCHANT_ACCOUNT]';
    const client = new Client({ config });
    client.setEnvironment("TEST");
    const checkout = new CheckoutAPI(client);
    checkout.payments({
        amount: { currency: "EUR", value: 1000 },
        paymentMethod: {"COMPONENT_DATA"}, // Data object passed from onChange event of the front end
        reference: "YOUR_ODRER_NUMBER",
        merchantAccount: config.merchantAccount,
        shopperReference: "shopperReference",
        returnUrl: "https://your-company.com/checkout?shopperOrder=12xy.."
    }).then(res => res);

    Response

    Depending on the payment result, you receive a response containing:

    • resultCode: Provides information about the result of the request.
    • pspReference: Our unique identifier for the transaction.
    • details: This array shows the fields that you need to pass in your next request.
    • action: If you receive this object, this indicates that you need to perform an additional action on your front end to complete the payment. The type field specifies the required action.
    • action.paymentData: If you receive action.type redirect, keep a copy of the paymentData. You will need to pass this in your next request.

  2. The next steps depend on if you received an action object in the response.

    • If you received an action object, pass this to your front end or client app and proceed to step 4. Make sure that you only pass the action object and not the full response.
    • If you did not get an action object, proceed to step 6 to present the payment result to your shopper.
    /payments response
      {
        "resultCode":"IdentifyShopper",
        "action":{
          "paymentData":"...",
          "paymentMethodType":"scheme",
          "type":"threeDS2Fingerprint"
          ...
        }
      ...
      }

Step 4: Perform additional front end actions

  1. V 3.1.0 Call createFromAction and pass the action object from the previous step. This will return a new Component that you need to mount:

    checkout.createFromAction(action).mount('#my-container');
  2. The Component performs additional front-end actions depending on the action.type. Your next steps depend on the type of action that the Component performs.

    action.type Description Next steps
    redirect The Component redirects the shopper to another website or app to complete the payment. Handle the redirect result.
    voucher The Component displays the voucher which the shopper
    uses to complete the payment.
    Proceed to step 6 and inform the shopper that you are waiting for the payment.
    You receive a notification webhook informing you of the payment result.
    qrCode The Component presents the QR code
    and calls the onAdditionalDetails event.
    1. Get the state.data from the onAdditionalDetails event and pass it your server.
    2. Proceed to step 5.
    threeDS2Fingerprint or
    threeDS2Challenge
    The Component performs the 3D Secure 2 device fingerprinting or presents a challenge to the shopper.
    After performing the authentication flows, Drop-in calls the onAdditionalDetails event.
    1. Get the state.data from the onAdditionalDetails event and pass it your server.
    2. Proceed to step 5.

Step 5: Submit additional payment details

If the Component presented a QR code, use the /payments/details endpoint to check the payment result. If you used the 3D Secure 2 Component for native authentication, use the same endpoint to submit authentication results and to complete the payment.

  1. From your server, make a POST /payments/details request with the state.data from the onAdditionalDetails event.

    The example below shows how you would submit additional payment details in case you received a threeDS2Fingerprint action.type.

    curl https://checkout-test.adyen.com/v51/payments/details \
    -H "x-API-key: YOUR_X-API-KEY" \
    -H "content-type: application/json" \
    -d '{
          "{hint:state.data.details from onAdditionalDetails}details{/hint}":{
             "threeds2.fingerprint":"eyJ0aHJlZURTQ29tcEluZCI6IlkifQ=="
          },
          "{hint:state.data.paymentData from onAdditionalDetails}paymentData{/hint}":"Ab02b4c0!BQABAgAKspbjN8+5..."
    }'
    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 = COMPONENT_DATA
    # Data object passed from onAdditionalDetails event of the front end, parsed from JSON to a Hash.
    
    response = adyen.checkout.payments.details(request)
    
    # Check if further action is needed.
    if response.body.has_key(:action)
       # Pass the action object to your frontend
       puts response.body[:action]
    else
       # No further action needed, pass the resultCode to your frontend
       puts response.body[:resultCode]
    end
    // Set your X-API-KEY with the API key from the Customer Area.
    String apiKey = "YOUR_X-API-KEY";
    
    String paymentData = "Ab02b4c0!BQABAgAKspbjN8+5...";
    String fingerPrint = "eyJ0aHJlZURTQ29tcEluZCI6IlkifQ==";
    
    Client client = new Client(apiKey,Environment.TEST);
    Checkout checkout = new Checkout(client);
    PaymentDetailsRequest paymentDetailsRequest = new PaymentDetailsRequest();
    paymentDetailsRequest.setFingerPrint();
    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 = COMPONENT_DATA;
    // Data object passed from onAdditionalDetails event of the front end parsed from JSON to an array
    
    $result = $service->paymentDetails($params);
    
    // Check if further action is needed
    if (array_key_exists("action", $result){
       // Pass the action object to your frontend.
       // $result["action"]
    }
    else {
       // No further action needed, pass the resultCode to your front end
       // $result['resultCode']
    }
    #Set your X-API-KEY with the API key from the Customer Area.
    adyen = Adyen.Adyen()
    adyen.client.xapikey = 'YOUR_X-API-KEY'
    
    request = COMPONENT_DATA
    # Data object passed from onAdditionalDetails event of the front end, parsed from JSON to a dictionary
    
    result = adyen.checkout.payments_details(request)
    
    # Check if further action is needed.
    if 'action' in result.message:
       # Pass the action object to your front end
       # result.message['action']
    else:
       # No further action needed, pass the resultCode to your front end
       # result.message['resultCode']
    // Set your X-API-KEY with the API key from the Customer Area.
    string apiKey = "YOUR_X-API-KEY";
    
    string fingerPrint = "eyJ0aHJlZURTQ29tcEluZCI6IlkifQ==";
    string paymentData = "Ab02b4c0!BQABAgAKspbjN8+5...";
    
    var client = new Client (apiKey, Environment.Test);
    var checkout = new Checkout(client);
    
    var details = new Dictionary<string, string>
    {
      { "threeds2.fingerprint": fingerPrint }
    };
    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: {COMPONENT_DATA}  // Data object passed from onAdditionalDetails event of the front end
    }).then(res => res);

    Depending on the payment result, you receive a response containing:

    • resultCode: Provides information about the result of the request.
    • pspReference: Our unique identifier for the transaction.
    • action: If you receive this object, this indicates that you need to perform step 4 again.

  2. The next steps depend on if you received an action object in the response.

    • If you received an action object, pass the action object to your front end and perform step 4 again.
    • If you did not get an action object, proceed to the next step to present the payment result to your shopper.
    Successful payment response
    {
     "pspReference": "88154795347618C",
     "resultCode": "Authorised"
    }
    Refused response
    {
     "pspReference": "89783918347627F",
     "refusalReason": "Not enough balance",
     "resultCode": "Refused"
    }

Step 6: Present the payment result

After the shopper completes the payment and no more further actions are required on the front end or client app, use the resultCode to inform the shopper of the payment status.

resultCode Description Action to take
Authorised The payment was successful. Inform the shopper that the payment was successful.
Error Inform the shopper that there was an error processing their payment. You'll receive a refusalReason in the same response, indicating the cause of the error.
Pending The shopper has completed the payment but the final result is not yet known. Inform the shopper that you've received their order, and are waiting for the payment to be completed.
You will receive the final result of the payment in an AUTHORISATION notification.
PresentToShopper Present the voucher or the QR code to the shopper. For a voucher payment method, inform the shopper that you are waiting for their payment. You will receive the final result of the payment in an AUTHORISATION notification.

For a qrCode payment method, wait for the AUTHORISATION notification before presenting the payment result to the shopper.
Refused The payment was refused. Inform the shopper that the payment was refused. Ask the shopper to try the payment again using a different payment method or card.
Received For some payment methods, it can take some time before the final status of the payment is known. Inform the shopper that you've received their order, and are waiting for the payment to clear.
You will receive the final result of the payment in an AUTHORISATION notification.

For other possible resultCode values and recommended messages that you can present to your shopper, see Result codes.

Handling the redirect result

If you receive an action.type redirect, the Component redirects your shopper to another website using an HTTP GET or HTTP POST. The shopper will be redirected back to your website using the same method.

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

Checking redirect parameters

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

  • paymentData:Value you received in the /payments response. You need submit this in your /payments/details request later.
  • details: Array that contains the key parameter names and the corresponding data type that you should expect when the shopper is redirected to your returnURL. If other parameters are appended to the returnURL or sent in the form data but are not included in the details object, ignore them. These are also the parameters that you will need to submit in a /payments/details request.
  • method: The HTTP request method used to redirect the shopper to your returnURL after they complete the payment.
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 might receive the following response:

/payments response
{
  "resultCode": "RedirectShopper",
  "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

After the shopper is redirected back to your returnURL with an HTTP GET, you need to:

  1. URL-decode the parameters appended to your returnURL and pass the parameters to your back end. Example parameters that you might get are payload or redirectResult.

         To know which parameters you should expect to be appended to the returnURL, check the details.key returned in the /payments response.

         For example, a shopper can be redirected back to your website with a payload parameter:

   GET /?shopperOrder=12xy..&&payload=Ab02b4c0!BQABF... HTTP/1.1
   Host: www.your-company.com/checkout
  1. From your server, submit 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/v51/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:
    /payments/details response
      {
       "resultCode": "Authorised",
       "pspReference": "88154795347618C"
     }

HTTP POST redirect

After the shopper is redirected back to your returnURL with an HTTP POST, you need to:

  1. URL-decode the parameters from the form data and pass the parameters to your back end. To know which parameters you should expect in the form data, check the details.key returned in the /payments response. For example, 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..
  2. From your server, submit 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, MD and PaRes.
    curl https://checkout-test.adyen.com/v51/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);
    You receive a response containing:
    /payments/details response
      {
       "resultCode": "Authorised",
       "pspReference": "88154795347618C"
     }

Test and go live

Before going live, use our list of test cards and other payment methods to test your integration. We recommend testing each payment method that you intend to offer to your shoppers.

You can check the status of a test payment in your Customer Area, under TransactionsPayments.

When you are ready to go live, you need to:

  1. Apply for a live account.
  2. Configure your live account
  3. Submit a request to add payment methods in your live Customer Area .
  4. Switch from test to our live endpoints.
  5. Load AdyenCheckout from one of our live environments closest to where your shoppers are. Set the environment configuration object to:

    • Europe: live
    • Australia: live-au
    • US: live-us

Configuring Components

You can include the following additional configuration when instantiating Components on your payments form:

You can also override the values that you set here by specifying these parameters for individual payment methods at the Component level.

Configuration object Description
showPayButton Adyen provides a Pay button. To use the Pay button for each payment method, set this to true. The Pay button triggers the onSubmit event.

If you want to use your own button and then trigger the submit flow on your own, set this to false and call the .submit() method from your own button implementation. For example, component.submit().
amount Amount to be displayed on the Pay Button. It expects an object with the value and currency properties. For example, { value: 1000, currency: 'USD' }.

Events

Use the following events to include additional logic on your checkout page:

Event name Description
onChange(state, component) Called when the shopper has provided the required payment details for the specific payment method.
onError(error) Called when an error occurs in the Component.
onSubmit(state, component) Called when the shopper selects the Pay button.
onAdditionalDetails(state,component) Called when a payment method requires more details.

For example, here are the additional configuration that you need to include to show the pre-built Pay button:

function handleOnSubmit(state, component) {
    state.isValid // True or false. Specifies if all the information that the shopper provided is valid.
    state.data // Provides the data that you need to pass in the `/payments` call.
    component // Provides the active component instance that called this event.
}

const configuration = {
    ...
    showPayButton: true,
    onSubmit: handleOnSubmit,
    amount: {             // Optional. Used to display the amount in the Pay Button.
            value: 1000,
            currency: 'EUR'
        }
};

const checkout = new AdyenCheckout(configuration);

See also

Next steps