Skip to content

Configuration

Configure Checkout Drop-in with unified settings for all payment methods, callbacks, and transaction data.

Overview

Checkout Drop-in uses a single, unified configuration at initialisation. Instead of configuring individual payment components, you configure Drop-in once and it automatically handles all payment methods.

Configuration structure

All configuration happens at initialisation via CheckoutDropIn.initialize():

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import com.pxp.checkout.checkoutdropin.CheckoutDropIn
import com.pxp.checkout.checkoutdropin.types.CheckoutDropInConfig
import com.pxp.checkout.checkoutdropin.types.PaymentMethod
import com.pxp.checkout.exceptions.BaseSdkException
import com.pxp.checkout.models.CardIntentType
import com.pxp.checkout.models.DropInTransactionData
import com.pxp.checkout.models.DropInTransactionIntentData
import com.pxp.checkout.models.Environment
import com.pxp.checkout.models.EntryType
import com.pxp.checkout.models.SessionConfig
import com.pxp.checkout.models.*
import com.pxp.checkout.checkoutdropin.types.*
import com.pxp.checkout.services.models.transaction.Shopper
import java.time.Instant
import java.util.UUID

val checkoutDropIn = remember {
    CheckoutDropIn.initialize(
        context = context,
        config = CheckoutDropInConfig(
            // REQUIRED
            environment = Environment.TEST,
            session = session,
            ownerType = "MerchantGroup",
            ownerId = "MERCHANT-1",
            transactionData = DropInTransactionData(
                amount = 99.99,
                currency = "USD",
                entryType = EntryType.Ecom,
                intent = DropInTransactionIntentData(
                    card = CardIntentType.Authorisation,
                    paypalDropInIntent = DropInPayPalIntentType.Purchase,
                    aeropayDropInIntent = DropInAeropayIntentType.Authorisation
                ),
                merchant = "MERCHANT-1",
                merchantTransactionId = UUID.randomUUID().toString(),
                merchantTransactionDate = { Instant.now().toString() }
            ),

            // OPTIONAL: Fraud detection
            kountDisabled = false, // Set to true to disable Kount fraud detection

            // RECOMMENDED: Callbacks (optional in the SDK; strongly recommended for production)
            onSuccess = { result -> /* ... */ },
            onError = { paymentMethod: PaymentMethod?, error: BaseSdkException -> /* ... */ },

            // OPTIONAL: Callbacks
            onGetShopper = { Shopper(id = "shopper-123") },
            onGetShippingAddress = { /* return ShippingAddress? */ null },
            onBeforeSubmit = { paymentMethod -> /* return true to proceed */ },
            onSubmit = { paymentMethod -> /* ... */ },
            analyticsEvent = { event -> /* ... */ }
        )
    )
}

LaunchedEffect(Unit) {
    checkoutDropIn.create()
}

checkoutDropIn.Content(modifier = Modifier.fillMaxWidth())

Required configuration

Environment

Specifies which Unity environment to connect to:

environment = Environment.TEST // or Environment.LIVE

Supported environment values:

ValueDescription
Environment.TESTSandbox environment. Use this for development, testing, and staging.
Environment.LIVELive environment. Use this for production deployments.

Session data

Session data is a SessionConfig value retrieved from your backend. Map the Sessions API response into this type before you pass it to Drop-in. Call fetchSessionFromBackend() from a coroutine (for example LaunchedEffect). See Quickstart.

import com.pxp.checkout.models.SessionConfig

val session: SessionConfig = fetchSessionFromBackend()

// Pass to Drop-in
session = session

SessionConfig required fields:

  • sessionId: Unique session identifier.
  • hmacKey: HMAC authentication key.
  • data: Session data payload from the Sessions API.
  • encryptionKey: Public encryption key.
  • locale: Locale for the session (e.g., "en-US").

Optional fields:

  • allowedFundingTypes: Which payment methods are enabled for the session. For the card panel, include a non-null cards array (it may be empty). cardSchemes alone doesn't enable the card UI. For Aeropay, map allowedFundingTypes.payByBanks.aeropay (externalMerchantId, configurationId) into SessionConfig. See Implementation and Aeropay.
  • restrictions: Optional card and funding restrictions for the session.

For session creation details, see our implementation guide.

