Skip to content

Implementation

Complete guide to integrating Checkout Drop-in into your Android application.

Overview

Checkout Drop-in provides a complete, pre-built payment interface that automatically handles multiple payment methods. It follows a simple three-step lifecycle:

  1. Initialise: Configure Drop-in with your session and transaction data.
  2. Create: Generate the composable component from a coroutine.
  3. Handle callbacks: Respond to payment success, errors, and other events.

Drop-in automatically detects available payment methods, renders the UI, and handles all payment flows.

Backend verification is mandatory. Always verify payments on your backend before fulfilling orders. Frontend callbacks can be manipulated by malicious users.

Before you start

Make sure you've activated the Checkout Drop-in service in the Unity Portal.

Step 1: Add the SDK dependency

To get started, add the latest version of the Android SDK to your project using Maven Central.

In your app-level build.gradle file, add the dependency:

dependencies {
    implementation("io.pxp:android-components-sdk:{versionNumber}")
}

Step 2: Get your API credentials

In order to initialise Checkout Drop-in, you'll need to send authenticated requests to the PXP API.

To get your credentials:

  1. In the Unity Portal, go to Merchant setup > Merchant groups.
  2. Select a merchant group.
  3. Click the Inbound calls tab.
  4. Copy the Client ID in the top-right corner.
  5. Click New token.
  6. Choose a number of days before token expiry. For example, 30.
  7. Click Save to confirm. Your token is now created.
  8. Copy the token ID and token value. Make sure to keep these confidential to protect the integrity of your authentication process.

As best practice, we recommend regularly generating and implementing new tokens.

Step 3: Create a session on your backend

Checkout Drop-in requires a session from the PXP Sessions API. This must be done on your backend using HMAC authentication to keep your credentials secure.

Understanding HMAC authentication

Our platform uses HMAC (Hash-based Message Authentication Code) with SHA256 for authentication to ensure secure communication and data integrity. This method involves creating a signature by hashing your request data with a secret key, which must then be included in the HTTP headers of your API request.

Create an HMAC signature

Build the HMAC message by concatenating four values without separators:

  1. Timestamp: Current time in Unix seconds (e.g., 1754701373)
  2. Request ID: A unique GUID for this request (e.g, ce244054-b372-42c2-9102-f0d976db69f6)
  3. Request path: The API endpoint path: api/v1/sessions
  4. Request body: The complete JSON request body as a minified string

Your Token ID isn't part of the HMAC message. It belongs in the Authorization header with the timestamp and signature.

Example request body to minify:

{
  "merchant": "MERCHANT-1",
  "site": "SITE-1",
  "sessionTimeout": 120,
  "merchantTransactionId": "0ce72cfd-014d-4256-a006-a56601b2ffc4",
  "transactionMethod": {
    "intent": {
      "card": "Authorisation",
      "paypal": "Purchase",
      "aeropay": "Authorisation"
    }
  },
  "amounts": {
    "currencyCode": "USD",
    "transactionValue": 25.00
  },
  "allowTransaction": true,
  "serviceType": "CheckoutDropIn"
}

When creating the HMAC signature, the request body must be minified (no whitespace or formatting). The formatted JSON above is for readability only.

Kotlin example matching the working session sample:

import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
import java.nio.charset.StandardCharsets.UTF_8
import java.util.UUID

fun createSessionAuthHeader(
    tokenId: String,
    tokenValue: String,
    requestBody: String, // minified JSON
): Pair<String, String> {
    val timestamp = (System.currentTimeMillis() / 1000).toString()
    val requestId = UUID.randomUUID().toString()
    val requestPath = "api/v1/sessions"

    val message = "$timestamp$requestId$requestPath$requestBody"
    val hmac = hmacSha256(message, tokenValue)
    val authHeader = "PXP-UST1 $tokenId:$timestamp:$hmac"

    return requestId to authHeader
}

private fun hmacSha256(message: String, key: String): String {
    val mac = Mac.getInstance("HmacSHA256")
    mac.init(SecretKeySpec(key.toByteArray(UTF_8), "HmacSHA256"))
    return mac.doFinal(message.toByteArray(UTF_8))
        .joinToString("") { "%02X".format(it) }
}

// Send with headers:
// X-Client-Id: <CLIENT_ID>
// X-Request-Id: <requestId>
// Authorization: <authHeader>
// Content-Type: application/json

For a full backend walkthrough, see Quickstart.

