Skip to content

fix(android): fix Google Pay in WebView — enable Payment Request API by default and add manifest queries#458

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-google-pay-capacitor-v8
Draft

fix(android): fix Google Pay in WebView — enable Payment Request API by default and add manifest queries#458
Copilot wants to merge 3 commits intomainfrom
copilot/fix-google-pay-capacitor-v8

Conversation

Copy link
Contributor

Copilot AI commented Mar 2, 2026

Google Pay was broken in Android WebView due to two separate issues that both needed to be fixed.

Root Causes

1. Missing <queries> in AndroidManifest.xml (the critical fix for Android 11+)

Android 11+ enforces Package Visibility — apps must explicitly declare which intents they need to interact with. Without the three org.chromium.intent.action.PAY, IS_READY_TO_PAY, and UPDATE_PAYMENT_DETAILS intent queries, the WebView cannot discover or communicate with Google Pay at all, so the payment sheet never appears.

2. Payment Request API not enabled by default (required for WebView 120+)

Starting with WebView 120 (ubiquitous on devices running Capacitor v8 apps), Android WebView disables the W3C Payment Request API by default for security. The plugin was only calling WebSettingsCompat.setPaymentRequestEnabled(true) behind enableGooglePaySupport: true (which defaulted to false), so users not explicitly opting in had Google Pay silently fail.

Changes

  • AndroidManifest.xml — Added the three required Payment Request intent queries so Android 11+ Package Visibility allows WebView to communicate with Google Pay:

    <!-- Required for Payment Request API (Google Pay) in WebView on Android 11+ -->
    <intent><action android:name="org.chromium.intent.action.PAY" /></intent>
    <intent><action android:name="org.chromium.intent.action.IS_READY_TO_PAY" /></intent>
    <intent><action android:name="org.chromium.intent.action.UPDATE_PAYMENT_DETAILS" /></intent>
  • WebViewDialog.java — Move setPaymentRequestEnabled(true) outside the enableGooglePaySupport guard; it now runs unconditionally on WebView 120+ (the minimum required by WebViewFeature.PAYMENT_REQUEST). Downgrade the fallback log to Log.w so developers on older WebViews get a visible warning. Removes dead code: setMixedContentMode(MIXED_CONTENT_ALWAYS_ALLOW) that was immediately overridden by MIXED_CONTENT_COMPATIBILITY_MODE in the same block.

  • enableGooglePaySupport now controls only popup-window support (setSupportMultipleWindows) for the OR_BIBED_15 flow — not the Payment Request API.

  • src/definitions.ts — Updated JSDoc to reflect narrowed scope of enableGooglePaySupport and document the WebView 120+ requirement.

Original prompt

This section details on the original issue you should resolve

<issue_title>bug: Google pay not working on capacitor v8</issue_title>
<issue_description> ────────────────────────────────────────────────────────────────────────────────

Bug Report

Capacitor Version

  💊   Capacitor Doctor  💊                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                          
  Latest Dependencies:                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                          
    @capacitor/cli: 8.1.0                                                                                                                                                                                                                                                                 
    @capacitor/core: 8.1.0                                                                                                                                                                                                                                                                
    @capacitor/android: 8.1.0                                                                                                                                                                                                                                                             
    @capacitor/ios: 8.1.0                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                          
  Installed Dependencies:                                                                                                                                                                                                                                                                 
        ...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes Cap-go/capacitor-inappbrowser#456

<!-- START COPILOT CODING AGENT TIPS -->
---

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. [Learn more about Advanced Security.](https://gh.io/cca-advanced-security)

Co-authored-by: riderx <4084527+riderx@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Google Pay not working on Capacitor v8 fix(android): enable Payment Request API by default so Google Pay works without extra config Mar 2, 2026
@riderx
Copy link
Member

riderx commented Mar 3, 2026

@copilot wtf the report of the user stay it stop worked in fucking v8, that was not the problem fix the fucking problem

…or Google Pay

Co-authored-by: riderx <4084527+riderx@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 3, 2026

@copilot wtf the report of the user stay it stop worked in fucking v8, that was not the problem fix the fucking problem

You're right that enabling setPaymentRequestEnabled alone wasn't the full fix. The root cause is two-fold:

  1. AndroidManifest.xml was missing the required <queries> entries (commit bfd93bc) — On Android 11+ Package Visibility rules prevent the WebView from seeing/communicating with payment apps (Google Pay) unless the app explicitly declares the org.chromium.intent.action.PAY, org.chromium.intent.action.IS_READY_TO_PAY, and org.chromium.intent.action.UPDATE_PAYMENT_DETAILS intent queries. Without these, the Payment Request API cannot locate Google Pay and the sheet never appears.

  2. setPaymentRequestEnabled(true) not called by default — Starting with WebView 120 (ubiquitous on devices running Capacitor v8 apps), Android WebView disables the Payment Request API by default for security. The plugin was only enabling it behind enableGooglePaySupport: true (which defaulted to false).

Both changes are now in this PR. The manifest fix is the critical one for Android 11+ (which covers all Capacitor v8 target devices).

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 3, 2026

Copilot AI changed the title fix(android): enable Payment Request API by default so Google Pay works without extra config fix(android): fix Google Pay in WebView — enable Payment Request API by default and add manifest queries Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants