Redirect
This guide describes how to add the redirect flow for payment methods to your Airwallex iOS SDK integration.
How it works
The diagram below depicts the integration flow for a redirect payment.
Step 1: (Optional) Create a Customer
Create a Customer object and pass it to your server if you want to save your customer's details and attach payment information to this object. Note that this step is compulsory when you process recurring payments for a new customer.
From your server, access Airwallex API to Create a Customer API.
Step 2: Create a PaymentIntent
Your client app will need a PaymentIntent to create a payment session for Airwallex SDK to present a payment flow.
From your server, access Airwallex API to Create a PaymentIntent API and pass the returned PaymentIntent to the client app.
Step 3: Create a one-off PaymentSession
Create an AWXOneOffSession
with the PaymentIntent
created in the previous step, a returnURL
to your app, and shipping address and shopper country code of this order.
Step 4: Present payment flow to the shopper
Present payment flow with the Session
created in the previous step. Airwallex SDK will then process the payment flow and return payment status to a delegate when the shopper completes or cancels payment.
Step 5: Query and present payment result
After the PaymentIntent
is confirmed by SDK, this delegate will be called by the SDK automatically and you can check the status to see whether the payment process has completed or not.
A completed flow does NOT imply a successful transaction. You will need to query the payment result afterwards through your server to know whether the order is paid or not. Inside AWXPaymentResultDelegate
, ask your server to retrieve the PaymentIntent.
On your server, retrieve the Payment Intent API, get the payment result and pass it to the client app.