Owner identification

Identifies who owns this transaction:

ownerType = "MerchantGroup",
ownerId = "MERCHANT-1"

Transaction data

Defines the payment amount, currency, and intent:

import com.pxp.checkout.models.CardIntentType

transactionData = DropInTransactionData(
    amount = 99.99,
    currency = "USD",
    entryType = EntryType.Ecom,
    intent = DropInTransactionIntentData(
        card = CardIntentType.Authorisation,
        paypalDropInIntent = DropInPayPalIntentType.Purchase,
        aeropayDropInIntent = DropInAeropayIntentType.Authorisation
    ),
    merchant = "MERCHANT-1",
    merchantTransactionId = UUID.randomUUID().toString(),
    merchantTransactionDate = { Instant.now().toString() }
)

Transaction data properties

These properties define the transaction Drop-in submits:

PropertyDescription
amount
Double
required
Transaction amount shown and submitted by the Drop-in.
currency
String
required
Currency code, for example "USD". Must be a valid ISO 4217 currency code. Aeropay requires currency = "USD".
entryType
EntryType?
Transaction entry type. Usually EntryType.Ecom for e-commerce transactions. Aeropay requires EntryType.Ecom.
intent
DropInTransactionIntentData
required
Card, PayPal, and Aeropay intent configuration. Set card with CardIntentType for card and card-on-file only (not Google Pay), paypalDropInIntent with DropInPayPalIntentType, and aeropayDropInIntent with DropInAeropayIntentType. Google Pay availability comes from session allowedFundingTypes.wallets.googlePay. See supported transaction intents.
merchant
String
required
Merchant name or identifier used for the transaction.
merchantTransactionId
String
required
Merchant-generated transaction ID. Use a UUID or order ID to ensure uniqueness.
merchantTransactionDate
() -> String
required
Function returning the transaction date and time string in ISO 8601 format.
shopper
Shopper?
Optional shopper data attached to the transaction.
recurring
RecurringData?
Optional recurring payment configuration for subscriptions.
cardAcceptorName
String?
Optional card acceptor name shown on card statements.

Merchant transaction ID

Your unique identifier for the transaction:

merchantTransactionId = UUID.randomUUID().toString()

// Or use your own format
merchantTransactionId = "order-${orderId}"

Optional configuration

Unified callbacks

Drop-in provides unified callbacks that work for all payment methods. onSuccess and onError are optional in the SDK constructor (they default to null), but are strongly recommended for production. If you omit onError, initialisation and payment failures are silently ignored.

import android.util.Log
import com.pxp.checkout.checkoutdropin.types.CheckoutDropInConfig
import com.pxp.checkout.services.models.transaction.Shopper

CheckoutDropInConfig(
    // OPTIONAL: Get shopper information
    onGetShopper = {
        Shopper(id = "shopper-123")
    },

    // RECOMMENDED: Called when payment succeeds
    onSuccess = { result ->
        Log.d("CheckoutDropIn", "Payment successful: ${result.systemTransactionId}")
        // CRITICAL: Always verify on backend before fulfilling the order
        verifyPaymentOnBackend(result)
    },

    // RECOMMENDED: Called when payment fails
    onError = { paymentMethod, error ->
        Log.e(
            "CheckoutDropIn",
            "Payment failed [${paymentMethod?.value}]: ${error.errorCode}: ${error.message}"
        )
    },

    // OPTIONAL: Called before payment submission (suspend; return false to cancel)
    onBeforeSubmit = { paymentMethod ->
        Log.d("CheckoutDropIn", "Payment method: $paymentMethod")
        // Suspend work such as validateOrder(...) is allowed here
        true
    },

    // OPTIONAL: Called when payment starts processing
    onSubmit = { paymentMethod ->
        Log.d("CheckoutDropIn", "Processing payment...")
    }
)

Card-on-file is created only when onGetShopper returns a Shopper with a non-empty id and the session allows cards. The saved-cards UI appears only when card tokens are returned. See Cards: card display properties.

For detailed callback documentation, see Events.

Shipping address callback

Use onGetShippingAddress to supply a shipping address for billing prefill and for PayPal when shippingPreference is SET_PROVIDED_ADDRESS. Card, Google Pay, and PayPal transaction builders can consume this callback.

