# decode

In entry code scenarios, Alipay+ stores the payment information as a code value. The Alipay+ client SDK calls the **decode** API to send the code value to the Mobile Payment Provider (MPP). The MPP can then call the server API **userInitiatedPay** to decode the code value and obtain the payment information.

> **Note**: For entry codes to work, the MPP must implement the **decode** API.

## Method signature

```java
public interface MPMService {

    void decode(DecodeServiceParams params, Callback<DecodeServiceResult> callback);

}
```

## Request parameters

| **Item** | **Type** | **Description** | **Required** |
| --- | --- | --- | --- |
| params | [DecodeServiceParams](android_appendix#YOVLs) | The parameters that are required to obtain the order information. | M |
| callback | Callback | The callback to be invoked after the payment process ends. See [Callback](android_decode#MvbML) for details. | M |

#### Callback

| **Item** | **Type** | **Description** | **Required** |
| --- | --- | --- | --- |
| result | [DecodeServiceResult](android_appendix#kwkQF) | The result information that is required if the payment is successful. | O |

## Response parameters

N/A

## Sample

Definition of _YOUR\_MPM\_SERVICE\_CLASS_:

```java
public class YOUR_MPM_SERVICE_CLASS implements MPMService {

    public void decode(DecodeServiceParams params, Callback<DecodeServiceResult> callback) {
        // Step 1: Send a userInitiatedPay request
        // Step 2: Determine the value of the actionForm.actionType parameter in the userInitiatedPay response
        if (actionType.equals("HANDLE_BY_SDK")) {
            // If the value of the actionForm.actionType parameter is "HANDLE_BY_SDK"
            // Step 3-CALL_SDK: Construct a DecodeServiceResult instance and fill in the value of the actionForm.sdkActionPayload parameter in the userInitiatedPay response
            DecodeServiceResult result = new DecodeServiceResult();
            result.sdkActionPayload = response.actionForm.sdkActionPayload;
            callback.onSuccess(result);
        } else {
            // If the value of the actionForm.actionType parameter is not "HANDLE_BY_SDK"
            // Step 3-Default: Invoke the cashier after receiving the request from Alipay+
            // Step 4-Default: User completes the payment
            // Step 5-Default: Construct a DecodeServiceResult instance and callback
            DecodeServiceResult result = new DecodeServiceResult();
            callback.onSuccess(result); // If the payment is successful
            callback.onFailure("XX", "YY"); // If the payment failed
        }
    }
}
```

Instance of _YOUR\_MPM\_SERVICE\_CLASS_:

```java
AlipayPlusClientMPM.getInstance().mpmService = new YOUR_MPM_SERVICE_CLASS();
```