antom.createElement()
antom.createElement() is a factory method. After successfully calling loadAntom() to load the SDK and obtain the antom instance, you can use this method to dynamically create the corresponding payment or card binding element instance by passing in the specified elementType.
Method signature
When calling this method, please use the following standard method signature format.
JavaScript
antom.createElement(elementType, options);
TypeScript
antom.createElement(elementType: ElementType, options?: AppConfig): Element
Parameters
This method accepts two parameters, which specify the type of element to be created and its configuration.
Parameter | Data type | Required | Description |
elementType | String | Yes | Element type, valid values are:
|
Object | Yes | A configuration object used to set the appearance theme and multilingual environment of components. |
options
Please pass in the corresponding options parameter based on the Element type used and the specific business scenario.
CVV Element or Vaulting Element
When elementType is CVV or vaulting, pass in the following options configuration object.
Parameter | Data type | Required | Description |
appearance | Object | No | Used for custom appearance configuration. For more information, refer to Appearance customization. It contains the following parameters:
|
locale | String | No | Multilingual configuration. Note:
Valid values are:
|
Express
When elementType is express, pass in the following options configuration object.
Parameter | Type | Required | Description |
sessionData | String | No | Payment session data. Note: Required when the payment method is Apple Pay, Google Pay, or Alipay. For PayPal, it is returned by createOrder() on the server side. |
Object | No | Payment amount. Note: Required when the payment method is PayPal. | |
paymentMethods | Object | No | List of enabled payment methods, which also determines the button rendering order. Valid values are:
Note: This parameter is optional. If it is not passed, no express checkout button will be displayed. To render express checkout buttons, pass in at least one payment method value. |
Object | No | PayPal configuration parameters, required when integrating PayPal. | |
Object | No | Button type for each payment method. Note: Alipay does not support this parameter. | |
Object | No | Button color for each payment method. Note: Alipay does not support this parameter. | |
buttonHeight | Number | No | Unified button height, in px. |
amount
Parameter | Type | Required | Description |
currency | String | Yes | Note: It must be consistent with the currency used when creating sessionData . |
value | String | Yes |
paypal
Parameter | Type | Required | Description |
businessDivision | String | Yes | Business division (country/region) identifier. |
channelMerchantAccountId | String | Yes | PayPal merchant ID. |
createOrder() | Function | Yes | Pass in order information to call the createPaymentSession (One-time Payments) API to create a payment session and obtain the createOrder() required paymentSessionData. |
Object | No | Button shape. | |
Function | No | Shipping address change callback, wheredata is the raw data returned by PayPal. | |
Function | No | Shipping option change callback, wheredata is the raw data returned by PayPal. |
style
Parameter | Type | Required | Description |
shape | String | No | Button shape:
|
buttonType
Parameter | Type | Required | Description |
applePay | String | No | The supported labels for the Apple Pay payment method button include:
|
googlePay | String | No | The supported labels for the Google Pay payment method button include:
|
paypal | String | No | The supported labels for the PayPal payment method button include:
|
buttonTheme
Parameter | Type | Required | Description |
applePay | String | No | The supported colors for the Apple Pay payment method button include:
|
googlePay | String | No | The supported colors for the Google Pay payment method button include:
|
paypal | String | No | The supported colors for the PayPal payment method button include:
|
Return value
This method returns an element instance object that provides methods for mounting, unmounting, destroying, and updating configurations, enabling flexible management of the component lifecycle on the page.
Function | Description |
Register event listeners for the Element instance. | |
Used to mount an element to a specified page node, and can be passed in a specific HTMLElement. | |
Unmount the current Element (can be remounted). | |
Destroy the current Element (cannot be remounted). | |
Update the configuration. |
Error codes
Use the element.on() method to listen for error codes related to the antom.createElement() method. For a detailed list of error codes, please refer to the Error codes.