Configure Checkout Drop-in with unified settings for all payment methods, callbacks, and transaction data.
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.
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())Specifies which Unity environment to connect to:
environment = Environment.TEST // or Environment.LIVESupported environment values:
| Value | Description |
|---|---|
Environment.TEST | Sandbox environment. Use this for development, testing, and staging. |
Environment.LIVE | Live environment. Use this for production deployments. |
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 = sessionSessionConfig 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-nullcardsarray (it may be empty).cardSchemesalone doesn't enable the card UI. For Aeropay, mapallowedFundingTypes.payByBanks.aeropay(externalMerchantId,configurationId) intoSessionConfig. See Implementation and Aeropay.restrictions: Optional card and funding restrictions for the session.
For session creation details, see our implementation guide.
Identifies who owns this transaction:
ownerType = "MerchantGroup",
ownerId = "MERCHANT-1"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() }
)These properties define the transaction Drop-in submits:
| Property | Description |
|---|---|
amountDouble required | Transaction amount shown and submitted by the Drop-in. |
currencyString required | Currency code, for example "USD". Must be a valid ISO 4217 currency code. Aeropay requires currency = "USD". |
entryTypeEntryType? | Transaction entry type. Usually EntryType.Ecom for e-commerce transactions. Aeropay requires EntryType.Ecom. |
intentDropInTransactionIntentData 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. |
merchantString required | Merchant name or identifier used for the transaction. |
merchantTransactionIdString 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. |
shopperShopper? | Optional shopper data attached to the transaction. |
recurringRecurringData? | Optional recurring payment configuration for subscriptions. |
cardAcceptorNameString? | Optional card acceptor name shown on card statements. |
Your unique identifier for the transaction:
merchantTransactionId = UUID.randomUUID().toString()
// Or use your own format
merchantTransactionId = "order-${orderId}"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.
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.
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.
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,
)
)Shared Drop-in settings used across payment methods. Some properties apply only to specific methods (for example Google Pay issuer and funding filters):
| Property | Description |
|---|---|
acceptedCardNetworksList<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. |
allowedCardFundingSourceList<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. |
allowedIssuerCountryCodesList<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. |
transactionInfoTransactionInfo? | Payment display information such as country code, merchant display name, total label, total status, and line items. |
shippingOptionsList<ShippingOption>? | Shipping options displayed for supported wallet flows. |
couponInfoCouponInfo? | Optional coupon code and description. |
riskScreeningDataRiskScreeningData? | 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). |
Use DropInCardConfig to control which card sections appear in Drop-in:
| Property | Description |
|---|---|
showCOFBoolean? | 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. |
showNewCardBoolean? | 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-specific settings:
| Property | Description |
|---|---|
fundingSourcesList<PaypalFundingSources>? | Optional PayPal funding sources, such as PAYPAL or PAYLATER. |
shippingOptionString? | Optional selected shipping option value. |
enableOneClickPaymentBoolean? | Enables PayPal one-click payment behaviour when supported. |
localeString? | PayPal locale override. |
payeeEmailAddressString? | Payee email address for the PayPal transaction. |
paymentDescriptionString? | Description shown for the PayPal payment. |
useBuiltInChangePreferredPaymentMethodBoolean? | Uses the built-in preferred payment method change behaviour when supported. |
consentComponentBoolean? | Enables PayPal consent component behaviour when supported. |
shippingPreferenceShippingPreference? | Shipping handling for PayPal. Values are NO_SHIPPING, GET_FROM_FILE, and SET_PROVIDED_ADDRESS. |
buyerCountryString? | 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-specific settings:
| Property | Description |
|---|---|
collectCvcCollectCvcMode? | Controls CVC collection for Google Pay. Values are ALWAYS, NEVER, and DEFAULT. |
billingAddressRequiredBoolean? | Requests a billing address from Google Pay. |
billingAddressParametersBillingAddressParameters? | Billing address options. Currently supports phoneNumberRequired. |
shippingAddressRequiredBoolean? | Requests a full shipping address from Google Pay. |
shippingAddressParametersShippingAddressParameters? | Shipping address options, including allowedCountryCodes and phoneNumberRequired. |
blockedIssuerCountryCodesList<String>? | Blocks cards issued in the listed ISO country codes. Mutually exclusive with global.allowedIssuerCountryCodes. |
Configure Aeropay through methodConfig.aeropay (DropInAeropayConfig). All properties are optional:
| Property | Description |
|---|---|
userIdString? | Pre-configured Aeropay user ID. When set, consumer data collection and OTP are skipped. |
skipConsumerDataCollectionBoolean | When true with complete onGetShopper consumer fields and no editable fields, skip the consumer data screen and go to OTP. |
editableConsumerDataFieldsList<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. |
excludedBankAccountIdsList<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.
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.
When global or card config values are omitted, Drop-in uses these fallbacks:
| Config value | Fallback behaviour |
|---|---|
methodConfig.global.acceptedCardNetworks | Falls 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.countryCode | Falls back to siteConfig.merchantConfiguration.countryCode. |
methodConfig.global.transactionInfo.totalLabel | Falls back to "TOTAL". |
methodConfig.global.transactionInfo.totalStatus | Falls back to DropInTotalStatus.FINAL. |
methodConfig.global.transactionInfo.lineItems | Falls back to one generated subtotal display item using transactionData.amount. |
methodConfig.card | Falls back to both card-on-file and new card sections enabled when methodConfig or card is omitted. |
methodConfig.card.showCOF | Falls 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.showNewCard | Falls back to true. When both showCOF and showNewCard resolve to false, the Card payment method panel is hidden. |
When PayPal config values are omitted, Drop-in uses these fallbacks:
| Config value | Fallback behaviour |
|---|---|
methodConfig.paypal.fundingSources | Falls back to session.allowedFundingTypes.wallets.paypal.allowedFundingOptions. |
methodConfig.paypal.shippingPreference | Falls back to PayPal NoShipping. |
methodConfig.paypal.enableOneClickPayment | Falls back to true. |
methodConfig.paypal.locale | Falls back to "en-US". |
methodConfig.paypal.consentComponent | Falls back to true. |
methodConfig.paypal.useBuiltInChangePreferredPaymentMethod | The built-in change preferred payment method toggle is only created when this value is explicitly true. |
methodConfig.global.shippingOptions.amount | For PayPal shipping options, non-numeric amounts fall back to 0.0. |
When Google Pay config values are omitted, Drop-in uses these fallbacks:
| Config value | Fallback behaviour |
|---|---|
methodConfig.googlePay.collectCvc | Falls back to CollectCvcMode.DEFAULT. |
methodConfig.googlePay.billingAddressRequired | Falls back to false. |
methodConfig.googlePay.billingAddressParameters.phoneNumberRequired | Falls back to false. |
methodConfig.googlePay.shippingAddressRequired | Falls back to false. |
methodConfig.googlePay.shippingAddressParameters.phoneNumberRequired | Falls back to false. |
methodConfig.global.shippingOptions | If omitted, Google Pay sets shippingOptionRequired = false and doesn't pass shipping option parameters. |
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.
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())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())