{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-guides/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["sub-heading","admonition"]},"type":"markdown"},"seo":{"title":"Troubleshooting","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":"troubleshooting","__idx":0},"children":["Troubleshooting"]},{"$$mdtype":"Tag","name":"SubHeading","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Learn how to diagnose and fix common issues with the Google Pay Android component."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"exception-types-and-error-codes","__idx":1},"children":["Exception types and error codes"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"component-exceptions","__idx":2},"children":["Component exceptions"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Google Pay Android component throws specific exceptions for different 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":{"width":"40%","data-label":"Exception"},"children":["Exception "]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Error code"},"children":["Error code"]},{"$$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":["GooglePayLoadFailedException"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["SDK0704"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The Google Pay API failed to load. For example, due to network issues, Google Play Services unavailable, or device incompatibility."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GooglePayNotReadyException"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["SDK0701"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Google Pay isn't ready on this device. For example, Google Play Services not installed, no Google account, or no payment methods configured."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GooglePayClientNotInitializedException"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["SDK0703"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The Google Pay client was not properly initialised before attempting a payment."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GooglePayConfigurationValidationFailedException"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["SDK0705"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Configuration validation failed. For example, missing required fields, invalid payment method configuration, or incorrect format."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GooglePayPaymentFailedException"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["SDK0702"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Payment processing failed. For example, due to network issues, declined payment, or server errors."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GooglePayDecryptAndTokenVaultFailedException"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["SDK0706"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Payment token decryption or vault storage failed. Check gateway configuration and token handling."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["UnsupportedFundingTypeGooglePaySdkException"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["SDK0108"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Google Pay is not included in the allowed funding types for this session."]}]}]}]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Payment cancellation by the user is not thrown as an exception. Instead, use the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onCancel"]}," callback to handle user cancellations gracefully."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"error-handling-best-practices","__idx":3},"children":["Error handling best practices"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"comprehensive-error-handler","__idx":4},"children":["Comprehensive error handler"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import android.util.Log\nimport com.pxp.checkout.components.googlepay.*\nimport com.pxp.checkout.services.kount.*\nimport com.pxp.checkout.models.*\n\nval config = GooglePayButtonComponentConfig().apply {\n    onError = { error ->\n        // Log error for debugging\n        Log.e(\"GooglePay\", \"Error: ${error::class.simpleName} - ${error.message}\", error)\n        \n        // Handle specific error types\n        val userMessage = when (error) {\n            is GooglePayNotReadyException -> {\n                showAlternativePaymentMethods()\n                \"Google Pay is not available on this device. Please use an alternative payment method.\"\n            }\n            is GooglePayConfigurationValidationFailedException -> {\n                logCriticalError(\"Configuration validation error\", error)\n                \"Payment system temporarily unavailable. Please try again in a few moments.\"\n            }\n            is GooglePayClientNotInitializedException -> {\n                logCriticalError(\"Client not initialised\", error)\n                \"Payment system not ready. Please refresh and try again.\"\n            }\n            is GooglePayLoadFailedException -> {\n                \"Unable to load payment system. Please check your connection and try again.\"\n            }\n            is GooglePayPaymentFailedException -> {\n                \"Payment failed. Please check your payment information and try again.\"\n            }\n            is GooglePayDecryptAndTokenVaultFailedException -> {\n                logCriticalError(\"Token vault error\", error)\n                \"Payment processing error. Please try again.\"\n            }\n            is UnsupportedFundingTypeGooglePaySdkException -> {\n                showAlternativePaymentMethods()\n                \"Google Pay is not available for this session. Please use an alternative payment method.\"\n            }\n            else -> {\n                logCriticalError(\"Unknown error\", error)\n                \"An unexpected error occurred. Please try again or contact support.\"\n            }\n        }\n        \n        showErrorMessage(userMessage)\n    }\n    \n    // Handle user cancellation separately (not an exception)\n    onCancel = {\n        Log.d(\"GooglePay\", \"User cancelled Google Pay\")\n    }\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"troubleshooting-common-issues","__idx":5},"children":["Troubleshooting common issues"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"google-pay-button-isnt-showing","__idx":6},"children":["Google Pay button isn't showing"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The symptoms of this are:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The button is not rendered in the UI."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Empty space where the button should appear."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["No Google Pay option is visible to customers."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"diagnostic-steps","__idx":7},"children":["Diagnostic steps"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import android.accounts.AccountManager\nimport android.os.Build\nimport com.google.android.gms.common.ConnectionResult\nimport com.google.android.gms.common.GoogleApiAvailability\n\n// Check Google Pay availability\nfun checkGooglePayAvailability(context: Context): Boolean {\n    Log.d(\"GooglePay\", \"Checking availability...\")\n    \n    // Check Google Play Services\n    val googleApiAvailability = GoogleApiAvailability.getInstance()\n    val resultCode = googleApiAvailability.isGooglePlayServicesAvailable(context)\n    \n    if (resultCode != ConnectionResult.SUCCESS) {\n        Log.e(\"GooglePay\", \"Google Play Services unavailable: $resultCode\")\n        return false\n    }\n    \n    // Check Android version\n    if (Build.VERSION.SDK_INT < 24) {\n        Log.e(\"GooglePay\", \"Android version too low: ${Build.VERSION.SDK_INT}\")\n        return false\n    }\n    \n    // Check for Google account\n    val accountManager = AccountManager.get(context)\n    val accounts = accountManager.getAccountsByType(\"com.google\")\n    \n    if (accounts.isEmpty()) {\n        Log.w(\"GooglePay\", \"No Google account found\")\n        return false\n    }\n    \n    // Verify payment method configuration\n    val config = getGooglePayConfig()\n    val paymentMethods = config.paymentDataRequest.allowedPaymentMethods\n    \n    if (paymentMethods.isEmpty() || \n        paymentMethods[0].parameters.allowedCardNetworks.isEmpty()) {\n        Log.e(\"GooglePay\", \"Invalid payment method configuration\")\n        return false\n    }\n    \n    Log.d(\"GooglePay\", \"Google Pay is available\")\n    return true\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"solutions","__idx":8},"children":["Solutions"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import androidx.compose.runtime.*\nimport com.pxp.checkout.PxpCheckout\nimport com.pxp.checkout.components.googlepay.*\n\n// Solution 1: Graceful fallback\n@Composable\nfun AdaptivePaymentButtons(pxpCheckout: PxpCheckout) {\n    val googlePayAvailable = remember {\n        checkGooglePayAvailability(context)\n    }\n    \n    if (googlePayAvailable) {\n        GooglePayButton(pxpCheckout)\n    } else {\n        AlternativePaymentMethods()\n    }\n}\n\n// Solution 2: Progressive loading with timeout\n@Composable\nfun GooglePayWithFallback(pxpCheckout: PxpCheckout) {\n    var showGooglePay by remember { mutableStateOf(true) }\n    var isLoading by remember { mutableStateOf(true) }\n    \n    LaunchedEffect(Unit) {\n        withTimeoutOrNull(5000) {\n            delay(100)\n            isLoading = false\n        }\n        \n        if (isLoading) {\n            showGooglePay = false\n            isLoading = false\n        }\n    }\n    \n    when {\n        isLoading -> CircularProgressIndicator()\n        showGooglePay -> GooglePayButton(pxpCheckout)\n        else -> AlternativePaymentMethods()\n    }\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"payment-sheet-not-opening","__idx":9},"children":["Payment sheet not opening"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The symptoms of this are:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Button is visible and clickable but nothing happens."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["No error messages are shown."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Payment sheet doesn't appear after button click."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"diagnostic-steps-1","__idx":10},"children":["Diagnostic steps"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import android.util.Log\nimport com.google.android.gms.common.ConnectionResult\nimport com.google.android.gms.common.GoogleApiAvailability\nimport com.pxp.checkout.components.googlepay.*\nimport kotlinx.coroutines.CompletableDeferred\n\nval config = GooglePayButtonComponentConfig().apply {\n    onGooglePaymentButtonClicked = {\n        Log.d(\"GooglePay\", \"Button clicked\")\n        Log.d(\"GooglePay\", \"Config: $paymentDataRequest\")\n        \n        // Verify Google Play Services\n        val googlePlayAvailable = GoogleApiAvailability.getInstance()\n            .isGooglePlayServicesAvailable(context)\n        \n        if (googlePlayAvailable != ConnectionResult.SUCCESS) {\n            Log.e(\"GooglePay\", \"Google Play Services unavailable: $googlePlayAvailable\")\n        }\n        \n        // Verify amount\n        val amount = paymentDataRequest.transactionInfo.totalPrice.toDoubleOrNull()\n        if (amount == null || amount <= 0) {\n            Log.e(\"GooglePay\", \"Invalid amount: $amount\")\n        }\n        \n        CompletableDeferred(Unit)\n    }\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"solutions-1","__idx":11},"children":["Solutions"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import com.pxp.checkout.PxpCheckout\nimport com.pxp.checkout.components.googlepay.*\nimport kotlinx.coroutines.CompletableDeferred\n\n// Solution 1: Add validation before opening sheet\nval config = GooglePayButtonComponentConfig().apply {\n    onGooglePaymentButtonClicked = {\n        // Validate synchronously\n        val email = getCustomerEmail()\n        if (email.isEmpty() || !email.contains(\"@\")) {\n            showError(\"Please enter a valid email address\")\n            return@onGooglePaymentButtonClicked null\n        }\n        \n        // Validate terms\n        if (!areTermsAccepted()) {\n            showError(\"Please accept terms and conditions\")\n            return@onGooglePaymentButtonClicked null\n        }\n        \n        // Validate amount\n        val amount = paymentDataRequest.transactionInfo.totalPrice.toDoubleOrNull()\n        if (amount == null || amount <= 0) {\n            showError(\"Invalid payment amount\")\n            return@onGooglePaymentButtonClicked null\n        }\n        \n        // All validation passed\n        CompletableDeferred(Unit)\n    }\n}\n\n// Solution 2: Handle configuration errors\nimport android.util.Log\nimport com.pxp.checkout.PxpCheckout\nimport com.pxp.checkout.components.googlepay.*\nimport com.pxp.checkout.types.ComponentType\n\nfun createGooglePayButton(pxpCheckout: PxpCheckout): GooglePayButtonComponent? {\n    return try {\n        validateGooglePayConfiguration(config)\n        \n        pxpCheckout.createComponent<GooglePayButtonComponent, GooglePayButtonComponentConfig>(\n            type = ComponentType.GOOGLE_PAY_BUTTON,\n            config = config\n        )\n    } catch (e: GooglePayConfigurationValidationFailedException) {\n        Log.e(\"GooglePay\", \"Configuration validation failed\", e)\n        showError(\"Payment configuration error. Please contact support.\")\n        showAlternativePaymentMethods()\n        null\n    } catch (e: Exception) {\n        Log.e(\"GooglePay\", \"Failed to create button\", e)\n        showError(\"Unable to initialise Google Pay. Please try again.\")\n        showAlternativePaymentMethods()\n        null\n    }\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"payment-authorisation-failures","__idx":12},"children":["Payment authorisation failures"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The symptoms of this are:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The Google Pay sheet appears but payment fails."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Customer sees a generic error message."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Transaction doesn't complete successfully."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"diagnostic-steps-2","__idx":13},"children":["Diagnostic steps"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import android.util.Log\nimport com.pxp.checkout.PxpCheckout\nimport com.pxp.checkout.components.googlepay.*\nimport com.pxp.checkout.services.kount.*\nimport com.pxp.checkout.models.*\nimport kotlinx.coroutines.async\n\nval config = GooglePayButtonComponentConfig().apply {\n    onPreAuthorisation = suspend { data ->\n        Log.d(\"GooglePay\", \"Pre-authorisation data: $data\")\n        Log.d(\"GooglePay\", \"Gateway token ID: ${data?.gatewayTokenId}\")\n        \n        try {\n            // Validate amount\n            val amount = getOrderTotal()\n            if (amount <= 0) {\n                Log.e(\"GooglePay\", \"Invalid amount: $amount\")\n                throw IllegalStateException(\"Invalid transaction amount\")\n            }\n            \n            // Check inventory\n            val inventoryAvailable = checkInventory()\n            if (!inventoryAvailable) {\n                Log.e(\"GooglePay\", \"Inventory not available\")\n                throw IllegalStateException(\"Items no longer available\")\n            }\n            \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        } catch (e: Exception) {\n            Log.e(\"GooglePay\", \"Pre-authorisation failed\", e)\n            null // Cancel payment\n        }\n    }\n    \n    onPostAuthorisation = { result, paymentData ->\n        when (result) {\n            is MerchantSubmitResult -> {\n                Log.d(\"GooglePay\", \"Payment authorised: ${result.merchantTransactionId}\")\n            }\n            is FailedSubmitResult -> {\n                Log.e(\"GooglePay\", \"Payment failed: ${result.errorCode} - ${result.errorReason}\")\n            }\n        }\n    }\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"solutions-2","__idx":14},"children":["Solutions"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import android.util.Log\nimport kotlinx.coroutines.delay\n\n// Solution 1: Enhanced validation\nfun validatePaymentData(paymentData: Any?): Boolean {\n    require(paymentData != null) { \"Payment data is missing\" }\n    \n    val amount = getOrderTotal()\n    require(amount > 0 && amount < 1000000) { \"Invalid payment amount\" }\n    \n    require(getCurrentCustomerEmail().isNotEmpty()) { \"Customer email is required\" }\n    \n    return true\n}\n\n// Solution 2: Implement retry logic\nsuspend fun processPaymentWithRetry(\n    paymentData: Any,\n    maxRetries: Int = 2\n): PaymentResult {\n    repeat(maxRetries) { attempt ->\n        try {\n            Log.d(\"Payment\", \"Payment attempt ${attempt + 1} of $maxRetries\")\n            return processPayment(paymentData)\n        } catch (e: Exception) {\n            Log.w(\"Payment\", \"Attempt ${attempt + 1} failed: ${e.message}\")\n            \n            if (isRetryableError(e) && attempt < maxRetries - 1) {\n                delay(1000L * (attempt + 1))\n                continue\n            }\n            throw e\n        }\n    }\n    throw IllegalStateException(\"Payment retry logic failed\")\n}\n\nfun isRetryableError(error: Exception): Boolean {\n    val retryableErrors = listOf(\"network error\", \"timeout\", \"temporary failure\")\n    return retryableErrors.any { error.message?.lowercase()?.contains(it) == true }\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"debugging-tools-and-techniques","__idx":15},"children":["Debugging tools and techniques"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"logging-setup","__idx":16},"children":["Logging setup"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import android.content.Context\nimport android.util.Log\nimport android.os.Build\nimport com.google.android.gms.common.ConnectionResult\nimport com.google.android.gms.common.GoogleApiAvailability\nimport com.pxp.checkout.components.googlepay.*\n\n// Log environment information\nfun logGooglePayEnvironment(context: Context) {\n    Log.d(\"GooglePay\", \"=== Environment ===\")\n    Log.d(\"GooglePay\", \"Device: ${Build.MANUFACTURER} ${Build.MODEL}\")\n    Log.d(\"GooglePay\", \"Android: ${Build.VERSION.RELEASE} (SDK ${Build.VERSION.SDK_INT})\")\n    \n    val googlePlayAvailable = GoogleApiAvailability.getInstance()\n        .isGooglePlayServicesAvailable(context)\n    Log.d(\"GooglePay\", \"Google Play Services: $googlePlayAvailable\")\n}\n\n// Log configuration\nfun logGooglePayConfig(config: GooglePayButtonComponentConfig) {\n    Log.d(\"GooglePay\", \"=== Configuration ===\")\n    val method = config.paymentDataRequest.allowedPaymentMethods.firstOrNull()\n    Log.d(\"GooglePay\", \"Card networks: ${method?.parameters?.allowedCardNetworks}\")\n    Log.d(\"GooglePay\", \"Auth methods: ${method?.parameters?.allowedAuthMethods}\")\n    Log.d(\"GooglePay\", \"Amount: ${config.paymentDataRequest.transactionInfo.totalPrice}\")\n    Log.d(\"GooglePay\", \"Currency: ${config.paymentDataRequest.transactionInfo.currencyCode}\")\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"logcat-filtering","__idx":17},"children":["Logcat filtering"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Filter Logcat for Google Pay related logs:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"adb logcat | grep -E \"GooglePay|PxpCheckout\"\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"android-studio-profiler","__idx":18},"children":["Android Studio Profiler"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use Android Studio's built-in profilers to monitor performance, memory usage, and network calls during payment processing."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"prevention-and-best-practices","__idx":19},"children":["Prevention and best practices"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"pre-flight-checks","__idx":20},"children":["Pre-flight checks"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Perform checks before initialising Google Pay to catch issues early:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import android.accounts.AccountManager\nimport android.content.Context\nimport android.os.Build\nimport android.util.Log\nimport com.google.android.gms.common.ConnectionResult\nimport com.google.android.gms.common.GoogleApiAvailability\n\nfun performPreflightChecks(context: Context): Boolean {\n    // Check Google Play Services\n    val googlePlayResult = GoogleApiAvailability.getInstance()\n        .isGooglePlayServicesAvailable(context)\n    if (googlePlayResult != ConnectionResult.SUCCESS) {\n        Log.w(\"GooglePay\", \"Google Play Services unavailable\")\n        return false\n    }\n    \n    // Check Android version\n    if (Build.VERSION.SDK_INT < 24) {\n        Log.w(\"GooglePay\", \"Android version too low\")\n        return false\n    }\n    \n    // Check Google account\n    val accountManager = AccountManager.get(context)\n    if (accountManager.getAccountsByType(\"com.google\").isEmpty()) {\n        Log.w(\"GooglePay\", \"No Google account\")\n        return false\n    }\n    \n    // Check payment configuration\n    val config = getGooglePayConfig()\n    if (config.paymentDataRequest.allowedPaymentMethods.isEmpty()) {\n        Log.w(\"GooglePay\", \"No payment methods configured\")\n        return false\n    }\n    \n    return true\n}\n\n// Use before initialisation\nimport androidx.compose.runtime.*\nimport com.pxp.checkout.PxpCheckout\n\n@Composable\nfun SafeGooglePayButton(pxpCheckout: PxpCheckout) {\n    val isAvailable = remember {\n        performPreflightChecks(context)\n    }\n    \n    if (isAvailable) {\n        GooglePayButton(pxpCheckout)\n    } else {\n        AlternativePaymentMethods()\n    }\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"error-monitoring","__idx":21},"children":["Error monitoring"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Track errors using your preferred monitoring service:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import android.util.Log\nimport com.google.firebase.crashlytics.FirebaseCrashlytics\nimport com.pxp.checkout.components.googlepay.*\nimport com.pxp.checkout.models.*\n\nval config = GooglePayButtonComponentConfig().apply {\n    onError = { error ->\n        // Log to your monitoring service (e.g., Firebase Crashlytics, Sentry)\n        FirebaseCrashlytics.getInstance().apply {\n            setCustomKey(\"component\", \"GooglePay\")\n            setCustomKey(\"error_type\", error::class.simpleName ?: \"Unknown\")\n            recordException(error)\n        }\n        \n        // Show user-friendly message\n        showErrorMessage(error)\n    }\n    \n    onPostAuthorisation = { result, _ ->\n        when (result) {\n            is MerchantSubmitResult -> {\n                Log.d(\"GooglePay\", \"Payment successful: ${result.merchantTransactionId}\")\n            }\n            is FailedSubmitResult -> {\n                Log.e(\"GooglePay\", \"Payment failed: ${result.errorCode}\")\n            }\n        }\n    }\n}\n","lang":"kotlin"},"children":[]}]},"headings":[{"value":"Troubleshooting","id":"troubleshooting","depth":1},{"value":"Exception types and error codes","id":"exception-types-and-error-codes","depth":2},{"value":"Component exceptions","id":"component-exceptions","depth":3},{"value":"Error handling best practices","id":"error-handling-best-practices","depth":2},{"value":"Comprehensive error handler","id":"comprehensive-error-handler","depth":3},{"value":"Troubleshooting common issues","id":"troubleshooting-common-issues","depth":2},{"value":"Google Pay button isn't showing","id":"google-pay-button-isnt-showing","depth":3},{"value":"Diagnostic steps","id":"diagnostic-steps","depth":4},{"value":"Solutions","id":"solutions","depth":4},{"value":"Payment sheet not opening","id":"payment-sheet-not-opening","depth":3},{"value":"Diagnostic steps","id":"diagnostic-steps-1","depth":4},{"value":"Solutions","id":"solutions-1","depth":4},{"value":"Payment authorisation failures","id":"payment-authorisation-failures","depth":3},{"value":"Diagnostic steps","id":"diagnostic-steps-2","depth":4},{"value":"Solutions","id":"solutions-2","depth":4},{"value":"Debugging tools and techniques","id":"debugging-tools-and-techniques","depth":2},{"value":"Logging setup","id":"logging-setup","depth":3},{"value":"Logcat filtering","id":"logcat-filtering","depth":3},{"value":"Android Studio Profiler","id":"android-studio-profiler","depth":3},{"value":"Prevention and best practices","id":"prevention-and-best-practices","depth":2},{"value":"Pre-flight checks","id":"pre-flight-checks","depth":3},{"value":"Error monitoring","id":"error-monitoring","depth":3}],"frontmatter":{"seo":{"title":"Troubleshooting"}},"lastModified":"2026-04-22T10:43:46.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/guides/checkout/components/android/google-pay/troubleshooting","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}