Check out Adyen Android on GitHub.
Use Drop-in, our all-in-one UI solution, to accept payments on your Android app using a single client-side implementation. We recommend that you use Drop-in if you want a quick way to start accepting payments on your website, with little to no customization.
Supported payment methods
Drop-in readily supports cards, wallets, and most local payment methods. For a list of supported payment methods, refer to Supported payment methods.
Adding new payment methods usually requires no additional implementation effort, however some payment methods require additional configuration. For more information, refer to our payment method integration guides.
We're actively adding payment methods to Drop-in. To check the latest on Drop-in, see our release notes.
How Drop-in looks
How Drop-in works
The following general flow applies for each payment method supported in Drop-in:
On this page we talk about both server-side and client-side integration steps:
- Set up Drop-in.
- From your server, submit a request to get a list of payment methods available to the shopper.
- Initialize Drop-in.
- Submit a payment request with data you receive from Drop-in.
- Some payment methods require additional actions before a payment can be completed. Submit the results of the additional payment details with data you receive from Drop-in.
- Present the payment result to the shopper.
When you have completed the integration, proceed to test your integration.
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
Android Drop-in is available through Maven Central. You only need to add the build dependency on Gradle.
Add the following to your build.gradle
(Module) file. To get the latest version, check our GitHub repository.
implementation 'com.adyen.checkout:drop-in:<latest-version>'
Get your client key
To configure Drop-in, you'll need a 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 Drop-in
You will need to create an implementation of the Drop-in Service in your client-side app to provide information to your server. Your server will use this information to make calls to the Adyen server.
-
Extend the
DropInService
class.The methods
makePaymentsCall
andmakeDetailsCall
pass payment data between your client app and your server, and are expected to return aDropInServiceResult
.The
DropInServiceResult
contains the result of the API calls from your server. Drop-in uses theDropInServiceResult
to determine if you must take additional action to complete the payment, such as redirecting the shopper to another site or performing 3D Secure authentication.class YourDropInService : DropInService() { // Handling for submitting a payment request override fun makePaymentsCall(paymentComponentJson: JSONObject): DropInServiceResult { ... // See step 3 - Your server should make a /payments call containing the `paymentComponentJson` // Create the `DropInServiceResult` based on the /payments response return DropInServiceResult.Action("action JSON object") } // Handling for submitting additional payment details override fun makeDetailsCall(actionComponentJson: JSONObject): DropInServiceResult { ... // See step 4 - Your server should make a /payments/details call containing the `actionComponentJson` // Create the `DropInServiceResult` based on the /payments/details response return DropInServiceResult.Finished("Authorised") } }
-
After your server makes a payment request, the API response may return an
action
object. Your server should return any of the following types ofDropInServiceResult
to your client app:Type When to return this value Action If you received an action
object in the API response, returnDropInServiceResult.Action
and theaction
object.Finished If you did not receive an action
object in the API response, returnDropInServiceResult.Finished
and theresultCode
from the response.Error Return this if an error happened during the connection. -
Add the service to your manifest file.
<service android:name=".YourDropInService"/>
-
Configure Drop-in:
Name Required Description ClientKey
A public key linked to your API credential, used for client-side authentication. Environment
The default value is TEST. When you're ready to accept live payments, change the value to one of our live environments. Amount
Show the amount a shopper has to pay on the Pay button. To do this, you include the currency and the amount (in minor units) that the shopper has to pay. ShopperLocale
By default, Drop-in 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 in the [paymentMethod]Configuration
object and in step 2 where you make the/paymentMethods
call.[paymentMethod]Configuration
Optional configuration for specific payment methods, for example CardConfiguration
for cards.
The following example shows how you would configure Drop-in for testing, with a Pay button displaying 10 EUR.
val amount = Amount()
// Optional. In this example, the Pay button will display 10 EUR.
amount.currency = "EUR"
amount.value = 10_00
val dropInConfiguration = DropInConfiguration.Builder(YourContext, YourDropInService::class.java, "YOUR_CLIENT_KEY")
// Optional. Use if you want to display the amount and currency on the Pay button.
.setAmount(amount)
// When you're ready to accept live payments, change the value to one of our live environments.
.setEnvironment(Environment.TEST)
.build()
Optional configuration for payment methods
When configuring Drop-in, you can optionally add a configuration object for a specific payment method. This overrides the global DropInConfiguration
for that payment method, so make sure to specify the values for all required parameters for the payment method that you want to configure.
For example, if you call DropInConfiguration.Builder.setEnvironment(Environment.LIVE)
, you must also call CardConfiguration.Builder.setEnvironment(Environment.LIVE)
.
The following example shows how you would configure Drop-in for live payments, using the CardConfiguration
object to hide the switch for saving card details.
// Configuration for cards.
val cardConfiguration = CardConfiguration.Builder(YourContext, "YOUR_CLIENT_KEY")
// hides the switch for saving card details
.setShowStorePaymentField(false)
// Required to accept live card payments.
.setEnvironment(Environment.LIVE)
.build()
// Global Drop-in configuration
val dropInConfiguration = DropInConfiguration.Builder(YourContext, YourDropInService::class.java, "YOUR_CLIENT_KEY")
// Make sure that you have set the environment in the payment method configuration object as well.
.setEnvironment(Environment.LIVE)
.addCardConfiguration(cardConfiguration)
.build()
To see which parameters you can configure for specific payment methods, refer to our payment method guides.
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 and value of the payment, in minor units. |
|
channel |
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 Drop-in configuration. |
A request to get the available payment methods for a shopper in the Netherlands, for a payment of 10 EUR:
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: Initialize Drop-in
-
Deserialize the response with the
SERIALIZER
object and store it as aPaymentMethodsApiResponse
.val paymentMethodsApiResponse = PaymentMethodsApiResponse.SERIALIZER.deserialize(paymentMethodsResponse)
-
Call
.startPayment()
method and pass these parameters:- the context (for example,
this@MainActivity
) - the deserialized
PaymentMethodsApiResponse
object (for example,paymentMethodsApiResponse
) - your extended
DropInService
class (for example,dropInConfiguration
) - Optional: an Intent to be launched after Drop-in finishes (for example,
ResultActivity
)
- the context (for example,
You should not initialize Drop-in if the PaymentMethodsApiResponse
is null.
//Optional. In this example, ResultActivity will be launched after Drop-in finishes
val resultIntent = Intent(YourContext, ResultActivity::class.java)
DropIn.startPayment(YourContext, paymentMethodsApiResponse, dropInConfiguration, resultIntent)
Drop-in presents the available payment methods and collects payment details from the shopper.
Step 4: Make a payment
When the shopper submits their payment details, the makePaymentsCall
method in your YourDropInService
class is invoked with the paymentComponentJson
JSON object as parameter.
-
Pass the
paymentComponentJson
JSON object to your server to submit the shopper's payment details. Your server needs 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
andvalue
of the payment, in minor units.reference
Your unique reference for this payment. paymentMethod
The paymentComponentData.paymentMethod
from your client app.returnUrl
In case of a redirection, this is the URL to where your shopper should be redirected back to after they complete the payment. This URL can have a maximum of 1024 characters. Get this URL from Drop-in in the RedirectComponent.getReturnUrl(context)
.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. | 1. Return DropInServiceResult.Finished to your client app, along with the the resultCode from the response. 2. Proceed to step 6. |
With action object |
The shopper needs to do additional actions to complete the payment. | 1. Return DropInServiceResult.Action to your client app, along with the action object. 2. Proceed to step 5. |
The following example shows a /payments response with action.type
: threeDS2:
Step 5: Submit additional payment details
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.
To handle these additional client app actions, Drop-in checks if DropInServiceResult.Action
was returned. If so, do the following:
-
In your client app, the
makeDetailsCall
method in yourYourDropInService
class is invoked with theactionComponentJson
JSON object as parameter. In themakeDetailsCall
method described in step 1 you should submit the additional payment details by passing theactionComponentJson
object from your app to your server. -
From your server, make a POST /payments/details request with the
actionComponentJson
object from your client app:
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 /payments/details response includes:
pspReference
: Our unique identifier for the transaction.resultCode
: Indicates the status of the payment.
Step 6: Present the payment result
After the shopper completes the payment and the client app requires no further action, use the resultCode
previously passed with the DropInServiceResult.Finished
to present the payment result to the shopper.
How you obtain the resultCode
depends on whether you specified a resultIntent
when calling DropIn.startPayment
:
Call DropIn.getDropInResultFromIntent
inside onCreate
within the newly launched activity:
class ResultActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val result = DropIn.getDropInResultFromIntent(intent)
}
}
To handle the error and cancelled by user scenarios, call DropIn.handleActivityResult
inside onActivityResult
within the activity that initiated the payment (DropIn.startPayment
). The result is obtained in the DropInResult
wrapper class:
class CheckoutActivity : Activity() {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
val dropInResult = DropIn.handleActivityResult(requestCode, resultCode, data) ?: return
when (dropInResult) {
is DropInResult.Error -> handleError(dropInResult.reason)
is DropInResult.CancelledByUser -> handleCancelled()
is DropInResult.Finished -> { // No need to handle this case, it will not occur if resultIntent is specified
}
}
}
}
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.
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 Drop-in 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.