import com.pxp.checkout.models.ShippingAddress

onGetShippingAddress = {
    ShippingAddress(
        // Populate from your checkout form or order record
        addressLine1 = "221B Baker Street",
        city = "London",
        postalCode = "NW1 6XE",
        countryCode = "GB"
    )
}

For PayPal shipping preference details, see Implementation and the PayPal configuration table below.

Analytics

Track payment flow events:

analyticsEvent = { event ->
    Log.d("Analytics", "Event: ${event.eventName}")
    // Send to your analytics platform
    sendToFirebaseAnalytics(event)
}

For detailed analytics documentation, see Analytics.

Payment method configuration

Configure payment-method-specific settings under methodConfig. The example below uses card, PayPal, Google Pay, and Aeropay:

methodConfig = DropInMethodConfig(
    global = DropInGlobalConfig(
        acceptedCardNetworks = listOf(
            CardNetworks.VISA,
            CardNetworks.MASTERCARD
        ),
        allowedIssuerCountryCodes = listOf("US", "GB")
    ),
    card = DropInCardConfig(
        showCOF = true,
        showNewCard = true
    ),
    paypal = DropInPaypalConfig(
        shippingPreference = ShippingPreference.GET_FROM_FILE
    ),
    googlePay = DropInGooglePayConfig(
        collectCvc = CollectCvcMode.DEFAULT,
        billingAddressRequired = true
    ),
    aeropay = DropInAeropayConfig(
        // userId = "existing-aeropay-user-id",
        // skipConsumerDataCollection = true,
    )
)

Global configuration

Shared Drop-in settings used across payment methods. Some properties apply only to specific methods (for example Google Pay issuer and funding filters):

PropertyDescription
acceptedCardNetworks
List<CardNetworks>?
Limits accepted card networks for card and wallet payments, including manual card brand selection. Supported values include VISA, MASTERCARD, AMERICAN_EXPRESS, UNION_PAY, DINERS, JCB, and DISCOVER.
allowedCardFundingSource
List<CardFundingSource>?
Google Pay only. Controls credit and prepaid card allowance in the Google Pay sheet (allowCreditCards and allowPrepaidCards). Supported values are CREDIT, DEBIT, and PREPAID. Does not filter manual new-card entry.
allowedIssuerCountryCodes
List<String>?
Google Pay only. ISO 3166-1 alpha-2 issuer country allow-list. Use googlePay.blockedIssuerCountryCodes for a block-list (mutually exclusive). Does not filter manual new-card entry.
transactionInfo
TransactionInfo?
Payment display information such as country code, merchant display name, total label, total status, and line items.
shippingOptions
List<ShippingOption>?
Shipping options displayed for supported wallet flows.
couponInfo
CouponInfo?
Optional coupon code and description.
riskScreeningData
RiskScreeningData?
Kount risk screening data for fraud checks.
onGetConsent
(PaymentMethod) -> Boolean
Returns whether the shopper has consented for that payment method when Drop-in has no visible consent component for it. For cards, used for new-card tokenisation when site storeCardConsent is Ask and the checkbox isn't shown. Not required for card storage when the site is ConsentAlreadyObtained. Applies to Card, PayPal, and Google Pay only. It doesn't apply to Aeropay (PaymentMethod.AEROPAY). See Cards — Store-card consent and Events — onGetConsent.
onCancel
(PaymentMethod, Any?) -> Unit
Called when the buyer cancels a supported payment flow, including closing the Aeropay popup (PaymentMethod.AEROPAY).

Card configuration

Use DropInCardConfig to control which card sections appear in Drop-in:

PropertyDescription
showCOF
Boolean?
Controls whether the card-on-file (saved cards) section and its submit button are created. Defaults to true when omitted. When true, card-on-file is created only if the session allows cards and onGetShopper returns a shopper with a non-empty id. The saved-cards UI appears only when cardTokens is non-empty.
showNewCard
Boolean?
Controls whether the new card form and related billing address, store-card consent checkbox (when the site asks for consent), and new-card submit button are created. Defaults to true when omitted. Store-card consent behaviour is driven by site storeCardConsent, not by an SDK property. See Cards — Store-card consent.

