To enable accepting payments through the Adyen POS Mobile SDK, take the following steps:
- Add the Adyen POS Mobile SDK for Android to the Android Studio (or other) project that contains your Android POS app.
- Add code to establish a session.
- Add code to enable transactions through the Adyen POS Mobile SDK.
Add the Adyen POS Mobile SDK
- Reach out to your Adyen contact to get the Adyen POS Mobile SDK for Android.
-
Import the Adyen POS Mobile SDK for Android by adding the following lines to your POS app's
build.gradle
file.implementation 'com.adyen.ipp:pos-mobile:$version' implementation 'com.adyen.ipp:card-reader-management:$version'
Establish a session
The Adyen POS Mobile 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 SDK uses the session data from the /sessions
response to authenticate with our payments platform. Because the session expires after some time, the 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:
-
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 setup token provided by the Adyen POS Mobile SDK for Android through theAuthenticationService.authenticate(setupToken)
callback ofAuthenticationService
.
-
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 thePOIID
in theMessageHeader
of the payment request.
Enable transactions
To enable the payments functionality of the Adyen POS Mobile SDK for Android, add code to your Android POS app:
-
Initialize the Adyen POS Mobile SDK (possibly in your own
Application.onCreate()
).InPersonPayments.initialize(application = application)
-
Implement the
AuthenticationProvider
interface. Note that you need to extract thesdkData
from the server response and create anAuthenticationResponse
object withsdkData
in the constructor. Below is an example of how you could do that (assuming your project uses OkHttp).class MyAuthenticationProvider : AuthenticationProvider() { override suspend fun authenticate(setupToken: String): Result<AuthenticationResponse> { // 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 AuthenticationResponse ... return Result.success(AuthenticationResponse(sdkData)) } } } }
-
Implement the
AuthenticationService
abstract class: in your implementation, provide an instance of yourAuthticationProvider
from the previous step. If you use Dagger2/Hilt dependency injection, below is an example of how you could do this:class MyAuthenticationService : AuthenticationService() { @Inject override lateinit var authenticationProvider: AuthenticationProvider }
-
Add the service to your POS app's
AndroidManifest.xml
file.<service android:name=".MyAuthenticationService"/>
-
Make sure that the
AuthenticationService
can provide newsdkData
at any time.
If there is no session or the session has expired, the service is called using theAuthenticationService.authenticate(setupToken)
callback. Using the providedsetupToken
you need to get thesdkData
through your backend and return it. For instructions, see Establish a session.