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

copy
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 onResult for details.

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, new Locale("en", "US").  Valid values are:

  • en_US: Default values. English
  • pt_BR: Portuguese (Brazil)
  • pt_PT: Portuguese
  • es_ES: Spanish
  • ko_KR: Korean
  • zh_CN: Simplified Chinese
  • zh_HK: Traditional Chinese
  • ms_MY: Malaysian
  • 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.

sandbox

String

Whether to enable a sandbox environment.

  • true: Sandbox environment.
  • false: Default value. Production environment.

showLoading

String

Whether to display the loading animation during the request process.

  • true: Default value. Use the default loading mode.
  • false: The default load mode is not used. When set to false, it is recommended to customize with the loading event callback.

notRedirectAfterComplete

String

Sets whether to redirect back to your page after payment or card binding completion. Valid values are:

  • false: Default value. Redirects to your page after successful payment or card binding completion. Automatic redirection does not occur in cases of payment or card binding failure or other scenarios, and you need to handle those situations manually. The same applies if the value is empty.
  • true: No redirection after payment or card binding completion. You need to manually control the subsequent payment or card binding flow based on client-side event codes.

Notes:

  • For best practices on handling payment or card binding success or failure when redirecting back to the merchant page, refer to Redirect to the merchant page.
  • The payment or card binding result event codes returned on the client-side are for reference only in page navigation. Transaction status updates must be based on the results returned by the respective server-side API:
  • This parameter only takes effect for payment methods that complete payment or card binding within Payment Element or Vaulting Element.

appearance

String(JSON)

Used for custom appearance configuration. For more information, refer to Appearance customization. It contains the following parameters:

  • themeString type. Theme color.
  • layout: String type. Arrangement method.
  • variablesObject type. Override underlying CSS custom properties using CSS design tokens (e.g., content-primary) to implement theme customization.

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

AMSStatusResult

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

UI_STATE_ERROR

N/A

An error occurred. The transaction cannot be initiated.

Abnormal timing when creating SDK instances or createComponent().

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

true

Success/Failure

If you set notRedirectAfterComplete to true when creating the Payment Element or Vaulting Element instance and the payment method supports completing payments or card binding within the SDK, the payment or card binding result will be returned via the  onSubmitPayCallback() method. You need to handle the redirect logic yourself based on the payment or card binding result event code returned by the onSubmitPayCallback() method in the corresponding scenario:

false

Success

After payment or card binding is completed, the redirection happens based on the respective scenario:

false

Failure

The payment or card binding result will be returned via the onSubmitPayCallback() method. You need to handle the redirect logic yourself based on the payment or card binding result event code returned by the onSubmitPayCallback() method in the corresponding scenario:

Notes: