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.
Step 1. Add SDK to your project
- 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.
- 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:
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:
- Add AlipayPlusClient.framework to your project. Make sure to select Copy items if needed.
- Add AlipayPlusClient.framework/AlipayPlusResource.bundle to your project. Make sure to select Copy items if needed.
- Make sure to add -ObjC to Build Settings > Linking > Other Linker Flags to use class category.
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
- Import the SDK header file to your project.
- Set up the SDK with required configurations.
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:
- Import Alipay SDK to your project through CocoaPods.
Note: If you want to manually import Alipay SDK, contact your solution architect.
- Add the following line to the SDK configuration. This enables smooth redirection from the Alipay app to your app.
configuration.fromScheme = @"yourAppScheme";
The complete SDK configuration is as follows:
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.
- 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.
- (BOOL)canProcessOrderWithPaymentResult:(NSURL*)resultUrl; - (void)processOrderWithPaymentResult:(NSURL*)resultUrl;
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.