Enable Google Pay in Android WebView

Google for DevelopersAbout 3 min readJul 3, 2025Watch original
THE SUMMARYAI-generated

Key Concepts:

  • Android WebView
  • Google Pay integration
  • androidx.webkit dependency
  • Payment Request API
  • AndroidManifest configuration
  • Pay and Wallet Console

Google Pay Support in Android WebView

The video announces the support of Google Pay within Android WebView, enabling seamless purchases for users through an Android-native experience. Users can leverage device tokens from their Google Wallet, providing high-quality tokens for transactions.

Benefits of Using Google Pay in WebView:

  • Seamless purchase experience for users.
  • Android-native experience.
  • Utilization of device tokens from Google Wallet.
  • High-quality tokens for transactions.
  • Increased checkout speed.
  • Improved user experience.

Steps to Enable Google Pay in Android WebView:

  1. Add or Update androidx.webkit Dependency:

    • Add the androidx.webkit dependency to your Android project using your build system (e.g., Gradle).
    • If already using androidx.webkit, ensure the version is 1.14.0 or higher.
    • Example: implementation "androidx.webkit:webkit:1.14.0" (or higher).
  2. Testing Environment:

    • Test on a device with Chrome version 137 or higher.
    • Ensure Google Play services version is 25.18.30 or higher.
  3. AndroidManifest Configuration:

    • Adjust the AndroidManifest.xml file to allow Chromium-defined actions: PAY, IS_READY_TO_PAY, and UPDATE_PAYMENT_DETAILS.
    • This involves adding intent filters to the relevant activity or service declarations.
  4. Enable Payment Request API:

    • Enable the Payment Request API for the WebView using the WebSettingsCompat directive from the androidx.webkit dependency.
    • Use the correct import statement for WebSettingsCompat.
    • Example:
      import androidx.webkit.WebSettingsCompat;
      import androidx.webkit.WebViewFeature;
      
      if (WebViewFeature.isFeatureSupported(WebViewFeature.PAYMENT_REQUEST_API)) {
          WebSettingsCompat.setPaymentRequestEnabled(webView.getSettings(), true);
      }
      

Important Considerations:

  • Pay and Wallet Console Approval: Your application needs to be approved in the Pay and Wallet Console before using Google Pay in production.
  • Support Team Approval: Await approval from the Google Pay support team.

Technical Terms and Concepts:

  • Android WebView: A system component that allows Android apps to display web pages.
  • androidx.webkit: A support library providing backward-compatible features for WebView.
  • Payment Request API: A web standard that simplifies the checkout process by providing a consistent interface for payment methods.
  • AndroidManifest.xml: The configuration file for Android apps, specifying permissions, components, and other metadata.
  • WebSettingsCompat: A class in the androidx.webkit library that provides compatibility methods for WebView settings.
  • Device Tokens: Cryptographic tokens representing a user's payment credentials stored in Google Wallet.
  • Pay and Wallet Console: Google's platform for managing Google Pay integrations and configurations.

Logical Connections:

The video logically connects the need for Google Pay integration in WebViews with the steps required to implement it. It starts by highlighting the benefits, then provides a step-by-step guide, and concludes with important considerations and resources.

Conclusion:

Integrating Google Pay within Android WebView can be achieved with a few straightforward steps, primarily involving adding the androidx.webkit dependency, configuring the AndroidManifest.xml, and enabling the Payment Request API. This integration offers a seamless and improved checkout experience for users, leading to increased checkout speed and overall user satisfaction. Remember to get your application approved in the Pay and Wallet Console before deploying to production.

AI summaries can miss context or contain errors. Check important details against the original video.

Go a little deeper.

Have a question about this video? Load its transcript to open the video chat.