Alipay+ DocsAlipay+ Docs

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
NS_ASSUME_NONNULL_BEGIN
@protocol MPPAlipayPlusClientMPMProtocol <NSObject>
- (void)decode:(MPPDecodeServiceParams *)params
    payCompletionHandler:(void(^)(MPPDecodeServiceResult *_Nullable result, NSError * _Nullable error))payCompletionHandler;
@end
NS_ASSUME_NONNULL_END

Request parameters

Item

Type

Description

Required

params

MPPDecodeServiceParams

The parameters that are required to obtain the order information.

M

payCompletionHandler

iOS Block

The callback to be invoked after the payment process ends. See payCompletionHandler or details.

M

payCompletionHandler

Item

Type

Description

Required

result

MPPDecodeServiceResult

The result information that is required if the payment is successful.

O

Response parameters

N/A

Sample

Definition of YOUR_MPM_SERVICE_CLASS:

copy
#import <MPPAlipayPlusClientMPM/MPPAlipayPlusClientMPM.h>

@interface YOUR_MPM_SERVICE_CLASS: NSObject <MPPAlipayPlusClientMPMProtocol>
- (void)decode:(MPPDecodeServiceParams *)params
    payCompletionHandler:(void(^)(MPPDecodeServiceResult *_Nullable result, NSError * _Nullable error))payCompletionHandler;
@end

@implementation YOUR_MPM_SERVICE_CLASS

- (void)decode:(MPPDecodeServiceParams *)params
    payCompletionHandler:(void(^)(MPPDecodeServiceResult *_Nullable result, NSError * _Nullable error))payCompletionHandler; {
    // 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 an MPPDecodeServiceResult instance and fill in the value of the actionForm.sdkActionPayload parameter in the userInitiatedPay response 
        MPPDecodeServiceResult *result = MPPDecodeServiceResult.new;
        result.sdkActionPayload = response.actionForm.sdkActionPayload;
        payCompletionHandler(result, nil);
    } 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 an MPPDecodeServiceResult instance and callback
        MPPDecodeServiceResult *result = MPPDecodeServiceResult.new;
        payCompletionHandler(result, nil);
 }
@end

Instance of YOUR_MPM_SERVICE_CLASS:

copy
#import <MPPAlipayPlusClientMPM/MPPAlipayPlusClientMPM.h>

[MPPAlipayPlustClient shared].mpmService = YOUR_MPM_SERVICE_CLASS.new