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.
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. The following configuration is a sample that prints logs to the console. 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 route configurations are downloaded
Provided by Alipay+. The recommended default value is https://open-sea.alipayplus.com/aps/api/v1/codes/inquiryCodeRules.
The minimum required level of the loaded route configurations when initializing the Alipay+ server SDK. The initialization fails if the minimum-level configurations fail to be loaded. Valid values are:
Decided by the MPP.
Interval of pulling route configurations in minutes
Retry interval of pulling route configurations in minutes
Path where pulled route configurations 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.
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.