Check out Adyen Android on GitHub.
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.
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.
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 talk about both server-side and client-side integration steps:
- Set up Components.
- From your server, submit a request to get a list of payment methods available to the shopper.
- Collect payment details from the shopper and pass the details to your server.
- From your server, submit a payment request with the data returned by the Component.
- Determine from the response if you need to perform additional actions on your client app, such as to redirect the shopper to complete the payment.
- From your server, submit additional payment details.
- Present the payment result to the shopper.
Whenever you want to offer a new payment method, you need to add the specific Component on your checkout page. The steps for integrating are similar regardless of the payment method, but some require additional configuration. For more information, refer to our payment method integration guides.
Before you begin
If you haven't done so already, follow our Get started guide to set up your test account, get your API key, and install a server-side library.
Install the Adyen Android client-side library
Our Android Components are available through Maven Central. You only need to add the build dependency for the specific Android Component on Gradle. To know the specific Component name, refer to the payment method pages.
For example, to use the Card Component and the Redirect Component, add the following to your build.gradle
(Module) file. To get the latest version, check our GitHub repository.
implementation "com.adyen.checkout:card:<latest-version>"
implementation "com.adyen.checkout:redirect:<latest-version>"
Get your client key
All Components require a client key. To get your client key:
- Log in to your Customer Area.
- Go to Developers > API credentials, and select the API credential for your integration, for example ws@Company.[YourCompanyAccount].
- Under Authentication, select Generate New Client Key.
- Select Save.
Step 1: Set up Components
-
Build a client-side configuration of the Component for the payment method you are offering. You will use this configuration object in Step 3.
Name Required Description Environment
The default value is TEST. When you're ready to accept live payments, change the value to one of our live environments. ClientKey
A public key linked to your API credential, used for client-side authentication. ShopperLocale
By default, the Component is rendered in the language set for the device. To change the language, set the shopper locale to the required language code. You also need to set the shopper locale when you make the /paymentMethods
call.Other configuration Optional configuration for the specific payment method. For more information, refer to our payment method integration guides. // Replace Card with the Component you want to configure. val cardConfiguration = CardConfiguration.Builder(context, "YOUR_CLIENT_KEY") // When you're ready to accept live payments, change the value to one of our live environments. .setEnvironment(Environment.TEST) // Optional. Use to set the language rendered in Component, overriding the default device language setting. // See list of supported languages at https://github.com/Adyen/adyen-android/tree/main/card/src/main/res .setShopperLocale(Locale("nl", "NL")) // Create the configuration for the payment method that you want to add. .build()
-
Add the Component view to your layout. You will attach the initialized component to this view in Step 3.
<!-- Replace card with the Component view that you want to add --> <!-- See list of supported payment methods at https://docs.adyen.com/payment-methods--> <com.adyen.checkout.card.CardView android:id="@+id/YOUR_COMPONENT_VIEW_ID" .../>
Step 2: Get available payment methods
When your shopper is ready to pay, get a list of the available payment methods based on their country, device, and the payment amount.
From your server, make a POST /paymentMethods request, providing the following parameters. While most parameters are optional, we recommend that you include them because Adyen uses these to tailor the list of payment methods for your shopper.
Parameter name | Required | Description |
---|---|---|
merchantAccount |
![]() |
Your merchant account name. |
amount |
The currency of the payment and its value in minor units. |
|
channel |
The platform where the payment is taking place. Use Android. Adyen returns only the payment methods available for Android. | |
countryCode |
The shopper's country code. Adyen returns only the payment methods available in this country. | |
shopperLocale |
By default, the shopperlocale is set to en-US. To change the language, set this to the shopper's language and country code. You also need to set the same ShopperLocale within your Component configuration. |
curl https://checkout-test.adyen.com/v69/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": "Android",
"shopperLocale": "nl-NL"
}'
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({
:countryCode => 'NL',
:shopperLocale => 'nl-NL',
:amount => {
:currency => 'EUR',
:value => 1000
},
:channel => 'Android',
:merchantAccount => 'YOUR_MERCHANT_ACCOUNT'
})
// Set your X-API-KEY with the API key from the Customer Area.
String xApiKey = "YOUR_X-API-KEY";
Client client = new Client(xApiKey,Environment.TEST);
Checkout checkout = new Checkout(client);
PaymentMethodsRequest paymentMethodsRequest = new PaymentMethodsRequest();
paymentMethodsRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
paymentMethodsRequest.setCountryCode("NL");
paymentMethodsRequest.setShopperLocale("nl-NL");
Amount amount = new Amount();
amount.setCurrency("EUR");
amount.setValue(1000L);
paymentMethodsRequest.setAmount(amount);
paymentMethodsRequest.setChannel(PaymentMethodsRequest.ChannelEnum.Android);
PaymentMethodsResponse paymentMethodsResponse = checkout.paymentMethods(paymentMethodsRequest);
// Pass the response to your front end
// Set your X-API-KEY with the API key from the Customer Area.
$client = new \Adyen\Client();
$client->setEnvironment(\Adyen\Environment::TEST);
$client->setXApiKey("YOUR_X-API-KEY");
$service = new \Adyen\Service\Checkout($client);
$params = array(
"countryCode" => "NL",
"shopperLocale" => "nl-NL",
"amount" => array(
"currency" => "EUR",
"value" => 1000
),
"channel" => "Android",
"merchantAccount" => "YOUR_MERCHANT_ACCOUNT"
);
$result = $service->paymentMethods($params);
# Set your X-API-KEY with the API key from the Customer Area.
adyen = Adyen.Adyen()
adyen.payment.client.platform = "test"
adyen.client.xapikey = 'YOUR_X-API-KEY'
request = {
'countryCode': 'NL',
'shopperLocale': 'nl-NL',
'amount': {
'value': 1000,
'currency': 'EUR'
},
'channel': 'Android',
'merchantAccount': 'YOUR_MERCHANT_ACCOUNT'
}
result = adyen.checkout.payment_methods(request)
// Set your X-API-KEY with the API key from the Customer Area.
string apiKey = "YOUR_X-API-KEY";
var client = new Client (apiKey, Environment.Test);
var checkout = new Checkout(client);
var amount = new Adyen.Model.Checkout.Amount("EUR", 1000);
var paymentMethodsRequest = new Adyen.Model.Checkout.PaymentMethodsRequest(merchantAccount: "YOUR_MERCHANT_ACCOUNT")
{
CountryCode = "NL",
ShopperLocale = "nl-NL",
Amount = amount,
Channel = Adyen.Model.Checkout.PaymentMethodsRequest.ChannelEnum.Android,
};
var paymentMethodsResponse = checkout.PaymentMethods(paymentMethodsRequest);
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 = '[YOUR_X-API-KEY]';
config.merchantAccount = '[YOUR_MERCHANT_ACCOUNT]';
const client = new Client({ config });
client.setEnvironment("TEST");
const checkout = new CheckoutAPI(client);
const paymentsResponse = checkout.paymentMethods({
merchantAccount: config.merchantAccount,
countryCode: "NL",
shopperLocale: "nl-NL",
amount: { currency: "EUR", value: 1000, },
channel: "Android"
}).then(res => res);
import (
"github.com/adyen/adyen-go-api-library/v5/src/checkout"
"github.com/adyen/adyen-go-api-library/v5/src/common"
"github.com/adyen/adyen-go-api-library/v5/src/adyen"
)
// Set your X-API-KEY with the API key from the Customer Area.
client := adyen.NewClient(&common.Config{
Environment: common.TestEnv,
ApiKey: "[YOUR_X-API-KEY]",
})
res, httpRes, err := client.Checkout.PaymentMethods(&checkout.PaymentMethodsRequest{
CountryCode: "NL",
ShopperLocale: "nl-NL",
Amount: &checkout.Amount{
Value: 1000,
Currency: "EUR",
},
Channel: "Android",
MerchantAccount: "[YOUR_MERCHANT_ACCOUNT]",
})
The response includes the list of available paymentMethods
:
Pass the response to your client app. You will use this in the next step to present which payment methods are available to the shopper.
Step 3: Collect payment details
In this step, we use the client-side Component to collect payment details from your shopper.
-
Deserialize the
/paymentMethods
response with theSERIALIZER
object.val paymentMethodsApiResponse = PaymentMethodsApiResponse.SERIALIZER.deserialize(paymentMethodsResponse)
-
From the result, get the object containing the payment method
type
for the Component. For example, to initialize the Card Component, get the object containingpaymentMethods.type
scheme. -
Initialize an instance of the Component. To do this, you need to call
PROVIDER.get
from your payment method's Component and pass the following:- The context (for example,
this@YourActivity
) - The
PaymentMethod
object (for example,paymentMethod
) - The component configuration object (for example,
cardConfiguration
)
// Replace CardComponent with the payment method Component that you want to add. // See list of supported payment methods at https://docs.adyen.com/payment-methods val cardComponent = CardComponent.PROVIDER.get(this@YourActivity, paymentMethod, cardConfiguration)
- The context (for example,
-
Attach the Component to the view to start getting your shopper's payment details. You need to call
attach
from the payment method's Component view and pass in two things:- the component object (for example,
cardComponent
) - the context (for example,
this@YourActivity
)
// Replace CardComponent with the payment method Component that you want to add. // See list of supported payment methods at https://docs.adyen.com/payment-methods cardView.attach(cardComponent, this@YourActivity)
- the component object (for example,
-
You start receiving updates when the shopper enters their payment details. Check if
isValid
is true, and if the shopper proceeds to pay, pass thepaymentComponentState.data.paymentMethod
to your server.// Replace CardComponent with the payment method Component that you want to add. // See list of supported payment methods at https://docs.adyen.com/payment-methods cardComponent.observe(this@MainActivity) { state -> if (state?.isValid == true) { //serialize data val paymentComponentData = PaymentComponentData.SERIALIZER.serialize(state.data) // When the shopper proceeds to pay, pass the serialized `state.data` to your server to send a /payments request } }
Step 4: Make a payment
After the shopper submits their payment details or chooses to pay with a payment method that requires a redirection, you need to make a payment request to Adyen.
From your server, make a POST /payments request specifying:
Parameter name | Required | Description |
---|---|---|
merchantAccount |
![]() |
Your merchant account name. |
amount |
![]() |
The currency of the payment and its value in minor units. |
reference |
![]() |
Your unique reference for this payment. |
paymentMethod |
![]() |
The paymentComponentState.data.paymentMethod from your client app. This is from the state.data in the previous step. |
returnUrl |
![]() |
The URL where the shopper is taken back to in case of a redirection. Specify your Android URI scheme, followed by the RedirectComponent.getReturnUrl(context) from the Component. In our examples, we use adyencheckout as the Android URI scheme. The returnUrl can have a maximum of 1024 characters. |
applicationInfo
|
If you're building an Adyen solution for multiple merchants, include some basic identifying information, so that we can offer you better support. For more information, refer to Building Adyen solutions. |
You need to include additional parameters in your payment request to:
- Integrate some payment methods. For more information, refer to our payment method integration guides.
- Make use of our risk management features. For more information, see Required risk fields.
- Use native 3D Secure 2 authentication.
- Tokenize your shopper's payment details or make recurring payments.
Here's an example of how you would make a payment request for 10 EUR:
curl https://checkout-test.adyen.com/v69/payments \
-H "x-API-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{
"amount":{
"currency":"EUR",
"value":1000
},
"reference":"YOUR_ORDER_NUMBER",
"paymentMethod":{hint:paymentMethod field of an object passed from the front end or client app}STATE_DATA{/hint},
"returnUrl":"adyencheckout://your.package.name",
"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"
# STATE_DATA is the paymentMethod field of an object passed from the front end or client app, deserialized from JSON to a data structure.
paymentMethod = STATE_DATA
response = adyen.checkout.payments({
:paymentMethod => paymentMethod,
:amount => {
:currency => 'EUR',
:value => 1000
},
:reference => 'YOUR_ORDER_NUMBER',
:returnUrl => 'adyencheckout://your.package.name',
: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.
String xApiKey = "YOUR_X-API-KEY";
Client client = new Client(xApiKey,Environment.TEST);
Checkout checkout = new Checkout(client);
PaymentsRequest paymentsRequest = new PaymentsRequest();
paymentsRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
// STATE_DATA is the paymentMethod field of an object passed from the front end or client app, deserialized from JSON to a data structure.
paymentsRequest.setPaymentMethod(STATE_DATA)
Amount amount = new Amount();
amount.setCurrency("EUR");
amount.setValue(1000L);
paymentsRequest.setAmount(amount);
paymentsRequest.setReference("YOUR_ORDER_NUMBER");
paymentsRequest.setReturnUrl("adyencheckout://your.package.name");
PaymentsResponse paymentsResponse = checkout.payments(paymentsRequest);
// Set your X-API-KEY with the API key from the Customer Area.
$client = new \Adyen\Client();
$client->setEnvironment(\Adyen\Environment::TEST);
$client->setXApiKey("YOUR_X-API-KEY");
$service = new \Adyen\Service\Checkout($client);
// STATE_DATA is the paymentMethod field of an object passed from the front end or client app, deserialized from JSON to a data structure.
$paymentMethod = STATE_DATA;;
$params = array(
"paymentMethod" => $paymentMethod,
"amount" => array(
"currency" => "EUR",
"value" => 1000
),
"reference" => "YOUR_ORDER_NUMBER",
"returnUrl" => "adyencheckout://your.package.name",
"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.payment.client.platform = "test"
adyen.client.xapikey = 'YOUR_X-API-KEY'
# STATE_DATA is the paymentMethod field of an object passed from the front end or client app, deserialized from JSON to a data structure.
paymentMethod = STATE_DATA
result = adyen.checkout.payments({
'paymentMethod': paymentMethod,
'amount': {
'value': 1000,
'currency': 'EUR'
},
'reference': 'YOUR_ORDER_NUMBER',
'returnUrl': 'adyencheckout://your.package.name',
'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.
string apiKey = "YOUR_X-API-KEY";
var client = new Client (apiKey, Environment.Test);
var checkout = new Checkout(client);
var amount = new Adyen.Model.Checkout.Amount("EUR", 1000);
var paymentsRequest = new Adyen.Model.Checkout.PaymentRequest
{
// STATE_DATA is the paymentMethod field of an object passed from the front end or client app, deserialized from JSON to a data structure.
PaymentMethod = STATE_DATA,
Amount = amount,
Reference = "YOUR_ORDER_NUMBER",
ReturnUrl = @"adyencheckout://your.package.name",
};
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 = '[YOUR_X-API-KEY]';
config.merchantAccount = '[YOUR_MERCHANT_ACCOUNT]';
const client = new Client({ config });
client.setEnvironment("TEST");
const checkout = new CheckoutAPI(client);
checkout.payments({
merchantAccount: config.merchantAccount,
// STATE_DATA is the paymentMethod field of an object passed from the front end or client app, deserialized from JSON to a data structure.
paymentMethod: STATE_DATA,
amount: { currency: "EUR", value: 1000, },
reference: "YOUR_ORDER_NUMBER",
returnUrl: "adyencheckout://your.package.name"
}).then(res => res);
import (
"github.com/adyen/adyen-go-api-library/v5/src/checkout"
"github.com/adyen/adyen-go-api-library/v5/src/common"
"github.com/adyen/adyen-go-api-library/v5/src/adyen"
)
// Set your X-API-KEY with the API key from the Customer Area.
client := adyen.NewClient(&common.Config{
Environment: common.TestEnv,
ApiKey: "[YOUR_X-API-KEY]",
})
// STATE_DATA is the paymentMethod field of an object passed from the front end or client app, deserialized from JSON to a data structure.
paymentMethod := STATE_DATA
res, httpRes, err := client.Checkout.Payments(&checkout.PaymentRequest{
PaymentMethod: paymentMethod,
Amount: checkout.Amount{
Value: 1000,
Currency: "EUR",
},
Reference: "YOUR_ORDER_NUMBER",
ReturnUrl: "adyencheckout://your.package.name",
MerchantAccount: "[YOUR_MERCHANT_ACCOUNT]",
})
Your next steps depend on whether the /payments response contains an action
object:
Description | Next steps | |
---|---|---|
No action object |
No additional steps are needed to complete the payment. | Use the resultCode to present the payment result to your shopper. |
With action object |
The shopper needs to do additional actions to complete the payment. | 1. Pass the action object to your client app. Make sure that you only pass the action object and not the full response. 2. Proceed to step 5. |
The following example shows a /payments response with action.type
: threeDS2:
Step 5: Perform additional client-side actions
Some payment methods require additional action from the shopper such as: to authenticate a payment with 3D Secure, or to switch to another app to complete the payment.
If your /payments API response includes an action
object, deserialize the object in your client-side app.
val action = Action.SERIALIZER.deserialize(paymentResponse.action)
Use the action.type
to determine which Action Component you should initialize.
action.type |
Next steps |
---|---|
redirect | 1. Use the Redirect Component. 2. Proceed to step 6 to check the payment result or submit additional details. |
threeDS2 | Use the 3D Secure 2 Component to perform 3D Secure 2 device fingerprinting and/or present the 3D Secure 2 challenge to the shopper. |
await | Use the Await Component to handle await actions. |
qrCode | Use the QR Code Component to handle QR code actions. |
**SDK **The type can sometimes include the payment method name. For example, wechatpaySDK . |
Use the specific payment method action Component to trigger the app switch from your app to the payment method's app. For example, refer to WeChat Pay Component. |
Redirect Component
Many payment methods require redirecting the shopper to another website. You can handle the redirect either by using the Redirect Component, or the specific payment method Component, for example the 3D Secure 2 Component.
Step 1: Initialize the Redirect Component
-
Before initializing the Component, make sure that you've added the following to your
build.gradle
file:
Check the latest version on GitHub.implementation "com.adyen.checkout:redirect:<latest-version>"
-
Create a configuration object for the Component, passing your client key:
val redirectConfiguration = RedirectConfiguration.Builder(context, "YOUR_CLIENT_KEY") .setEnvironment(Environment.TEST) .build()
-
To initialize an instance of the Component, call
PROVIDER.get
from the Component and pass in the context (for example,this@YourActivity
), application class, and the configuration object created in the previous step:val redirectComponent = RedirectComponent.PROVIDER.get(this@YourActivity, application, redirectConfiguration)
-
From your instance, call
handleAction
and pass:- the context (for example,
this@YourActivity
) - the
action
object from the deserialized/payments
response.
redirectComponent.handleAction(this@YourActivity, action)
- the context (for example,
Step 2: Handle the redirect
-
Add an
IntentFilter
to theActivity
that will handle thereturnUrl
specified in your/payments
request.
The<activity android:name=".YourActivity"> <intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <data android:host="${applicationId}" android:scheme="adyencheckout"/> </intent-filter> </activity>
${applicationId}
will be replaced withyour.package.name
at build time. -
Get the result of the redirect from the
Activity
. Pass theintent
back to the Component. Depending on your activity's launchMode, you can get this intent in eitheronCreate
oronNewIntent
.private fun handleIntent(intent: Intent?) { val data = intent?.data if (data != null && data.toString().startsWith(RedirectUtil.REDIRECT_RESULT_SCHEME)) { redirectComponent.handleIntent(intent) } }
-
The Component notifies the
observer
with theactionComponentData
object from the data inintent.data
. Pass this to your server.redirectComponent.observe(this) { actionComponentData -> // Send a /payments/details/ call containing the `actionComponentData` sendPaymentDetails(actionComponentData) }
Step 6: Submit additional payment details
If the shopper performed additional action, you need to submit additional payment details to either complete the payment, or to check the payment result.
Make a /payments/details request, and include:
details
: TheactionComponentData.details
from the Component.
curl https://checkout-test.adyen.com/v69/payments/details \
-H "x-API-key: YOUR_X-API-KEY" \
-H "content-type: application/json" \
-d '{hint:object passed from the front end or client app}STATE_DATA{/hint}'
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"
# STATE_DATA is an object passed from the front end or client app, deserialized from JSON to a data structure.
request = STATE_DATA
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 xApiKey = "YOUR_X-API-KEY";
Client client = new Client(xApiKey,Environment.TEST);
Checkout checkout = new Checkout(client);
// STATE_DATA is an object passed from the front end or client app, deserialized from JSON to a data structure.
PaymentsDetailsRequest paymentsDetailsRequest = STATE_DATA;
PaymentsResponse paymentsDetailsResponse = checkout.paymentsDetails(paymentsDetailsRequest);
// Set your X-API-KEY with the API key from the Customer Area.
$client = new \Adyen\Client();
$client->setEnvironment(\Adyen\Environment::TEST);
$client->setXApiKey("YOUR_X-API-KEY");
$service = new \Adyen\Service\Checkout($client);
// STATE_DATA is an object passed from the front end or client app, deserialized from JSON to a data structure.
$params = STATE_DATA;
$result = $service->paymentsDetails($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.payment.client.platform = "test"
adyen.client.xapikey = 'YOUR_X-API-KEY'
# STATE_DATA is an object passed from the front end or client app, deserialized from JSON to a data structure.
request = STATE_DATA
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";
var client = new Client (apiKey, Environment.Test);
var checkout = new Checkout(client);
// STATE_DATA is an object passed from the front end or client app, deserialized from JSON to a data structure.
var paymentsDetailsRequest = STATE_DATA;
var paymentsDetailsResponse = 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 = '[YOUR_X-API-KEY]';
const client = new Client({ config });
client.setEnvironment("TEST");
const checkout = new CheckoutAPI(client);
// STATE_DATA is an object passed from the front end or client app, deserialized from JSON to a data structure.
checkout.paymentsDetails(STATE_DATA).then(res => res);
import (
"github.com/adyen/adyen-go-api-library/v5/src/checkout"
"github.com/adyen/adyen-go-api-library/v5/src/common"
"github.com/adyen/adyen-go-api-library/v5/src/adyen"
)
// Set your X-API-KEY with the API key from the Customer Area.
client := adyen.NewClient(&common.Config{
Environment: common.TestEnv,
ApiKey: "[YOUR_X-API-KEY]",
})
// STATE_DATA is an object passed from the front end or client app, deserialized from JSON to a data structure.
req := STATE_DATA;
res, httpRes, err := client.Checkout.PaymentsDetails(&req)
The response includes:
pspReference
: Our unique identifier for the transaction.resultCode
: The status of the payment. Use this to present the payment result to your shopper in step 7.
Step 7: Present the payment result
After the shopper completes the payment and no more further actions are required on the 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 webhook. |
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 webhook. |
For other possible resultCode
values and recommended messages that you can present to your shopper, see Result codes.
Error handling
In case you encounter errors in your integration, refer to the following:
- API error codes: If you receive a non-HTTP 200 response, use the
errorCode
to troubleshoot and modify your request. - Payment refusals: If you receive an HTTP 200 response with an Error or Refused
resultCode
, check the refusal reason and, if possible, modify your request.
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 Transactions > Payments.
To debug or troubleshoot test payments, you can also use API logs in your test environment.
When you are ready to go live, you need to:
- Apply for a live account.
- Assess your PCI DSS compliance, and submit the Self-Assessment Questionnaire-A.
- Configure your live account.
- Switch from test to our live endpoints.
-
Load the Component from one of our live environments and set the
Environment
to match your live endpoints:Endpoint region environment
valueEurope EUROPE or LIVE Australia AUSTRALIA US UNITED_STATES Asia Pacific South East APSE The
Environment
must match the region of the live endpoints you're connecting to.