Configuring the SDK

Each merchant has configuration specific to their account which is accessible from the /configuration API endpoint. This configuration is used by the SDK for rendering UI components with the correct branding and assets, T&Cs, web links, and currency formatting, and is applied globally using the Afterpay.setConfiguration method.

The following sample demonstrates how the SDK can be configured using the data supplied by the Afterpay API. It is up to you to decide how best to supply the locale.

Environment is required only for checkout V2; it’s recommended to use AfterpayEnvironment.PRODUCTION for release builds and AfterpayEnvironment.SANDBOX for all others.

val configuration = api.getConfiguration()

Afterpay.setConfiguration(
    minimumAmount = configuration.minimum?.amount,
    maximumAmount = configuration.maximum.amount,
    currency = configuration.maximum.currency,
    locale = Locale.US,
    environment = AfterpayEnvironment.SANDBOX
    consumerLocale = Locale.ENGLISH // optional. overrides the device language
)
  • The configuration must always be set when using the SDK, and before any included components are initialised.
  • The merchant account is subject to change and it is recommended to update this configuration once per day. The example project provides a reference demonstrating how this may be implemented.
  • Configuring the SDK with a UK locale will display Clearpay assets and branding, T&Cs, and currency formatting.