Session request parameters

The session request accepts the following parameters:

ParameterDescription
merchant
string (≤ 20 characters)
required
Your unique merchant identifier, as assigned by PXP. You can find it in the Unity Portal, by going to Merchant setup > Merchants and checking the Merchant ID column.
site
string (≤ 20 characters)
required
Your unique site identifier, as assigned by PXP. You can find it in the Unity Portal, by going to Merchant setup > Sites and checking the Site ID column.
merchantTransactionId
string (≤ 50 characters)
required
A unique identifier of your choice that represents this transaction.
sessionTimeout
number
required
The duration of the session, in minutes.
transactionMethod
object
required
Details about the transaction method, including the intent for each payment type.
transactionMethod.intent
object
required
The transaction intent for each payment method.
transactionMethod.intent.card
string
The intent for card transactions (session request). Google Pay availability comes from allowedFundingTypes.wallets.googlePay, not this intent field.

Possible values:
  • Authorisation
  • Purchase
  • Verification
  • EstimatedAuthorisation
transactionMethod.intent.paypal
string
The intent for PayPal transactions.

Possible values:
  • Authorisation
  • Purchase
transactionMethod.intent.aeropay
string
The intent for Aeropay transactions.

Possible values:
  • Authorisation
  • Purchase
  • EstimatedAuthorisation
amounts
object
required
Details about the transaction amount.
amounts.currencyCode
string (3 characters)
required
The currency code associated with the transaction, in ISO 4217 format. See Supported payment currencies.
amounts.transactionValue
number
required
The transaction amount. Numbers after the decimal are zero-padded when they are fewer than the expected currencyCode exponent. For example, GBP 1.1 = GBP 1.10, USD 1 = USD 1.00, or BHD 1.3 = 1.300. The transaction is rejected if numbers after the decimal are greater than the expected currencyCode exponent (e.g., GBP 1.234), or if a decimal is supplied when the currencyCode exponent does not require it (e.g., JPY 1.0).
allowTransaction
boolean
Whether or not to proceed with the transaction.
serviceType
string
Set to "CheckoutDropIn" for Checkout Drop-in sessions.

Session response

If your request is successful, you'll receive a 200 response containing the session data. Map these fields into SessionConfig on the client (sessionId, hmacKey, data, encryptionKey, and locale are required). Include allowedFundingTypes.cards (an empty array is valid) so the card panel can render. cardSchemes alone doesn't enable the card UI.

{
  "sessionId": "c5f0799b-0839-43ce-abc5-5b462a98f250",
  "hmacKey": "904bc42395d4af634e2fd48ee8c2c7f52955a1da97a3aa3d82957ff12980a7bb",
  "data": "session-data-payload-from-sessions-api",
  "encryptionKey": "20d175a669ad3f8c195c9c283fc86155",
  "locale": "en-US",
  "sessionExpiry": "2025-05-19T13:39:20.3843454Z",
  "allowedFundingTypes": {
    "cardSchemes": [
      "Visa",
      "Diners",
      "Mastercard",
      "AmericanExpress"
    ],
    "cards": [],
    "wallets": {
      "paypal": {
        "allowedFundingOptions": [
          "venmo",
          "paylater",
          "paypal"
        ],
        "merchantId": "paypal-merchant-123"
      },
      "googlePay": {
        "merchantId": "BCR2DN4TWWPKJ45P",
        "merchantName": "Your Store Name",
        "gatewayMerchantId": "gateway-merchant-id"
      }
    },
    "payByBanks": {
      "aeropay": {
        "externalMerchantId": "your-aeropay-merchant-id",
        "configurationId": "your-aeropay-configuration-id"
      }
    }
  }
}

When mapping the session into SessionConfig, map wallets.googlePay to GooglePayWalletConfig(merchantId, merchantName). gatewayMerchantId is an API response field; the Android SDK uses merchantId for Google Pay gateway configuration internally.

Checkout Drop-in automatically detects available payment methods from the allowedFundingTypes in your session data. You don't need to manually configure which payment methods to show. For cards, the session must include the cards key (an empty list is valid). cardSchemes is used for network resolution and doesn't substitute for cards.

For Aeropay pay-by-bank setup (payByBanks.aeropay, USD and EntryType.Ecom, intents, and shopper data), see Aeropay.

Step 4: Initialise Drop-in in your app

Import the necessary types and initialise Drop-in with your configuration.

