Antom, leading provider of tailored payment solutions

element.on()

CVV ELement or Vaulting Element
Use the element.on() or element.once() method to register event listeners for the Element instance. Depending on your business needs, perform one of the following actions:
  • If continuous listening is needed, call element.on() to register continuous listening, where the callback function is executed each time the event is triggered
  • If you want the event to be handled only once, call element.once() to register one-time listening, where the listener is automatically canceled after the event is triggered once.
After calling the method, when the corresponding event is triggered internally in the Element instance, the callback function will be executed.
Note: Event names and specific data structures may vary slightly depending on product form and integration scenario. The following lists only typical usage.

Method signature

When calling this method, please use the following standard method signature format.
JavaScript
javascript
element.on(event, callback);
element.once(event, callback);
TypeScript
typescript
element.on(event: string, callback: (data: EventDataType) => void): offFunction
element.once(event: string, callback: (data: EventDataType) => void): void

Parameters

Parameter
Data type
Required
Description
event
String
Yes
The event name, such as 'error'.
callback
Function
Yes
Event callback function. The parameter is the data object corresponding to the event.

error event

Used to monitor the web page loaded by the SDK, which contains the following parameters:
Parameter
Data type
Required
Description
code
String
Yes
Error code. For specific information, refer to the Error codes.
message
String
Yes
Error message, describing the specific content of the error.
type
String
No
Error type, used to categorize the error.
detail
Any
No
Error details, which may include debugging information.

Return value

  • element.on(): Returns an offFunction. Calling this function will unregister the event listener.
  • element.once(): No return value. The listener is automatically unregistered after the event is triggered once.
Express Element
Used to register event listeners on an Express Element instance so that the corresponding callback logic is executed when the specified event is triggered. For supported event types, see the event descriptions below.

Method signature

When calling this method, use the following standard method signature format:
JavaScript
javascript
express.on(event, handler);
TypeScript
typescript
express.on<T extends keyof ExpressElementEvents>(event: T, handler: (payload: ExpressElementEvents[T]) => void): void

Parameters

Parameter
Type
Required
Description
event
String
Yes
Event name. For details, see Events below.
handler
Function
Yes
Event callback function,used to handle the logic after the corresponding event is triggered. The payload data structure it receives depends on the specific event type.

Events

Listen to the following events through element.on() . Different events pass different payload structures to handler.

ready event

Triggered when button rendering is complete. Contains the following parameters:
Parameter
Type
Required
Description
Object
Yes
Whether each payment method is rendered successfully.

availablePaymentMethods

Parameter
Type
Required
Description
alipay
Boolean
No
Whether the Alipay payment button is rendered successfully:
  • true: Alipay can currently be displayed or used.
  • false: Alipay is currently unavailable.
applePay
Boolean
No
Whether the Apple Pay payment button is rendered successfully:
  • true: Apple Pay can currently be displayed or used.
  • false: Apple Pay is currently unavailable.
googlePay
Boolean
No
Whether the Google Pay payment button is rendered successfully:
  • true: Google Pay can currently be displayed or used.
  • false: Google Pay is currently unavailable.
paypal
Boolean
No
Whether the PayPal payment button is rendered successfully:
  • true: PayPal can currently be displayed or used.
  • false: PayPal is currently unavailable.

click event

Triggered when the buyer clicks a payment button. This is a notification-only event. The SDK does not wait for a response, and merchants can use it for tracking. Contains the following parameters:
Parameter
Type
Required
Description
String
Yes
The payment method clicked by the buyer.

confirm event

Triggered after the buyer confirms using an express payment method. The timing for triggering this event varies by payment method, as follows:
  • Alipay:Triggered after the buyer clicks the payment button.
  • Apple Pay, Google Pay, PayPal:Triggered after the buyer completes authorization in the corresponding wallet.
In this event callback, the merchant needs to choose whether to continue or abort the payment process:
  • Call antom.confirmPayment(): Continue and complete the payment.
  • Call paymentFailed(): Proactively cancel the payment.
