loadAntom()

loadAntom() is the entry function for loading an Antom SDK instance. By accepting configuration parameters, it asynchronously loads and returns the Antom instance, which is used for subsequent operations such as creating Elements, updating configuration parameters, initiating payments, or binding payment methods.

Note:

  • The SDK uses a singleton pattern internally. Multiple calls to loadAntom() will return the same instance.
  • loadAntom() is an asynchronous function. You must use await or .then() to retrieve the instance.
  • When using the npm package, if script loading fails due to network issues, the method will return reject. It is recommended to check your network connection and refresh the page, or directly visit the corresponding CDN link to verify if the resource is accessible.

Method signature

When calling this method, please use the following standard method signature format:

copy
loadAntom(config)

Parameters

This method accepts a configuration object that is used to initialize the SDK’s runtime environment and core behavior.

Parameter

Type

Required

Description

configObject

No

SDK configuration object, which is used to set the environment, language, and debugging mode.

config

Parameter

Type

Required

Description

envString

No

Environment configuration options. Valid values are:

  • sandbox: Sandbox environment for testing.
  • prod: Default value. Production environment for online services.
environmentString

No

The alias for env. If both are set, the value of env takes precedence. Valid values are:

  • sandbox: Sandbox environment for testing.
  • prod: Default value. Production environment for online services.

Note: The env and environment parameters serve the same function; it is recommended to use the env parameter consistently.

debugBoolean

No

Used to enable debug mode. Enabling it will output detailed logs, making it easier for developers to troubleshoot issues. Valid values are:

  • trueEnable debug mode.
  • falseDefault value, disable debug mode.
localeString

No

Used to set the internal display language for the SDK (such as error messages and prompts). Valid values are:

  • en_US: Default value. English
  • pt_BR: Portuguese (Brazil)
  • pt_PT: Portuguese
  • es_ES: Spanish
  • ko_KR: Korean
  • zh_CN: Simplified Chinese
  • zh_HK: Traditional Chinese
  • ms_MY: Malay
  • in_ID: Indonesian
  • th_TH: Thai
  • vi_VN: Vietnamese
  • tl_PH: Filipino
  • it_IT: Italian
  • de_DE: German
  • fr_FR: French
  • nl_NL: Dutch
  • ja_JP: Japanese
  • ro: Romanian
  • pl_PL: Polish
  • ar_SA: Arabic
  • tr_TR: Turkish
  • hi_IN: Hindi

Note: If the parameter is omitted or contains an unsupported value, the system will default to English.

Return values

This method returns a Promise object, which resolves to an antom instance that provides the following main methods:

Function

Description

antom.createElement()

Create Element instances, such as CVVElementVaultingElement, etc.

antom.confirmPayment()

Initiate payment confirmation for saved card scenarios.

antom.confirmCardSetup()

Confirm card information for card binding scenarios.

antom.updateConfig()

Update SDK configuration parameters.

antom.destroy()

Destroy the antom instance and free up all related resources.

Sample

CDN

copy
const antom = await window.loadAntom();

When introducing SDK through CDN, it is recommended to add CDN link of the latest antom sdk in the page. If the project is Typescript used, @ alipay/ams-checkout/antom can be added to compilerOptions.types in the tsconfig to get typescript input prompt when writing code. The following is a sample configuration:

copy
{
  "compilerOptions": {
    "types": ["@alipay/ams-checkout/antom"]
  }
}

npm

copy
import { loadAntom } from '@alipay/ams-checkout';
// Load the production environment SDK
const antom = await loadAntom();