This topic shows how to integrate Alipay+ MPP Server SDK with your server.
Before you begin
The following requirements must be met:
- JDK 6 or higher.
- Maven 3.3.9 or higher if you integrate the SDK via Maven.
1 Initializing POM
To initialize POM dependencies, complete the following steps:
- Contact your solution architect to obtain the SDK JAR file. If you use a private Maven repository manager like Nexus, upload the downloaded JAR file to your repository. Refer to the following sample for details on how to upload the file. Replace placeholders as required.
- Download POM dependencies from Maven. Refer to the following sample for details on how to download POM dependencies from Maven. The minimum required versions of open source dependencies are listed in the sample.
Note: Logging library dependencies are not included in the sample. For more information about logging library dependencies, see 2.2.2 Initializing logging library.
2 Initializing logging library
Based on SLF4J, MPP developers can use a custom logging library. Refer to the following samples for details on how to initialize the Log4j2 logging library, which is an option provided by Alipay+. The MPP can also choose other logging libraries.
To initialize the Log4j2 logging library, complete the following steps:
- Add Log4j2 dependencies to your project.
- Add your custom Log4j2 configuration file to the classpath and configure the LOG_PATH property to specify the path on which the log files are kept. For more information about the log files, see Log file locations. For the setting of the LOG_PATH property, application represents the application.properties file; config/application represents the path to the classpath:config/application.properties file. The value of ac.log.path property can be read from the application.properties file.
The following configuration is a sample that prints logs. The actual logging configuration depends on your project. See
Configuration for details.
3 Importing bean definitions from components
To import bean definitions from the Alipay+ server SDK, use the following configuration files:
4 Defining component properties
To define component properties, complete the following steps:
- Register your properties file by using XML or Java.
Sample code for XML:
Sample code for Java:
- Add component properties.
The following table shows all component properties in detail:
HTTP server URL where the code rules are downloaded
Provided by Alipay+. The recommended default value is https://open-sea.alipayplus.com/aps/api/v1/codes/inquiryCodeRules.
The mode of initiating Alipay+ server SDK
Set the value to
Your server side first pulls the latest code rules from the Alipay+ server SDK. If the pull fails, you load the code rules stored in your local backup files. If the loading also fails, you can obtain the local code rules preset in the jar file.
Interval of pulling code rules in minutes
Retry interval of pulling code rules in minutes
Path where pulled code rules are saved
Decided by the MPP. Example:
Socket timeout for HTTP client in milliseconds
Connection timeout for HTTP client in milliseconds
Connection request timeout for HTTP client in milliseconds
The type of environment where the SDK is called
Valid values are:
Note: Set the value to
The client ID of the MPP that is assigned by Alipay+
Note: The value of this parameter must be prefixed with "TEST_" during acceptance testing.
The path on which the log files are kept
The default value is
Note: If the default value is used, the default log path is
5 Initializing components
Use the following API to initialize components before identifying codes. For more information, see CodeIdentificationService#init.
Initialize the code identification service.
6 Identifying codes
When the MPP cannot recognize the code value, use the following API to check whether the code can be processed by Alipay+. For more information, see CodeIdentificationService#identifyCode.
Identify codes that can be processed by Alipay+.
After you have integrated the SDK, you can move on to use the SDK in different payment scenarios.
For more information about how to use the SDK in Cashier Payment, see Cashier Payment integration.
For more information about how to use the SDK in Merchant-presented Mode Payment, see Merchant-presented Mode Payment integration.