AliPay+ via Onerway: Headless Guide
Integrate AliPay+ via Onerway on your website or mobile application and fully customize your checkout experience using your own UI.
Before you begin
This guide assumes that you know how to:
Accept payments with AliPay+ via Onerway
Prepare the client session
AliPay+ via Onerway requires the following data to process a payment successfully. Pass the following data in the client session, or in the payment request (for manual payment creation).
Parameter Name | Required | Description |
---|---|---|
currencyCode | ✓ | 3-letter currency code in ISO 4217 format, e.g. USD for US dollars |
order ↳ lineItems | ✓ | Details of the line items of the order |
Prepare the SDK for payments
Handle payment method
AliPay+ via Onerway requires instance of Redirect Manager in order to be presented to the user:
PACYPAY_ALIPAY_PLUS
must be returned as PaymentMethod.type
in the onAvailablePaymentMethodsLoad
callback.
When the user has selected the payment method, call the start function. This function automatically:
- opens a popup to present a loading indicator, then the payment method web page
- shows an overlay on top of your page that prompts the user to focus on the popup
Handle payment method
AliPay+ via Onerway requires instance of Redirect Manager in order to be presented to the user:
PACYPAY_ALIPAY_PLUS
must be returned as PaymentMethod.type
in the onAvailablePaymentMethodsLoad
callback.
When the user has selected the payment method, call the start function. This function automatically:
- opens a popup to present a loading indicator, then the payment method web page
- shows an overlay on top of your page that prompts the user to focus on the popup
Pre-requisites
Handling redirects is required for Payment Methods that present a webpage or open a 3rd party application for the customer to enter their credentials and validate their payment.
To enable this feature, ensure that you include the urlScheme
parameter when configuring the PrimerPaymentMethodOptions
object.
Set up redirects
Handle redirects
When the user is redirected back to the main app, the function application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool is automatically called by iOS. Make sure to call Primer.shared.application...
to forward this information to the SDK so that Universal Checkout can continue the flow.
Handle payment method
AliPay+ via Onerway requires a Native UI Manager in order to be presented to the user:
Handle payment method
AliPay+ via Onerway requires a Native UI Manager in order to be presented to the user:
Handle payment method
AliPay+ via Onerway requires a Native UI Manager in order to be presented to the user:
This code is intended solely for illustrative purposes. As many payment methods share a common approach, it is recommended to centralize the implementation of these methods within your codebase. For a practical demonstration of how to achieve this, please refer to the guide on how to handle Native UI payment methods.
Go live
You don’t need to do anything particular to go live — just make sure to use production credentials.