Android SDK
When capturing a Stored Credential for the first time

- Create a customer object and pass it to your server if it is a new customer. Recurring payment requires a customer ID to be initiated.
From your server, Create a Customer API with customer data received from client app and save the Customer ID returned.
- (Optional) If the shopper wishes to pay for the first order
Your client app will need a PaymentIntent to form a payment session for Airwallex SDK to present payment flow.
From your server, access Airwallex API to Create a Payment Intent API and pass the PaymentIntent returned to client app.
- Call
AirwallexStarter.presentPaymentFlowto present the payment flow or the autentication flow to the shopper.
a. PaymentIntent was created
Call AirwallexStarter.presentPaymentFlow with an AirwallexRecurringWithIntentSession and a PaymentResultListener to present payment flow to the shopper. See sample code below for parameters required to create an AirwallexRecurringWithIntentSession.
Java1val session = AirwallexRecurringWithIntentSession.Builder(2 paymentIntent = requireNotNull(3 paymentIntent,4 { "PaymentIntent is required" }5 ),6 customerId = requireNotNull(7 paymentIntent.customerId,8 { "CustomerId is required" }9 ),10 nextTriggerBy = nextTriggerBy,11 countryCode = Settings.countryCode12 )13 .setRequireCvc(requiresCVC)14 .setMerchantTriggerReason(if (nextTriggerBy == PaymentConsent.NextTriggeredBy.MERCHANT) PaymentConsent.MerchantTriggerReason.SCHEDULED else PaymentConsent.MerchantTriggerReason.UNSCHEDULED)15 .setReturnUrl(Settings.returnUrl)16 .setAutoCapture(Settings.autoCapture)17 .build()18AirwallexStarter.presentPaymentFlow(this, session,19 object : Airwallex.PaymentResultListener {2021 override fun onCompleted(status: AirwallexPaymentStatus) {2223 }24 }25 )
b. NO payment is required here
Call AirwallexStarter.presentPaymentFlow with an AirwallexRecurringSession and a PaymentResultListener to present the authentication flow to the shopper. See sample code below for parameters required to create an AirwallexRecurringWithIntentSession.
Java1val session = AirwallexRecurringSession.Builder(2 customerId = customerId,3 currency = currency,4 amount = orderAmount,5 nextTriggerBy = nextTriggerBy,6 countryCode = countryCode // Alpha-2 country code of shopper region7)8 .setShipping(shipping)9 .setRequireCvc(requiresCVC)10 .setMerchantTriggerReason(if (nextTriggerBy == PaymentConsent.NextTriggeredBy.MERCHANT) PaymentConsent.MerchantTriggerReason.SCHEDULED else PaymentConsent.MerchantTriggerReason.UNSCHEDULED)11 .setReturnUrl(Settings.returnUrl)12 .build()1314AirwallexStarter.presentPaymentFlow(this, session,15 object : Airwallex.PaymentResultListener {1617 override fun onCompleted(status: AirwallexPaymentStatus) {1819 }20 }21)
- In your
PaymentFLowListener, handle the authentication result returned from SDK and present it to the shopper.
If PaymentIntent was created earlier, in onSuccess function above, ask your server to retrieve the payment result. From your server , retrieve the Payment Intent API after SDK has confirmed it with Airwallex API, and pass the payment result to your client app.
When initiating a subsequent one-click transaction (CIT)

-
Create a Payment Intent with Customer ID to request payment for this order. You will get Payment Intent ID and client_secret returned
-
Call
AirwallexStarter.presentPaymentFlowwith anAirwallexSessionand aPaymentResultListenerto present payment flow to the shopper.
Java12val session = AirwallexPaymentSession.Builder(3 paymentIntent = paymentIntent,4 countryCode = Settings.countryCode5 )6 .setReturnUrl(Settings.returnUrl)7 .setAutoCapture(Settings.autoCapture)8 .build()9 AirwallexStarter.presentPaymentFlow(this, session,10 object : Airwallex.PaymentResultListener {1112 override fun onCompleted(status: AirwallexPaymentStatus) {1314 }15 }16 )17
- Retrieve the Payment Intent API in
onSuccessfunction above to get the payment result from thePaymentIntentafter the SDK has confirmed it with Airwallex API.
When initiating a subsequent subscription and autodebit transaction (MIT)

-
From your server, Create a Payment Intent API to request for a subsequent payment.
-
Confirm the Payment Intent API with reference to Payment Consent ID of the stored Payment Consent