Search

Are you looking for test card numbers?

Would you like to contact support?

Payment-method icon

Cards Drop-in integration

Add cards to an existing Drop-in integration.

Our Web Drop-in renders the available cards in your payment form, and securely collects any sensitive card information, so it doesn't touch your server.

When using Drop-in to accept card payments, you can:

Before you begin

This page explains how to add card payments to your existing Web Drop-in integration. The Web Drop-in integration works the same way for all payment methods. If you haven't done this integration yet, refer to our Drop-in integration guide.

Before starting your integration:

  1. Make sure that you have set up your back end implementation, and added Drop-in to your payments form.
  2. Add the cards that you want to accept in your test Customer Area.

Show the available cards in your payment form

For information about the supported countries and currencies for each card, refer to Payment methods.

Drop-in uses the combination of countryCode and amount.currency from your /paymentMethods request to show the available cards to your shopper.

When the shopper is entering their card details, Drop-in tries to recognize the card brand. When successful, Drop-in renders the brand icon and the corresponding input field for the card security code (CVC, CVV, or CID).

Optional Drop-in configuration

When creating an instance of Drop-in, you can optionally specify:

Field Description Default
name String that is used to display the payment method name to the shopper. Depends on the shopperLocale specified in /paymentMethods request.
showStoredPaymentMethods Set to false if you don't want Drop-in to show previously stored payment methods in the payment method list. true
brands Array of card brands that will be recognized. For a list of possible values, refer to Supported card types. ['mc','visa','amex']
showBrandIcon Set to false to have Web Drop-in not show the brand logo when the card brand has been recognized. true
enableStoreDetails Set to true to show the check box for saving the card details for recurring payments. false
hasHolderName Set to true to show the input field for the card holder name. false
holderNameRequired Set to true to make the card holder name a required field. To show the field, you additionally need to set hasHolderName to true. false
hideCVC Set to true to hide the CVC field. false
styles Set a style object to customize the card input fields. For a list of supported properties, refer to Styling card input fields.
billingAddressRequired v 3.5.0 Set to true to collect the shopper's billing address. false
billingAddressAllowedCountries v 3.5.0 Specify allowed country codes for the billing address. For example, ['US', 'CA', 'BR']. The Country field dropdown menu shows a list of all countries.
data v 3.5.0 Object that contains placeholder information that you can use to prefill fields.
For example:
- holderName: Placeholder for the card holder name field.
- billingAddress: Object that contains placeholder information for the billing address such as street, postalCode, city, country, and stateOrProvince.
Empty
installmentOptions v 3.8.0 If you want to offer credit card installments, specify here the numbers of monthly installments that the shopper can choose from.
For example, to have 2, and 3, and 4 as the default installment options for all cards:
{ "card": { "values": [2, 3, 4] }}

You can also customize your shopper's experience when specific events occur.

Event Description
onChange Called when the shopper enters data in the card input fields.
onLoad Called once all the card input fields have been created but are not yet ready to use.
onConfigSuccess Called once the card input fields are ready to use.
onFieldValid Called when a specific field is validated and encrypted or becomes invalid.
onBrand Called once we detect the card brand.
onError Called in case of an invalid card number, invalid expiry date, or incomplete field. Called again when errors are cleared.
onFocus Called when a field gains or loses focus.
onBinValue Provides the BIN Number of the card (up to 6 digits), called as the user types in the PAN.
   const dropin = checkout
       .create('dropin', {
           paymentMethodsConfiguration: {
               card: { // Example optional configuration for cards
                   hasHolderName: true,
                   holderNameRequired: true,
                   enableStoreDetails: true,
                   billingAddressRequired: true, // Set to true to show the billing address input fields.
                   name: 'Credit or debit card',
                   onBrand: handleOnBrand // Your function for handling onBrand event,
                   data : {
                       holderName: 'S. Hopper'
                   }
               },
               ...
           }
       })
       .mount('#dropin');

Make a payment

When the shopper selects the Pay button, Drop-in calls the onSubmit event, which contains a state.data.

  1. Pass the state.data to your server.
  2. From your server, make a /payments request, specifying:

    • paymentMethod: The state.data.paymentMethod from the onSubmit event.
    • billingAddress: Optional The state.data.billingAddress from the onSubmit event. Applicable if you configured Drop-in to collect the shoppers's billing address and if you want to use AVS.