The Card payment method panel is visible when either resolved flag is true. When both are false, Drop-in omits the entire card panel.

card = DropInCardConfig(
    showCOF = true,
    showNewCard = true
)

For examples such as card-on-file only, new card only, or hiding the card panel, see Cards.

PayPal configuration

PayPal-specific settings:

PropertyDescription
fundingSources
List<PaypalFundingSources>?
Optional PayPal funding sources, such as PAYPAL or PAYLATER.
shippingOption
String?
Optional selected shipping option value.
enableOneClickPayment
Boolean?
Enables PayPal one-click payment behaviour when supported.
locale
String?
PayPal locale override.
payeeEmailAddress
String?
Payee email address for the PayPal transaction.
paymentDescription
String?
Description shown for the PayPal payment.
useBuiltInChangePreferredPaymentMethod
Boolean?
Uses the built-in preferred payment method change behaviour when supported.
consentComponent
Boolean?
Enables PayPal consent component behaviour when supported.
shippingPreference
ShippingPreference?
Shipping handling for PayPal. Values are NO_SHIPPING, GET_FROM_FILE, and SET_PROVIDED_ADDRESS.
buyerCountry
String?
Buyer country override.
onShippingAddressChange
(String) -> String?
Called when the PayPal shipping address changes. Return an updated order patch JSON string to apply the change, or null to reject it.
onShippingOptionsChange
(String) -> String?
Called when the PayPal shipping option changes. Return an updated order patch JSON string to apply the change, or null to reject it.

Google Pay configuration

Google Pay-specific settings:

PropertyDescription
collectCvc
CollectCvcMode?
Controls CVC collection for Google Pay. Values are ALWAYS, NEVER, and DEFAULT.
billingAddressRequired
Boolean?
Requests a billing address from Google Pay.
billingAddressParameters
BillingAddressParameters?
Billing address options. Currently supports phoneNumberRequired.
shippingAddressRequired
Boolean?
Requests a full shipping address from Google Pay.
shippingAddressParameters
ShippingAddressParameters?
Shipping address options, including allowedCountryCodes and phoneNumberRequired.
blockedIssuerCountryCodes
List<String>?
Blocks cards issued in the listed ISO country codes. Mutually exclusive with global.allowedIssuerCountryCodes.

Aeropay configuration

Configure Aeropay through methodConfig.aeropay (DropInAeropayConfig). All properties are optional:

PropertyDescription
userId
String?
Pre-configured Aeropay user ID. When set, consumer data collection and OTP are skipped.
skipConsumerDataCollection
Boolean
When true with complete onGetShopper consumer fields and no editable fields, skip the consumer data screen and go to OTP.
editableConsumerDataFields
List<ConsumerDataField>?
Prefill fields that remain editable on the consumer data screen. Values are ConsumerDataField.FIRST_NAME, ConsumerDataField.LAST_NAME, ConsumerDataField.EMAIL, and ConsumerDataField.PHONE_NUMBER.
excludedBankAccountIds
List<Number>?
Bank account IDs to hide from bank selection.

onGetConsent doesn't apply to Aeropay. Handle Aeropay popup close with methodConfig.global.onCancel and PaymentMethod.AEROPAY.

For full Aeropay configuration, eligibility, and callback behaviour, see Aeropay.

Fallback behaviour

Drop-in method configuration values are optional overrides. When you omit an optional value, the SDK derives the effective component configuration from the checkout session, Unity site configuration, or SDK defaults.

Global and card fallbacks

When global or card config values are omitted, Drop-in uses these fallbacks:

Config valueFallback behaviour
methodConfig.global.acceptedCardNetworksFalls back to session.allowedFundingTypes.cardSchemes from the Sessions API response (typically populated from Unity Portal card configuration). If neither methodConfig.global.acceptedCardNetworks nor cardSchemes is present, defaults to an empty list.
methodConfig.global.transactionInfo.countryCodeFalls back to siteConfig.merchantConfiguration.countryCode.
methodConfig.global.transactionInfo.totalLabelFalls back to "TOTAL".
methodConfig.global.transactionInfo.totalStatusFalls back to DropInTotalStatus.FINAL.
methodConfig.global.transactionInfo.lineItemsFalls back to one generated subtotal display item using transactionData.amount.
methodConfig.cardFalls back to both card-on-file and new card sections enabled when methodConfig or card is omitted.
methodConfig.card.showCOFFalls back to true. Card-on-file is created only when the session allows cards and onGetShopper returns a non-empty shopper id. The saved-cards UI appears only when tokens are available.
methodConfig.card.showNewCardFalls back to true. When both showCOF and showNewCard resolve to false, the Card payment method panel is hidden.

