Alipay+ DocsAlipay+ Docs

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 or U, the application startup is blocked. The MPP can troubleshoot the problems based on result codes and logs.

For more information about how to use the API (such as the parameter description), see CodeIdentificationService#init.

Sample

copy
CodeIdentificationInitResult result = codeIdentificationService.init();
if (result.getResult().getResultStatus().equals("S")){
    // Initialization success.
} else {
    // Block the application startup and troubleshoot
}

Step 2: Identify the QR 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. The MPP can take further actions according to the following rules:
    • If isSupported is true and postCodeMatchActionType is OPEN_URL, the MPP needs to open the entry code URL by using the launch API of the Alipay+ client SDK.
    • If isSupported is true and postCodeMatchActionType is DECODE, the MPP needs to call the userInitiatedPay API to decode.
    • If isSupported is false, the code cannot be processed by Alipay+.
  • If result.resultStatus is F, the code identification is failed. The MPP can troubleshoot 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, or try to call the interface again later.

For more information about how to use the API (such as the parameter description), see CodeIdentificationService#identifyCode.

Sample

copy
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
}