Are you looking for test card numbers?

Would you like to contact support?

Point-of-sale icon

Add the Adyen POS Mobile SDK for iOS

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

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 accepting payments through the Adyen POS Mobile SDK, take the following steps:

  1. Add the Adyen POS Mobile SDK for iOS to the Xcode project that contains your iOS POS app.
  2. Add code to establish a session.
  3. Add code to enable payments through the Adyen POS Mobile SDK.

Objective-C compatibility

If your POS app requires the Adyen POS Mobile SDK for iOS to be compatible with Objective-C, link the ADYPOS package product to your app target instead of AdyenPOS. The integration process is the same. The only difference is that the public symbols are prefixed with ADY. For example, PaymentService is called ADYPaymentService.

Add the Adyen POS Mobile SDK

You can add the Adyen POS Mobile SDK for iOS to your POS app using Swift Package Manager, or manually.

Add using Swift Package Manager

Add the Adyen POS Mobile SDK for iOS as a package dependency to your Xcode project following the instructions in the Swift Package Manager documentation.
In case of a local package, enter the local path to the directory as follows:

file:///{...}/adyen-pos-package-ios

Add manually

If you are integrating the XCFramework directly:

  1. In your Xcode project, select File > Add Files and select the Adyen POS Mobile SDK for iOS.
  2. Check that the application target is linked to AdyenPOS (or ADYPOS for Objective-C compatibility).

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:

  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 POS Mobile SDK through the PaymentServiceDelegate.register(with:) callback of PaymentServiceDelegate.
    /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 POS Mobile SDK, add code to your iOS POS app:

  1. Implement the PaymentServiceDelegate protocol. Below is an example of how you could do that.
    struct SessionsResponse: Decodable {
        let sdkData: String
    }
    
    class MyPaymentServiceDelegate: PaymentServiceDelegate {
        internal func register(
            with setupToken: String
        ) async throws -> String {
            /// Make a call to your backend to trigger a `/sessions` request, supplying the provided `setupToken`.
            let request = URLRequest(url: URL(string: "{ADDRESS_OF_YOUR_BACKEND_API}")!)
            let (data, _) = try await URLSession.shared.data(for: request)
            let response = try JSONDecoder().decode(SessionsResponse.self, from: data)
            return response.sdkData
        }
    }
    The actual structure of the SessionsResponse depends on your backend implementation.
  2. Create an instance of PaymentService with the PaymentService(delegate:) initializer and pass the delegate object. Make sure you keep a strong reference to the payment service instance so that it is retained for the duration of the transaction. Also make sure your delegate is strongly referenced, because the PaymentService keeps a weak reference to the delegate.
    let paymentService = PaymentService(delegate: myPaymentServiceDelegate)
  3. Make sure that the PaymentServiceDelegate can provide new sdkData at any time.
    If there is no session or the session has expired, the delegate is called using the PaymentServiceDelegate.register(with:) 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