Requirements
Get your client key
- Log in to your Customer Area.
- Go to Developers > API credentials, and select the credential username for your integration, for example ws@Company.[YourCompanyAccount].
- Under Client settings > Authentication select the Client key tab.
- Select Generate client key.
- Select the copy icon **and store your client key securely in your system.
- Under Add allowed origins, enter your domains and select Add.
- Select Save changes.
Show the available cards in your payment form
For information about the supported locations and currencies for each card, refer to Payment methods. To show the Card Component in your payment form, you need to:- Specify in your /paymentMethods request a combination of countryCode and amount.currency. This is used to determine which cards are available to the shopper.
-
Deserialize the /paymentMethods response, and get the object with
type: scheme.
For showing stored cards, get the object withtype: storedPaymentMethods. -
Add the Card Component:
a. Import the Card Component to your
build.gradlefile.For the latest version, refer to our GitHub. b. Create acardConfigurationobject, and pass your client key. You can also include optional configuration, for example to make the cardholder name required.c. Initialize the Card Component. Pass the object from the /paymentMethods response and thecardConfigurationobject.d. Add the Card Component view to your layout.e. Attach the Component to the view to start getting your shopper’s payment details.f. When shoppers enter their payment details, you start receiving updates. IfisValidis true and the shopper proceeds to pay, pass thepaymentComponentState.datato your server and make a payment request.
Optional configuration
When you create theCardConfiguration object, you can optionally add configuration parameters.
Address field configuration
Configure the postal code field inAddressConfiguration.PostalCode.
Include the following parameter:
Address field settings
Make a payment
When the shopper proceeds to pay, the Component returns thepaymentComponentState.data.paymentMethod.
-
Pass the
paymentComponentState.datato your server. -
From your server, make a /payments request, specifying:
paymentMethod: ThepaymentComponentState.data.paymentMethodfrom your client app.
- pspReference: Our unique identifier for the transaction.
resultCode: Use this to present the payment result to your shopper.merchantReference: Thereferencefrom the /payments request.additionalData: Additional information about the transaction.
To specify the fields that you want to receive inadditionalData, log in to your Customer Area, and go to Developers > Additional data.
Present the payment result
Use the resultCode from the /payments response to present the payment result to your shopper. You will also receive the outcome of the payment asynchronously in a webhook. For card payments, you can receive the followingresultCode values:
Additional
resultCode values are possible in case of the 3D Secure authentication flow. For more information, refer to Result codes.
Recurring payments
Adyen’s tokenization service allows you to securely store shopper’s card details for recurring payments. To make recurring payments, you first need to create a shopper token, and then use the token to make future payments for the shopper.Create a token
When a shopper chooses to pay with card, the Card Component renders a switch for saving the card details for future payments. If a shopper selects this option, thepaymentComponentState from the Component will include data.storePaymentMethod. Pass this to your server.
To create a token, include in your /payments request:
storePaymentMethod: ThepaymentComponentState.data.storePaymentMethodfrom your client app.- shopperReference: Your unique identifier for the shopper.
showStoredPaymentMethods to false when creating the cardConfiguration object:
Show a stored card in your payment form
When the shopper proceeds to pay, the Component returns thepaymentComponentState.data.paymentMethod.
-
Pass the
paymentComponentState.data.paymentMethodto your server. -
From your server, make a /payments request, specifying:
paymentMethod: ThepaymentComponentState.data.paymentMethodfrom your client app.
curl
Java
PHP
C#
Go
Python
Ruby
NodeJS (TypeScript)
Test and go live
If your client-side integration isn’t ready, you can test API requests with encrypted card details by adding atest_ prefix to the test card details.
Before making live card payments:
- Test your integration using our test card numbers. You can check the status of test payments in your Customer Area > Transactions > Payments.
- Add the cards that you want to accept in your live Customer Area.
- Configure the Component using the client key from your live Customer Area.
- Before you can start accepting card payments in the live environment, you need to assess your PCI DSS compliance and submit the required Self-Assessment Questionnaire A document. For more information, refer to PCI DSS compliance guide.