# 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](../sdk_mpp/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](../sdk_mpp/init).

#### Sample

```java
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](../sdk_mpp/identify_code) 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_mpp/pay_private_order_code) 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](../sdk_mpp/identify_code).

#### Sample

```java
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
}
```