curl https://checkout-test.adyen.com/v64/payments \
-H "X-API-key: [Your API Key here]" \
-H "Content-Type: application/json" \
-d '{
  "amount": {
    "currency": "USD",
    "value": 1000
  },
  "reference": "YOUR_ORDER_NUMBER",
  "{hint:state.data.paymentMethod from onSubmit}paymentMethod{/hint}": {
    "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...",
    "holderName": "S. Hopper"
  },
  "{hint:state.data.billingAddress from onSubmit}billingAddress{/hint}": {
       "street": "Infinite Loop",
       "houseNumberOrName": "1",
       "postalCode": "95014",
       "city": "Cupertino",
       "stateOrProvince": "CA",
       "country": "US"
  },
  "returnUrl": "https://your-company.com/checkout?shopperOrder=12xy..",
  "merchantAccount": "YOUR_MERCHANT_ACCOUNT"
}'
# 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({
  :amount => {
    :currency => "USD",
    :value => 1000
  },
  :reference => "YOUR_ORDER_NUMBER",
  :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...",
    :holderName => "S. Hopper"
  },
  :billingAddress => {
    :city => "Cupertino",
    :country => "US",
    :houseNumberOrName => "1",
    :postalCode => "95014",
    :stateOrProvince => "CA",
    :street => "Infinite Loop"
  },
  :returnUrl => "https://your-company.com/checkout?shopperOrder=12xy..",
  :merchantAccount => "YOUR_MERCHANT_ACCOUNT"
})
Client client = new Client("YOUR_API_KEY", Environment.TEST);

    Checkout checkout = new Checkout(client);

    PaymentsRequest paymentsRequest = new PaymentsRequest();

    paymentsRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
    paymentsRequest.setReference("YOUR_ORDER_REFERENCE");

    DefaultPaymentMethodDetails paymentMethodDetails = new DefaultPaymentMethodDetails();
    paymentMethodDetails.setType("scheme");
    paymentMethodDetails.setEncryptedCardNumber("adyenjs_0_1_18$k7s65M5V0KdPxTErhBIPoMPI8HlC..");
    paymentMethodDetails.setEncryptedExpiryMonth("adyenjs_0_1_18$p2OZxW2XmwAA8C1Avxm3G9UB6e4..");
    paymentMethodDetails.setEncryptedExpiryYear("adyenjs_0_1_18$CkCOLYZsdqpxGjrALWHj3QoGHqe+..");
    paymentMethodDetails.setEncryptedSecurityCode("adyenjs_0_1_24$XUyMJyHebrra/TpSda9fha978+..");
    paymentMethodDetails.setHolderName("S. Hopper");

    paymentsRequest.setPaymentMethod(paymentMethodDetails);

    Amount amount = new Amount();
    amount.setCurrency("USD");
    amount.setValue(1000L);

    paymentsRequest.setAmount(amount);

    Address billingAddress = new Address();
    billingAddress.setCity("Cupertino");
    billingAddress.setCountry("US");
    billingAddress.setHouseNumberOrName("1");
    billingAddress.setPostalCode("95014");
    billingAddress.setStreet("Infinite Loop");

    paymentsRequest.setBillingAddress(billingAddress);

    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);

