Quick start
This topic introduces how to quickly set up the Alipay+ Android SDK.
Before you begin
Before you get started, ensure that the following requirements are met:
- Install or update Android Studio to a working version.
- Use target API level 15 (ICE_CREAM_SANDWICH_MR1) or later.
- Use Gradle 4.1 or later.
- Set up a physical device or use an emulator to run your app.
Step 1: Add the 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.
The following table lists the SDK packages that are required for different Alipay+ payment products:
Product | Merchant-presented Mode Payment | Auto Debit | |
aar | Foundational |
| |
Product-specific |
|
| |
- Add the SDK binaries (the .aar files) to the libs folder of your project.
- Add the following code to the build.gradle file of your module.
copy
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"])
}Step 2: Set up the SDK before using other APIs
Configure the following parameters to set up the SDK before you use other APIs provided by the SDK.
copy
Configuration configuration = new Configuration();
configuration.envType = "PROD";
configuration.clientId = "XXX";
configuration.siteName = "YYY";
AlipayPlusClient.getInstance().setConfiguration(configuration);Note: When configuring the SDK in the sandbox environment, set configuration.envType to
PROD.
Step 3: (Optional) Configure log monitoring
To track activity lifecycles within the SDK, initialize the monitoring component using the following code:
copy
// Listen to log type
IAPTinyLogger.setLogEnabledByType(true, IAPTinyLogType.LOG_TYPE_EVENT);
IAPTinyLogger.setLogEnabledByType(true, IAPTinyLogType.LOG_TYPE_EXCEPTION);
IAPTinyLogger.setLogEnabledByType(true, IAPTinyLogType.LOG_TYPE_DIAGNOSE);
// Setting up observer
IAPTinyLogger.addObserver(
new ILogObserver() {
@Override
public void logger(IAPTinyLogger iapTinyLogger, IAPTinyLog iapTinyLog) {
// Print iapTinyLog.name and iapTinyLog.parameters
}
}
);Next steps
After you have integrated the SDK, refer to the following guides to implement specific payment scenarios: