init()
init() method is called by the merchant application to initialize the AMSPaymentElement or AMSVaultElement instance and pass in SDK configuration parameters.
Note: This method must be called before
createComponent().
Method signature
Future<void> init(
Map<String, dynamic>? configurations,
void Function(AMSStatusResult) onResult,
)Parameters
Parameter | Data type | Is required? | Description |
configurations | Map<String, dynamic> | No | SDK configuration object, passed in as key-value. Refer to Supported configuration items for details. |
onResult | Function | Yes | Initialization result callback function. Used to return the result of successful or failed initialization. Refer to |
Supported configuration items
Parameter | Data type | Description |
locale | String | Formed by connecting a language code (ISO-639) and a country code (ISO-3166) with an underscore, for example,
|
sandbox | String | Whether to enable a sandbox environment.
|
showLoading | String | Whether to display the loading animation during the request process.
|
notRedirectAfterComplete | String | Sets whether to redirect back to your page after payment or card binding completion. Valid values are:
|
appearance | String(JSON) | Used for custom appearance configuration. For more information, refer to Appearance customization. It contains the following parameters:
|
onResult
The result callback from the init() method receives an AMSStatusResult object indicating whether the initialization was successful.
Parameter | Data type | Is required? | Description |
result | Yes | Status results containing initialization status and error details. |
Return value
This method returns no value, and the initialization result is returned asynchronously through the onResult callback.
Error codes
code | status | message | Description | Further action |
| N/A | An error occurred. The transaction cannot be initiated. | Abnormal timing when creating SDK instances or | Integration code exception. Troubleshoot yourself required. If the problem persists, contact Antom technical support. |
Best practices
Redirect to the merchant page
The following scenarios describe how redirecting to the merchant page and returning payment or card binding results are handled. Follow the guidelines below:
notRedirectAfterComplete | Payment or card binding result | Recommended action |
| Success/Failure | If you set notRedirectAfterComplete to |
| Success | After payment or card binding is completed, the redirection happens based on the respective scenario:
|
| Failure | The payment or card binding result will be returned via the |
Notes:
- If the payment or card binding requires redirecting to an external page (the payment method does not support payment within the SDK), the payment result will not be returned via
onSubmitPayCallback(). After completing the payment or card binding on the external page, the payment method will determine whether to automatically redirect back to the paymentRedirectUrl you provided in the createPaymentSession (One-time Payments) API or the redirectUrl result page you provided in the createVaultingSession API.- The payment or card binding results returned by the
onSubmitPayCallback()method are only for client-side page navigation and status display. For the final order status, obtain it through Step 4: Obtain the payment result or Step 4: Obtain the card binding result.