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 useawaitor.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:
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 |
| config | Object | No | SDK configuration object, which is used to set the environment, language, and debugging mode. |
config
| Parameter | Type | Required | Description |
| env | String | No | Environment configuration options. Valid values are:
|
| environment | String | No | The alias for env. If both are set, the value of env takes precedence. Valid values are:
|
| debug | Boolean | No | Used to enable debug mode. Enabling it will output detailed logs, making it easier for developers to troubleshoot issues. Valid values are:
|
| locale | String | No | Used to set the internal display language for the SDK (such as error messages and prompts). Valid values are:
|
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 CVVElement, VaultingElement, 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. |
Destroy the |
Sample
CDN
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:
{
"compilerOptions": {
"types": ["@alipay/ams-checkout/antom"]
}
}npm
import { loadAntom } from '@alipay/ams-checkout';
// Load the production environment SDK
const antom = await loadAntom();