Alipay

This guide explains how to process Alipay payments with our SDK.

Configuration

In order to use Alipay your should register merchant account. You can find detailed instructions in the Alipay guide.

Adding Alipay to your app must be done in one of two ways, depending on whether you are using the Ready-to-Use UI or the SDK & Your Own UI. These two ways are covered in the sections below. Please follow the instructions relevant to the approach you have chosen.

Todo Java Script

iOS

Ready-to-Use UI

If you are using our ready-to-use checkout screens
  1. Drap and drop OPPWAMobile-Alipay.xcframework to the “Frameworks” folder of your project. Make sure “Copy items if needed” is checked.
  2. Check “Frameworks, Libraries, and Embedded Content” section under the general settings tab of your application’s target. Ensure the Embed dropdown has Embed and Sign selected for the framework.
  3. Configure Alipay in OPPCheckoutSettings along with other customizations. Make sure you set shopper result URL, it’s mandatory to support Alipay:

      4. Make sure Alipay is included to the payment brand list:

      And you are done!

SDK & Your Own UI

If you are using our SDK & Your Own UI then there is a little more work to be done, but it is still easy to add. There are two options for accepting Alipay payments:

  1. Accept Alipay payment as usual asynchronous transaction. For this reason, please see this guide.
  2. Accept Alipay payment using their native SDK. This case will be describe bellow.

Create OPPPaymentParams with the checkout id and submit a transaction. See below the full Alipay flow.

Call the native method from Alipay SDK with the value alipaySignedOrderInfo property from the transaction which your received in the callback:

Alipay may return the result of the transaction directly in the completion block or as Asynchronous notification to App delegate.

Note: Android

Android

Import alipaySdk-15.5.9.aar into your project (File > New > New Module > Import .JAR/.AAR Package). Then, add the module dependency to the build.gradle:
// this name must match the library name defined with an include: in your settings.gradle file
implementation project(":alipaySdk")

Migrating to version 2.34.0: If you have previously used the Alipay module, please remove it and add new module again as described above.

Ready-to-Use UI

If you are using our ready-to-use checkout screens, configure Alipay in CheckoutSettings along with other customizations. Simple add the Alipay to the payment brands:

And you are done!

SDK & Your Own UI

If you are using our SDK & Your Own UI then there is a little more work to be done, but it is still easy to add. There are two options for accepting Alipay payments. Create PaymentParams with the checkout id and submit a transaction:

Call the native method from Alipay SDK with the value alipaySignedOrderInfo from the transaction which your received in the callback:

NOTE: This method must be called from a different thread.