PayPal fallbacks

When PayPal config values are omitted, Drop-in uses these fallbacks:

Config valueFallback behaviour
methodConfig.paypal.fundingSourcesFalls back to session.allowedFundingTypes.wallets.paypal.allowedFundingOptions.
methodConfig.paypal.shippingPreferenceFalls back to PayPal NoShipping.
methodConfig.paypal.enableOneClickPaymentFalls back to true.
methodConfig.paypal.localeFalls back to "en-US".
methodConfig.paypal.consentComponentFalls back to true.
methodConfig.paypal.useBuiltInChangePreferredPaymentMethodThe built-in change preferred payment method toggle is only created when this value is explicitly true.
methodConfig.global.shippingOptions.amountFor PayPal shipping options, non-numeric amounts fall back to 0.0.

Google Pay fallbacks

When Google Pay config values are omitted, Drop-in uses these fallbacks:

Config valueFallback behaviour
methodConfig.googlePay.collectCvcFalls back to CollectCvcMode.DEFAULT.
methodConfig.googlePay.billingAddressRequiredFalls back to false.
methodConfig.googlePay.billingAddressParameters.phoneNumberRequiredFalls back to false.
methodConfig.googlePay.shippingAddressRequiredFalls back to false.
methodConfig.googlePay.shippingAddressParameters.phoneNumberRequiredFalls back to false.
methodConfig.global.shippingOptionsIf omitted, Google Pay sets shippingOptionRequired = false and doesn't pass shipping option parameters.

Scale best practice

On Android, Checkout Drop-in always renders at 100%. Use standard Android layout, system font scaling, and device testing to fit the checkout, not Unity Portal scale controls.

If you need layout adjustments on Android, size the host activity/Compose container and surrounding merchant UI.

Complete configuration examples

Minimal configuration (most common)

Fetch a session from your backend, then initialise Drop-in with required fields and core callbacks:

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import com.pxp.checkout.checkoutdropin.CheckoutDropIn
import com.pxp.checkout.checkoutdropin.types.CheckoutDropInConfig
import com.pxp.checkout.checkoutdropin.types.PaymentMethod
import com.pxp.checkout.exceptions.BaseSdkException
import com.pxp.checkout.models.CardIntentType
import com.pxp.checkout.models.DropInTransactionData
import com.pxp.checkout.models.DropInTransactionIntentData
import com.pxp.checkout.models.Environment
import com.pxp.checkout.models.EntryType
import com.pxp.checkout.models.SessionConfig
import com.pxp.checkout.models.*
import com.pxp.checkout.checkoutdropin.types.*
import com.pxp.checkout.services.models.transaction.Shopper
import java.time.Instant
import java.util.UUID

var sessionConfig by remember { mutableStateOf<SessionConfig?>(null) }

LaunchedEffect(Unit) {
    sessionConfig = fetchSessionFromBackend()
}

val checkoutDropIn = remember(sessionConfig) {
    sessionConfig?.let { session ->
        CheckoutDropIn.initialize(
            context = context,
            config = CheckoutDropInConfig(
            environment = Environment.TEST,
            session = session,
            ownerType = "MerchantGroup",
            ownerId = "MERCHANT-1",
            transactionData = DropInTransactionData(
                amount = 99.99,
                currency = "USD",
                entryType = EntryType.Ecom,
                intent = DropInTransactionIntentData(
                    card = CardIntentType.Authorisation,
                    paypalDropInIntent = DropInPayPalIntentType.Purchase,
                    aeropayDropInIntent = DropInAeropayIntentType.Authorisation
                ),
                merchant = "MERCHANT-1",
                merchantTransactionId = UUID.randomUUID().toString(),
                merchantTransactionDate = { Instant.now().toString() }
            ),
            kountDisabled = false, // OPTIONAL: Set to true to disable Kount fraud detection
            onGetShopper = {
                Shopper(id = "shopper-123")
            },
            onSuccess = { result ->
                verifyPaymentOnBackend(result)
            },
            onError = { paymentMethod: PaymentMethod?, error: BaseSdkException ->
                showError(error.message ?: "Payment failed")
            }
        )
        )
    }
}