Contains the following parameters:
Parameter
Type
Required
Description
Object
No
Related information after the user confirms the payment.

data

Parameter
Type
Required
Description
String
Yes
Payment method.
Object
No
Billing information.
Note: Returned after Apple Pay and Google Pay wallet authorization.
Object
No
Shipping address.
Note: Returned after Apple Pay and Google Pay wallet authorization.
paymentFailed()
Function
No
Payment failure callback. Used to proactively terminate the payment in the confirm process. After it is called, the current payment process ends, and there is no need to call antom.confirmPayment().
billingDetails
Parameter
Type
Required
Description
name
String
No
Name.
email
String
No
Email.
phone
String
No
Phone number.
Object
No
Billing address.
shippingAddress
Parameter
Type
Required
Description
name
String
No
Name.
phone
String
No
Phone number.
Object
No
Shipping address.
address
Parameter
Type
Required
Description
line1
String
No
House number and street information.
line2
String
No
Additional address information.
city
String
No
City.
state
String
No
State, region, or province.
country
String
No
Country or region, compliant with the ISO 3166 country code standard.
postalCode
String
No
Postal code.

error event

Triggered when an error occurs during rendering, setup, wallet interaction, confirm timeout, or other stages. Contains the following parameters:
Parameter
Type
Required
Description
String
No
The payment method where the error occurred.
Note: Some errors, such as SETUP_ERROR or SESSION_DATA_INVALID may not belong to a specific payment method.
source
String
No
Error source, including:
  • SDK_INTERNAL: SDK internal error.
  • SDK_USAGE: SDK usage error.
  • APP_RUNTIME: Element runtime error.
  • SERVER_API: API call error.
  • SYSTEM: System environment error.
String
Yes
Error code.
message
String
Yes
Error message.
reason
String
No
Error reason.
traceId
String
No
Trace ID, which can be used for troubleshooting.

code

General
code
Description
Next steps
SETUP_ERROR
Express initialization failed.
Contact Antom technical support for details.
MERCHANT_CONFIRM_TIMEOUT
confirmPayment() was not called within 20s.
Call confirmPayment() within 20s.
CHECKOUT_NOT_READY
The amount is updated before the checkout is loaded.
Update the amount after the checkout is loaded.
PAYMENT_IN_PROGRESS
The amount is updated during payment.
Update the amount before payment.
AMOUNT_VALUE_INVALID
An invalid amount is passed in.
Pass in a valid amount.
AMOUNT_VALUE_EMPTY
No amount is passed in.
Pass in a valid amount.
AMOUNT_CURRENCY_MISMATCH
A currency inconsistent with sessionData is passed in.
Pass in the same currency as the one used to create sessionData.
AMOUNT_CURRENCY_UNSUPPORTED
An invalid currency is passed in.
Pass in a valid currency.
AMOUNT_PRECISION_UNSUPPORTED
The amount passed in exceeds the supported precision.
Pass in a valid amount.
AMOUNT_RESOLVE_FAILED
Amount conversion failed.
Contact Antom technical support for details.
Apple Pay
code
Description
Next steps
APPLE_PAY_NOT_SUPPORTED
The current device does not support Apple Pay.
Check whether the network, device, or region supports Apple Pay.
APPLE_PAY_MISSING_DATA
Apple Pay initialization parameters are incomplete.
Initiate the payment again.
APPLE_PAY_TOKEN_ERROR
Failed to obtain the Apple Pay token.
Refresh the page and try again.
APPLE_PAY_PAYMENT_SESSION_REQUEST_FAILED
Apple Pay merchant validation failed.
Refresh the page and try again.
Google Pay
code
Description
Next steps
GOOGLE_PAY_NOT_SUPPORTED
The device/browser does not support Google Pay.
The device/browser does not support Google Pay. Possible reason: the network cannot load Google's SDK.
GOOGLE_PAY_PAYMENT_FAILED
Google Pay payment failed.
Google Pay payment failed. Check the network or pay again.
PayPal
code
Description
Next steps
PAYPAL_ERROR
PayPal did not return an error code.
Pass through the messgae returned by PayPal.
PAYPAL_RENDER_FAILED
PayPal button rendering failed.
Pass through the messgae returned by PayPal.
PAYPAL_CREATE_ORDER_FAILED
createOrder() encountered an exception.
Contact Antom technical support for details.
PAYPAL_ORDER_ID_NOT_FOUND
createOrder() returned abnormal sessionData.
Retrieve sessionData again.
PAYPAL_RUNTIME_ERROR
PayPal SDK returned an error.
Pass through the messgae returned by PayPal.
PAYPAL_BUTTONS_INIT_ERROR
PayPal button initialization failed.
Pass through the messgae returned by PayPal.
PAYPAL_SDK_LOAD_ERROR
PayPal SDK script failed to load.
Check the network.
CHANNEL_CLIENT_ID_QUERY_FAILED
The channelClientId API did not return clientId.
Contact Antom technical support for details.
CHANNEL_CLIENT_ID_QUERY_ERROR
The channelClientId API failed.
Contact Antom technical support for details.

