setOption()

The setOption() method is used to set configuration options.

Method signature

copy
public AMSBaseConfiguration setOption(String key, Object value)

Parameters

Parameter

Type

Required

Description

key

String

Yes

The key of the configuration item. Refer to Available keys.

value

Object

Yes

The value of the configuration item, with the type varying depending on the key.

Available keys

Key

Type

Description

sandbox

Boolean

Whether to use the sandbox environment.

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

showLoading

Boolean

Whether to display a loading animation during the request process.

  • true: Default value. The default loading mode is used.
  • false: The default loading mode is not used. When set to false, it is recommended to customize your own loading event callbacks.

notRedirectAfterComplete

Boolean

Used to set 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 redirecting back to the merchant page upon payment or card binding success or failure, please 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:

  • theme: String type, theme color.
  • layout: String type, layout configuration.
  • variables: Object type, override underlying CSS custom properties using CSS design tokens (e.g., content-primary) to implement theme customization.

Return value

Returns the this() method to support chained invocation.

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. Please 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 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 based on the payment or card binding result event code returned by the onSubmitPayCallback() method in the corresponding scenario:

Notes: