Airwallex logo

Low-level API integration

Copy for LLMView as Markdown

Build your own entirely custom UI on top of our low-level APIs. Make sure you add dependency for Airwallex or AirwallexPayment.

How it works

The diagram below depicts the integration flow for a card payment.

iOS Card one-off

Prepare payment session

Before using the low-level APIs, you need to create a payment session. See Prepare payment session for details on setting up the environment, creating a customer, payment intent, and payment session.

Collect payment information using custom UI

For native UI integration, this step is handled by the Airwallex-provided UI. For low-level API integration, you must implement your own UI to collect all the information required for payment.

PCI-DSS compliance

For card payment, your app must be PCI-DSS compliant if using Confirm card payment with card and billing details flow. Provide a PCI-DSS AOC and renew it regularly.

Create PaymentSessionHandler

PaymentSessionHandler is at the center of the API integration.

swift
1let paymentSessionHandler = PaymentSessionHandler(
2 session: "The session created above",
3 viewController: "hosting view controller which also handles AWXPaymentResultDelegate"
4)
5// store the `paymentSessionHandler` in your view controller or class that is tied to your view's lifecycle
6self.paymentSessionHandler = paymentSessionHandler

Pay with card

swift
1// Confirm intent with card and billing
2paymentSessionHandler.startCardPayment(
3 with: "The AWXCard object collected by your custom UI",
4 billing: "The AWXPlaceDetails object collected by your custom UI"
5)

Pay with consent object - Confirm intent with a payment consent object (AWXPaymentConsent):

swift
1paymentSessionHandler.startConsentPayment(with: "payment consent")

Pay with consent ID - Confirm intent with a valid payment consent ID only when the card is saved as network token:

swift
1paymentSessionHandler.startConsentPayment(withId: "consent ID")

Pay with Apple Pay

Make sure you have set up Apple Pay correctly. See the Apple Pay section in Prepare payment session.

swift
1paymentSessionHandler.startApplePay()

Pay with redirect

You should provide all required fields defined in /api/v1/pa/config/payment_method_types/${payment method name} in additionalInfo.

swift
1paymentSessionHandler.startRedirectPayment(
2 with: "payment method name",
3 additionalInfo: "all required information"
4)

Handle payment result

Implement AWXPaymentResultDelegate to receive payment lifecycle callbacks.

swift
1func paymentViewController(_ controller: UIViewController?, didCompleteWith status: AirwallexPaymentStatus, error: Error?) {
2 // call back for status success / in progress / failure / cancel
3}
4
5func paymentViewController(_ controller: UIViewController?, didCompleteWithPaymentConsentId paymentConsentId: String) {
6 // If the payment consent is created during payment process, you can implement this optional function to get the ID of this payment consent for any further usage.
7}

Retrieve the payment result

For any actions subsequent to the payment such as shipping goods or sending email receipts, you can retrieve the payment result using the following options:

Was this page helpful?