To enable the Adyen SDK to handle payments, you need to add code to your POS app. This code starts a transaction with:
- A Terminal API payment request.
- The payment interface you want to use: the card reader.
- The presentation mode you want to use.
After you have added this code, payments take place as follows:
- Your app creates a Terminal API payment request that is serialized to JSON, or you receive the Terminal API payment request from your backend.
- You pass the payment request to the Adyen SDK.
- The Adyen SDK checks if the session is still valid, and if necessary establishes a new session.
- The transaction starts on your mobile device. The Adyen SDK shows instructions on your mobile device to guide the customer.
- The Adyen SDK passes the Terminal API payment response to your POS app.
Add code to start a transaction
In your POS app, add code for the following steps:
If you create the Terminal API payment request in your POS app, use
POIIDin the MessageHeader of the payment request. (If you create the payment request in the backend, the backend uses the
Create an instance of
Transaction.Request(data:), and pass the Terminal API payment request from your POS app or backend.
let transaction = try Transaction.Request(data: requestData)
PaymentInterfacefrom an instance of
Use the card reader.
let paymentService = PaymentService(...) let paymentInterface = try paymentService .getPaymentInterface(with: .cardReader)
TransactionPresentationModethat matches the UI framework of the POS app.
The UI is embedded in a
The UI is presented on top of the provided
let presentationMode: TransactionPresentationMode = .viewModifier
PaymentService.performTransaction(with:paymentInterface:presentationMode:)on your instance of
let transactionResponse = await paymentService.performTransaction( with: transaction, paymentInterface: paymentInterface, presentationMode: presentationMode )
The Adyen SDK now checks for a session, and starts the transaction.
- Pass the
transactionResponseto your POS app. This is the Terminal API payment response, including data you can use to generate a receipt.