{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-guides/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["sub-heading","br","details","admonition","tabs","tab"]},"type":"markdown"},"seo":{"title":"Google Pay","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":"google-pay","__idx":0},"children":["Google Pay"]},{"$$mdtype":"Tag","name":"SubHeading","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Enable fast, secure checkout with Google Pay for Android customers."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"overview","__idx":1},"children":["Overview"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Google Pay is automatically included in the drop-in when enabled in your session and when the customer's device supports it. The drop-in handles all Google Pay setup, button rendering, and payment processing automatically."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"key-benefits","__idx":2},"children":["Key benefits"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Automatic detection:"]}," Only shows when the device supports Google Pay"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Zero configuration:"]}," Drop-in handles all Google Pay setup"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Native experience:"]}," Uses the device's native Google Pay sheet"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Unified callbacks:"]}," Same ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onSuccess"]},"/",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onError"]}," as other payment methods"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Fast checkout:"]}," Customers authenticate and complete payment in seconds"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"how-it-works","__idx":3},"children":["How it works"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When a customer selects Google Pay:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The customer taps \"Google Pay\" in the accordion. The native payment sheet appears."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The customer authenticates with their device (fingerprint, PIN)."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The customer approves the payment. The payment sheet closes automatically."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The payment is processed through Unity."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Your ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onSuccess"]}," callback fires."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"configuration","__idx":4},"children":["Configuration"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Configure Google Pay-specific settings including merchant information, button customization, address collection, and card restrictions."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"configuration-properties","__idx":5},"children":["Configuration properties"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following properties are available for Google Pay configuration:"]},{"$$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":{"width":"50%","data-label":"Property"},"children":["Property "]},{"$$mdtype":"Tag","name":"th","attributes":{"width":"50%","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":["merchantName"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["String"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Merchant name shown in Google Pay sheet. Should match your business name."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["merchantId"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["String"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Google Pay merchant ID (obtained from Google). Required for production."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["buttonType"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["GooglePayButtonType"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Button style: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Plain"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Buy"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Checkout"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Donate"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Order"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Pay"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Subscribe"]},". Defaults to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Pay"]},"."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["buttonTheme"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["GooglePayButtonTheme"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Button theme: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Dark"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Light"]},". Defaults to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Dark"]},"."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["allowedCardNetworks"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["List<String>"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Which card brands to accept (e.g., ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["listOf(\"VISA\", \"MASTERCARD\")"]},"). Falls back to session configuration."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["allowedCardAuthMethods"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["List<String>"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Card authentication methods: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PAN_ONLY"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CRYPTOGRAM_3DS"]},". Defaults to both."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["allowPrepaidCards"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["Boolean"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Allow prepaid cards. Defaults to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]},"."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["allowCreditCards"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["Boolean"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Allow credit cards. Defaults to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]},"."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["billingAddressRequired"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["Boolean"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Request billing address from customer. Defaults to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["false"]},"."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["billingAddressFormat"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["BillingAddressFormat"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Billing address format: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Min"]}," (postal code and country) or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Full"]}," (complete address). Defaults to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Min"]},"."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["emailRequired"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["Boolean"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Request email address from customer. Defaults to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["false"]},"."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["shippingAddressRequired"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["Boolean"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Request shipping address from customer. Defaults to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["false"]},"."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["shippingAddressAllowedCountryCodes"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["List<String>"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Restrict shipping to specific countries (e.g., ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["listOf(\"GB\", \"US\", \"FR\")"]},")."]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"settings-used-from-global-configuration","__idx":6},"children":["Settings used from global configuration"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Google Pay inherits the following settings from ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["methodConfig.global"]},":"]},{"$$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":{"width":"40%","data-label":"Property"},"children":["Property "]},{"$$mdtype":"Tag","name":"th","attributes":{"width":"60%","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":["onCancel"]},{"$$mdtype":"Tag","name":"Break","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Details","attributes":{},"children":["(paymentMethod: PaymentMethod, data: Any?) -> Unit"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Called when user cancels Google Pay payment (dismisses payment sheet)."]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"complete-example","__idx":7},"children":["Complete example"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This example shows a full Google Pay configuration with global settings and Google Pay-specific options:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"methodConfig = DropInMethodConfig(\n    // Global callbacks that apply to Google Pay\n    global = DropInGlobalConfig(\n        // Handle Google Pay cancellation\n        onCancel = { paymentMethod, data ->\n            if (paymentMethod == PaymentMethod.GOOGLE_PAY) {\n                Log.d(\"Checkout\", \"Google Pay payment cancelled: $data\")\n                \n                // Track analytics\n                analytics.trackEvent(\"google_pay_cancelled\", mapOf(\n                    \"timestamp\" to System.currentTimeMillis()\n                ))\n                \n                // Update UI\n                Toast.makeText(\n                    context,\n                    \"Google Pay payment was cancelled. Please try again.\",\n                    Toast.LENGTH_SHORT\n                ).show()\n            }\n        }\n    ),\n    \n    googlePay = DropInGooglePayConfig(\n        // Merchant information\n        merchantName = \"Demo Store\",\n        merchantId = \"BCR2DN4TZXY2MLBU\", // Your Google Pay merchant ID\n        \n        // Button customisation\n        buttonType = GooglePayButtonType.Buy,\n        buttonTheme = GooglePayButtonTheme.Dark,\n        \n        // Allowed payment methods\n        allowedCardNetworks = listOf(\"VISA\", \"MASTERCARD\", \"AMEX\"),\n        allowedCardAuthMethods = listOf(\"PAN_ONLY\", \"CRYPTOGRAM_3DS\"),\n        \n        // Card restrictions\n        allowPrepaidCards = true,\n        allowCreditCards = true,\n        \n        // Billing address collection\n        billingAddressRequired = true,\n        billingAddressFormat = BillingAddressFormat.Full,\n        \n        // Contact information\n        emailRequired = true,\n        \n        // Shipping address collection\n        shippingAddressRequired = true,\n        shippingAddressAllowedCountryCodes = listOf(\"GB\", \"US\", \"FR\", \"DE\")\n    )\n)\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"google-pay-requirements","__idx":8},"children":["Google Pay requirements"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Google Pay requires the following to function correctly:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Device compatibility"]},": Google Pay works on Android 7.0 (API level 24) or higher"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Google Play Services"]},": Google Play Services must be installed and up to date"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Customer setup"]},": The customer must have at least one card added to their Google Pay account"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["HTTPS"]},": Your backend endpoints must be served over HTTPS"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Unity Portal configuration"]},": Google Pay must be enabled and configured in the Unity Portal"]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For testing, you can omit the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["merchantId"]}," property. However, you must provide a valid Google Pay merchant ID for production deployments."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"implementation","__idx":9},"children":["Implementation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Google Pay works through the standard implementation, with no Google Pay-specific code needed:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import androidx.compose.foundation.layout.fillMaxWidth\nimport androidx.compose.material.CircularProgressIndicator\nimport androidx.compose.runtime.*\nimport androidx.compose.ui.Modifier\nimport androidx.compose.ui.platform.LocalContext\nimport com.pxp.checkout.checkoutdropin.CheckoutDropIn\nimport com.pxp.checkout.checkoutdropin.types.CheckoutDropInConfig\nimport com.pxp.checkout.components.checkoutdropincomponent.CheckoutDropInComponent\nimport com.pxp.checkout.models.DropInTransactionData\nimport com.pxp.checkout.models.DropInTransactionIntentData\nimport com.pxp.checkout.models.Environment\nimport com.pxp.checkout.models.EntryType\nimport com.pxp.checkout.models.IntentType\nimport com.pxp.checkout.checkoutdropin.types.DropInSubmitResult\nimport com.pxp.checkout.exceptions.BaseSdkException\n\n@Composable\nfun CheckoutScreen() {\n    val context = LocalContext.current\n    var sessionData by remember { mutableStateOf<SessionData?>(null) }\n    var checkoutDropInComponent by remember { mutableStateOf<CheckoutDropInComponent?>(null) }\n    var isLoading by remember { mutableStateOf(true) }\n    \n    // Fetch session from backend (with Google Pay enabled)\n    LaunchedEffect(Unit) {\n        try {\n            val response = apiClient.post(\"/api/create-session\") {\n                contentType(ContentType.Application.Json)\n            }\n            \n            if (response.status.value == 200) {\n                val result = response.body<SessionResponse>()\n                if (result.success && result.data != null) {\n                    sessionData = result.data\n                } else {\n                    Log.e(\"Checkout\", \"Failed to create session: ${result.error}\")\n                }\n            }\n        } catch (e: Exception) {\n            Log.e(\"Checkout\", \"Error creating session\", e)\n        } finally {\n            isLoading = false\n        }\n    }\n    \n    // Initialize Drop-in once session is loaded\n    LaunchedEffect(sessionData) {\n        sessionData?.let { session ->\n            val checkoutDropIn = CheckoutDropIn.initialize(\n                context = context,\n                config = CheckoutDropInConfig(\n                    environment = Environment.TEST,\n                    session = session,\n                    ownerType = \"MerchantGroup\",\n                    ownerId = \"MERCHANT-1\",\n                    transactionData = DropInTransactionData(\n                        currency = \"GBP\",\n                        amount = 99.99,\n                        entryType = EntryType.Ecom,\n                        intent = DropInTransactionIntentData(\n                            card = IntentType.Purchase  // Google Pay uses card intent\n                        ),\n                        merchant = \"Demo Store\",\n                        merchantTransactionId = { UUID.randomUUID().toString() },\n                        merchantTransactionDate = { Instant.now().toString() }\n                    ),\n                    onGetShopper = {\n                        Shopper(id = \"shopper-123\")\n                    },\n                    onSuccess = { result: DropInSubmitResult ->\n                        Log.d(\"Checkout\", \"Google Pay payment successful!\")\n                        Log.d(\"Checkout\", \"System transaction ID: ${result.systemTransactionId}\")\n                        Log.d(\"Checkout\", \"Payment method: ${result.paymentMethod}\") // Will be \"GooglePay\"\n                        \n                        // CRITICAL: Verify on backend\n                        coroutineScope.launch {\n                            verifyPaymentOnBackend(result)\n                        }\n                    },\n                    onError = { error: BaseSdkException ->\n                        Log.e(\"Checkout\", \"Google Pay payment failed\", error)\n                        Toast.makeText(\n                            context,\n                            \"Payment failed: ${error.message}\",\n                            Toast.LENGTH_LONG\n                        ).show()\n                    }\n                )\n            )\n            checkoutDropInComponent = checkoutDropIn.create()\n        }\n    }\n    \n    // Render Drop-in\n    if (isLoading) {\n        CircularProgressIndicator()\n    } else {\n        checkoutDropInComponent?.Content(modifier = Modifier.fillMaxWidth())\n    }\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"session-configuration-backend","__idx":10},"children":["Session configuration (backend)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Enable Google Pay in your session request:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// BACKEND: Create a session with Google Pay enabled\nconst sessionRequest = {\n  merchant: \"MERCHANT-1\",\n  site: \"SITE-1\",\n  sessionTimeout: 120,\n  merchantTransactionId: crypto.randomUUID(),\n  transactionMethod: {\n    intent: {\n      card: \"Purchase\"  // Google Pay uses card intent\n    }\n  },\n  amounts: {\n    currencyCode: \"GBP\",\n    transactionValue: 99.99\n  },\n  allowedFundingTypes: {\n    wallets: {\n      googlePay: {\n        // Google Pay configuration from the Unity Portal will be used\n        // You can optionally specify merchant information here\n        merchantName: \"Demo Store\",\n        merchantId: \"BCR2DN4TZXY2MLBU\"\n      }\n    }\n  },\n  allowTransaction: true,\n  serviceType: \"CheckoutDropIn\"\n};\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"payment-flows","__idx":11},"children":["Payment flows"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Drop-in supports two Google Pay payment flows, configured via the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["intent"]}," parameter:"]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"label":"Pay now (Purchase)","disable":false},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Immediate, single-step payment where funds are captured right away."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import com.pxp.checkout.models.DropInTransactionData\nimport com.pxp.checkout.models.DropInTransactionIntentData\nimport com.pxp.checkout.models.EntryType\nimport com.pxp.checkout.models.IntentType\n\ntransactionData = DropInTransactionData(\n    currency = \"GBP\",\n    amount = 99.99,\n    entryType = EntryType.Ecom,\n    intent = DropInTransactionIntentData(\n        card = IntentType.Purchase  // Pay Now flow - Google Pay uses card intent\n    ),\n    merchant = \"Demo Store\",\n    merchantTransactionId = { UUID.randomUUID().toString() },\n    merchantTransactionDate = { Instant.now().toString() }\n)\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use this flow for:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Digital products"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Simple orders with immediate fulfillment"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Subscriptions"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Donations"]}]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Confirm payment (Authorisation)","disable":false},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Two-step payment: authorise now, capture later (within scheme-specific time windows)."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import com.pxp.checkout.models.DropInTransactionData\nimport com.pxp.checkout.models.DropInTransactionIntentData\nimport com.pxp.checkout.models.EntryType\nimport com.pxp.checkout.models.IntentType\n\ntransactionData = DropInTransactionData(\n    currency = \"GBP\",\n    amount = 149.99,\n    entryType = EntryType.Ecom,\n    intent = DropInTransactionIntentData(\n        card = IntentType.Authorisation  // Confirm Payment flow - Google Pay uses card intent\n    ),\n    merchant = \"Demo Store\",\n    merchantTransactionId = { UUID.randomUUID().toString() },\n    merchantTransactionDate = { Instant.now().toString() }\n)\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use this flow for:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Physical products (capture on shipment)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Inventory validation needed"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Final amount may change (shipping, taxes)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Complex order workflows"]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"handling-responses","__idx":12},"children":["Handling responses"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"google-pay-callback-data","__idx":13},"children":["Google Pay callback data"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When a Google Pay payment succeeds, your ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onSuccess"]}," callback receives the same standard result as other payment methods:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"onSuccess = { result: DropInSubmitResult ->\n    Log.d(\"Checkout\", \"Payment Details:\")\n    Log.d(\"Checkout\", \"- System Transaction ID: ${result.systemTransactionId}\")\n    Log.d(\"Checkout\", \"- Merchant Transaction ID: ${result.merchantTransactionId}\")\n    Log.d(\"Checkout\", \"- Payment Method: ${result.paymentMethod}\") // \"GooglePay\"\n    \n    // Note: Amount, currency, and card details must be retrieved from backend\n    // Google Pay tokenises cards - actual card details are not exposed\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"error-handling","__idx":14},"children":["Error handling"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Handle Google Pay-specific errors:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import com.pxp.checkout.exceptions.BaseSdkException\n\nonError = { error: BaseSdkException ->\n    Log.e(\"Checkout\", \"Error code: ${error.code}\")\n    Log.e(\"Checkout\", \"Error message: ${error.message}\")\n    \n    // Handle user cancellation\n    if (error.message?.contains(\"cancelled\", ignoreCase = true) == true ||\n        error.message?.contains(\"closed\", ignoreCase = true) == true) {\n        Log.d(\"Checkout\", \"User cancelled Google Pay payment\")\n        // Don't show error - user intentionally cancelled\n        return@CheckoutDropInConfig\n    }\n    \n    // Handle Google Pay-specific errors based on message content\n    when {\n        error.message?.contains(\"not available\", ignoreCase = true) == true -> {\n            Toast.makeText(\n                context,\n                \"Google Pay isn't available on this device. Please use a different payment method.\",\n                Toast.LENGTH_LONG\n            ).show()\n        }\n        error.message?.contains(\"not supported\", ignoreCase = true) == true -> {\n            Toast.makeText(\n                context,\n                \"Google Pay isn't supported for this transaction. Please use a different payment method.\",\n                Toast.LENGTH_LONG\n            ).show()\n        }\n        error.message?.contains(\"declined\", ignoreCase = true) == true -> {\n            Toast.makeText(\n                context,\n                \"Payment declined. Please try a different payment method.\",\n                Toast.LENGTH_LONG\n            ).show()\n        }\n        error.message?.contains(\"timeout\", ignoreCase = true) == true -> {\n            Toast.makeText(\n                context,\n                \"Google Pay timed out. Please try again.\",\n                Toast.LENGTH_SHORT\n            ).show()\n        }\n        else -> {\n            Toast.makeText(\n                context,\n                \"Google Pay payment failed: ${error.message}\",\n                Toast.LENGTH_LONG\n            ).show()\n        }\n    }\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"common-error-scenarios","__idx":15},"children":["Common error scenarios"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following table describes common Google Pay error scenarios:"]},{"$$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":{"align":"left","data-label":"Scenario"},"children":["Scenario"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"How to detect"},"children":["How to detect"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Recommended action"},"children":["Recommended action"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["User cancelled"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["error.message"]}," contains \"cancelled\" or \"closed\""]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["No alert needed - user action was intentional"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Not available"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["error.message"]}," contains \"not available\" or \"not supported\""]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Google Pay button should be hidden automatically"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Payment declined"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["error.message"]}," contains \"declined\""]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Suggest trying different payment method"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Configuration error"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["error.message"]}," contains \"configuration\" or \"setup\""]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Contact support, check Unity Portal settings"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Network error"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Network-related error message"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Check connection and retry"]}]}]}]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Google Pay errors return descriptive messages rather than specific error code constants. Check the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["error.message"]}," property for error details. You can also use the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onCancel"]}," callback in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["methodConfig.global"]}," to specifically handle user cancellations."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"backend-verification","__idx":16},"children":["Backend verification"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Always verify Google Pay payments on your backend to ensure payment success before fulfilling orders:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import com.pxp.checkout.checkoutdropin.types.DropInSubmitResult\n\nonSuccess = { result: DropInSubmitResult ->\n    // Send to backend for verification\n    coroutineScope.launch {\n        try {\n            val response = apiClient.post(\"/api/verify-payment\") {\n                contentType(ContentType.Application.Json)\n                setBody(mapOf(\n                    \"systemTransactionId\" to result.systemTransactionId,\n                    \"merchantTransactionId\" to result.merchantTransactionId\n                ))\n            }\n            \n            if (response.status.value == 200) {\n                val verified = response.body<VerificationResponse>()\n                if (verified.success) {\n                    // Navigate to success screen\n                    navController.navigate(\"success?orderId=${verified.orderId}\")\n                } else {\n                    Toast.makeText(\n                        context,\n                        \"Payment verification failed\",\n                        Toast.LENGTH_LONG\n                    ).show()\n                }\n            }\n        } catch (e: Exception) {\n            Log.e(\"Checkout\", \"Verification error\", e)\n            Toast.makeText(\n                context,\n                \"Failed to verify payment\",\n                Toast.LENGTH_LONG\n            ).show()\n        }\n    }\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"backend-verification-code","__idx":17},"children":["Backend verification code"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use the following backend code to verify Google Pay transactions via the PXP API:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// BACKEND: Verify Google Pay payment\napp.post('/api/verify-payment', async (req, res) => {\n  const { systemTransactionId, merchantTransactionId } = req.body;\n  \n  try {\n    // Query PXP API to get transaction details\n    const txnPath = `api/v1/transactions/${systemTransactionId}`;\n    const { authHeader, requestId } = createAuthHeader(\n      txnPath,\n      '',\n      process.env.PXP_TOKEN_ID,\n      process.env.PXP_TOKEN_VALUE\n    );\n    \n    const transaction = await fetch(\n      `https://api-services.pxp.io/${txnPath}`,\n      {\n        headers: {\n          'X-Client-Id': process.env.PXP_CLIENT_ID,\n          'X-Request-Id': requestId,\n          'Authorization': authHeader\n        }\n      }\n    ).then(r => r.json());\n    \n    // Verify transaction state\n    if (transaction.state !== 'Authorised' && transaction.state !== 'Captured') {\n      return res.json({ success: false, error: 'Transaction not successful' });\n    }\n    \n    // Verify merchant transaction ID matches\n    if (transaction.merchantTransactionId !== merchantTransactionId) {\n      return res.json({ success: false, error: 'Transaction ID mismatch' });\n    }\n    \n    // Verify amount matches expected amount from your order records\n    const order = await getOrderByMerchantTransactionId(merchantTransactionId);\n    const txnAmount = transaction.amounts?.transactionValue || transaction.amount || 0;\n    if (Math.abs(txnAmount - order.amount) > 0.01) {\n      return res.json({ success: false, error: 'Amount mismatch' });\n    }\n    \n    // Google Pay payments show as Card funding type in PXP API\n    const fundingType = transaction.fundingData?.fundingType || \n                       transaction.fundingType || \n                       'Unknown';\n    if (fundingType !== 'Card') {\n      return res.json({ success: false, error: 'Invalid funding type' });\n    }\n    \n    // Fulfill order\n    const orderId = await fulfillOrder(transaction);\n    \n    return res.json({ success: true, orderId });\n    \n  } catch (error) {\n    console.error('Verification error:', error);\n    return res.json({ success: false, error: 'Verification failed' });\n  }\n});\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"testing-google-pay","__idx":18},"children":["Testing Google Pay"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"test-cards","__idx":19},"children":["Test cards"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use the following test cards in the Google Pay test environment:"]},{"$$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":{"align":"left","data-label":"Card network"},"children":["Card network"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Test card number"},"children":["Test card number"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Expiry"},"children":["Expiry"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"CVC"},"children":["CVC"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Visa"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["4111 1111 1111 1111"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Any future date"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Any 3 digits"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Mastercard"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["5555 5555 5555 4444"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Any future date"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Any 3 digits"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Amex"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["3782 822463 10005"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Any future date"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Any 4 digits"]}]}]}]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To test Google Pay, you must add these test cards to your Google account in the test environment. Open Google Wallet on your test device and add the test cards manually."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"test-environment","__idx":20},"children":["Test environment"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Configure your app for Google Pay testing:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"// Use test environment for Google Pay testing\nCheckoutDropInConfig(\n    environment = Environment.TEST,  // Test environment\n    // ... other config\n    methodConfig = DropInMethodConfig(\n        googlePay = DropInGooglePayConfig(\n            // Omit merchantId for testing\n            merchantName = \"Demo Store\",\n            // ... other config\n        )\n    )\n)\n","lang":"kotlin"},"children":[]}]},"headings":[{"value":"Google Pay","id":"google-pay","depth":1},{"value":"Overview","id":"overview","depth":2},{"value":"Key benefits","id":"key-benefits","depth":3},{"value":"How it works","id":"how-it-works","depth":2},{"value":"Configuration","id":"configuration","depth":2},{"value":"Configuration properties","id":"configuration-properties","depth":3},{"value":"Settings used from global configuration","id":"settings-used-from-global-configuration","depth":3},{"value":"Complete example","id":"complete-example","depth":3},{"value":"Google Pay requirements","id":"google-pay-requirements","depth":3},{"value":"Implementation","id":"implementation","depth":2},{"value":"Session configuration (backend)","id":"session-configuration-backend","depth":3},{"value":"Payment flows","id":"payment-flows","depth":3},{"value":"Handling responses","id":"handling-responses","depth":2},{"value":"Google Pay callback data","id":"google-pay-callback-data","depth":3},{"value":"Error handling","id":"error-handling","depth":3},{"value":"Common error scenarios","id":"common-error-scenarios","depth":4},{"value":"Backend verification","id":"backend-verification","depth":2},{"value":"Backend verification code","id":"backend-verification-code","depth":3},{"value":"Testing Google Pay","id":"testing-google-pay","depth":2},{"value":"Test cards","id":"test-cards","depth":3},{"value":"Test environment","id":"test-environment","depth":3}],"frontmatter":{"seo":{"title":"Google Pay"}},"lastModified":"2026-05-19T15:21:05.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/guides/checkout/drop-in/web/google-pay","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}