AMSPaymentProtocol
Callback protocol for payment or card binding processes. This protocol defines callback methods for payment and card binding lifecycle events. All methods are optional. To receive these callbacks, set the paymentDelegate property on AMSPaymentElement.shared or ​AMSVaultElement.shared​.
Declaration
Objective-C
@protocol AMSPaymentProtocol <NSObject>
@optional
- (void)onLaunch;
- (void)onReady;
- (void)onEventCallback:(NSString * _Nonnull)eventCode
eventResult:(AMSEventResult * _Nonnull)eventResult;
- (void)onSizeChanged:(CGFloat)width
height:(CGFloat)height;
- (void)onBeforeSubmit:(NSDictionary * _Nullable)paymentInfo
completion:(void (^)(AMSResultInfo * _Nonnull))completion;
- (void)onSubmitPayCallback:(AMSStatusResult * _Nullable)eventResult;
@endSwift
public protocol AMSPaymentProtocol : NSObjectProtocol {
optional func onLaunch()
optional func onReady()
optional func onEventCallback(_ eventCode: String, eventResult: AMSEventResult)
optional func onSizeChanged(_ width: CGFloat, height: CGFloat)
optional func onBeforeSubmit(_ paymentInfo: [AnyHashable: Any]?, completion: @escaping (AMSResultInfo) -> Void)
optional func onSubmitPayCallback(_ eventResult: AMSStatusResult?)
}Callback methods
onLaunch()
Called when SDK initialization is completed.
Objective-C
- (void)onLaunch;Swift
optional func onLaunch()onReady()
Called when list data rendering is completed and buyers can start interacting.
Objective-C
- (void)onReady;Swift
optional func onReady()onEventCallback()
Called when internal SDK events occur.
Objective-C
- (void)onEventCallback:(NSString * _Nonnull)eventCode
eventResult:(AMSEventResult * _Nonnull)eventResult;Swift
optional func onEventCallback(_ eventCode: String, eventResult: AMSEventResult)Parameter | Type | Required | Description |
eventCode | String | Yes | Event code, identifying the event type. |
eventResult | Yes | Event result. |
onSizeChanged()
Called when component size changes.
Objective-C
- (void)onSizeChanged:(CGFloat)width
height:(CGFloat)height;Swift
optional func onSizeChanged(_ width: CGFloat, height: CGFloat)Parameter | Type | Required | Description |
width | CGFloat | Yes | Component‘s new width. |
height | CGFloat | Yes | Component‘s new height. |
onBeforeSubmit()
Custom processing callback before payment submission or card binding. Merchants can modify payment or card binding parameters or decide whether to continue submission in this callback.
Objective-C
- (void)onBeforeSubmit:(NSDictionary * _Nullable)paymentInfo
completion:(void (^)(AMSResultInfo * _Nonnull))completion;Swift
optional func onBeforeSubmit(_ paymentInfo: [AnyHashable: Any]?, completion: @escaping (AMSResultInfo) -> Void)Parameter | Type | Required | Description |
paymentInfo | [AnyHashable: Any]? | Yes | Payment or card binding information to be processed. |
completion | (AMSResultInfo) -> Void | Yes | Control the payment or card binding process through |
onSubmitPayCallback()
Result callback after submitting payment or card binding.
Objective-C
- (void)onSubmitPayCallback:(AMSStatusResult * _Nullable)eventResult;Swift
optional func onSubmitPayCallback(_ eventResult: AMSStatusResult?)Parameter | Type | Required | Description |
eventResult | Yes | Submission result, including status code or error information. |