Alipay+ DocsAlipay+ Docs

showPaymentSheet

The showPaymentSheet API is used to show the payment sheet for the user to complete the payment after the user places an order with Alipay+. You can display the recommended Mobile Payment Partners (MPPs) that are supported by Alipay+ on the payment sheet.

Note:

  • The payment sheet mentioned in this section is also known as the Alipay+ checkout page.
  • If only one payment method is available, the payment sheet is not displayed. In this case, the user is directly redirected to the MPP client to complete the payment.

After the user selects an MPP and clicks Pay Now, the user is redirected to the MPP client to complete the payment. In the preceding process, you can receive callbacks about key events, such as when the user clicks Close or when the user clicks Pay Now.

How to handle the key events:

  • When you receive the event that the user has selected an MPP and clicked Pay Now, the SDK closes the payment sheet and redirects the user to the MPP client to complete the payment. The payment status will not be updated through callbacks. Therefore, you may need to call your server to query the payment status.
  • When the user clicks Close, the SDK closes the payment sheet. You can define custom logic to process the event.
  • If the value of the paymentData parameter is illegal, the payment sheet is not displayed and the corresponding callback is invoked to notify the caller.

About the payment sheet:

  • The payment sheet will be rendered in the key window and cover the interface of the active app, including the navigation bar and status bar.
  • The payment sheet is closed only when the user clicks Close or clicks Pay Now after selecting an MPP.

Method signature

copy
@Interface AlipayPlusClient:NSObject
- (void)showPaymentSheet:(NSString *)paymentData 
                        callback:(void(^)(IAPPaymentSheetEvent *sheetEvent))callback;

@end

Request parameters

Name

Type

Length

Description

Required

paymentData

NSString

/

The payment data that is used for rendering the payment sheet.

M

callback

Block

(void(^)(IAPPaymentSheetEvent *sheetEvent))

/

A block is used to return the status of the payment sheet.

See callback for details.

M

callback

Name

Type

Length

Description

Required

sheetEvent

IAPPaymentSheetEvent

/

An object that describes the event that occurred when the status of the payment sheet changed.

O

Response parameters

N/A

Sample

copy
[[AlipayPlusClient shared] showPaymentSheet:@"xxx" callback:^(IAPPaymentSheetEvent * _Nonnull sheetEvent) {
    if ([sheetEvent.name isEqualToString:IAPPaymentSheetEventDidShow]) {
        // your own logic
    } else if ([sheetEvent.name isEqualToString:IAPPaymentSheetEventThrowException]) {
        // your own logic
    } else if ([sheetEvent.name isEqualToString:IAPPaymentSheetEventUserDidCancel]) {
        // your own logic
    } else if ([sheetEvent.name isEqualToString:IAPPaymentSheetEventDidSelectWalletAndPay]) {
        // your own logic
    } else if ([sheetEvent.name isEqualToString:IAPPaymentSheetEventPaymentException]) {
        // your own logic after payment interruption
        // Currently, this type of event may occur only after you import Alipay SDK to optimize the Alipay payment experience.
    } else if ([sheetEvent.name isEqualToString:IAPPaymentSheetEventPaymentCanceled]) {
        // your own logic after payment cancelation
        // Currently, this type of event may occur only after you import Alipay SDK to optimize the Alipay payment experience.
    } else if ([sheetEvent.name isEqualToString:IAPPaymentSheetEventPaymentFailed]) {
        // your own logic after payment failure
        // Currently, this type of event may occur only after you import Alipay SDK to optimize the Alipay payment experience.
    } else if ([sheetEvent.name isEqualToString:IAPPaymentSheetEventPaymentSuccess]) {
        // your own logic after payment success
        // Currently, this type of event may occur only after you import Alipay SDK to optimize the Alipay payment experience.
    } else if ([sheetEvent.name isEqualToString:IAPPaymentSheetEventPaymentProcessing]) {
        // your own logic after payment finishes but status is ongoing
        // Currently, this type of event may occur only after you import Alipay SDK to optimize the Alipay payment experience.
    }
}];