AMSPaymentElement.Builder

AMSPaymentElement.Builder is a constructor class used to progressively configure and ultimately create AMSPaymentElement instances. After passing the necessary parameters through its constructor, the build() method must be called on the main thread to complete the instance construction.

Constructor

copy
new AMSPaymentElement.Builder(Activity activity, AMSBaseConfiguration configuration)

Parameters

When creating an AMSPaymentElement.Builder instance, you need to pass in the following parameters:

Parameter

Data type

Required

Description

activity

Activity

Yes

The current Activity context.

configuration

AMSBaseConfiguration

Yes

An instance of the AMSBaseConfiguration class, used to provide the configuration required for SDK initialization.

Return value

Returns an AMSPaymentElement.Builder instance, which is used to continue configuring and constructing the AMSPaymentElement object.

build()

After completing the Builder initialization, call the build() method to construct the AMSPaymentElement instance.

Method signature

copy
public AMSPaymentElement build()

Parameters

This method takes no parameters.

Return value

Returns the constructed AMSPaymentElement instance. This instance contains the following methods:

Note: If configuration is null, then null is returned. If not called on the main thread, RuntimeException will be thrown.

Method nameDescription
preload()

Used to preload WebApp page and KYC page resources.

createComponent()

Used to create and display the payment component UI. This method is mutually exclusive with the confirmPayment() method.

confirmPayment()

Used to submit and confirm saved card payment for the current component instance. This method is mutually exclusive with the createComponent() method.

reset()

Used to reset the payment process and clear the current state.

onDestroy()

Used to destroy the instance and release all associated resources.

Error codes

code

status

Suggested prompt for buyers (message)

Description

Recommended action

UI_STATE_ERROR

FAIL

Request exception, transaction cannot be initiated.

The API was called at an invalid time or in an invalid state.

Check your integration code. If the issue persists, contact Antom Technical Support.

Sample

copy
AMSBaseConfiguration configuration = new AMSBaseConfiguration();
configuration.setLocale(new Locale("en", "US"));
configuration.setOption("sandbox", true);

AMSPaymentElement paymentElement = new AMSPaymentElement.Builder(activity, configuration).build();