Each time a user in the European Economic Area (EEA) wants to check their transaction history, you must authenticate them using SCA. To do so:
- Check SCA eligibility
- Initiate a request for your user's transaction history using the
sdkOutput
that you got when you checked the device for SCA eligibility. - Authenticate your user with the Authentication SDK.
- Get the transaction history using the
sdkOutput
from the authentication step.
Requirements
- Make sure that you have installed the Authentication SDK.
- Make sure that you have registered a device for your user.
- Make sure that your API credential has the following role:
- TransferService Webservice Retrieve role
Check SCA eligibility
Before requesting the transaction history, you must check for SCA eligibility and initiate the process to authenticate your users.
The following tabs explain how to check for SCA eligibility and initiate authentication using Kotlin, Swift, or JavaScript.
To initiate authentication on an Android device:
To check if the Android device is eligible for SCA:
-
Initiate the
AdyenAuthentication
class in your Activity or Fragment.Initiate authenticationExpand viewCopy link to code blockCopy codeprivate lateinit var adyenAuthentication: AdyenAuthentication override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) adyenAuthentication = AdyenAuthentication(this) } -
Check if SCA is available on the device.
Check SCA eligibilityExpand viewCopy link to code blockCopy codelifecycleScope.launch { val availabilityResult: AvailabilityResult = adyenAuthentication.checkAvailability() if (availabilityResult is AvailabilityResult.Available) { availabilityResult.sdkOutput } } The function returns an
sdkOutput
. -
Pass the
sdkOutput
to your server.
You will use the sdkOutput
when initiating a request for transaction history.
Initiate a request for the 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 you get when you initiate authentication..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. Request transaction historyExpand viewCopy link to code blockCopy codecurl https://balanceplatform-api-test.adyen.com/btl/v4/transactions?balanceAccountId=BA00000000000000000000002&createdSince=2022-05-30T15:07:40Z&createdUntil=2022-05-31T15:07:40Z \ -H 'x-api-key: ADYEN_BALANCE_PLATFORM_API_KEY' \ -H 'content-type: application/json' \ -H 'WWW-Authenticate: SCA realm="Transaction" auth-param1="eyJjaGFsbGVuZ2UiOiJiVlV6ZW5wek0waFNl..."' \ -X GET \ -d '{ }' 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.ResponseExpand viewCopy link to code blockCopy code{ "type": "https://docs.adyen.com/errors/unauthorized", "title": "Unauthorized", "status": 401, "errorCode": "00_401" } -
Pass
auth-param1
to the SDK assdkInput
.
Authenticate your user
To authenticate your user with the Authentication SDK:
-
Trigger the SDK and pass the
auth-param1
value from the previous step assdkInput
.Authenticate with SCA SDKExpand viewCopy link to code blockCopy codelifecycleScope.launch { if (adyenAuthentication.hasCredential("sdkInput")) { // Authenticate existing credential val authenticationResult: AuthenticationResult = adyenAuthentication.authenticate("sdkInput") when (authenticationResult) { is AuthenticationResult.AuthenticationSuccessful -> { authenticationResult.sdkOutput } is AuthenticationResult.Canceled -> { // User cancelled the authentication flow } is AuthenticationResult.Error -> { // Unexpected error authenticationResult.errorMessage } is AuthenticationResult.AuthenticationError -> { // FIDO API Error authenticationResult.authenticationError } } } else { // None of the existing credentials exist in this device } } If successful, the SDK generates a Base64-encoded
sdkOutput
data blob. -
Pass
sdkOutput
to your server.
Get the transaction history
To get the transaction 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 you get when you initiate authentication. |
curl https://balanceplatform-api-test.adyen.com/btl/v4/transactions?balanceAccountId=BA00000000000000000000002&createdSince=2022-05-30T15:07:40Z&createdUntil=2022-05-31T15:07:40Z \ -H 'x-api-key: ADYEN_BALANCE_PLATFORM_API_KEY' \ -H 'content-type: application/json' \ -H 'WWW-Authenticate: SCA realm="Transaction" auth-param1="CeCcEEJf2UPC7pB0K7AtEgLZX7cTvnqNznJF..."' \ -X GET \ -d '{ }'
- Use the content of the data array to present the transaction information to your user.
{ "data": [ { "balancePlatform": "YOUR_BALANCE_PLATFORM", "creationDate": "2023-08-10T14:51:20+02:00", "id": "EVJN42272224222B5JB8BRC84N686ZEUR", "accountHolder": { "description": "Your description for the account holder", "id": "AH00000000000000000000001" }, "amount": { "currency": "USD", "value": -1000 }, "balanceAccount": { "description": "Your description for the account holder", "id": "BA00000000000000000000001" }, "bookingDate": "2023-08-10T14:51:33+02:00", "status": "booked", "transfer": { "id": "3JNC3O5ZVFLLGV4B", "reference": "Your internal reference for the transfer" }, "valueDate": "2023-08-10T14:51:20+02:00" }, { "balancePlatform": "YOUR_BALANCE_PLATFORM", "creationDate": "2023-08-10T15:34:31+02:00", "id": "EVJN4227C224222B5JB8G3Q89N2NB6EUR", "accountHolder": { "description": "Your description for the account holder", "id": "AH00000000000000000000001" }, "amount": { "currency": "USD", "value": 123 }, "balanceAccount": { "description": "Your description for the account holder", "id": "BA00000000000000000000001" }, "bookingDate": "2023-08-10T15:34:40+02:00", "status": "booked", "transfer": { "id": "48POO45ZVG11166J", "reference": "Your internal reference for the transfer" }, "valueDate": "2023-08-10T15:34:31+02:00" } ], "_links": { "next": { "href": "https://balanceplatform-api-test.adyen.com/btl/v4/transactions?balancePlatform=YOUR_BALANCE_PLATFORM&createdUntil=2023-08-20T13%3A07%3A40Z&createdSince=2023-08-10T10%3A50%3A40Z&cursor=S2B-c0p1N0tdN0l6RGhYK1YpM0lgOTUyMDlLXElyKE9LMCtyaFEuMj1NMHgidCsrJi1ZNnhqXCtqVi5JPGpRK1F2fCFqWzU33JTojSVNJc1J1VXhncS10QDd6JX9FQFl5Zn0uNyUvSXJNQTo" } } }