{"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 web."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"overview","__idx":1},"children":["Overview"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Google Pay component 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 error 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":["Shipping address and billing address formats are correct."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Browser and 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":{"width":"40%","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":["INVALID_DISPLAY_ITEMS"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Display items invalid."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Malformed line items."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["INVALID_SHIPPING_OPTIONS"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Shipping options invalid."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Malformed shipping configuration."]}]},{"$$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":["Unsupported browser/device."]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"validation-example","__idx":4},"children":["Validation example"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Example of handling validation errors\nconst googlePayConfig = {\n  // ... configuration\n  onError: (error) => {\n    if (error.code === 'SDK0705') { // GOOGLE_PAY_CONFIGURATION_VALIDATION_FAILED\n      console.error('Google Pay configuration validation failed:', error.message);\n      \n      // Handle specific validation errors based on error message\n      if (error.message.includes('allowedPaymentMethods')) {\n        console.error('Invalid payment methods configuration');\n        showError('Payment configuration error. Please contact support.');\n      }\n      \n      if (error.message.includes('totalPrice')) {\n        console.error('Invalid total price format');\n        showError('Payment amount error. Please refresh and try again.');\n      }\n      \n      if (error.message.includes('gatewayMerchantId') || error.message.includes('merchant ID')) {\n        console.error('Gateway merchant ID missing or invalid');\n        showError('Payment system configuration error. Please contact support.');\n      }\n      \n      // Log for debugging\n      console.error('Validation error details:', {\n        message: error.message,\n        code: error.code\n      });\n    }\n  }\n};\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"custom-validation","__idx":5},"children":["Custom validation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Implement custom validation logic before allowing the Google Pay sheet to open."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"const googlePayConfig = {\n  onCustomValidation: async () => {\n    const validations = [];\n    \n    // 1. Validate email\n    const email = document.getElementById('email')?.value;\n    if (!email || !/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email)) {\n      validations.push('Please enter a valid email address');\n    }\n    \n    // 2. Validate terms acceptance\n    const termsAccepted = document.getElementById('terms')?.checked;\n    if (!termsAccepted) {\n      validations.push('Please accept the terms and conditions');\n    }\n    \n    // 3. Validate minimum order amount\n    const orderTotal = getOrderTotal();\n    const minimumOrderAmount = 10.00;\n    if (orderTotal < minimumOrderAmount) {\n      validations.push(`Minimum order amount is $${minimumOrderAmount.toFixed(2)}`);\n    }\n    \n    // 4. Validate inventory availability\n    try {\n      const inventoryCheck = await checkInventoryAvailability();\n      if (!inventoryCheck.allAvailable) {\n        validations.push('Some items in your cart are no longer available');\n      }\n    } catch (error) {\n      validations.push('Unable to verify inventory. Please try again.');\n    }\n    \n    // 5. Validate customer eligibility\n    const customerEligible = await checkCustomerEligibility();\n    if (!customerEligible) {\n      validations.push('Google Pay is not available for your account');\n    }\n    \n    // Show errors if any\n    if (validations.length > 0) {\n      showValidationErrors(validations);\n      return false; // Prevent payment sheet from opening\n    }\n    \n    return true; // All validations passed\n  }\n};\n\nfunction showValidationErrors(errors) {\n  const errorContainer = document.getElementById('validation-errors');\n  errorContainer.innerHTML = `\n    <div class=\"error-message\">\n      <h4>Please fix the following errors:</h4>\n      <ul>\n        ${errors.map(error => `<li>${error}</li>`).join('')}\n      </ul>\n    </div>\n  `;\n  errorContainer.style.display = 'block';\n  \n  // Scroll to errors\n  errorContainer.scrollIntoView({ behavior: 'smooth', block: 'center' });\n}\n","lang":"typescript"},"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},{"value":"Custom validation","id":"custom-validation","depth":2}],"frontmatter":{"seo":{"title":"Data validation"}},"lastModified":"2026-02-26T12:14:32.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/guides/checkout/components/web/google-pay/data-validation","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}