Are you looking for test card numbers?

Would you like to contact support?

No momento, esta página não está disponível em inglês
Default icon

Create a token to make recurring payments

Learn how to create and use tokens you stored with Adyen.

You can use tokens for:

  • One-off payments: One-off transactions where a shopper can either store their payment details or pay in your website or app at a later time using their saved details.
  • Subscriptions: A recurring transaction made at regular intervals for a product or a service.
  • Automatic top-ups: Contracts that occur on a non-fixed schedule using stored card details. This includes automatic top-ups when the cardholder's balance drops below a certain amount.

Set parameters to flag transactions

To flag the type of recurring transaction, use the following fields:

  • recurringProcessingModel: Pass it when you first create a token (to indicate what you intend to use the token for), and for each payment that you make with the token.
  • shopperInteraction: Indicates whether you're creating a token, or using a previously created token.
Business model
Initial payment Later payment(s)
recurringProcessingModel shopperInteraction recurringProcessingModel shopperInteraction
One-off payments CardOnFile Ecommerce CardOnFile ContAuth
Subscriptions
SCA is required for the initial payment
Subscription Ecommerce Subscription ContAuth
Automatic top-ups and other non-fixed schedule contracts
SCA is required for the initial payment
UnscheduledCardOnFile Ecommerce UnscheduledCardOnFile ContAuth

When creating a token that you want to use for more than one type of recurring payment (for example, initially Subscription but in future also CardOnFile), use the recurringProcessingModel that is most appropriate at the time of token creation. In subsequent transactions you can then specify the applicable recurringProcessingModel.

If you are implementing 3D Secure for PSD2 SCA compliance, use our self-service guide to find out about the PSD2 SCA compliance rules that apply to your business.

Import recurring payment details

If you have existing recurring contracts with another payment service provider, you can migrate and import recurring payment details to Adyen. When you import the data, you won't need to collect your shopper's payment details again to create a token.

When the recurring payment details are successfully migrated, you receive an output file. From this file you can get the parameters that you need to use the tokens in future payments.

Create a token and pay

Select the tab that fits your business model and follow the integration steps:

One-off transactions where a shopper stores payment details or where the shopper purchases from your website or app at a later time using the saved details.

If you're using one of our client-side solutions, refer to Cards Drop-in pages for Web, iOS, and Android or Component pages for Web, iOS, and Android.

Save payment details for one-off payments

  1. From your server, make a POST /payments request and include the following values:
    • paymentMethod: Object that contains the shopper's payment details.
    • shopperReference: Your unique identifier for the shopper. The length of a shopperReference should be more than 3 characters.
    • shopperInteraction: Ecommerce
    • recurringProcessingModel: CardOnFile
    • storePaymentMethod (for API v49 and later): true
    • amount: Object that contains the value to be paid. You can set the amount.value to 0 to validate the payment details with a zero-auth transaction before processing payments.
