Integrate our drop-in Checkout SDK into your Android app.
The Checkout SDK is our quickest way of integrating 250+ supported payment methods and 3D Secure into your Android app.
The SDK handles presenting a list of payment methods to the shopper, collecting their details, and submitting them to Adyen. It also takes care of encrypting and transmitting sensitive payment data, so it never touches your server. To use the SDK, you'll also need to set up a server that can create a payment session and verify the result of payments.
To accept online payments with the Checkout SDK, you'll need to:
- Integrate the Android SDK.
- Create a payment session from your server.
- Verify the payment result on your server.
Before accepting live payments, we also recommend that you test your integration.
To see an example of an Android SDK integration, check out our GitHub.
Before you begin
- Sign up for an Adyen test account at https://www.adyen.com/signup.
- Get your API Key. Save a copy as you'll need it for API calls you make to the Adyen payments platform.
For more information on these steps, refer to Get started with Adyen.
Step 1: Integrate SDK
Here we describe how you integrate with v2 of our Android SDK, which is the latest version. If you've integrated with a previous version, use our documentation for v1 of the Android SDK.
To add the Checkout SDK to your app:
Import the SDK
Add the SDK modules into your project by adding the following to your build.gradle file.
- Initialize SDK
Next, call the
startPaymentmethod of the
returnUrlwill be returned in
CheckoutSetupParameters. Pass these to your server to create a payment session. Then, handle the
paymentSessionvalue received by your server with
Present payment form
StartPaymentParametersto present the payment form to the shopper.
When the shopper completes the payment form and clicks Pay, the Checkout SDK submits their payment details to the Adyen payments platform.
Handle payment result
When the payment is completed you will receive the result in your calling Activity. Present this to the shopper in your app. For a list of possible payment results and what these mean, refer to Result codes.
You'll also receive a
payload. Send this to your server to verify the result of the payment.
Step 2: Create payment session
A payment session is used to securely transmit payment data between the shopper and the Adyen payments platform. Create one from your server by making a POST request to the
merchantAccount name, and a
channel of Android.
Also include the
amount, your unique
reference for this payment, and the
countryCode of the shopper.
Finally, include the
returnUrl generated by the SDK.
You can also use our demo server until you have implemented your own:
Execute this code from your server, not your app. This helps to prevent tampering with transaction data.
The response will contain a
paymentSession. Use this to initialize the SDK.
Step 3: Verify payment result
/payments/resultrequest. Include the
payloadthat was generated by the SDK.
If the payment was successful you'll receive an Authorised
resultCode and a
pspReference, which is our unique identifier for the transaction. If you've set up notifications, you'll also receive a successful AUTHORISATION notification.
If you received a different
resultCode, check our result codes documentation for what action you should take.
Next, let's look at how you can test your integration.
Testing your integration
You can check the status of a test payment in your Customer Area, under Transactions > Payments.
When you've completed testing, there are some additional steps you'll need to complete before you can accept live payments from shoppers. Refer to Getting started with Adyen for more information.
Customizing your Checkout
You can customize the payment form presented in your app by:
When your app has an
AppCompat theme, the payment form rendered by the SDK will inherit your app's styling and font (from either
To customize either of these, add new theme to your
Setting the screen orientation
By default, the payment form is displayed in portrait orientation. To use a different orientation, override the
<integer> specified in your
Set the orientation by specifying one of the following integers:
- 0: Landscape orientation.
- 1: Portrait orientation.
- 6: Sensor landscape orientation.
- 7: Sensor portrait orientation.
You can also use any
screenOrientation referred to in the Android developer documentation. To do this, specify the Constant Value of your preferred
screenOrientation as the
Set up notifications
Receive confirmation when a payment is authorised or fails.
Find out how to cancel, refund, or capture a payment using our API.