- Getting Started
- Tutorials
- Reference
- API Reference
- Basic Payment
- Authentication
- Card Account
- Virtual Account
- Bank Account
- Customer
- Billing Address
- Shipping Address
- Corporate
- Merchant
- Cart
- Airline
- Tokenization
- Recurring
- Recurring Migration
- 3D Secure
- Custom Parameters
- Async Payments
- Webhook notifications
- Risk
- Response Parameters
- Card On File
- Chargeback
- Result Codes
- Brands Reference
- API Reference
- FAQ

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.
iOS
Ready-to-Use UI
If you are using our ready-to-use checkout screens- Drap and drop
OPPWAMobile-Alipay.framework
to the "Frameworks" folder of your project.
Make sure "Copy items if needed" is checked. - Embed the framework
- Go to the app target’s General configuration page.
- Add the framework target to the Embedded Binaries section by clicking the Add icon.
- Select
OPPWAMobile-Alipay.framework
from the list of binaries.
- Add a Run Script
- Go to the app target’s Build Phases tab.
- In Xcode menu, select Editor > Add Build Phase > Add Run Script Build Phase. You should now see a Run Script section in your Build Phase options.
Important: "Run Script" phase should be put after "Embed Framework" phase. You can reoder build phases by dragging them using your mouse. - Set it to use
/bin/sh
and check the Run script only when installing option. - Enter the following script:
- Review your Build Phases:
OPPWAMobile-Alipay.framework
is added to the "Link Binary With Libraries" and "Embed Frameworks" phases.- "Run Script" phase is put after the "Embed Frameworks" phase and contains our script.
- Configure Alipay in
OPPCheckoutSettings
along with other customizations. - Make sure Alipay is included to the payment brand list:
The framework contains a build for both the simulator (i386, x86_64) and the actual devices (ARM). As it is not permitted to submit a binary for an unsupported architecture to App Store, you have to add script that "manually" removes unused architectures from the final binary.
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
find "$APP_PATH" -name 'OPPWAMobile*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"
echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
done

Make sure you set shopper result URL, it's mandatory to support Alipay:
OPPCheckoutSettings *checkoutSettings = [[OPPCheckoutSettings alloc] init];
checkoutSettings.shopperResultURL = @"com.companyname.appname.payments://result";
let checkoutSettings = OPPCheckoutSettings()
checkoutSettings.shopperResultURL = "com.companyname.appname.payments://result"
checkoutSettings.paymentBrands = @[@"ALIPAY", ... ];
checkoutSettings.paymentBrands = ["ALIPAY", ...]
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:
- Accept Alipay payment as usual asynchronous transaction. For this reason, please see this guide.
- Accept Alipay payment using their native SDK. This case will be describe bellow.
OPPPaymentParams
with the checkout id and submit a transaction. See below the full Alipay flow.
NSError *error = nil;
OPPPaymentParams *paymentParams = [OPPPaymentParams paymentParamsWithCheckoutID:checkoutID paymentBrand:@"ALIPAY" error:&error];
if (error) {
// See error.code (OPPErrorCode) and error.localizedDescription to identify the reason of failure.
} else {
OPPTransaction *transaction = [OPPTransaction transactionWithPaymentParams:paymentParams];
[self.provider submitTransaction:transaction completionHandler:^(OPPTransaction * _Nonnull transaction, NSError * _Nullable error) {
if (error) {
// Handle the error.
} else {
// Use transaction.alipaySignedOrderInfo for authorization transaction through Alipay SDK
}
}];
}
do {
let paymentParams = try OPPPaymentParams(checkoutID: checkoutID, paymentBrand: "ALIPAY")
let transaction = OPPTransaction(paymentParams: paymentParams)
provider.submitTransaction(transaction) { (transaction, error) in
if (error != nil) {
// Handle the error.
} else {
// Use transaction.alipaySignedOrderInfo for authorization transaction through Alipay SDK
}
} catch let error as NSError {
// See error.code (OPPErrorCode) and error.localizedDescription to identify the reason of failure.
}
Call the native method from Alipay SDK with the value alipaySignedOrderInfo
property from the transaction which your received in the callback:
[[AlipaySDK defaultService] payOrder:transaction.alipaySignedOrderInfo fromScheme:@"com.companyname.appname.payments" callback:^(NSDictionary *resultDic) {
// Sent request to your server to obtain transaction status
}];
AlipaySDK.defaultService().payOrder(transaction.alipaySignedOrderInfo, fromScheme: "com.companyname.appname.payments") { (result) in
// Sent request to your server to obtain transaction status
}
Alipay may return the result of the transaction directly in the completion block or as Asynchronous notification to App delegate.
Android
Import alipaySdk-15.5.9.aar
into your project (File > New > New Module > Import .JAR/.AAR Package).
Then, reference it from your application (File > Project Structure > Dependencies > Add Module Dependency).
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
Configuration
Add the following line to the app's proguard-rules.pro
file:
-keep class com.alipay.sdk.** { *; }
Set up payment brand
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:
Set<String> paymentBrands = new LinkedHashSet<String>();
paymentBrands.add("ALIPAY");
CheckoutSettings checkoutSettings = new CheckoutSettings(checkoutId, paymentBrands);
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:
PaymentParams paymentParams = new PaymentParams(checkoutId, "ALIPAY");
Transaction transaction = new Transaction(paymentParams);
/* use IProviderBinder to interact with service and submit transaction */
binder.submitTransaction(transaction);
Call the native method from Alipay SDK with the value alipaySignedOrderInfo property from the transaction which your received in the callback:
PayTask payTask = new PayTask(YOUR_ACTIVITY.this, true);
String result = payTask.pay(transaction.getAlipaySignedOrderInfo());
/* process the result */
NOTE: This method must be called from a different thread.