curl https://checkout-test.adyen.com/v68/payments \
-H "X-API-key: [Your API Key here]" \
-H "Content-Type: application/json" \
-d '{
   "amount":{
      "value":0,
      "currency":"USD"
   },
   "paymentMethod":{
      "type":"scheme",
      "number":"4111111111111111",
      "expiryMonth":"10",
      "expiryYear":"2020",
      "cvc":"737",
      "holderName":"John Smith"
   },
   "storePaymentMethod":true,
   "reference":"YOUR_ORDER_NUMBER",
   "shopperInteraction": "Ecommerce",
   "recurringProcessingModel": "CardOnFile",
   "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
   "shopperReference":"YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
   "returnUrl":"https://your-company.com/..."
}'
# 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 => 0
  },
  :reference => "YOUR_ORDER_NUMBER",
  :paymentMethod => {
    :type => "scheme",
    :number => "4111111111111111",
    :expiryMonth => "10",
    :expiryYear => "2020",
    :cvc => "737"
  },
  :storePaymentMethod => true,
  :shopperInteraction => Ecommerce,
  :recurringProcessingModel => CardOnFile,
  :shopperReference => "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
  :returnUrl => "https://your-company.com/...",
  :merchantAccount => "YOUR_MERCHANT_ACCOUNT"
})
// Set your X-API-KEY with the API key from the Customer Area.
Config config = new Config();
        config.setApiKey("Your X-API-KEY"));
        Client client = new Client(config);
         
        Checkout checkout = new Checkout(client);
        PaymentsRequest paymentsRequest = new PaymentsRequest();
        Amount amount = new Amount();
        amount.setCurrency("USD");
        amount.setValue(0L);
        paymentsRequest.setAmount(amount);
        paymentsRequest.setReference("YOUR_ORDER_NUMBER");
        paymentsRequest.setPaymentMethod(new HashMap<String, String>());
        paymentsRequest.addCardData("4111111111111111", "02", "2030", "737", "Simon Hopper", true);
        paymentsRequest.setShopperReference("YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j");
        paymentsRequest.setReturnUrl("https://your-company.com/...");
        paymentsRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
        paymentsRequest.setShopperInteraction("Ecommerce");
        paymentsRequent.setRecurringProcessingModel("CardOnFile");
        PaymentsResponse response = 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" => 0
  ),
  "reference" => "YOUR_ORDER_NUMBER",
  "paymentMethod" => array(
    "type" => "scheme",
    "number" => "4111111111111111",
    "expiryMonth" => "10",
    "expiryYear" => "2020",
    "cvc" => "737",
    "holderName" => "John Smith"
  ),
  "storePaymentMethod" => true,
  "shopperInteraction" => "Ecommerce",
  "recurringProcessingModel" => "CardOnFile",
  "merchantAccount" => "YOUR_MERCHANT_ACCOUNT",
  "shopperReference" => "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
  "returnUrl" => "https://your-company.com/..."
);
$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': {
      'value': 0,
      'currency': 'USD'
   },
   'reference': 'YOUR_ORDER_NUMBER',
   'paymentMethod': {
      'type': 'scheme',
      'number': '4111111111111111',
      'expiryMonth': '10',
      'expiryYear': '2020',
      'cvc': '737',
      'holderName': 'John Smith'
   },
   'storePaymentMethod': 'true',
   'shopperInteraction': 'Ecommerce',
   'recurringProcessingModel': 'CardOnFile',
   'shopperReference': 'YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j',
   'returnUrl': 'https://your-company.com/...',
   '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 amount = new Model.Checkout.Amount("USD", 0);
var details = new Model.Checkout.DefaultPaymentMethodDetails{
  Type = "scheme",
  Number = "4111111111111111",
  ExpiryMonth = "10",
  ExpiryYear = "2020",
  Cvc = "737",
  HolderName = "John Smith"
};
var paymentsRequest = new Model.Checkout.PaymentRequest
{
  Reference = "YOUR_ORDER_NUMBER",
  Amount = amount,
  ReturnUrl = @"https://your-company.com/...",
  MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
  StorePaymentMethod = "true",
  ShopperInteraction = "Ecommerce",
  RecurringProcessingModel = "CardOnFile",
  ShopperReference = "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
  PaymentMethod = details
};

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: 0 },
    paymentMethod: {
        type: 'scheme',
        number: '4111111111111111',
        expiryMonth: '10',
        expiryYear: '2020',
        cvc: '737',
        holderName: 'John Smith'
    },
    reference: "YOUR_ORDER_NUMBER",
    merchantAccount: config.merchantAccount,
    storePaymentMethod: "true",
    shopperInteraction: "Ecommerce",
    recurringProcessingModel: "CardOnFile",
    returnUrl: "https://your-company.com/..."
}).then(res => res);

The token is created after a successful payment authorisation to ensure that the payment details the shopper provided are linked to an active, chargeable account.

PSD2 regulations may have additional requirements for processing recurring transactions.

