{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-guides/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["sub-heading","br","details","required","admonition"]},"type":"markdown"},"seo":{"title":"Implementation","description":"Transform your commerce with PXP's unified platform—seamless payments, real-time insights, and global growth in one powerful integration.","lang":"en-UK","siteUrl":"https://developer.pxp.io","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"implementation","__idx":0},"children":["Implementation"]},{"$$mdtype":"Tag","name":"SubHeading","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Learn how to use the Google Pay component for Android in your project."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"overview","__idx":1},"children":["Overview"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Every component follows the same basic two-step lifecycle:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Create the component and configure it with your settings."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Render the component using Jetpack Compose. This makes the component visible and interactive. Cleanup happens automatically when the Composable leaves composition."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"before-you-start","__idx":2},"children":["Before you start"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To use the Google Pay button component, you first need to:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/checkout/components/android/install"},"children":["Install the Android SDK"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Complete the Google Pay onboarding process in the Unity Portal. See ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/checkout/components/android/google-pay/onboarding"},"children":["Onboarding"]}," for details."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Configure your Google Pay merchant account and link it to the Unity Portal."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-1-initialise-the-sdk","__idx":3},"children":["Step 1: Initialise the SDK"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To get started, initialise the PXP Checkout SDK with your merchant credentials and transaction data."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import com.pxp.PxpCheckout\nimport com.pxp.checkout.models.*\nimport com.pxp.checkout.services.models.transaction.Shopper\nimport java.text.SimpleDateFormat\nimport java.util.*\n\nclass PaymentActivity : ComponentActivity() {\n\n    private lateinit var pxpCheckout: PxpCheckout\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n\n        // Get session config from your backend API\n        val sessionConfig = fetchSessionFromYourBackend()\n\n        // Initialise PxpCheckout SDK\n        pxpCheckout = PxpCheckout.builder()\n            .withConfig(\n                PxpSdkConfig(\n                    environment = Environment.TEST,\n                    session = sessionConfig,\n                    ownerId = \"your-owner-id\",\n                    ownerType = \"MerchantGroup\",\n                    kountDisabled = false, // OPTIONAL: Set to true to disable Kount fraud detection\n                    transactionData = TransactionData(\n                        amount = 99.99,\n                        currency = \"GBP\",\n                        merchant = \"your-merchant-id\",\n                        merchantTransactionId = UUID.randomUUID().toString(),\n                        merchantTransactionDate = {\n                            SimpleDateFormat(\"yyyy-MM-dd'T'HH:mm:ss'Z'\", Locale.US)\n                                .apply { timeZone = TimeZone.getTimeZone(\"UTC\") }\n                                .format(Date())\n                        },\n                        entryType = EntryType.Ecom,\n                        intent = TransactionIntentData(\n                            card = IntentType.Authorisation\n                        )\n                    ),\n                    onGetShopper = {\n                        // Return current shopper data dynamically\n                        Shopper(\n                            id = \"shopper-${System.currentTimeMillis()}\",\n                            email = \"customer@example.com\",\n                            firstName = \"John\",\n                            lastName = \"Doe\"\n                        )\n                    },\n                    onGetShippingAddress = {\n                        // Return current shipping address dynamically (optional)\n                        ShippingAddress(\n                            addressLine1 = \"123 Main Street\",\n                            city = \"London\",\n                            postalCode = \"SW1A 1AA\",\n                            countryCode = \"GB\"\n                        )\n                    }\n                )\n            )\n            .withContext(this)\n            .build()\n\n        setContent {\n            YourAppTheme {\n                PaymentScreen(pxpCheckout = pxpCheckout)\n            }\n        }\n    }\n\n    private fun fetchSessionFromYourBackend(): SessionConfig {\n        // Call your merchant backend API to create a session\n        // Your backend should call PXP API to create a session\n        return SessionConfig(\n            sessionId = \"session-123\",\n            hmacKey = \"hmac-key\",\n            data = \"session-data\",\n            encryptionKey = \"encryption-key\",\n            locale = \"en-GB\"\n        )\n    }\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Parameter"},"children":["Parameter"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["environment"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["Environment"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Required","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The environment type.",{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},"Possible values:",{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Environment.TEST"]},": Sandbox."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Environment.LIVE"]},": Live payments."]}]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["session"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["SessionConfig"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Required","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Session configuration obtained from your backend."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["session.sessionId"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["String"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Required","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Unique session identifier."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["session.hmacKey"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["String"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Required","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["HMAC key for session validation."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["session.data"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["String"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Required","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Session data payload."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["session.encryptionKey"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["String"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Required","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Encryption key for secure data transmission."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ownerId"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["String"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Required","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The identifier of the owner."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ownerType"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["String"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Required","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The type of owner. Use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\"MerchantGroup\""]},"."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["kountDisabled"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["Boolean"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Whether to disable the Kount fraud detection service. Defaults to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["false"]}," (fraud detection enabled)."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onGetShopper"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["() -> Shopper?"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Callback function to provide shopper data dynamically. Returns ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Shopper"]}," object from ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["com.pxp.checkout.services.models.transaction"]}," package with shopper information including ID, email, name, and contact details. Required when using consent tokens for storing payment methods."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onGetShippingAddress"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["() -> ShippingAddress?"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Callback function to provide shipping address dynamically. Returns ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ShippingAddress"]}," object from ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["com.pxp.checkout.models"]}," package with shipping address information. Optional."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["transactionData"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["TransactionData"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Required","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Details about the transaction."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["transactionData.amount"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["Double"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Required","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Transaction amount."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["transactionData.currency"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["String (3 characters)"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Required","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Currency code in ISO 4217 format (e.g., ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\"GBP\""]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\"USD\""]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\"EUR\""]},")."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["transactionData.merchant"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["String"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Required","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Your merchant identifier."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["transactionData.merchantTransactionId"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["String"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Required","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Your unique identifier for this transaction."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["transactionData.merchantTransactionDate"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["() -> String"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Required","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Function that returns the transaction date in ISO 8601 format."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["transactionData.entryType"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["EntryType"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Entry type. Use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["EntryType.Ecom"]}," for e-commerce transactions."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["transactionData.intent"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["TransactionIntentData"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Transaction intents for each payment method.",{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},"Possible values for card:",{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["IntentType.Authorisation"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["IntentType.Purchase"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["IntentType.Verification"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["IntentType.EstimatedAuthorisation"]}]}]}]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-2-configure-the-google-pay-component","__idx":4},"children":["Step 2: Configure the Google Pay component"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create the configuration for your Google Pay button with payment settings and event handlers."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The SDK automatically configures ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tokenizationSpecification"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["merchantInfo"]}," with the correct gateway, merchant ID, and merchant name from your session. You only need to provide ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["allowedPaymentMethods"]}," with the card parameters and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["transactionInfo"]},"."]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import com.pxp.checkout.components.googlepay.types.*\nimport com.pxp.checkout.services.kount.*\nimport com.pxp.checkout.models.MerchantSubmitResult\nimport com.pxp.checkout.models.FailedSubmitResult\n\nval googlePayConfig = GooglePayButtonComponentConfig().apply {\n    \n    // Button style\n    style = GooglePayButtonStyle(\n        type = GooglePayButtonType.PAY,\n        theme = GooglePayButtonTheme.DARK,\n        cornerRadius = 8\n    )\n    \n    // Payment data request (REQUIRED)\n    paymentDataRequest = PaymentDataRequest(\n        allowedPaymentMethods = listOf(\n            PaymentMethodSpecification(\n                parameters = PaymentMethodParameters(\n                    allowedCardNetworks = listOf(\n                        CardNetwork.VISA,\n                        CardNetwork.MASTERCARD,\n                        CardNetwork.AMEX\n                    ),\n                    allowedAuthMethods = listOf(\n                        CardAuthMethod.PAN_ONLY,\n                        CardAuthMethod.CRYPTOGRAM_3DS\n                    )\n                )\n            )\n        ),\n        transactionInfo = TransactionInfo(\n            currencyCode = \"GBP\",\n            totalPriceStatus = TotalPriceStatus.FINAL,\n            totalPrice = \"99.99\"\n        )\n    )\n    \n    // Pre-authorisation callback\n    onPreAuthorisation = suspend { preAuthData ->\n        Log.d(\"GooglePay\", \"Processing payment\")\n        \n        // Return risk screening data\n        GooglePayTransactionInitData(\n            riskScreeningData = RiskScreeningData(\n                performRiskScreening = true,\n                excludeDeviceData = false,\n                userIp = \"192.168.1.100\",\n                account = RiskScreeningAccount(\n                    id = \"user_12345678\",\n                    creationDateTime = \"2024-01-15T10:30:00.000Z\"\n                ),\n                items = listOf(\n                    RiskScreeningItem(\n                        price = 99.99,\n                        quantity = 1,\n                        category = \"Electronics\",\n                        sku = \"GPAY-001\"\n                    )\n                ),\n                fulfillments = listOf(\n                    RiskScreeningFulfillment(\n                        type = FulfillmentType.SHIPPED,\n                        shipping = RiskScreeningShipping(\n                            shippingMethod = ShippingMethod.STANDARD\n                        ),\n                        recipientPerson = RiskScreeningRecipientPerson(\n                            phoneNumber = \"+1234567890\"\n                        )\n                    )\n                )\n            )\n        )\n    }\n    \n    // Handle successful payment\n    onPostAuthorisation = { result, paymentData ->\n        when (result) {\n            is MerchantSubmitResult -> {\n                Log.d(\"GooglePay\", \"Payment successful: ${result.systemTransactionId}\")\n                handlePaymentSuccess(result)\n            }\n            is FailedSubmitResult -> {\n                Log.e(\"GooglePay\", \"Payment failed: ${result.errorReason}\")\n                handlePaymentFailure(result)\n            }\n        }\n    }\n    \n    // Handle errors\n    onError = { error ->\n        Log.e(\"GooglePay\", \"Error: ${error.message}\")\n        showError(error.message)\n    }\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-3-create-and-render-the-component","__idx":5},"children":["Step 3: Create and render the component"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create the Google Pay component and render it in your Compose UI."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import com.pxp.checkout.components.googlepay.GooglePayButtonComponent\nimport com.pxp.checkout.types.ComponentType\n\n@Composable\nfun PaymentScreen(pxpCheckout: PxpCheckout) {\n    \n    val googlePayComponent = remember {\n        pxpCheckout.createComponent<GooglePayButtonComponent, GooglePayButtonComponentConfig>(\n            type = ComponentType.GOOGLE_PAY_BUTTON,\n            config = googlePayConfig\n        )\n    }\n    \n    Column(\n        modifier = Modifier\n            .fillMaxWidth()\n            .padding(16.dp),\n        horizontalAlignment = Alignment.CenterHorizontally\n    ) {\n        Text(\n            text = \"Complete your purchase\",\n            style = MaterialTheme.typography.headlineMedium,\n            modifier = Modifier.padding(bottom = 16.dp)\n        )\n        \n        // Render the Google Pay button\n        googlePayComponent?.Content(\n            modifier = Modifier\n                .fillMaxWidth()\n                .height(56.dp)\n        )\n    }\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"complete-example","__idx":6},"children":["Complete example"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Here's a complete working example that puts everything together:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import android.os.Bundle\nimport androidx.activity.ComponentActivity\nimport androidx.activity.compose.setContent\nimport androidx.compose.foundation.layout.*\nimport androidx.compose.material3.*\nimport androidx.compose.runtime.*\nimport androidx.compose.ui.Alignment\nimport androidx.compose.ui.Modifier\nimport androidx.compose.ui.unit.dp\nimport androidx.lifecycle.lifecycleScope\nimport com.pxp.PxpCheckout\nimport com.pxp.checkout.components.googlepay.GooglePayButtonComponent\nimport com.pxp.checkout.components.googlepay.types.*\nimport com.pxp.checkout.models.*\nimport com.pxp.checkout.services.kount.*\nimport com.pxp.checkout.services.models.transaction.Shopper\nimport com.pxp.checkout.types.ComponentType\nimport kotlinx.coroutines.launch\nimport java.text.SimpleDateFormat\nimport java.util.*\n\nclass MainActivity : ComponentActivity() {\n\n    private lateinit var pxpCheckout: PxpCheckout\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n\n        lifecycleScope.launch {\n            // Initialise SDK\n            pxpCheckout = initializeSDK()\n\n            setContent {\n                MaterialTheme {\n                    GooglePayScreen(pxpCheckout)\n                }\n            }\n        }\n    }\n\n    private suspend fun initializeSDK(): PxpCheckout {\n        val sessionConfig = fetchSessionFromYourBackend()\n\n        return PxpCheckout.builder()\n            .withConfig(\n                PxpSdkConfig(\n                    environment = Environment.TEST,\n                    session = sessionConfig,\n                    ownerId = \"your-owner-id\",\n                    ownerType = \"MerchantGroup\",\n                    kountDisabled = false,\n                    transactionData = TransactionData(\n                        amount = 99.99,\n                        currency = \"GBP\",\n                        merchant = \"your-merchant-id\",\n                        merchantTransactionId = UUID.randomUUID().toString(),\n                        merchantTransactionDate = {\n                            SimpleDateFormat(\"yyyy-MM-dd'T'HH:mm:ss'Z'\", Locale.US)\n                                .apply { timeZone = TimeZone.getTimeZone(\"UTC\") }\n                                .format(Date())\n                        },\n                        entryType = EntryType.Ecom,\n                        intent = TransactionIntentData(\n                            card = IntentType.Authorisation\n                        )\n                    ),\n                    onGetShopper = {\n                        Shopper(\n                            id = \"shopper-${System.currentTimeMillis()}\",\n                            email = \"customer@example.com\",\n                            firstName = \"John\",\n                            lastName = \"Doe\"\n                        )\n                    },\n                    onGetShippingAddress = {\n                        ShippingAddress(\n                            addressLine1 = \"123 Main Street\",\n                            city = \"London\",\n                            postalCode = \"SW1A 1AA\",\n                            countryCode = \"GB\"\n                        )\n                    }\n                )\n            )\n            .withContext(this)\n            .build()\n    }\n\n    private suspend fun fetchSessionFromYourBackend(): SessionConfig {\n        // Call your backend to fetch session\n        return SessionConfig(\n            sessionId = \"session-123\",\n            hmacKey = \"hmac-key\",\n            data = \"session-data\",\n            encryptionKey = \"encryption-key\",\n            locale = \"en-GB\"\n        )\n    }\n}\n\n@Composable\nfun GooglePayScreen(pxpCheckout: PxpCheckout) {\n    var showSuccess by remember { mutableStateOf(false) }\n    var errorMessage by remember { mutableStateOf<String?>(null) }\n\n    val googlePayConfig = remember {\n        GooglePayButtonComponentConfig().apply {\n            style = GooglePayButtonStyle(\n                type = GooglePayButtonType.PAY,\n                theme = GooglePayButtonTheme.DARK,\n                cornerRadius = 8\n            )\n\n            paymentDataRequest = PaymentDataRequest(\n                allowedPaymentMethods = listOf(\n                    PaymentMethodSpecification(\n                        parameters = PaymentMethodParameters(\n                            allowedCardNetworks = listOf(\n                                CardNetwork.VISA,\n                                CardNetwork.MASTERCARD,\n                                CardNetwork.AMEX\n                            ),\n                            allowedAuthMethods = listOf(\n                                CardAuthMethod.PAN_ONLY,\n                                CardAuthMethod.CRYPTOGRAM_3DS\n                            )\n                        )\n                    )\n                ),\n                transactionInfo = TransactionInfo(\n                    currencyCode = \"GBP\",\n                    totalPriceStatus = TotalPriceStatus.FINAL,\n                    totalPrice = \"99.99\"\n                )\n            )\n\n            onPreAuthorisation = suspend { preAuthData ->\n                GooglePayTransactionInitData(\n                    riskScreeningData = RiskScreeningData(\n                        performRiskScreening = true,\n                        excludeDeviceData = false,\n                        userIp = \"192.168.1.100\",\n                        account = RiskScreeningAccount(\n                            id = \"user_12345678\",\n                            creationDateTime = \"2024-01-15T10:30:00.000Z\"\n                        ),\n                        fulfillments = listOf(\n                            RiskScreeningFulfillment(\n                                type = FulfillmentType.SHIPPED,\n                                recipientPerson = RiskScreeningRecipientPerson(\n                                    phoneNumber = \"+1234567890\"\n                                )\n                            )\n                        )\n                    )\n                )\n            }\n\n            onPostAuthorisation = { result, paymentData ->\n                when (result) {\n                    is MerchantSubmitResult -> {\n                        showSuccess = true\n                    }\n                    is FailedSubmitResult -> {\n                        errorMessage = result.errorReason\n                    }\n                }\n            }\n\n            onError = { error ->\n                errorMessage = error.message\n            }\n        }\n    }\n\n    val googlePayComponent = remember {\n        pxpCheckout.createComponent<GooglePayButtonComponent, GooglePayButtonComponentConfig>(\n            type = ComponentType.GOOGLE_PAY_BUTTON,\n            config = googlePayConfig\n        )\n    }\n\n    Scaffold { paddingValues ->\n        Column(\n            modifier = Modifier\n                .fillMaxSize()\n                .padding(paddingValues)\n                .padding(16.dp),\n            horizontalAlignment = Alignment.CenterHorizontally,\n            verticalArrangement = Arrangement.Center\n        ) {\n            if (showSuccess) {\n                Text(\n                    text = \"✓ Payment Successful!\",\n                    style = MaterialTheme.typography.headlineMedium,\n                    color = MaterialTheme.colorScheme.primary\n                )\n            } else {\n                Text(\n                    text = \"Complete your purchase\",\n                    style = MaterialTheme.typography.headlineMedium,\n                    modifier = Modifier.padding(bottom = 24.dp)\n                )\n\n                googlePayComponent?.Content(\n                    modifier = Modifier\n                        .fillMaxWidth()\n                        .height(56.dp)\n                )\n\n                errorMessage?.let { error ->\n                    Text(\n                        text = error,\n                        color = MaterialTheme.colorScheme.error,\n                        modifier = Modifier.padding(top = 16.dp)\n                    )\n                }\n            }\n        }\n    }\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"next-steps","__idx":7},"children":["Next steps"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Now that you've implemented the basic Google Pay integration, you can:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/checkout/components/android/google-pay/3ds"},"children":["Configure 3D Secure authentication"]}," for enhanced security."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/checkout/components/android/google-pay/recurring-payments"},"children":["Set up recurring payments"]}," to enable subscriptions."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/checkout/components/android/google-pay/configuration#cvc-collection"},"children":["Implement CVC collection"]}," for additional security."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/checkout/components/android/google-pay/events"},"children":["Handle payment events"]}," to track the payment lifecycle."]}]}]},"headings":[{"value":"Implementation","id":"implementation","depth":1},{"value":"Overview","id":"overview","depth":2},{"value":"Before you start","id":"before-you-start","depth":2},{"value":"Step 1: Initialise the SDK","id":"step-1-initialise-the-sdk","depth":2},{"value":"Step 2: Configure the Google Pay component","id":"step-2-configure-the-google-pay-component","depth":2},{"value":"Step 3: Create and render the component","id":"step-3-create-and-render-the-component","depth":2},{"value":"Complete example","id":"complete-example","depth":2},{"value":"Next steps","id":"next-steps","depth":2}],"frontmatter":{"seo":{"title":"Implementation"}},"lastModified":"2026-05-19T10:00:02.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/guides/checkout/components/android/google-pay/implementation","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}