import android.util.Log
import com.pxp.checkout.checkoutdropin.CheckoutDropIn
import com.pxp.checkout.checkoutdropin.types.CheckoutDropInConfig
import com.pxp.checkout.checkoutdropin.types.DropInSubmitResult
import com.pxp.checkout.checkoutdropin.types.PaymentMethod
import com.pxp.checkout.exceptions.BaseSdkException
import com.pxp.checkout.models.CardIntentType
import com.pxp.checkout.models.DropInAeropayIntentType
import com.pxp.checkout.models.DropInPayPalIntentType
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.services.models.transaction.Shopper
import java.time.Instant
import java.util.UUID

// Fetch SessionConfig from your backend (includes data and locale).
// Call fetchSessionFromBackend() from a coroutine — see Quickstart.
val session: SessionConfig = fetchSessionFromBackend()

// Initialise Checkout Drop-in
val checkoutDropIn = CheckoutDropIn.initialize(
    context = context,
    config = CheckoutDropInConfig(
        environment = Environment.TEST,
        session = session,
        ownerType = "MerchantGroup",
        ownerId = "MERCHANT-1",
        transactionData = DropInTransactionData(
            amount = 25.0,
            currency = "USD",
            entryType = EntryType.Ecom,
            intent = DropInTransactionIntentData(
                card = CardIntentType.Purchase,
                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 = {
            // For Aeropay, also return consumer fields when values are set, or use methodConfig.aeropay.userId
            Shopper(id = "shopper-123")
        },
        onBeforeSubmit = { paymentMethod ->
            // Validate merchant form
            validateMerchantForm()
        },
        onSuccess = { result: DropInSubmitResult ->
            // CRITICAL: Verify on backend before fulfilling order
            verifyPaymentOnBackend(result)
        },
        onError = { paymentMethod: PaymentMethod?, error: BaseSdkException ->
            // Show error message (paymentMethod is null for init or cross-method errors)
            Log.e("DropIn", "${error.errorCode}: ${error.message}")
            showPaymentError(error.message)
        }
    )
)

Configuration parameters

The CheckoutDropInConfig class accepts the following configuration parameters:

ParameterDescription
environment
Environment
required
The environment type.

Possible values:
  • Environment.TEST: For development and testing.
  • Environment.LIVE: For live transactions.
session
SessionConfig
required
Details about the checkout session returned from the Unity Sessions API. See Session config parameters.
ownerType
String
required
Always set to "MerchantGroup" for Drop-in.
ownerId
String (≤ 20 characters)
required
Your unique merchant or merchant group identifier, as assigned by PXP. You can find it in the Unity Portal.
transactionData
DropInTransactionData
required
Details about the transaction.
clientId
String
Client identifier used by the SDK configuration. Defaults to empty string.
merchantId
String
Optional merchant identifier when required by the integration. Defaults to empty string.
kountDisabled
Boolean
Set to true to disable Kount fraud detection. Defaults to false.
restrictions
Restrictions?
Optional card restrictions supplied at SDK level.
paypalConfig
PaypalConfig?
Optional PayPal configuration used by SDK-level PayPal flows.
onGetShippingAddress
() -> ShippingAddress?
Function to supply shipping address when Drop-in needs it.
onGetShopper
() -> Shopper?
Function to retrieve shopper information. Required for card-on-file when showCOF is enabled, and for storing a new card when site store-card consent allows it. Returns a Shopper object containing a non-empty id. For Aeropay, return valid consumer fields when you supply values, or set methodConfig.aeropay.userId. See Cards — Store-card consent and Aeropay.
locale
String
Locale used by the checkout experience. Defaults to "en-US".
localisation
LocalisationConfig?
Optional localisation overrides. Defaults to null.
analyticsEvent
(BaseAnalyticsEvent) -> Unit
Receives SDK analytics events so merchants can forward them to their analytics platform.
methodConfig
DropInMethodConfig?
Optional payment-method-specific configuration for global, card, PayPal, Google Pay, and Aeropay behaviour (DropInMethodConfig). Use methodConfig.card (DropInCardConfig) to show or hide card-on-file (showCOF) and new card entry (showNewCard). Both default to true when omitted. Store-card consent mode comes from Unity site configuration (storeCardConsent), not from this object. See Configuration, Cards, and Aeropay.
onBeforeSubmit
suspend (PaymentMethod) -> Boolean
Callback fired when a payment method is selected and the user is about to submit payment. Receives payment method. Return true to proceed or false to cancel. For Aeropay, returning false prevents the popup from opening.
onSubmit
(PaymentMethod) -> Unit
Callback fired when payment processing begins. Use this to show loading indicators. For Aeropay, Drop-in always proceeds after onSubmit (there's no merchant onPreAuthorisation gate).
onSuccess
(DropInSubmitResult) -> Unit
Callback fired when payment succeeds. Strongly recommended for production.
onError
(PaymentMethod?, BaseSdkException) -> Unit
Callback fired when payment fails or setup fails. Receives optional payment method (null for init or cross-method errors such as SDK1100) and error details including errorCode and message. Strongly recommended for production. Without it, failures are silently ignored.

Session config parameters

The SessionConfig class maps the Unity Sessions API response onto the Android client. Map these fields with toSessionConfig() (or equivalent) after your backend creates the session:

ParameterDescription
sessionId
String
required
Unique identifier for the checkout session returned by the Sessions API.
hmacKey
String
required
HMAC key used to secure session communications.
data
String
required
Encrypted session data payload returned by the Sessions API.
encryptionKey
String
required
Key used to encrypt sensitive session data during communication.
locale
String
required
Locale for the session, for example "en-US".
allowedFundingTypes
AllowedFundingTypes?
Optional funding configuration that determines which payment methods Drop-in can show. Include at least a non-null cards array (which may be empty) so the card UI can render. For Aeropay, include payByBanks.aeropay with non-blank externalMerchantId and configurationId. See Aeropay.
restrictions
Restrictions?
Optional card restrictions returned with the session. Separate from CheckoutDropInConfig.restrictions.

Transaction data parameters

The DropInTransactionData class contains transaction details:

ParameterDescription
amount
Double
required
The transaction amount. Must match the currency's expected decimal places.
currency
String (3 characters)
required
The currency code associated with the transaction, in ISO 4217 format. See Supported payment currencies.
entryType
EntryType?
The entry type.

Possible values:
  • EntryType.Ecom: E-commerce transactions
  • EntryType.Moto: Mail order or telephone order transactions
intent
DropInTransactionIntentData
required
The transaction intents for each payment method. See supported transaction intents for details.
merchant
String
required
Your merchant name or identifier.
merchantTransactionId
String (≤ 50 characters)
required
A unique identifier for this transaction, as assigned by you.
merchantTransactionDate
() -> String
required
A function that returns the current date and time 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.

Transaction intent parameters

The DropInTransactionIntentData class specifies payment intents:

ParameterDescription
card
CardIntentType?
The intent for card and card-on-file transactions in Drop-in. Does not control Google Pay (use session wallets.googlePay).

Typical Drop-in values:
  • CardIntentType.Authorisation
  • CardIntentType.EstimatedAuthorisation
  • CardIntentType.Purchase
  • CardIntentType.Verification
paypalDropInIntent
DropInPayPalIntentType?
The intent for PayPal transactions.

Possible values:
  • DropInPayPalIntentType.Authorisation
  • DropInPayPalIntentType.Purchase
aeropayDropInIntent
DropInAeropayIntentType?
The intent for Aeropay transactions.

Possible values:
  • DropInAeropayIntentType.Authorisation
  • DropInAeropayIntentType.Purchase
  • DropInAeropayIntentType.EstimatedAuthorisation
See Aeropay.

Step 5: Create and render Drop-in

Call create() from a coroutine, then render with CheckoutDropIn.Content() so Drop-in can show its loading UI while components initialise:

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier

@Composable
fun CheckoutScreen(checkoutDropIn: CheckoutDropIn) {
    LaunchedEffect(checkoutDropIn) {
        checkoutDropIn.create()
    }

    // Prefer CheckoutDropIn.Content() over calling Content() on the create() return value
    checkoutDropIn.Content(modifier = Modifier.fillMaxWidth())
}

At this point, Drop-in will:

  • Detect available payment methods from your session
  • Render a vertical accordion with all available payment methods
  • Apply branding from the Unity Portal
  • Show a "Secured by PXP" branded footer

Step 6: Handle callbacks

Drop-in provides callbacks to handle payment lifecycle events. onSuccess and onError are optional in the SDK but strongly recommended for production.

onGetShopper callback

Returns shopper information for Card-on-File functionality.

import com.pxp.checkout.services.models.transaction.Shopper

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

onSuccess callback

Fires when payment succeeds. DropInSubmitResult includes systemTransactionId, optional merchantTransactionId, optional authenticationId (3DS), paymentMethod, and optional paymentData (for example Google Pay wallet data).

Always verify on your backend before fulfilling orders.

In a Compose screen, launch verification with rememberCoroutineScope():

import androidx.compose.runtime.rememberCoroutineScope
import kotlinx.coroutines.launch

val scope = rememberCoroutineScope()

onSuccess = { result ->
    // Verify payment on backend
    scope.launch {
        val verified = verifyPaymentOnBackend(
            systemTransactionId = result.systemTransactionId,
            merchantTransactionId = result.merchantTransactionId, // String?
            authenticationId = result.authenticationId
        )

        if (verified.success) {
            navigateToSuccess(verified.orderId)
        } else {
            showError("Payment verification failed")
        }
    }
}

onError callback

Fires when payment fails or setup fails. Display appropriate error messages. Use error.errorCode for programmatic handling.

onError = { paymentMethod, error ->
    Log.e(
        "CheckoutDropIn",
        "Payment failed [${paymentMethod?.value}]: ${error.errorCode} - ${error.message}"
    )
    showError(error.message ?: "Payment failed. Please try again.")
}

Never trust frontend callbacks for order fulfilment. Always verify payments on your backend using webhooks or the Transactions API before fulfilling orders.

Step 7: Backend verification (critical)

Frontend callbacks can be manipulated by malicious users. You must verify all payments on your backend before fulfilling orders.

Primary method: Webhooks

Unity sends real-time webhook notifications to your backend when transactions complete. Configure your webhook endpoint in the Unity Portal.

Learn more about webhook configuration and implementation.

Optional fallback: Query the Transactions API

If you need instant feedback before the webhook arrives, you can query PXP's Transactions API. This is typically used as a fallback to provide immediate UI feedback while webhooks handle the authoritative verification.

Learn more about querying transactions via API.

Error handling

All errors return a consistent BaseSdkException with errorCode and message properties. Common scenarios include card declined, insufficient funds, expired card, CVV failure, and 3DS authentication failure. Display the error message to users and allow them to retry or use a different payment method.

// BaseSdkException
val errorCode: String  // for example "SDK1100"
// message from Exception

Learn more about error handling.

Complete example

Here's a complete example showing Drop-in integration in a Jetpack Compose activity:

import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.*
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.pxp.checkout.checkoutdropin.CheckoutDropIn
import com.pxp.checkout.checkoutdropin.types.CheckoutDropInConfig
import com.pxp.checkout.checkoutdropin.types.DropInSubmitResult
import com.pxp.checkout.checkoutdropin.types.PaymentMethod
import com.pxp.checkout.exceptions.BaseSdkException
import com.pxp.checkout.models.CardIntentType
import com.pxp.checkout.models.DropInAeropayIntentType
import com.pxp.checkout.models.DropInPayPalIntentType
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.services.models.transaction.Shopper
import kotlinx.coroutines.launch
import java.time.Instant
import java.util.UUID

class CheckoutActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContent {
            MaterialTheme {
                CheckoutScreen()
            }
        }
    }

    @Composable
    fun CheckoutScreen() {
        val scope = rememberCoroutineScope()
        var session by remember { mutableStateOf<SessionConfig?>(null) }
        var isLoading by remember { mutableStateOf(false) }
        var errorMessage by remember { mutableStateOf<String?>(null) }

        LaunchedEffect(Unit) {
            try {
                session = fetchSessionFromBackend()
            } catch (e: Exception) {
                errorMessage = "Failed to create session: ${e.message}"
            }
        }

        val checkoutDropIn = remember(session) {
            session?.let { sessionConfig ->
                CheckoutDropIn.initialize(
                    context = this@CheckoutActivity,
                    config = CheckoutDropInConfig(
                        environment = Environment.TEST,
                        session = sessionConfig,
                        ownerType = "MerchantGroup",
                        ownerId = "MERCHANT-1",
                        transactionData = DropInTransactionData(
                            amount = 25.0,
                            currency = "USD",
                            entryType = EntryType.Ecom,
                            intent = DropInTransactionIntentData(
                                card = CardIntentType.Purchase,
                                paypalDropInIntent = DropInPayPalIntentType.Purchase,
                                aeropayDropInIntent = DropInAeropayIntentType.Authorisation
                            ),
                            merchant = "MERCHANT-1",
                            merchantTransactionId = UUID.randomUUID().toString(),
                            merchantTransactionDate = { Instant.now().toString() }
                        ),
                        kountDisabled = false,
                        onGetShopper = {
                            Shopper(id = "shopper-123")
                        },
                        onBeforeSubmit = { paymentMethod ->
                            validateMerchantForm()
                        },
                        onSubmit = { paymentMethod ->
                            isLoading = true
                            errorMessage = null
                        },
                        onSuccess = { result: DropInSubmitResult ->
                            isLoading = false

                            scope.launch {
                                val verified = verifyPaymentOnBackend(
                                    systemTransactionId = result.systemTransactionId,
                                    merchantTransactionId = result.merchantTransactionId,
                                    authenticationId = result.authenticationId
                                )

                                if (verified.success) {
                                    navigateToSuccess(verified.orderId)
                                } else {
                                    errorMessage = "Payment verification failed"
                                }
                            }
                        },
                        onError = { paymentMethod: PaymentMethod?, error: BaseSdkException ->
                            isLoading = false
                            errorMessage = error.message ?: "Payment failed"
                            Log.e(
                                "CheckoutDropIn",
                                "Error [${paymentMethod?.value}]: ${error.errorCode}"
                            )
                        }
                    )
                )
            }
        }

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

        Surface(
            modifier = Modifier.fillMaxSize(),
            color = MaterialTheme.colorScheme.background
        ) {
            Column(
                modifier = Modifier
                    .fillMaxSize()
                    .padding(16.dp)
            ) {
                Text(
                    text = "Complete Your Purchase",
                    style = MaterialTheme.typography.headlineMedium,
                    modifier = Modifier.padding(bottom = 16.dp)
                )

                Card(
                    modifier = Modifier
                        .fillMaxWidth()
                        .padding(bottom = 16.dp)
                ) {
                    Column(modifier = Modifier.padding(16.dp)) {
                        Text(
                            text = "Order Summary",
                            style = MaterialTheme.typography.titleMedium
                        )
                        Spacer(modifier = Modifier.height(8.dp))
                        Text(text = "Product: Premium Subscription")
                        Text(text = "Amount: $25.00 USD")
                    }
                }

                if (errorMessage != null) {
                    Card(
                        colors = CardDefaults.cardColors(
                            containerColor = MaterialTheme.colorScheme.errorContainer
                        ),
                        modifier = Modifier
                            .fillMaxWidth()
                            .padding(bottom = 16.dp)
                    ) {
                        Text(
                            text = errorMessage!!,
                            color = MaterialTheme.colorScheme.onErrorContainer,
                            modifier = Modifier.padding(16.dp)
                        )
                    }
                }

                if (isLoading) {
                    Box(
                        modifier = Modifier.fillMaxWidth(),
                        contentAlignment = Alignment.Center
                    ) {
                        CircularProgressIndicator()
                    }
                }

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

                Text(
                    text = "Your payment information is securely processed by PXP. We never store your full card details.",
                    style = MaterialTheme.typography.bodySmall,
                    modifier = Modifier.padding(top = 16.dp)
                )
            }
        }
    }

    private suspend fun fetchSessionFromBackend(): SessionConfig {
        // Call your backend to create a session
        // Return SessionConfig with sessionId, hmacKey, data, encryptionKey, locale
        TODO("Implement session fetching")
    }

    private fun validateMerchantForm(): Boolean {
        // Validate merchant-owned form fields
        return true
    }

    private suspend fun verifyPaymentOnBackend(
        systemTransactionId: String,
        merchantTransactionId: String?,
        authenticationId: String? = null,
    ): VerificationResult {
        // Call your backend to verify the payment
        TODO("Implement payment verification")
    }

    private fun navigateToSuccess(orderId: String?) {
        // Navigate to success screen
        TODO("Implement navigation")
    }
}

data class VerificationResult(
    val success: Boolean,
    val orderId: String? = null
)

What's next?

Now that you've integrated Checkout Drop-in, here are some recommended next steps:

  • Configuration: Customise payment method behaviour and callbacks.
  • Events: Learn about all available callbacks and event handling.
  • Testing: Use test cards and sandbox environment to test your integration.
  • Configure webhooks: Set up server-side webhook handling for reliable payment verification.