> ## Documentation Index
> Fetch the complete documentation index at: https://primer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# configure

Configure Universal Checkout using this method.
Based on the use case, set different settings that can be passed to Universal Checkout.
Set the Primer Checkout listener in order to receive different events from the SDK.
Please refer to the section below for more information.

```kotlin KOTLIN theme={"dark"}
fun configure(
    settings: PrimerSettings? = null,
    listener: PrimerCheckoutListener? = null,
)
```

## Parameters

<Expandable defaultOpen title="Properties">
  <ResponseField name="settings" type="PrimerSettings">
    ⚠️ If no settings are provided, the SDK will initialize with its default settings. <br />
    Use `PrimerSettings` to provide different options based on your use case.

    <Expandable defaultOpen>
      <ResponseField name="paymentHandling" type="PrimerPaymentHandling" post={["Default: PrimerPaymentHandling.AUTO"]}>
        Force the payment handling in the SDK.

        <Expandable>
          <ResponseField name="AUTO">
            By default, the SDK operates in `PrimerPaymentHandling.AUTO`
            mode. In this case the SDK is responsible for creating the payment.
          </ResponseField>

          <ResponseField name="MANUAL">
            You can use the `PrimerPaymentHandling.MANUAL` option
            in order to [handle the payment creation](/checkout/advanced/manual-payment-creation)
            by yourself.
          </ResponseField>
        </Expandable>
      </ResponseField>

      <ResponseField name="locale" type="Locale">
        Force the SDK locale. By default, the locale will be set to the device's
        locale.
      </ResponseField>

      <ResponseField name="paymentMethodOptions" type="PrimerPaymentMethodOptions">
        <Expandable>
          <ResponseField name="redirectScheme" type="String?">
            Sets the deeplink schema used when redirecting back from 3rd party
            applications to your application.
          </ResponseField>

          <ResponseField name="threeDsOptions" type="PrimerThreeDsOptions">
            Sets the 3DS options in the SDK.

            <Expandable defaultOpen title="Properties">
              <ResponseField name="threeDsAppRequestorUrl" type="String?">
                Set the [App link](https://developer.android.com/training/app-links) that's used to call your app after an **out-of-band (OOB)** authentication.
                Supported in 3D Secure protocol versions 2.2.0 and after.
              </ResponseField>
            </Expandable>
          </ResponseField>

          <ResponseField name="googlePayOptions" type="PrimerGooglePayOptions">
            ⚠️ Required when using Google Pay in your integration.

            <Expandable defaultOpen title="Properties">
              <ResponseField name="merchantName" type="String?">
                Set it the merchant name that you want to be shown on the Google Pay screen.
              </ResponseField>

              <ResponseField name="allowedCardNetworks" type="List<String>" post={["Default: listOf('AMEX', 'DISCOVER', 'JCB', 'MASTERCARD', 'VISA')"]}>
                Sets
                the [card networks](https://developers.google.com/pay/api-reference/android/guides/tutorial#supported-card-networks)
                that your application accepts.
              </ResponseField>

              <ResponseField name="buttonStyle" type="GooglePayButtonStyle" post={["Default: GooglePayButtonStyle.BLACK"]}>
                Sets the style of the Google Pay button.

                <Expandable defaultOpen title="GooglePayButtonStyle">
                  <ResponseField name="BLACK">
                    Style of button to be used on light theme.
                  </ResponseField>

                  <ResponseField name="WHITE">
                    Style of button to be used on dark theme.
                  </ResponseField>
                </Expandable>
              </ResponseField>

              <ResponseField name="captureBillingAddress" type="Boolean" post={["Default: false"]}>
                Sets whether user's billing address should be captured from Google Pay.
              </ResponseField>

              <ResponseField name="existingPaymentMethodRequired" type="Boolean" post={["Default: false"]}>
                If set to `true`, this specifies that Google Pay can only be used for payments if the user's Google
                Pay wallet already contains allowed payment methods.
              </ResponseField>

              <ResponseField name="shippingAddressParameters" type="PrimerGoogleShippingAddressParameters" post={["Default: null"]}>
                Indicates whether the shipping address should be collected during the checkout
                process. Note that setting at least one shipping method in Checkout. Shipping
                module is necessary

                <Expandable defaultOpen title="PrimerGoogleShippingAddressParameters">
                  <ResponseField name="phoneNumberRequired" type="Boolean" post={["Default: false"]}>
                    Sets whether the phone number should also be collected.
                  </ResponseField>
                </Expandable>
              </ResponseField>

              <ResponseField
                name="requireShippingMethod"
                type="Boolean"
                post={[
"Default: false"
]}
              >
                Indicates whether selecting a shipping method is required during the checkout process.
                At least one shipping option should be configured in order to use this option.

                This should be set to `true` if the `shippingAddressParameters` are also used.
              </ResponseField>

              <ResponseField name="emailAddressRequired" type="Boolean" post={["Default: false"]}>
                Indicates whether the email address should be collected during the checkout
                process.
              </ResponseField>

              <ResponseField name="buttonOptions" type="GooglePayButtonOptions">
                A configuration class for customizing the appearance of the Google Pay button.

                <Expandable defaultOpen title="Properties">
                  <ResponseField name="buttonType" type="Int">
                    Google Pay Button type as described in the official [documentation](https://developers.google.com/pay/api-reference/android/guides/brand-guidelines).
                  </ResponseField>

                  <ResponseField name="buttonTheme" type="Int">
                    Google Pay button style as described in the official [documentation](https://developers.google.com/pay/api-reference/android/guides/brand-guidelines#personalization)
                  </ResponseField>
                </Expandable>
              </ResponseField>
            </Expandable>
          </ResponseField>

          <ResponseField name="klarnaOptions" type="PrimerKlarnaOptions">
            ⚠️ Required when using Klarna in your integration.

            <Expandable defaultOpen title="Properties">
              <ResponseField name="recurringPaymentDescription" type="String?">
                Set the payment description that will be shown on the Klarna screen.
              </ResponseField>

              <ResponseField name="webViewTitle" type="String?" post={["Default: Klarna"]}>
                ⚠️ This option is `Deprecated`.
                Sets the toolbar title of the Activity displaying Klarna views.
              </ResponseField>
            </Expandable>
          </ResponseField>

          <ResponseField name="stripeOptions" type="PrimerStripeOptions">
            ⚠️ Required when using Stripe ACH in your integration.

            <Expandable defaultOpen title="Properties">
              <ResponseField name="publishableKey" type="String?">
                Set the [Stripe publishable key](https://docs.stripe.com/keys#obtain-api-keys).
              </ResponseField>

              <ResponseField name="mandateData" type="MandateData?">
                Data used for mandate in Drop-in

                <Expandable>
                  <ResponseField name="TemplateMandateData">
                    Data for the mandate allowing you to specify the name of the merchant that
                    would be used in a predefined mandate template.

                    <Expandable defaultOpen title="Properties">
                      <ResponseField name="merchantName" type="String">
                        The name of the merchant.
                      </ResponseField>
                    </Expandable>
                  </ResponseField>

                  <ResponseField name="FullMandateData">
                    Data for the mandate allowing you to specify the string resource pointing
                    to the full mandate.

                    <Expandable defaultOpen title="Properties">
                      <ResponseField name="value" type="@StringRes Int">
                        The string resource pointing to the full mandate.
                      </ResponseField>
                    </Expandable>
                  </ResponseField>

                  <ResponseField name="FullMandateStringData">
                    Data for the mandate allowing you to specify the full mandate as a string.

                    <Expandable defaultOpen title="Properties">
                      <ResponseField name="value" type="String">
                        The full mandate.
                      </ResponseField>
                    </Expandable>
                  </ResponseField>
                </Expandable>
              </ResponseField>
            </Expandable>
          </ResponseField>
        </Expandable>
      </ResponseField>

      <ResponseField name="uiOptions" type="PrimerUIOptions">
        Sets the different UI options in the SDK.

        <Expandable defaultOpen title="Properties">
          <ResponseField name="isInitScreenEnabled" type="Boolean" post={["Default: true"]}>
            Set to `false` to hide the loading screen before the Universal Checkout or the Vault Manager.
          </ResponseField>

          <ResponseField name="isSuccessScreenEnabled" type="Boolean" post={['Default: true']}>
            Set to `false` to hide the screen after a successful payment, or tokenization on the vault flow.
          </ResponseField>

          <ResponseField name="isErrorScreenEnabled" type="Boolean" post={["Default: true"]}>
            Set to `false` to hide the error screen when an error occurs.
          </ResponseField>

          <ResponseField name="dismissalMechanism" type="DismissalMechanism" post={["Default: GESTURES"]}>
            Set the mechanism for dismissing Universal Checkout. Options are:

            * `GESTURES`: The dialog can be dismissed by tapping outside or by swiping down.
            * `CLOSE_BUTTON`: A close button is provided, allowing users to dismiss the dialog manually.
          </ResponseField>

          <ResponseField name="theme" type="PrimerTheme">
            Set a custom theme for Primer SDK.
          </ResponseField>

          <ResponseField name="cardFormUIOptions" type="PrimerCardFormUIOptions?">
            Configure the card form UI options.

            <Expandable title="Properties" defaultOpen>
              <ResponseField name="payButtonAddNewCard" type="Boolean">
                When set to true, the Drop-In's card form pay button will show "Add new card"; otherwise
                it will show "Pay \$x.xx".
              </ResponseField>
            </Expandable>
          </ResponseField>
        </Expandable>
      </ResponseField>

      <ResponseField name="debugOptions" type="PrimerDebugOptions">
        Sets the different debug options in the SDK.

        <Expandable defaultOpen title="Properties">
          <ResponseField name="is3DSSanityCheckEnabled" type="Boolean" post={["Default: false"]}>
            Sets whether the security warnings returned when performing 3DS are ignored.
          </ResponseField>
        </Expandable>
      </ResponseField>

      <ResponseField name="clientSessionCachingEnabled" type="Boolean" post={["Default: false"]}>
        <Warning>
          Before enabling the flag to true it's recommended to reach out to Primer
          support for additional verification since there are edge cases where it's not
          advised.
        </Warning>

        Indicates whether client session caching is enabled.

        When set to `true`, responses from the server will be cached on the client side, allowing for faster subsequent
        access to the same data within the cache duration. When set to `false`, every request to the server will be
        processed without utilizing any client-side cache, ensuring that the client always receives the most up-to-date data.
      </ResponseField>

      <ResponseField name="apiVersion" type="PrimerApiVersion" post={["Default: PrimerApiVersion.V2_4"]}>
        Indicates the API version to use when interacting with the Primer backend. Options are:

        * `PrimerApiVersion.V2_4` - will use ApiVersion 2.4
        * `PrimerApiVersion.LATEST` - will use the latest available ApiVersion version

        Note that this is optional, if a value is not supplied, ApiVersion `V2.4` will be used by default.
      </ResponseField>
    </Expandable>
  </ResponseField>

  <ResponseField name="listener" type="PrimerCheckoutListener">
    Set Primer SDK's [Checkout Listener](/sdk/android/v2.x.x/primer/listeners/PrimerCheckoutListener) and implement the required methods.
  </ResponseField>
</Expandable>

## Example

```kotlin KOTLIN theme={"dark"}
val listener = object : PrimerCheckoutListener {
  override fun onCheckoutCompleted(checkoutData: PrimerCheckoutData) {

  }
}

val settings = PrimerSettings(
  paymentHandling = PrimerPaymentHandling.AUTO,
  paymentMethodOptions = PrimerPaymentMethodOptions(
    redirectScheme = "deeplink_scheme",
    klarnaOptions = PrimerKlarnaOptions("RECURRING_PAYMENT_DESCRIPTION"),
    googlePayOptions = PrimerGooglePayOptions(captureBillingAddress = true),
  ),
  uiOptions = PrimerUIOptions(
    isInitScreenEnabled = true,
    isSuccessScreenEnabled = true,
    isErrorScreenEnabled = true,
  ),
  cardFormUIOptions = PrimerCardFormUIOptions(
    payButtonAddNewCard = true,
  ),
  debugOptions = PrimerDebugOptions(is3DSSanityCheckEnabled = false),
  threeDsOptions = PrimerThreeDsOptions("APP_LINK")
)

Primer.instance.configure(settings, listener)
```
