{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-guides/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["sub-heading"]},"type":"markdown"},"seo":{"title":"Data validation","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":"data-validation","__idx":0},"children":["Data validation"]},{"$$mdtype":"Tag","name":"SubHeading","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Learn about built-in validation and implement additional scenarios for Google Pay on Android."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"overview","__idx":1},"children":["Overview"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Google Pay component for Android includes comprehensive validation to ensure data integrity and compliance with Google's requirements. All built-in validation is performed before creating payment requests and during the Google Pay flow. If validation fails, the SDK will throw an exception with detailed information."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can also easily build custom validation, depending on your business needs."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"built-in-validation","__idx":2},"children":["Built-in validation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["By default, the Google Pay component validates that:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Fields marked as required are provided."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Payment request data meets Google Pay API specifications."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Currency codes, country codes, and amounts are formatted properly."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Allowed payment methods and networks are properly configured."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Transaction information is complete and valid."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Android-specific requirements are met (Google Play Services, API level, permissions)."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Device compatibility requirements are met."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"error-codes","__idx":3},"children":["Error codes"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Google Pay component returns structured error codes for different validation failures:"]},{"$$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":"Error code"},"children":["Error code"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Common causes"},"children":["Common causes"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["REQUIRED_FIELD"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A required field is missing."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Missing mandatory configuration."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["INVALID_AMOUNT_FORMAT"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The amount format is invalid."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Non-string or negative amount."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["INVALID_CURRENCY_CODE"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The currency code is invalid."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Non-ISO 4217 currency format."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["INVALID_COUNTRY_CODE"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The country code is invalid."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Non-ISO 3166-1 alpha-2 format."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["INVALID_PAYMENT_METHOD"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Payment method configuration invalid."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Unsupported payment method type."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["INVALID_CARD_NETWORKS"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Card networks invalid."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Unsupported network values."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["INVALID_AUTH_METHODS"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Authentication methods invalid."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Unsupported auth method values."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["INVALID_TRANSACTION_INFO"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Transaction info invalid."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Malformed transaction data."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["INVALID_TOTAL_PRICE_STATUS"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Total price status invalid."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Invalid status value."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GOOGLE_PAY_NOT_AVAILABLE"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Google Pay not available."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Google Play Services not available."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ANDROID_VERSION_TOO_LOW"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Android version insufficient."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Device running Android < 7.0."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["MISSING_PERMISSIONS"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Required permissions missing."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["AndroidManifest.xml not configured."]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"validation-example","__idx":4},"children":["Validation example"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"import android.util.Log\nimport com.pxp.checkout.components.googlepay.*\n\n// Handle validation errors\nval googlePayConfig = GooglePayButtonComponentConfig().apply {\n    // ... configuration\n    \n    onError = { error ->\n        when (error) {\n            is GooglePayConfigurationValidationFailedException -> {\n                Log.e(\"GooglePay\", \"Configuration validation failed: ${error.message}\")\n                \n                // Handle specific validation errors\n                val message = error.message ?: \"\"\n                \n                when {\n                    message.contains(\"allowedPaymentMethods\") -> {\n                        Log.e(\"GooglePay\", \"Invalid payment methods configuration\")\n                        showError(\"Payment configuration error. Please contact support.\")\n                    }\n                    message.contains(\"totalPrice\") -> {\n                        Log.e(\"GooglePay\", \"Invalid total price format\")\n                        showError(\"Payment amount error. Please refresh and try again.\")\n                    }\n                    message.contains(\"gatewayMerchantId\") || message.contains(\"merchant ID\") -> {\n                        Log.e(\"GooglePay\", \"Gateway merchant ID missing or invalid\")\n                        showError(\"Payment system configuration error. Please contact support.\")\n                    }\n                    else -> {\n                        showError(\"Payment configuration error.\")\n                    }\n                }\n                \n                // Log for debugging\n                Log.e(\"GooglePay\", \"Validation error details: ${error.stackTraceToString()}\")\n            }\n            else -> {\n                Log.e(\"GooglePay\", \"Payment error\", error)\n            }\n        }\n    }\n}\n","lang":"kotlin"},"children":[]}]},"headings":[{"value":"Data validation","id":"data-validation","depth":1},{"value":"Overview","id":"overview","depth":2},{"value":"Built-in validation","id":"built-in-validation","depth":2},{"value":"Error codes","id":"error-codes","depth":3},{"value":"Validation example","id":"validation-example","depth":3}],"frontmatter":{"seo":{"title":"Data validation"}},"lastModified":"2026-03-05T15:56:00.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/guides/checkout/components/android/google-pay/data-validation","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}