No momento, esta página não está disponível em português
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
You must include the following fields when you make a payment request with a token:
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
From your server, make a POST /payments request and include the following values:
paymentMethod: an 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.
amount: an 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.
// 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 Adyen.Model.Checkout.Amount("USD", 0);
var details = new Adyen.Model.Checkout.DefaultPaymentMethodDetails{
Type = "scheme",
Number = "4111111111111111",
ExpiryMonth = "10",
ExpiryYear = "2020",
Cvc = "737",
HolderName = "John Smith"
};
var paymentsRequest = new Adyen.Model.Checkout.PaymentRequest
{
Reference = "YOUR_ORDER_NUMBER",
Amount = amount,
ReturnUrl = @"https://your-company.com/...",
MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
StorePaymentMethod = true,
ShopperInteraction = Adyen.Model.Checkout.PaymentRequest.ShopperInteractionEnum.Ecommerce,
RecurringProcessingModel = Adyen.Model.Checkout.PaymentRequest.RecurringProcessingModelEnum.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.
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.
If you receive a RefusedresultCode, then the details were not tokenized. You need to submit another payment request to try tokenizing again.
Pending and Refusal result codes
Cards always return a synchronous response, with the API response informing you of the authorisation result.
For other payment methods, the authorisation can be processed asynchronously. Other payment methods can send a Pending status instead of an immediate Authorised response. We don't tokenize payment details until the payment has reached the Authorised status.
When the payment has been authorised, you receive a webhook event containing:
eventCode: RECURRING_CONTRACT
originalReference: the pspReference of the initial payment.
pspReference: the token needed to make recurring payments for this shopper.
Make sure that your server is able to receive RECURRING_CONTRACT as part of your standard webhook. If you have not set up this additional configuration yet, see Test and go live.
If you receive a RefusedresultCode, 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
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.
From your server, make a POST /payments request and include the following parameters:
paymentMethod: an 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.
# 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 Adyen.Model.Checkout.Amount("USD", 2000);
var details = new Adyen.Model.Checkout.DefaultPaymentMethodDetails{
Type = "scheme",
StoredPaymentMethodId = "7219687191761347",
EncryptedSecurityCode = "adyenjs_0_1_18$MT6ppy0FAMVMLH..."
};
var paymentsRequest = new Adyen.Model.Checkout.PaymentRequest
{
Reference = "YOUR_ORDER_NUMBER",
Amount = amount,
ReturnUrl = @"https://your-company.com/...",
MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
ShopperInteraction = Adyen.Model.Checkout.PaymentRequest.ShopperInteractionEnum.ContAuth,
RecurringProcessingModel = Adyen.Model.Checkout.PaymentRequest.RecurringProcessingModelEnum.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);
Let your shoppers set up subscriptions with you. Subscriptions are a series of transactions with fixed or variable amounts, charged at a fixed time interval.
Save payment details for subscriptions
From your server, make a POST /payments request and include the following values:
paymentMethod: an 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.
// 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.putPaymentMethodItem("type","scheme");
paymentsRequest.putPaymentMethodItem("number", "4111111111111111");
paymentsRequest.putPaymentMethodItem("expiryMonth", "10");
paymentsRequest.putPaymentMethodItem("expiryYear", "2020");
paymentsRequest.putPaymentMethodItem("cvc", "737");
paymentsRequest.putPaymentMethodItem("storePaymentMethod", "true");
paymentsRequest.setShopperReference("YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j");
paymentsRequest.setReturnUrl("https://your-company.com/...");
paymentsRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
paymentsRequest.setShopperInteraction("Ecommerce");
paymentsRequent.setRecurringProcessingModel("Subscription");
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" => "Subscription",
"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': 'Subscription',
'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 Adyen.Model.Checkout.Amount("USD", 0);
var details = new Adyen.Model.Checkout.DefaultPaymentMethodDetails{
Type = "scheme",
Number = "4111111111111111",
ExpiryMonth = "10",
ExpiryYear = "2020",
Cvc = "737",
HolderName = "John Smith"
};
var paymentsRequest = new Adyen.Model.Checkout.PaymentRequest
{
Reference = "YOUR_ORDER_NUMBER",
Amount = amount,
ReturnUrl = @"https://your-company.com/...",
MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
ShopperInteraction = Adyen.Model.Checkout.PaymentRequest.ShopperInteractionEnum.Ecommerce,
StorePaymentMethod = true,
RecurringProcessingModel = Adyen.Model.Checkout.PaymentRequest.RecurringProcessingModelEnum.Subscription,
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: "Subscription",
returnUrl: "https://your-company.com/..."
}).then(res => res);
The token is created after a successful payment authorization to ensure that the payment details the shopper provided are linked to an active, chargeable account.
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.
Cards always return a synchronous response, with the API response informing you of the authorisation result.
For other payment methods, the authorisation can be processed asynchronously. Other payment methods can send a Pending status instead of an immediate Authorised response. We don't tokenize payment details until the payment has reached the Authorised status.
When the payment has been authorised, you receive a webhook event containing:
eventCode: RECURRING_CONTRACT
originalReference: the pspReference of the initial payment.
pspReference: the token that you need to make recurring payments for this shopper.
Make sure that your server is able to receive RECURRING_CONTRACT as part of your standard webhook. If you have not set up this additional configuration yet, see Test and go live.
If you receive a RefusedresultCode, then the details were not tokenized. You need to submit another payment request to try tokenizing again.
Make a subscription payment
From your server, make a POST /payments request and include the following parameters:
paymentMethod: an 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.
# 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"
},
:shopperInteraction => ContAuth,
:recurringProcessingModel => Subscription,
:shopperReference => "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
: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.setShopperReference("YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j");
paymentsRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
paymentsRequest.setShopperInteraction("ContAuth");
paymentsRequent.setRecurringProcessingModel("Subscription");
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"
),
"returnUrl" => "https://your-company.com/checkout/",
"shopperInteraction" => "ContAuth",
"recurringProcessingModel" => "Subscription",
"merchantAccount" => "YOUR_MERCHANT_ACCOUNT",
"shopperReference" => "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j"
);
$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'
},
'shopperInteraction': 'ContAuth',
'recurringProcessingModel': 'Subscription',
'shopperReference': 'YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j',
'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 Adyen.Model.Checkout.Amount("USD", 2000);
var details = new Adyen.Model.Checkout.DefaultPaymentMethodDetails{
Type = "scheme",
StoredPaymentMethodId = "7219687191761347"
};
var paymentsRequest = new Adyen.Model.Checkout.PaymentRequest
{
Reference = "YOUR_ORDER_NUMBER",
Amount = amount,
MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
ShopperInteraction = Adyen.Model.Checkout.PaymentRequest.ShopperInteractionEnum.ContAuth,
RecurringProcessingModel = Adyen.Model.Checkout.PaymentRequest.RecurringProcessingModelEnum.Subscription,
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'
},
reference: "YOUR_ORDER_NUMBER",
merchantAccount: config.merchantAccount,
shopperInteraction: "ContAuth",
recurringProcessingModel: "Subscription"
}).then(res => res);
Offer contracts that occur on a non-fixed schedule using stored card details, for example, automatic top-ups when the cardholder's balance drops below a certain amount.
Save payment details for auto top-ups
From your server, make a POST /payments request and include the following values:
paymentMethod: an 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.
// 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.putPaymentMethodItem("type","scheme");
paymentsRequest.putPaymentMethodItem("number", "4111111111111111");
paymentsRequest.putPaymentMethodItem("expiryMonth", "10");
paymentsRequest.putPaymentMethodItem("expiryYear", "2020");
paymentsRequest.putPaymentMethodItem("cvc", "737");
paymentsRequest.putPaymentMethodItem("storePaymentMethod", "true");
paymentsRequest.setShopperReference("YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j");
paymentsRequest.setReturnUrl("https://your-company.com/...");
paymentsRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
paymentsRequest.setShopperInteraction("Ecommerce");
paymentsRequent.setRecurringProcessingModel("UnscheduledCardOnFile");
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" => "UnscheduledCardOnFile",
"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': 'UnscheduledCardOnFile',
'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 Adyen.Model.Checkout.Amount("USD", 0);
var details = new Adyen.Model.Checkout.DefaultPaymentMethodDetails{
Type = "scheme",
Number = "4111111111111111",
ExpiryMonth = "10",
ExpiryYear = "2020",
Cvc = "737",
HolderName = "John Smith"
};
var paymentsRequest = new Adyen.Model.Checkout.PaymentRequest
{
Reference = "YOUR_ORDER_NUMBER",
Amount = amount,
ReturnUrl = @"https://your-company.com/...",
MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
ShopperInteraction = Adyen.Model.Checkout.PaymentRequest.ShopperInteractionEnum.Ecommerce,
StorePaymentMethod = true,
RecurringProcessingModel = Adyen.Model.Checkout.PaymentRequest.RecurringProcessingModelEnum.UnscheduledCardOnFile,
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: "UnscheduledCardOnFile",
returnUrl: "https://your-company.com/..."
}).then(res => res);
The token is created after a successful payment authorization to ensure that the payment details the shopper provided are linked to an active, chargeable account.
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.
Cards always return a synchronous response, with the API response informing you of the authorisation result.
For other payment methods, the authorisation can be processed asynchronously. Other payment methods can send a Pending status instead of an immediate Authorised response. We don't tokenize payment details until the payment has reached the Authorised status.
When the payment has been authorised, you receive a webhook event containing:
eventCode: RECURRING_CONTRACT
originalReference: the pspReference of the initial payment.
pspReference: the token that you need to make recurring payments for this shopper.
Make sure that your server is able to receive RECURRING_CONTRACT as part of your standard webhook. If you have not set up this additional configuration yet, see Test and go live.
If you receive a RefusedresultCode, then the details were not tokenized. You need to submit another payment request to try tokenizing again.
Make auto top-up payments
From your server, make a POST /payments request and include the following parameters:
paymentMethod: an 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.
# 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"
},
:shopperInteraction => ContAuth,
:recurringProcessingModel => UnscheduledCardOnFile,
:shopperReference => "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
: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.setShopperReference("YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j");
paymentsRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
paymentsRequest.setShopperInteraction("ContAuth");
paymentsRequent.setRecurringProcessingModel("UnscheduledCardOnFile");
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"
),
"shopperInteraction" => "ContAuth",
"recurringProcessingModel" => "UnscheduledCardOnFile",
"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'
},
'shopperInteraction': 'ContAuth',
'recurringProcessingModel': 'UnscheduledCardOnFile',
'shopperReference': 'YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j',
'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 Adyen.Model.Checkout.Amount("USD", 2000);
var details = new Adyen.Model.Checkout.DefaultPaymentMethodDetails{
Type = "scheme",
StoredPaymentMethodId = "7219687191761347"
};
var paymentsRequest = new Adyen.Model.Checkout.PaymentRequest
{
Reference = "YOUR_ORDER_NUMBER",
Amount = amount,
MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
ShopperInteraction = Adyen.Model.Checkout.PaymentRequest.ShopperInteractionEnum.ContAuth,
RecurringProcessingModel = Adyen.Model.Checkout.PaymentRequest.RecurringProcessingModelEnum.UnscheduledCardOnFile,
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'
},
reference: "YOUR_ORDER_NUMBER",
merchantAccount: config.merchantAccount,
shopperInteraction: "ContAuth",
recurringProcessingModel: "UnscheduledCardOnFile"
}).then(res => res);
You can enable receiving the RECURRING_CONTRACT event code as part of your standard webhook. For instructions, see non-default event codes and additional settings. When enabled, you receive a webhook event 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.