cancel event

Triggered when the buyer cancels the payment. Contains the following parameters:
Parameter
Type
Required
Description
String
Yes
The canceled payment method.
data
String
No
Raw data returned by the payment method. Returned by the PayPal SDK when the user cancels.

contentHeightChanged event

Triggered when the content height changes,containing the following parameters:
Parameter
Type
Required
Description
height
Number
Yes
Element content height, in px.

Return value

This method has no return value.

Error codes

The following are the relevant error codes captured when calling the element.on() method.
element.mount() related
Code
Description
Further action
SUCCESS
Success.
No further action.
UNKNOWN_EXCEPTION
The method call failed for an unknown reason.
Prompt the buyer to confirm the status of the related methods:
PROCESS_FAIL
A general business failure occurred.
Contact Antom Technical Support to investigate the issue.
RISK_REJECT
The transaction cannot be further processed because of risk control. If the user has already paid for the transaction, the transaction will be refunded.
Prompt the buyer for risk control.
INQUIRY_PAYMENT_SESSION_FAILED
Payment session expired.
The order has been closed out of time. Use the new paymentRequestId to reinitiate payment.
UNKNOWN_ERROR
Unknown exception.
Prompt the buyer to handle form errors themselves.
API_GATEWAY_TIMEOUT
The gateway timed out.
Prompt the buyer gateway timeout.
API_TIMEOUT
Interface response timed out.
Prompt the buyer interface response timeout.
API_GATEWAY_ERROR
The gateway is abnormal.
Prompt the buyer to handle form errors themselves.
MOUNT_TIMEOUT
The mount operation timed out.
It is recommended that buyers refresh the page and try again.
MOUNT_MISSING_CONTAINER
No container element was passed in.
Ensure that the container element is passed correctly.
MOUNT_IFRAME_LOAD_ERROR
Failed to load the iframe.
It is recommended that buyers refresh the page and try again.
MOUNT_NOT_SUPPORT
The current status does not support mounting.
Avoid multiple mounting, or destroy the instance before mounting.
MOUNT_INITIAL_FAILED
Mount initialization failed.
It is recommended that buyers refresh the page and try again.
MISSING_PAYMENT_METHOD
The rendering template has not been issued.
Contact Antom Technical Support to investigate the issue.
USER_CLOSE_VAULTING
The buyer closed the half-floating layer for card binding.
Prompt the buyer according to the business needs, or guide the buyer to rebind the card.
antom.createElement() related
Code
Description
Further action
NOT_SUPPORT_ELEMENT
An unsupported element type has been created.
Create a supported Element.
SESSION_DATA_INVALID
Invalid sessionData.
Check whether the correct sessionData is being used.
ELEMENT_INIT_FAILED
Element initialization failed.
Contact Antom Technical Support to investigate the issue.
GENERATE_ELEMENT_KEY_FAILED
Element unique identifier generation failed.
Contact Antom Technical Support to investigate the issue.
CANNOT_CREATE_SAME_ELEMENT_TWICE
Two identical elements were created simultaneously.
Do not create two identical elements.
antom.confirmCardSetup() related
Code
Description
Further action
SUCCESS
Success.
No further action.
UNKNOWN_EXCEPTION
The method call failed for an unknown reason.
Prompt the buyer to confirm the status of the related methods:
PAYMENT_IN_PROCESS
The payment is being processed.
Prompt the buyer to confirm the status of the related methods:
USER_BALANCE_NOT_ENOUGH
Payment could not be completed due to insufficient buyer balance for the corresponding payment method.
Prompt the buyer that the balance is insufficient
REPEAT_REQ_REJECT
Repeat application.
Contact Antom Technical Support to investigate the issue.
ASSET_ORDER_NOT_EXIST
Order does not exist.
Contact Antom Technical Support to investigate the issue.
PROCESS_FAIL
A general business failure occurred.
Contact Antom Technical Support to investigate the issue.
RISK_REJECT
The transaction cannot be further processed because of risk control. If the user has already paid for the transaction, the transaction will be refunded.
Prompt the buyer for risk control.
INQUIRY_PAYMENT_SESSION_FAILED
Payment session has expired.
The order has timed out and been closed. Please initiate the payment again using a new paymentRequestId.
ACCESS_DENIED
Access denied.
Contact Antom Technical Support to investigate the issue.
CARD_EXPIRED
The bank card used for the transaction has expired.
No action is required from the merchant.
INVALID_EXPIRY_DATE_FORMAT
The expiryYear or expiryMonth is not in the correct format.
No action is required from the merchant.
INVALID_EXPIRATION_DATE
Invalid value for paymentMethod.paymentMethodMetaData.expiryYear or paymentMethod.paymentMethodMetaData.expiryDate.
No action is required from the merchant.
INVALID_CVV
The card CVV used for the transaction is invalid.
No action is required from the merchant.
INVALID_CARD_NUMBER
The bank card number used for the transaction is invalid.
No action is required from the merchant.
SELECTED_CARD_BRAND_NOT_AVAILABLE
The bank card brand designated by the merchant for the transaction is not supported.
Check the card brand by yourself.
CARD_NOT_SUPPORTED
The bank card used for the transaction is not supported.
No action is required from the merchant.
CARD_BIN_QUERY_ERROR
The bank card number used for the transaction is invalid.
No action is required from the merchant.
VERIFICATION_IN_PROCESS
Authentication is in process.
The PROCESSING status indicates that the authentication result has not been found after SDK polling. It is recommended to poll the payment result from the server.
INVALID_AMOUNT
Invalid amount
Contact Antom Technical Support to investigate the issue.
CURRENCY_NOT_SUPPORT
Currency is not supported.
Contact Antom Technical Support to investigate the issue.
NO_PAY_OPTIONS
No payment options are available.
Contact Antom Technical Support to investigate the issue.
ORDER_IS_CLOSED
The request you initiated has the same paymentRequestId as the closed transaction.
The order has timed out and been closed. Please initiate the payment again using a new paymentRequestId.
PARAM_ILLEGAL
A required parameter is missing or an illegal parameter exists. For example, a non-numeric input, an invalid date, or an argument of the wrong length and type.
Contact Antom Technical Support to investigate the issue.
FRAUD_REJECT
Due to the risk control, the transaction cannot be further processed. If the buyer has paid for the transaction, the transaction will be refunded.
If the buyer does not receive a refund within two weeks, contact Antom Technical Support to investigate the issue.
AUTHENTICATION_FAIL
Access denied.
Contact Antom Technical Support to investigate the issue.
PAYMENT_METHOD_SYSTEM_ERROR
Due to the risk control, the transaction cannot be further processed. If the buyer has paid for the transaction, the transaction will be refunded.
If the buyer does not receive a refund within two weeks, contact Antom Technical Support to troubleshoot the issue.
VERIFICATION_AMOUNT_EXCEED_LIMIT
Verify amount exceeds limit
Contact Antom Technical Support to investigate the issue.
DO_NOT_HONOR
Payment was refused by the issuing bank.
Prompt the buyer.
UNKNOWN_ERROR
Unknown exception.
Prompt the buyer to resolve form errors on their own.
API_GATEWAY_TIMEOUT
The gateway timed out.
Prompt the buyer gateway timeout.
API_TIMEOUT
Interface response timed out.
Prompt the buyer interface response timeout.
API_GATEWAY_ERROR
The gateway is abnormal.
Prompt the buyer to handle form errors themselves.
VALIDATION_FAILED
Form validation failed upon submission.
Prompt the merchant to modify the form and try again once it meets the requirements.
INQUIRY_RESULT_TIMEOUT
Query card binding result timed out.
Prompt the merchant to try again.
MISSING_SUCCESS_REDIRECT_URL
The redirect URL is missing upon successful redirection.
Contact Antom Technical Support to investigate the issue.
MISSING_3D_REDIRECT_URL
The 3D redirect link is missing.
Contact Antom Technical Support to investigate the issue.
NOT_SUPPORT_SUBMIT
This element does not support submission.
Contact Antom Technical Support to investigate the issue.
INVALID_MODAL_URL
Invalid modal url.
Contact Antom Technical Support to investigate the issue.
INVALID_REDIRECT_URL
Invalid redict url.
Contact Antom Technical Support to investigate the issue.
DDC_UPLOAD_PARAM_ILLEGAL
3DE DDC error, incorrect parameters for DDC upload.
Contact Antom Technical Support to investigate the issue.
DDC_UPLOAD_DATA_FAILED
3DE DDC error, channel page issue when submitting the FORM.
Contact Antom Technical Support to investigate the issue.
DDC_QUERY_ID_MISSING
3DE DDC exception, ddcquery results do not meet requirements, no ID.
Contact Antom Technical Support to investigate the issue.
DDC_QUERY_INFO_MISSING
3DE DDC exception, ddcquery results do not meet requirements, no ddcInf found.
Contact Antom Technical Support to investigate the issue.
DDC_QUERY_INFO_UUID_MISSING
3DE DDC exception, missing required parameter ddcSubmit.
Contact Antom Technical Support to investigate the issue.
DDC_PARAMETERS_INVALID
3DE DDC error, missing required parameters for 3DE.
Contact Antom Technical Support to investigate the issue.
DDC_INQUIRY_3D_REDIRECT_URL_PARAMS_MISSING
3DE DDC error, missing necessary parameters for 3DE link query.
Contact Antom Technical Support to investigate the issue.
DDC_QUERY_PAYMENT_REDIRECT_URL_TIMEOUT
3DE DDC error, ddc query redirection link timed out.
Contact Antom Technical Support to investigate the issue.
antom.confirmPayment() related
Error code
Description
Recommended action
UNKNOWN_EXCEPTION
The API call failed due to an unknown reason.
Contact Antom technical support for details.
PAYMENT_RESULT_TIMEOUT
A network exception occurred when obtaining the payment result.​
Try polling the payment result from the server.
USER_CANCELED
The user manually closed the code display or redirect guide page pop-up.
Initiate the payment again.
THREE_DS_FAILED
3DS authentication failed.
Check for network issues.
EXPIRED_CODE
The QR code has expired.
Inform the buyer that the QR code has expired.
CODE_VIEW_OPEN_FAILED
Unable to open the QR code pop-up.
Refresh the page and try again.
MERCHANT_CONFIRM_TIMEOUT
confirmPayment() was not called within 20 seconds.
Call confirmPayment() within 20 seconds.

Best practices

  • Event name case rules: Please strictly pass in the event name as defined in the documentation or SDK.
  • Multiple registrations: Calling element.on() multiple times for the same event will register multiple listeners, all of which will be triggered in the order they were registered. If no longer needed, please manage them according to business needs or cancel listening through other APIs.
  • Destruction timing: After calling element.destroy() or element.unmount(), the event listeners for the corresponding Element will no longer be effective.