Are you looking for test card numbers?

Would you like to contact support?

Point-of-sale icon

Make a payment

Add code to make a payment from your iOS POS app using the Adyen POS Mobile SDK.

Both Tap to Pay on iPhone and the iOS card reader solution use the same Adyen POS Mobile SDK for iOS. That's why the instructions include remarks for both solutions.

To enable the Adyen POS Mobile SDK for iOS to handle payments, you need to add code to your iOS POS app. This code starts a transaction with:

  • A Terminal API payment request.
  • The payment interface you want to use: your iPhone for Tap to Pay, or the card reader.
  • The presentation mode you want to use.

After you have added this code, payments take place as follows:

  1. Your iOS POS app creates a Terminal API payment request that is serialized to JSON, or you receive the Terminal API payment request from your backend.
    Tip
    To help you create Terminal API payment requests, we provide a TerminalAPIKit for iOS on GitHub. Installation and usage instructions are in the repository's README.
  2. You pass the payment request to the Adyen POS Mobile SDK.
  3. The SDK checks if the session is still valid, and if necessary establishes a new session.
  4. The transaction starts on your mobile device.
    In the card reader solution, the SDK shows instructions for the customer on your mobile device.
  5. The SDK passes the Terminal API payment response to your POS app.

Add code to start a transaction

In your iOS POS app, add code for the following steps:

  1. If you create the Terminal API payment request in your POS app, use PaymentService.installationId as POIID in the MessageHeader of the payment request. (If you create the payment request in the backend, the backend uses the installationId from the /sessions response.)
  2. Create an instance of Transaction.Request using Transaction.Request(data:), and pass the Terminal API payment request from your POS app or backend.
    let transaction = try Transaction.Request(data: requestData)
  3. Get a PaymentInterface from an instance of PaymentService, using PaymentService.getPaymentInterface(with:).
    Value Description
    tapToPay Use the iPhone for Tap to Pay.
    cardReader Use the card reader.
    let paymentService = PaymentService(...)
    let paymentInterface = try paymentService
                            .getPaymentInterface(with: .cardReader)
  4. Specify a TransactionPresentationMode that matches the UI framework of the POS app.
    Value Description
    viewModifier The UI is embedded in a View as a ViewModifier.
    presentingViewController The UI is presented on top of the provided UIViewController.
    let presentationMode: TransactionPresentationMode = .viewModifier
    If you use TransactionPresentationMode.viewModifier, apply it on your SwiftUI view as follows:
    Button(...) {
       // code to start the transaction
    }.transactionModal(with: {YOUR_INSTANCE_OF_PAYMENT_SERVICE})
  5. Invoke PaymentService.performTransaction(with:paymentInterface:presentationMode:) on your instance of PaymentService.
    let transactionResponse = await paymentService.performTransaction(
       with: transaction,
       paymentInterface: paymentInterface,
       presentationMode: presentationMode
    )
    The Adyen POS Mobile SDK now checks for a session, and starts the transaction. In the card reader solution, the SDK shows screens on your mobile device to help the customer.
  6. Pass the transactionResponse to your POS app. This is the Terminal API payment response, including data you can use to generate a receipt.

See also