DocumentationRecipesAPI ReferenceChangelog
Documentation

Google Pay Prerequisite

Prerequisite

dependencies {
  
    implementation("com.2c2p:pgw-sdk:4.7.1")
    implementation("com.2c2p:pgw-sdk-helper:4.2.1")
    implementation("com.google.android.gms:play-services-wallet:19.4.0")
      
    //To enable GooglePay in WebView
    implementation("androidx.webkit:webkit:1.14.0")
}

Enabling GooglePay within Webview

Do note the following user device requirements

Google Play services version 25.18.30 or higher
Android Webview for Chrome version 137 or higher

Add the following <queries> tags to your AndroidManifest.xml

<queries>
  <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>
</queries>

Enable the Payment Request API for the WebView

import android.webkit.WebSettings;
import android.webkit.WebView;
import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewFeature;

AndroidView(
    factory = {
        // Update WebView settings to allow JavaScript and payment request
        settings.javaScriptEnabled = true
        WebView(it).apply {
            if (WebViewFeature.isFeatureSupported(
                    WebViewFeature.PAYMENT_REQUEST)) {
                WebSettingsCompat.setPaymentRequestEnabled(settings, true);
            }
        }
    },
    update = {it.loadUrl(url)
    }
)
import android.webkit.WebSettings;
import android.webkit.WebView;
import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewFeature;

WebView webView = findViewById(R.id.webview);
WebSettings webSettings = webView.getSettings();

// Update WebView settings to allow JavaScript and payment request
webSettings.setJavaScriptEnabled(true);
if (WebViewFeature.isFeatureSupported(
          WebViewFeature.PAYMENT_REQUEST)) {
    WebSettingsCompat.setPaymentRequestEnabled(webSettings, true);
}
      

PGW SDK Demo App with GooglePay on WebView

Using Android WebView

Step 1: Check Google Pay brand guidelines on your app.

Reference: brand guidelines

Step 2: About the test environment.


  1. Select integration type as "Gateway" and upload screenshoot of your app. Lastly, submit for approval.
    Reference: brand guidelines
  2. Start to proceed Google Pay once your app approved. Please make sure your integration type are "Gateway".

Step 4: Make sure your app are signed with release key and using production environment.

Reference: deploy your application

Step 5(Optional): Join Google Pay test card suite group.

Reference: test suite group