To enable the Adyen POS Mobile SDK for Android to handle payments, you need to add code to your Android POS app. This code starts a transaction with:
- A Terminal API request.
- The card reader as the payment interface to use.
After you have added this code, payments take place as follows:
- Your Android POS app creates a Terminal API request that is serialized to JSON, or you receive the Terminal API payment request from your backend.
- You pass the Terminal API request to the Adyen POS Mobile SDK.
- The SDK checks if the session is still valid, and if necessary establishes a new session.
- The transaction starts on your mobile device. The SDK shows instructions for the customer on your mobile device.
- The SDK passes the Terminal API response to your POS app.
Handle a payment
In your Android POS app, add code for the following steps:
-
If you create the Terminal API payment request in your POS app, use
InPersonPayments.getInstallationId()
asPOIID
in the MessageHeader of the payment request.
Note that if you create the Terminal API payment request in the backend, the backend uses theinstallationId
from the/sessions
response.For the structure of a Terminal API payment request, see Make a payment.
-
Create an instance of
TransactionRequest
usingTransactionRequest.create(nexoRequest)
, and pass the Terminal API payment request from your POS app or backend.val transactionRequest = TransactionRequest.create(nexoRequest)
-
Get a
PaymentInterface
fromInPersonPayments
usingInPersonPayments.getPaymentInterface(CardReader)
.val paymentInterface = InPersonPayments.getPaymentInterface(CardReader)
-
Register a listener for the
PaymentResult
and pass thetransactionResponse
to your POS app. This is the Terminal API payment response, including data you can use to generate a receipt.val paymentLauncher = InPersonPayments.registerForPaymentResult(this) { // handle transaction response here ... }
-
Invoke
InPersonPayments.performTransaction()
with your transaction data, payment launcher, and authentication service.Optionally customize the user interface using
merchantUiParameters
with the following optional fields:merchantLogo
: A logo in WEBP, JPEG, or PNG format to show on your mobile device during the transaction flow. The logo will be shown at 100dp x 32dp (width x height).autoDismissDelay
: Indicates how long the SDK shows the screen that indicates the transaction succeeded. If not specified, this success screen is dismissed after four seconds. You can set a time in milliseconds as a Long with a minimum of 0.5 seconds (500L) and a maximum of 4 seconds (4000L).
InPersonPayments.performTransaction( context = context, paymentInterface = paymentInterface, transactionRequest = transactionRequest, paymentLauncher = paymentLauncher, authenticationServiceClass = MyAuthenticationService::class.java, merchantUiParameters = MerchantUiParameters.create( merchantLogo = R.drawable.temp_merchant_logo_int, autoDismissDelay = 2000L ) )
The Adyen POS Mobile SDK checks for a session, starts the transaction, and shows screens on your mobile device to help the customer.
Handle a refund
There are two types of refund: referenced and unreferenced. The main difference is that a referenced refund is connected to the original payment, and an unreferenced refund isn't. That makes unreferenced refunds a bit riskier. For an overview of the differences, see Refund a payment.
Refunds are usually not processed synchronously. When you send a request for a referenced or unreferenced refund, the Terminal API response only confirms we received the request. Unreferenced refunds, however, can be processed synchronously. This depends on the card scheme and the country where the card is used. If processed synchronously, you receive an additional field in the Terminal API response: acquirerResponseCode
.
To learn the outcome of a refund, you need to set up webhooks.
Handle a referenced refund
The Terminal API request for a referenced refund is a reversal request. The SDK contains a dedicated function for this.
In your Android POS app, add code for the following steps:
-
If you create the Terminal API reversal request in your POS app, use
InPersonPayments.getInstallationId()
as POIID in the MessageHeader of the payment request.
Note that if you create the Terminal API reversal request in the backend, the backend uses theinstallationId
from the/sessions
response.For the structure of the Terminal API reversal request, see Referenced refund.
-
Create an instance of
TransactionRequestReversal
usingTransactionRequestReversal.create(nexoRequest)
, and pass the Terminal API payment request from your POS app or backend. -
Invoke
InPersonPayments.performReversal()
with your transaction data andauthenticationProvider
.
Note thatauthenticationProvider
is an implementation of the AuthenticationProvider interface, which extracts thesdkData
from the server response.InPersonPayments.performReversal( transactionRequestReversal: TransactionRequestReversal, authenticationProvider: AuthenticationProvider ) val reversalResponse = InPersonPayments.performReversal( transactionRequestReversal = transactionReversal, authenticationProvider = authenticationProvider, )
-
Check the
reversalResponse
that you receive. This is the Terminal API response with the result of the transaction and data you can use to generate a receipt, or with any errors. -
Pass the
reversalResponse
to your POS app.
Handle an unreferenced refund
The Terminal API request for an unreferenced refund is a payment request with an additional parameter:
PaymentData.PaymentType
: Refund
This means you can use the same code as for handling a payment. The only difference is the structure of the Terminal API payment request that you pass as the payload to the TransactionRequest
.
For the structure of the Terminal API request, see Unreferenced refund.