antom.destroy()
Use this method to destroy the antom instance (the SDK instance returned by loadAntom()) and releases all associated resources. After calling antom.destroy(), the SDK instance can no longer be used. Difference of this method from element.destroy() is as stated below:
antom.destroy(): Destroys the entire SDK instance and simultaneously destroys all Elements created through this instance.element.destroy(): Destroys only a single Element instance.
Notes:
- After the SDK instance is destroyed, methods such as
antom.createElement(),antom.confirmPayment()andantom.confirmCardSetup()can no longer be called.- In general, the SDK does not automatically destroy itself; you need to manually call
antom.destroy()to release resources.- Calling
antom.destroy()multiple times will not return an error, but subsequent calls will have no effect.
Method signature
When calling this method, please use the following standard method signature format.
JavaScript
TypeScript
copy
antom.destroy()Parameters
This method takes no input parameters.
Return values
This method does not return any value.
Usage scenarios
Note: The following are typical examples and not an exhaustive list. You can determine how to release the component based on your specific business needs.
Manual call
In the following cases, call this method to release SDK component resources:
- When the buyer leaves the checkout page or switches views: When the buyer leaves the current checkout page (for example, navigates to another page or closes the checkout modal), it is recommended to call
antom.destroyto to release the SDK instance and all Element resources created by it. - When switching to a payment method not provided by SDK: When the payment flow provided by the SDK is no longer needed and you need to switch to another payment solution, you should call
antom.destroyto release all associated resources.
Automatic release
In the following cases, the SDK automatically releases resources:
- Payment succeeds without redirection to a result page: When the payment is successful and the process is configured not to redirect to a separate result page, the SDK automatically reclaims part of the resources used for the payment.