# How to identify Alipay+ codes

> For Mobile Payment Partners (MPPs) who don't want to use the Alipay+ server SDK, they can call the inquiryCodeRules API that is provided by Alipay+ to obtain Alipay+ code rules.

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 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](../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 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_ is `DECODE`, 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](../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
}
```

##