How to identify Alipay+ codes
This topic goes through the steps of how to identify whether a QR code is an Alipay+ code by integrating the Alipay+ server SDK. The MPP needs to follow the next steps to identify Alipay+ codes:
Step 1: Initialize the Alipay+ server SDK
Call the ac.code.service.CodeIdentificationService#init API to initialize the Alipay+ server SDK.
Processing logic
When handling the result, follow the processing logic below:
- If result.resultStatus is
S
, the initialization is successful. - If result.resultStatus is
F
orU
, the initialization is blocked. The MPP can troubleshoot based on result codes and logs.
For more information about how to use the API (such as the parameter description), see CodeIdentificationService#init.
Sample
CodeIdentificationInitResult result = codeIdentificationService.init();
if (result.getResult().getResultStatus().equals("S")){
// Initialization success.
} else {
// Block the application startup and troubleshoot
}
Step 2: Identify the order code
Call the ac.code.service.CodeIdentificationService#identifyCode API to identify whether the code can be processed by Alipay+.
Processing logic
When handling the result, follow the processing logic below:
- If result.resultStatus is
S
, the code identification is successful. See the following list for details:
- If isSupported is
true
and postCodeMatchActionType isDECODE
, the code can be processed by Alipay+. The MPP needs to send a request to Alipay+ to decode the code value. - If isSupported is
false
, the code cannot be processed by Alipay+. The MPP needs to reject the code.
- If result.resultStatus is
F
, the code identification failed. The MPP can handle the result based on result codes. - If result.resultStatus is
U
, unknown exceptions occur during the code identification and the MPP can check logs to view details. The MPP can try to call the API again later.
For more information about how to use the API (such as the parameter description), see CodeIdentificationService#identifyCode.
Sample
CodeIdentificationIdentifyRequest request = new CodeIdentificationIdentifyRequest();
request.setCodeValue("28100104df2342342****");
CodeIdentificationIdentifyResult result = codeIdentificationService.identifyCode(request);
if (result.getResult().getResultStatus().equals("S") && result.isSupported()){
// the code should be processed by Alipay+
}
if (result.getResult().getResultStatus().equals("F"){
// Please pay attention to resultCode
}