$params = array(
  "amount" => array(
    "currency" => "USD",
    "value" => 1000
  ),
  "reference" => "YOUR_ORDER_NUMBER",
  "paymentMethod" => array(
    "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...",
    "holderName" => "S. Hopper"
  ),
  "billingAddress" => [
    "city" => "Cupertino",
    "country" => "US",
    "houseNumberOrName" => "1",
    "stateOrProvince" => "CA",
    "postalCode" => "95014",
    "street" => "Infinite Loop"
  ],
  "returnUrl" => "https://your-company.com/...",
  "merchantAccount" => "YOUR_MERCHANT_ACCOUNT"
);
$result = $service->payments($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({
  "amount": {
    "currency": "USD",
    "value": 1000
  },
  "reference":"YOUR_ORDER_NUMBER",
  "paymentMethod": {
    "type": "scheme",
    "encryptedCardNumber": "adyenjs_0_1_18$k7s65M5V0KdPxTErhBIPoMPI8HlC..",
    "encryptedExpiryMonth": "adyenjs_0_1_18$p2OZxW2XmwAA8C1Avxm3G9UB6e4..",
    "encryptedExpiryYear": "adyenjs_0_1_18$CkCOLYZsdqpxGjrALWHj3QoGHqe+..",
    "encryptedSecurityCode": "adyenjs_0_1_24$XUyMJyHebrra/TpSda9fha978+..",
    "holderName": "S. Hopper"
  },
  "billingAddress": {
    "street": "Infinite Loop",
    "houseNumberOrName": "1",
    "postalCode": "95014",
    "city": "Cupertino",
    "stateOrProvince": "CA",
    "country": "US"
  },
  "returnUrl": "https://your-company.com/checkout?shopperOrder=12xy..",
  "merchantAccount": "YOUR_MERCHANT_ACCOUNT"
})
// 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 paymentRequest = new Adyen.Model.Checkout.PaymentRequest
{
    Amount = new Model.Checkout.Amount(Currency: "USD", Value: 1000),
    Reference = "YOUR_ORDER_NUMBER",
    PaymentMethod = new DefaultPaymentMethodDetails
    {
        EncryptedCardNumber = "adyenjs_0_1_18$k7s65M5V0KdPxTErhBIPoMPI8HlC..",
        EncryptedExpiryMonth = "adyenjs_0_1_18$p2OZxW2XmwAA8C1Avxm3G9UB6e4..",
        EncryptedExpiryYear = "adyenjs_0_1_18$CkCOLYZsdqpxGjrALWHj3QoGHqe+..",
        EncryptedSecurityCode = "adyenjs_0_1_24$XUyMJyHebrra/TpSda9fha978+..",
        HolderName = "S. Hopper",
        Type = "scheme"
    },
    BillingAddress = new Model.Checkout.Address
    {
        City = "Cupertino",
        Country = "US",
        HouseNumberOrName = "1",
        StateOrProvince = "CA",
        PostalCode = "95014",
        Street = "Infinite Loop"
    },
    ReturnUrl = "https://your-company.com/checkout?shopperOrder=12xy..",
    MerchantAccount = "YOUR_MERCHANT_ACCOUNT"
};

var paymentResponse = checkout.Payments(paymentsRequest);
// 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 = '[YOUR_MERCHANT_ACCOUNT]';
const client = new Client({ config });
client.setEnvironment("TEST");
const checkout = new CheckoutAPI(client);
checkout.payments({
    amount: { currency: "USD", value: 1000 },
    paymentMethod: {
        type: 'scheme',
        encryptedSecurityCode: "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
        encryptedExpiryMonth: "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
        encryptedExpiryYear: "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
        holderName: "S. Hopper",
        encryptedCardNumber: "adyenjs_0_1_18$MT6ppy0FAMVMLH..."
    },
    billingAddress: {
        city: "Cupertino",
        country: "CA",
        houseNumberOrName: "1",
        postalCode: "95014",
        stateOrProvince: "CA",
        street: "Infinite Loop"
    },
    reference: "YOUR_ORDER_NUMBER",
    merchantAccount: config.merchantAccount,
    returnUrl: "https://your-company.com/..."
}).then(res => res);

The /payments response contains:

  • pspReference: Our unique identifier for the transaction.
  • resultCode: Use this to present the payment result to your shopper.
  • merchantReference: The reference from the /payments request.
  • additionalData: Additional information about the transaction.
    To specify the fields that you want to receive in additionalData, log in to your Customer Area, and go to Account > API URLs > Additional data settings.

/payments response
{
  "additionalData": {
    "cardSummary": "1111"
  },
  "pspReference": "851572424333194G",
  "resultCode": "Authorised",
  "merchantReference": "YOUR_ORDER_NUMBER"
}

Present the payment result

Use the resultCode from the /payments response to present the payment result to your shopper. You will also receive the outcome of the payment asynchronously in a notification webhook.

For card payments, you can receive the following resultCode values:

resultCode Description Action to take
Authorised The payment was successful. Inform the shopper that the payment has been successful.
If you are using manual capture, you also need to capture the payment.
Cancelled The shopper cancelled the payment. Ask the shopper whether they want to continue with the order, or ask them to select a different payment method.
Error There was an error when the payment was being processed. For more information, check the refusalReason field. Inform the shopper that there was an error processing their payment.
Refused The payment was refused. For more information, check the refusalReason field. Ask the shopper to try the payment again using a different payment method.
Additional resultCode values are possible in case of the 3D Secure authentication flow. For more information, refer to Result codes.

Present debit and credit cards separately

In some scenarios, you may want to present your shoppers with separate payment forms for debit cards and credit cards. Some examples include:

  • In Brazil, many shoppers use Combo cards, allowing for both debit and credit transactions. Having a separate form for Debit Card and Credit Card gives your shoppers a clear indication of whether they are making a debit or credit transaction.
  • If you accept payments in Sweden, you need to present debit cards before credit cards in order to comply with local legislation.

For more details, see the corresponding sections about Brazil and Sweden.

Required versions

To present debit and credit cards separately in your Web Drop-in integration, you need to use:

  • Checkout API v53 or later.
  • Web Components 3.9.5 or later.

Show the available debit and credit cards

  1. When you make a POST /paymentMethods request from your server, include: The following example shows how you would do this for a shopper in the Netherlands, making a 47.00 EUR payment.
    /paymentMethods request
    curl https://checkout-test.adyen.com/v64/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": 4700
      },
      "splitCardFundingSources": true
    }'
    The response includes the list of available payment methods, with debit and credit cards split into separate objects.
    Response
    {
       ...
       "paymentMethods": [
           {
               "brands": [
                   "mc",
                   "visa",
                   "amex"
               ],
               ...
               "fundingSource": "credit",
               "name": "Credit Card",
               "type": "scheme"
           },
           {
               "brands": [
                   "mc",
                   "visa",
                   "amex"
               ],
               "fundingSource": "debit",
               "name": "Debit Card",
               "type": "scheme"
           }
       ]
    }