Authorised result code

If the payment was successful, you will get a response with:

  • resultCode: Authorised
  • additionalData.recurring.recurringDetailReference: The token for the saved payment details. You will need this to make future payments for the shopper.

    To get the recurringDetailReference synchronously in your payments response, you have to enable this feature.

{
    "additionalData": {
        "recurring.recurringDetailReference": "7219687191761347",
        "recurring.shopperReference":"YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j"
    },
    "pspReference": "DZ4DPSHB4WD2WN82",
    "resultCode": "Authorised",
    "amount": {
        "currency": "USD",
        "value": 0
    },
    "merchantReference": "YOUR_ORDER_NUMBER"
}

If you receive a Refused resultCode, then the details were not tokenized. You need to submit another payment request to try tokenizing again.

Make a one-off payment with saved payment details

  1. Present the shopper's saved payment method in your payment form.

    If you are using one of our client-side solutions (Drop-in, Components, or Pay by Link), you can present a shopper's stored cards in the payment form. For more information on how to do this, refer to the Cards documentation for Drop-in (Web, iOS, Android), the Card Component documentation (Web, iOS, Android), or our Pay by Link documentation.

    If you are using an API-only integration, you will need to build the UI for this yourself.

  2. From your server, make a POST /payments request and include the following parameters:

    • paymentMethod: Object that contains the shopper's tokenized payment details.
    • storedPaymentMethodId (for API v49 and later): This is the recurringDetailReference returned in the response when you created the token.
    • shopperReference: This is the shopperReference that you used the first time when you created the token for the shopper's card details.
    • shopperInteraction: ContAuth
    • recurringProcessingModel: CardOnFile
    • encryptedSecurityCode: (optional) Encrypted card verification code. If your shopper stored their card details, you can choose whether or not they need to send their CVC in subsequent payments.

    You cannot store your shopper's CVC as this violates PCI compliance rules.

If you are implementing 3D Secure for PSD2 SCA compliance, issuing banks might require SCA for ContAuth with CardOnFile transactions. See the PSD2 SCA compliance guide for more information.

