Are you looking for test card numbers?

Would you like to contact support?

Point-of-sale icon

Integrate the Adyen Android SDK

Update your code to integrate the Adyen SDK in your Android POS app.

To enable accepting payments through the Adyen Android SDK, take the following steps:

  1. Add the Adyen Android SDK to the Android Studio (or other) project that contains your POS app.
  2. Add code to establish a session.
  3. Add code to enable payments through the Adyen Android SDK.

Add the Adyen Android SDK

Reach out to your Adyen contact to get the Adyen Android SDK and the instructions for how to import the SDK into your project.

Establish a session

The Adyen Android SDK has to communicate in a secure way with the Adyen payments platform. To enable this, you must integrate a server-to-server /checkout/possdk/v68/sessions request to create a session. Your POS app needs to call your backend to trigger this /sessions request and get the session data.

The Adyen Android SDK uses the session data from the /sessions response to authenticate with our payments platform. Because the session expires after some time, the Adyen Android SDK checks regularly if it needs to establish a new session.

API key and roles

To authenticate your /sessions requests, you need an API credential. This API credential must have an API key and the following role:

  • Checkout webservice role. This role is assigned by default when the API key is created.

Make a /sessions request

To let your backend establish a session:

  1. From your backend, make a POST /checkout/possdk/v68/sessions request. In the request body, specify:

    • merchantAccount: the unique identifier of your merchant account.
    • store (optional): the unique identifier of the store that you want to process payments for.
    • setupToken: the session token provided by the Adyen Android SDK through the AuthenticationService.authenticate(setupToken) callback of AuthenticationService.
    /sessions request
    curl https://checkout-test.adyen.com/checkout/possdk/v68/sessions \
    -H "Content-Type: application/json" \
    -H "x-API-key: YOUR_API_KEY" \
    -X POST \
    -d '{
        "merchantAccount": "YOUR_MERCHANT_ACCOUNT",
        "store": "YOUR_STORE_ID",
        "setupToken": "SESSION_TOKEN"
    }'
  2. When you receive the response:

    • Check that you get a 201 Created HTTP status code.
    • Return the sdkData to your POS app.
    • If you create the Terminal API request on your backend, save the installationId and use this as the POIID in the MessageHeader of the payment request.
    /sessions response
    {
        "id": "APP_SESSION_ID",
        "installationId": "INSTALLATION_ID",
        "merchantAccount": "YOUR_MERCHANT_ACCOUNT",
        "store": "YOUR_STORE_ID",
        "sdkData": "SDK_DATA_BLOB"
    }

Enable payments

To enable the payments functionality of the Adyen Android SDK, add code to your Android POS app:

  1. Initialize the Adyen Android SDK (possibly in your own Application.onCreate())

    InPersonPayments.initialize(application = application)
  2. Implement the AuthenticationService interface. Below is an example of how you could do that (assuming your project uses OkHttp).

    class MyAuthenticationService : AuthenticationService() {
    
        override suspend fun authenticate(setupToken: String): Result<AuthenticationResult> {
    
            // Make a call to your backend to trigger a `/sessions` request, supplying the provided `setupToken`
    
            val client = OkHttpClient()
            val request = Request.Builder()
                .url("ADDRESS_OF_YOUR_BACKEND_API")
                .build()
    
            client.newCall(request).execute().use { response ->
                response.body?.let {
                    // parse your own back-end response and return AuthenticationResult
                    ...
                    return Result.success(AuthenticationResult(sdkData))
                }
            }
        }
    }
  3. Add the service to your POS app's AndroidManifest.xml file.

     <service android:name=".MyAuthenticationService"/>
  4. Make sure that the AuthenticationService can provide new sdkData at any time.
    If there is no session or the session has expired, the service is called using the AuthenticationService.authenticate(setupToken) callback. Using the provided setupToken you need to get the sdkData through your backend and return it. For instructions, see Establish a session.

See also