If your integration is set up correctly, the full /paymentMethods response is passed to the AdyenCheckout instance in your front end. Drop-in then automatically renders separate payment forms for Credit card and Debit card.

When the shopper selects the Pay button from any of the payment forms, Drop-in works the same way as when cards are presented in one form — it calls the onSubmit event which contains a state.data. You can then use the state.data to make a payment.

Brazil

For debit transactions, we highly recommend using 3D Secure and Automatic Capture due to some issuers' restrictions.

Sweden

If you send a /paymentMethods request with countryCode of SE, Drop-in automatically presents Debit Card before Credit Card, in order to comply with Swedish legislations.

Recurring payments

Adyen's tokenization service allows you to securely store shopper's card details for recurring payments. To make recurring payments, you first need to create a shopper token, and then use the token to make future payments for the shopper.

Create a token

To store shopper's card details, set enableStoreDetails to true when creating an instance of Drop-in. This will show a check box to your shopper for saving their card details for future payments.

If the shopper chooses to save their card details when making a payment, the onSubmit method from Drop-in will include state.data.storePaymentMethod. Pass this to your server.

To create a token, include in your /payments request:

  • storePaymentMethod: The state.data.storePaymentMethod from your front end.
  • shopperReference: Your unique identifier for the shopper.

Show a stored card in your payment form

To show a stored card in your payment form, include in your /paymentMethods request:

  • shopperReference: The unique shopper identifier that you specified when creating the token.

If you don't want to show previously stored payment methods in the Drop-in payment method list, set showStoredPaymentMethods to false when creating an instance of Drop-in.

Make a payment with a token

When the shopper selects the Pay button, Drop-in calls the onSubmit event, which contains a state.data.

  1. Pass the state.data to your server.
  2. From your server, make a /payments request, specifying:
    • paymentMethod: The state.data.paymentMethod from the onSubmit event.
    • shopperReference: The unique shopper identifier that you specified when creating the token.
    • shopperInteractionContAuth.
    • recurringProcessingModel: CardOnFile.
    {
    "amount":{
      "value":2000,
      "currency":"USD"
    },
    "paymentMethod":{
      "type":"scheme",
      "storedPaymentMethodId":"8415718415172204",
      "encryptedSecurityCode":"adyenjs_0_1_18$MT6ppy0FAMVMLH..."
    },
    "reference":"YOUR_ORDER_NUMBER",
    "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
    "returnUrl":"...",
    "shopperReference":"YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
    "shopperInteraction":"ContAuth",
    "recurringProcessingModel":"CardOnFile"
    }
    The /payments response contains:
    {
    "pspReference": "8815329842815468",
    "resultCode": "Authorised"
    }

You can also use tokens to make shopper-not-present payments for subscriptions or contracts. For more information, refer to Making a payment for a subscription or contract.

Test and go live

Before making live card payments:

  1. Test your integration using our test card numbers.
    You can check the status of test payments in your Customer Area > Transactions > Payments.
  1. Add the cards that you want to accept in your live Customer Area.
  1. Before you can start accepting card payments in the live environment, you need to assess your PCI DSS compliance and submit the required Self-Assessment Questionnaire A document. For more information, refer to PCI DSS compliance guide.

See also