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
copy
public interface MPMService {
void decode(DecodeServiceParams params, Callback<DecodeServiceResult> callback);
}
Request parameters
Callback
Item | Type | Description | Required |
result | The result information that is required if the payment is successful. | O |
Response parameters
N/A
Sample
Definition of YOUR_MPM_SERVICE_CLASS:
copy
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:
copy
AlipayPlusClientMPM.getInstance().mpmService = new YOUR_MPM_SERVICE_CLASS();