Antom, leading provider of tailored payment solutions

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

objectivec
@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

swift
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.

objectivec
- (void)onLaunch;

swift
optional func onLaunch()

onReady()

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

objectivec
- (void)onReady;

swift
optional func onReady()

onEventCallback()

Called when internal SDK events occur.

objectivec
- (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

AMSEventResult

Yes

Event result.

onSizeChanged()

Called when component size changes.

objectivec
- (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.

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

onSubmitPayCallback()

Result callback after submitting payment or card binding.

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

swift
optional func onSubmitPayCallback(_ eventResult: AMSStatusResult?)

Parameter

Type

Required

Description

eventResult

AMSStatusResult?

Yes

Submission result, including status code or error information.