LaunchedEffect(checkoutDropIn) {
    checkoutDropIn?.create()
}

checkoutDropIn?.Content(modifier = Modifier.fillMaxWidth())

Full configuration (with all callbacks)

This example shows Drop-in with the main optional callbacks and method configuration:

import android.util.Log
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.*
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import com.pxp.checkout.checkoutdropin.CheckoutDropIn
import com.pxp.checkout.checkoutdropin.types.*
import com.pxp.checkout.checkoutdropin.types.methodconfigs.*
import com.pxp.checkout.components.aeropaybutton.types.ConsumerDataField
import com.pxp.checkout.exceptions.BaseSdkException
import com.pxp.checkout.models.CardIntentType
import com.pxp.checkout.models.ShippingAddress
import com.pxp.checkout.models.*
import com.pxp.checkout.services.models.transaction.Shopper
import java.time.Instant
import java.util.UUID
import kotlinx.coroutines.launch

val scope = rememberCoroutineScope()
var sessionConfig by remember { mutableStateOf<SessionConfig?>(null) }

LaunchedEffect(Unit) {
    sessionConfig = fetchSessionFromBackend()
}

val checkoutDropIn = remember(sessionConfig) {
    sessionConfig?.let { session ->
        CheckoutDropIn.initialize(
            context = context,
            config = CheckoutDropInConfig(
            // REQUIRED
            environment = Environment.LIVE,
            session = session,
            ownerType = "MerchantGroup",
            ownerId = "MERCHANT-1",
            transactionData = DropInTransactionData(
                amount = 149.99,
                currency = "USD",
                entryType = EntryType.Ecom,
                intent = DropInTransactionIntentData(
                    card = CardIntentType.Authorisation,
                    paypalDropInIntent = DropInPayPalIntentType.Purchase,
                    aeropayDropInIntent = DropInAeropayIntentType.Authorisation
                ),
                merchant = "MERCHANT-1",
                merchantTransactionId = "order-${orderId}",
                merchantTransactionDate = { Instant.now().toString() }
            ),

            // OPTIONAL: Fraud detection
            kountDisabled = false, // Set to true to disable Kount fraud detection

            // OPTIONAL: Shipping address for billing prefill or PayPal SET_PROVIDED_ADDRESS
            onGetShippingAddress = {
                ShippingAddress(
                    addressLine1 = shippingLine1,
                    city = shippingCity,
                    postalCode = shippingPostalCode,
                    countryCode = shippingCountryCode
                )
            },

            // CALLBACKS
            onGetShopper = {
                Shopper(id = "shopper-123")
            },

            // Suspend callback: async validation is allowed
            onBeforeSubmit = { paymentMethod ->
                Log.d("CheckoutDropIn", "Payment method selected: $paymentMethod")

                // Custom validation (suspend OK)
                val isValid = validateOrder(orderId)
                if (!isValid) {
                    showToast("Order validation failed")
                    return@onBeforeSubmit false
                }

                // Check inventory (suspend OK)
                val inStock = checkInventory(orderId)
                if (!inStock) {
                    showToast("Item is out of stock")
                    return@onBeforeSubmit false
                }

                true // Proceed with payment
            },

            onSubmit = { paymentMethod ->
                Log.d("CheckoutDropIn", "Payment processing started for: $paymentMethod")
                // Show loading spinner
                showLoadingSpinner(true)
            },

            onSuccess = { result ->
                Log.d("CheckoutDropIn", "Payment successful: ${result.systemTransactionId}")

                showLoadingSpinner(false)

                // CRITICAL: Verify on backend before fulfilling
                scope.launch {
                    try {
                        val verified = verifyPaymentOnBackend(
                            systemTransactionId = result.systemTransactionId,
                            merchantTransactionId = result.merchantTransactionId,
                            orderId = orderId
                        )

                        if (verified.success) {
                            navigateToOrderConfirmation(verified.orderId)
                        } else {
                            showToast("Payment verification failed. Please contact support.")
                        }
                    } catch (e: Exception) {
                        Log.e("CheckoutDropIn", "Verification failed", e)
                        showToast("Unable to verify payment. Please contact support.")
                    }
                }
            },

            onError = { paymentMethod: PaymentMethod?, error: BaseSdkException ->
                Log.e(
                    "CheckoutDropIn",
                    "Payment error [${paymentMethod?.value}]: ${error.errorCode}"
                )
                showLoadingSpinner(false)

                // Show user-friendly error message
                val userMessage = when {
                    error.errorCode == "SDK1114" -> "Authorisation failed"
                    error.errorCode == "SDK1115" -> "Card payment failed"
                    error.errorCode == "SDK1116" -> "PayPal payment failed"
                    error.message?.contains("declined", ignoreCase = true) == true ->
                        "Card declined. Please try a different card."
                    error.message?.contains("insufficient funds", ignoreCase = true) == true ->
                        "Insufficient funds."
                    error.message?.contains("expired", ignoreCase = true) == true ->
                        "This card has expired."
                    error.message?.contains("cvv", ignoreCase = true) == true ->
                        "Invalid security code."
                    else -> error.message ?: "Payment failed. Please try again."
                }

                showError(userMessage)
            },

            analyticsEvent = { event ->
                // Send to Firebase Analytics
                firebaseAnalytics.logEvent(event.eventName, bundleOf(
                    "event_category" to "checkout",
                    "event_label" to event.toString()
                ))

                // Send to backend
                sendAnalyticsToBackend(event)
            },

            // Method-specific configuration
            methodConfig = DropInMethodConfig(
                global = DropInGlobalConfig(
                    acceptedCardNetworks = listOf(
                        CardNetworks.VISA,
                        CardNetworks.MASTERCARD,
                        CardNetworks.AMERICAN_EXPRESS
                    ),
                    allowedCardFundingSource = listOf(
                        CardFundingSource.CREDIT,
                        CardFundingSource.DEBIT
                    ),
                    allowedIssuerCountryCodes = listOf("US", "GB", "CA"),
                    transactionInfo = TransactionInfo(
                        countryCode = "US",
                        merchantDisplayName = "Demo Store",
                        totalLabel = "Total Amount",
                        totalStatus = DropInTotalStatus.FINAL,
                        lineItems = listOf(
                            TransactionLineItem(label = "Products", amount = "5.00"),
                            TransactionLineItem(label = "Shipping", amount = "2.00")
                        )
                    ),
                    onGetConsent = { paymentMethod ->
                        // Grant consent for cards and PayPal when no consent UI is shown
                        paymentMethod == PaymentMethod.CARD ||
                        paymentMethod == PaymentMethod.PAYPAL
                    },
                    onCancel = { paymentMethod, data ->
                        Log.d("CheckoutDropIn", "Payment cancelled: $paymentMethod")
                        showLoadingSpinner(false)
                        // Track cancellation
                        trackEvent("payment_cancelled", mapOf(
                            "payment_method" to paymentMethod.toString()
                        ))
                    }
                ),
                card = DropInCardConfig(
                    showCOF = true,
                    showNewCard = true
                ),
                paypal = DropInPaypalConfig(
                    shippingPreference = ShippingPreference.GET_FROM_FILE
                ),
                googlePay = DropInGooglePayConfig(
                    collectCvc = CollectCvcMode.DEFAULT,
                    shippingAddressRequired = true,
                    shippingAddressParameters = ShippingAddressParameters(
                        allowedCountryCodes = listOf("US", "GB"),
                        phoneNumberRequired = true
                    ),
                    billingAddressRequired = true,
                    billingAddressParameters = BillingAddressParameters(
                        phoneNumberRequired = true
                    )
                ),
                aeropay = DropInAeropayConfig(
                    // userId = "existing-aeropay-user-id",
                    // skipConsumerDataCollection = true,
                    // editableConsumerDataFields = listOf(ConsumerDataField.EMAIL),
                )
            )
        )
        )
    }
}

LaunchedEffect(checkoutDropIn) {
    checkoutDropIn?.create()
}

checkoutDropIn?.Content(modifier = Modifier.fillMaxWidth())