curl https://checkout-test.adyen.com/v68/payments \
-H "X-API-key: [Your API Key here]" \
-H "Content-Type: application/json" \
-d '{
   "amount":{
      "value":2000,
      "currency":"USD"
   },
   "paymentMethod":{
      "type":"scheme",
      "{hint:Previously known as recurringDetailReference}storedPaymentMethodId{/hint}":"7219687191761347",
      "encryptedSecurityCode": "adyenjs_0_1_18$MT6ppy0FAMVMLH..."
   },
   "reference":"YOUR_ORDER_NUMBER",
   "shopperInteraction": "ContAuth",
   "recurringProcessingModel": "CardOnFile",
   "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
   "shopperReference":"YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
   "returnUrl":"https://your-company.com/..."
}'
# 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 => 2000
  },
  :reference => "YOUR_ORDER_NUMBER",
  :paymentMethod => {
    :type => "scheme",
    :storedPaymentMethodId => "7219687191761347",
    :encryptedSecurityCode => "adyenjs_0_1_18$MT6ppy0FAMVMLH..."
  },
  :shopperInteraction => ContAuth,
  :recurringProcessingModel => CardOnFile,
  :shopperReference => "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
  :returnUrl => "https://your-company.com/...",
  :merchantAccount => "YOUR_MERCHANT_ACCOUNT"
})
// Set your X-API-KEY with the API key from the Customer Area.
Config config = new Config();
        config.setApiKey("Your X-API-KEY"));
        Client client = new Client(config);
         
        Checkout checkout = new Checkout(client);
        PaymentsRequest paymentsRequest = new PaymentsRequest();
        Amount amount = new Amount();
        amount.setCurrency("USD");
        amount.setValue(2000L);
        paymentsRequest.setAmount(amount);
        paymentsRequest.setReference("YOUR_ORDER_NUMBER");
        paymentsRequest.setPaymentMethod(new HashMap<String, String>());
        paymentsRequest.putPaymentMethodItem("type","scheme");
        paymentsRequest.putPaymentMethodItem("storedPaymentMethodId", "7219687191761347");
        paymentsRequest.putPaymentMethodItem("encryptedSecurityCode", "adyenjs_0_1_18$MT6ppy0FAMVMLH...");
        paymentsRequest.setShopperReference("YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j");
        paymentsRequest.setReturnUrl("https://your-company.com/...");
        paymentsRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
        paymentsRequest.setShopperInteraction("ContAuth");
        paymentsRequent.setRecurringProcessingModel("CardOnFile");
        PaymentsResponse response = 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" => 2000
  ),
  "reference" => "YOUR_ORDER_NUMBER",
  "paymentMethod" => array(
    "type" => "scheme",
    "storedPaymentMethodId" => "7219687191761347",
    "encryptedSecurityCode" => "adyenjs_0_1_18$MT6ppy0FAMVMLH..."
  ),
  "shopperInteraction" => "ContAuth",
  "recurringProcessingModel" => "CardOnFile",
  "merchantAccount" => "YOUR_MERCHANT_ACCOUNT",
  "shopperReference" => "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
  "returnUrl" => "https://your-company.com/..."
);
$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': {
      'value': 2000,
      'currency': 'USD'
   },
   'reference': 'YOUR_ORDER_NUMBER',
   'paymentMethod': {
      'type': 'scheme',
      'storedPaymentMethodId': '7219687191761347',
      'encryptedSecurityCode': 'adyenjs_0_1_18$MT6ppy0FAMVMLH...'
   },
   'shopperInteraction': 'ContAuth',
   'recurringProcessingModel': 'CardOnFile',
   'shopperReference': 'YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j',
   'returnUrl': 'https://your-company.com/...',
   '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 amount = new Model.Checkout.Amount("USD", 2000);
var details = new Model.Checkout.DefaultPaymentMethodDetails{
  Type = "scheme",
  StoredPaymentMethodId = "7219687191761347",
  EncryptedSecurityCode = "adyenjs_0_1_18$MT6ppy0FAMVMLH..."
};
var paymentsRequest = new Model.Checkout.PaymentRequest
{
  Reference = "YOUR_ORDER_NUMBER",
  Amount = amount,
  ReturnUrl = @"https://your-company.com/...",
  MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
  ShopperInteraction = "ContAuth",
  RecurringProcessingModel = "CardOnFile",
  ShopperReference = "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
  PaymentMethod = details
};

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: 2000 },
    paymentMethod: {
        type: 'scheme',
        storedPaymentMethodId: '7219687191761347',
        encryptedSecurityCode: 'adyenjs_0_1_18$MT6ppy0FAMVMLH...'
    },
    reference: "YOUR_ORDER_NUMBER",
    merchantAccount: config.merchantAccount,
    shopperInteraction: "ContAuth",
    recurringProcessingModel: "CardOnFile",
    returnUrl: "https://your-company.com/..."
}).then(res => res);

If the payment was successful, you'll receive a resultCode of Authorised.

{
   "pspReference": "VK9DRSLLRCQ2WN82",
   "resultCode": "Authorised"
}

Test and go live

To receive the recurringDetailReference synchronously in the payments response in your test environment, do the following:

  1. Log in to your test Customer Area.
  2. Go to Developers > Additional data.
  3. Select Recurring details and save your settings.

You can enable receiving the RECURRING_CONTRACT event code as part of your standard notifications. For instructions, see non-default event codes and additional settings. When enabled, you receive a notification webhook containing:

  • eventCode: RECURRING_CONTRACT
  • originalReference: The pspReference of the initial payment.
  • pspReference: The token that you need to make recurring payments for this shopper.

Before going live, make sure to go to your live Customer Area and follow the exact instructions as described above.

Próximas etapas