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
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 |
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
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, thennullis returned. If not called on the main thread, RuntimeException will be thrown.
| Method name | Description |
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() | Used to submit and confirm saved card payment for the current component instance. This method is mutually exclusive with the |
reset() | Used to reset the payment process and clear the current state. |
Used to destroy the instance and release all associated resources. |
Error codes
code | status | Suggested prompt for buyers (message) | Description | Recommended action |
|
| 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
AMSBaseConfiguration configuration = new AMSBaseConfiguration();
configuration.setLocale(new Locale("en", "US"));
configuration.setOption("sandbox", true);
AMSPaymentElement paymentElement = new AMSPaymentElement.Builder(activity, configuration).build();