Alipay+ DocsAlipay+ Docs

Quickstart

This topic introduces how to quickly set up Alipay+ ACQP iOS SDK.

Before you begin

Before you get started, ensure that the following requirements are met:

  • Install the following tools:
    • Xcode 12.* or later
  • Ensure that the minimum deployment target is set to iOS 9 or later.

Get started

Step 1. Add SDK to your project

  1. Log on to Alipay+ Developer Center to download the SDK binaries as a package. You can also obtain the source code if you need to review or customize the SDK source code.
  2. Ensure that the Alipay+ SDK and your own SDK (if exists) are linked together to your project.
  • If you previously used CocoaPods to publish your SDK or you can use CocoaPods to publish your SDK to other integrators, add the following line to your podspec file:
copy
s.vendored_frameworks = ['YOUR_PATH/AlipayPlusClient.framework'] 
s.resources = ["YOUR_PATH/AlipayPlusClient.framework/AlipayPlusResource.bundle"]
  • If you do not use CocoaPods, you can guide other integrators to manually add the SDK as follows:
    1. Add AlipayPlusClient.framework to your project. Make sure to select Copy items if needed.
    2. Add AlipayPlusClient.framework/AlipayPlusResource.bundle to your project. Make sure to select Copy items if needed. image
    3. Make sure to add -ObjC to Build Settings > Linking > Other Linker Flags to use class category.image

Note: If your project is created using swift and the "Undefined symbol: ___llvm_profile_runtime" error is triggered during build, try add -fprofile-instr-generate to Build Settings > Linking > Other Linker Flags to resolve the error.

Step 2. Set up the SDK before using other APIs

  1. Import the SDK header file to your project.
copy
import <AlipayPlusClient/AlipayPlusClient.h>
  1. Set up the SDK with required configurations.
copy
IAPConfiguration *configuration = IAPConfiguration.new;
configuration.envType = @"PROD";
configuration.acquirerId = @"xxx";
configuration.merchantId = @"yyy";
configuration.language= @"zzz";
[AlipayPlusClient.shared setConfiguration:configuration];

Step 3. (Optional) Set up the SDK to optimize Alipay payment experience

If you accept Alipay payments and want to optimize the Alipay payment experience, complete the following steps:

  1. Import Alipay SDK to your project through CocoaPods.
copy
pod  'AlipaySDK-iOS'

Note: If you want to manually import Alipay SDK, contact your solution architect.

  1. Add the following line to the SDK configuration. This enables smooth redirection from the Alipay app to your app.
copy
configuration.fromScheme = @"yourAppScheme";

The complete SDK configuration is as follows:

copy
IAPConfiguration *configuration = IAPConfiguration.new;
configuration.envType = @"PROD";
configuration.acquirerId = @"xxx";
configuration.merchantId = @"yyy";
configuration.fromScheme = @"yourAppScheme";
configuration.language= @"zzz";
[AlipayPlusClient.shared setConfiguration:configuration];

Note: In the Cashier Payment scenario, after you import Alipay SDK, the paymentRedirectUrl parameter in the pay API request does not take effect when the Alipay payment method is selected. Instead, the fromScheme parameter is used to redirect the user back to your app.

  1. Use the following APIs to process the redirect URL returned by the Alipay app. Ensure that the following requirements are met:
    • Call the canProcessOrderWithPaymentResult API to check if an URL can be processed by the Alipay+ SDK before calling the processOrderWithPaymentResult API to resolve the URL to obtain the payment result.
    • If SceneDelegate is used in your project, call these APIs inside the scene(_:openURLContexts:) method of your SceneDelegate; otherwise, call these APIs inside the application(_:open:options:) method of your AppDelegate.
copy
- (BOOL)canProcessOrderWithPaymentResult:(NSURL*)resultUrl;
- (void)processOrderWithPaymentResult:(NSURL*)resultUrl;

Next steps

After you have integrated the Alipay+ ACQP iOS SDK, you can move on to use the SDK in Cashier Payment. For more information, see Cashier Payment integration.