Before your user can start using Adyen's business accounts to transfer funds in the European Economic Area (EEA) or check their transaction history, your platform needs to comply with Payment Services Directive 2 (PSD2) that regulates secure payments and account access through Strong Customer Authentication (SCA). This means that during the authentication the user is required to provide two out of three factors:
- Knowledge: something only the user knows.
- Possession: something only the user possesses.
- Inherence: something the user is.
To help you comply with PSD2, we provide a client-side Authentication SDK that uses the possession factor through device binding and either the knowledge or the inherence factor, depending on the user's device access configuration. It is a two-factor authentication that requires a secondary verification method through a separate communication channel. For example, a mobile phone.
With Adyen's Authentication SDK, you can:
- Check if the user's device is eligible for Strong Customer Authentication (SCA).
- Register your user's mobile device to create device binding.
- Authenticate your user's subsequent actions.
The Authentication SDK integration also works with Adyen Issuing to authenticate a cardholder with 3D Secure.
System requirements
We provide the client-side Authentication SDK in the following languages:
- Kotlin or Java for Android applications
- Swift for iOS applications
Before you start implementing the SDK, make sure that your system follows the requirements.
- Your application targets minimum Android API level 21 or later.
- The authentication feature works on devices running on Android API level 26 and later.
- The authentication feature requires Google Play Services on the cardholder's device.
To ensure the correct support type for 3D Secure on the card program, contact our Support Team.
Installation
To install the Authentication SDK:
-
Add the following line to your
build.gradle
file.implementation "com.adyen.authentication:android-authentication:0.2.1"
Register device
Before starting the device registration, make sure that the operating system on the user's device supports SCA.
The following are the steps you need to do to register the user's device.
- Check SCA eligibility.
- Initiate the device registration from your server.
- Authenticate the user.
- Register the device.
- Finalize the registration from your server.
Step 1: Check SCA eligibility
This functionality requires additional configuration from Adyen. To enable it, contact our Support Team.
To check if the Android device is eligible for SCA:
-
Initiate the
AdyenAuthentication
class in your Activity or Fragment. -
Check if SCA is available on the device.
The output contains
sdkOutput
that you will use when initiating the registration. -
Pass
sdkOutput
to your server.We suggest that you store
sdkOutput
for further usage, in case you need to start the registration process again.
Step 2: Initiate device registration
Registering the device is a one-off procedure for each device. In case your user uses multiple devices, you'll need to register each of their devices separately.
To start the device registration:
-
From your server, make a POST
/registeredDevices
request. To make this request, your API credential needs the following role:- Bank SCA Webservice Role
Reach out to you Adyen contact to set it up for you.
In the request, specify the following:
Parameter Description paymentInstrumentId
The unique identifier of the payment instrument you want to register the device for. strongCustomerAuthentication.sdkOutput
Base64-encoded blob of data created in the previous step. The response returns:
sdkInput
: pass it to the SDK when registering the device.id
: device ID needed when finalizing the registration.
We suggest that you create and store a mapping between the registered device
id
and the human-readable account holder name. For example, RD00000000000000000000001 is "Cardholder's iPhone". You can use this pair later to show the details, for example, when unbinding the device.
Step 3: Authenticate user
In your client app, perform user authentication. PSD2 requires you to perform two-factor authentication (2FA) as an extra security step during the login process.
Step 4: Register the device
After you successfully authenticate your user:
-
Trigger the SDK to start the device registration and pass
sdkInput
from step 2.After the successful registration, the SDK generates a Base64-encoded
sdkOutput
data blob. -
Pass
sdkOutput
to your server.
Step 5: Finalize registration
To finalize the device registration:
-
From your server, make a PATCH
/registeredDevices/{id}
request, specifying the deviceid
in the path and the following parameters in the request body:Parameter Description paymentInstrumentId
The unique identifier of the payment instrument you want to register the device for. strongCustomerAuthentication.sdkOutput
Base64-encoded blob of data created in the previous step. The response contains
success
true.
The registration is now complete. The user can start authenticating future transactions using your app.
Make a transfer
Each time your user wants to make a transfer you need to authenticate them. To do so:
Step 1: Initiate transfer
Let's assume that your user chooses to make a funds transfer. To start the transfer:
-
Make a POST /transfers request, specifying the following parameters in the header:
Request header Description WWW-Authenticate
SCA realm
: Transfer.auth-param1
: Base64-encoded value of sdkOutput from checking SCA eligibility.Provide the following parameters in the request body:
Parameter Description amount The amount of the transfer. category Set to internal. description A human-readable description for the transfer. balanceAccountId Unique identifier of the source balance account. reference A reference of the transfer, only used internally within your platform. referenceForBeneficiary A reference that is sent to the recipient. counterparty.balanceAccountId Unique identifier of the target balance account. The response contains the following fields in the header:
status
: 401auth-param1
: Base64-encoded blob of data
You will need
auth-param1
when authenticating your user using the SDK. -
Pass
auth-param1
to the SDK.
Step 2: Authenticate user
Authenticate your user using the SDK. To do so:
-
Trigger the SDK to start user authentication and pass the
auth-param1
value from the previous step assdkInput
. As required by PSD2, the amount and the counterparty (payee) of the transfer that the user is authenticating for must be shown during the authentication. To comply with the regulations, we recommend that you implement a push notification and use theamount
andcounterparty
from the response in the previous step to show this information. -
Pass
sdkOutput
to your server.
Step 3: Finalize transfer
To finalize the transfer:
-
Make a POST /transfers request, specifying the following parameter in the request header:
Request header Description WWW-Authenticate
SCA realm
: Transfer.auth-param1
: Base64-encoded value of sdkOutput from user authentication.Provide the following parameters in the request body:
The parameter values must match the ones submitted to the
/transfers
endpoint previously when initiating the transfer.Parameter Description amount The amount of the transfer. category Set to internal. description A human-readable description of the transfer. balanceAccountId Unique identifier of the source balance account. reference A reference for the transfer, only used internally within your platform. referenceForBeneficiary A reference that is sent to the recipient. counterparty.balanceAccountId Unique identifier of the target balance account. The response header contains
status
authorised in the header, meaning the authentication and the transfer request were successful.
Get transaction history
Each time your user wants to check their transaction history, you need to authenticate them. To do so:
- Request your user's transaction history.
- Authenticate your user using the SDK.
- Get the transaction history.
Step 1: Request transaction history
To request the transaction history for the specified balance account:
-
Make a GET /transactions request, specifying the following parameter in the header:
Request header Description WWW-Authenticate
SCA realm
: Transaction.auth-param1
: Base64-encoded value of sdkOutput from checking SCA eligibility.Provide the following query parameters:
Parameter Description balanceAccountId Unique identifier of the balance account to get the transaction history for. createdSince Only include transactions that have been created on or after this point in time. The value must be in ISO 8601 format. For example, 2022-05-30T15:07:40Z. createdUntil Only include transactions that have been created on or before this point in time. The value must be in ISO 8601 format. For example, 2022-05-31T15:07:40Z. The response contains the following field in the header:
auth-param1
: Base64-encoded blob of data.
You will need
auth-param1
when authenticating your user using the SDK. -
Pass
auth-param1
to the SDK.
Step 2: Authenticate user
To authenticate your user using the SDK:
-
Trigger the SDK and pass the
auth-param1
value from the previous step assdkInput
. -
Pass
sdkOutput
to your server.
Step 3: Get transaction history
To get the transactions history:
-
Make a GET /transactions request, specifying the following parameter in the request header.
Request header Description WWW-Authenticate
SCA realm
: Transaction.auth-param1
: Base64-encoded value of sdkOutput from user authentication.The response contains the data array with the details of all transactions for the specified period.