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

copy
@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;

@end

Callback methods

onLaunch()

Called when SDK initialization is completed.

copy
- (void)onLaunch;

onReady()

Called when list data rendering is completed and buyers can start interacting.

copy
- (void)onReady;

onEventCallback()

Called when internal SDK events occur.

copy
- (void)onEventCallback:(NSString * _Nonnull)eventCode
            eventResult:(AMSEventResult * _Nonnull)eventResult;

Parameter

Type

Required

Description

eventCode

String

Yes

Event code, identifying the event type.

eventResult

AMSEventResult

Yes

Event result.

onSizeChanged()

Called when component size changes.

copy
- (void)onSizeChanged:(CGFloat)width
               height:(CGFloat)height;

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.

copy
- (void)onBeforeSubmit:(NSDictionary * _Nullable)paymentInfo
            completion:(void (^)(AMSResultInfo * _Nonnull))completion;

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 AMSResultInfo (action, scene, data).

onSubmitPayCallback()

Result callback after submitting payment or card binding.

copy
- (void)onSubmitPayCallback:(AMSStatusResult * _Nullable)eventResult;

Parameter

Type

Required

Description

eventResult

AMSStatusResult?

Yes

Submission result, including status code or error information.