Google Pay
Learn how to accept payments using Google Pay.
Google Pay allows customers to make payments in your app or website using any credit or debit card saved to their Google Account, including those from Google Play, YouTube, Chrome, or an Android device. Use the Google Pay API to request any credit or debit card stored in your customerβs Google account.
Google Pay is fully compatible with Stripeβs products and features (for example, recurring payments), allowing you to use it in place of a traditional payment form whenever possible. Use it to accept payments for physical goods, donations, subscriptions, and so on.
Google Pay terms
By integrating Google Pay, you agree to Googleβs terms of service.
Using Stripe and Google Pay versus the Google Play billing system
For sales of physical goods and services, your app can accept Google Pay or any other Stripe-supported payment method. Those payments are processed through Stripe, and you only need to pay Stripeβs processing fees. However, in-app purchases of digital products and content must use the Google Play billing system. Those payments are processed by Google and are subject to their transaction fees.
For more information about which purchases must use the Google Play billing system, see Google Playβs developer terms.
Accept a payment using Google Pay in your Android app
GooglePayLauncher, part of the Stripe Android SDK, is the fastest and easiest way to start accepting Google Pay in your Android apps.
Prerequisites
To support Google Pay in Android, you need the following:
- A
minSdkVersionof19or higher. - A
compileSdkVersionof28or higher.
Additionally, if you wish to test with your own device, you need to add a payment method to your Google Account.
Set up your integration
This guide assumes youβre using the latest version of the Stripe Android SDK.
To use Google Pay, first enable the Google Pay API by adding the following to the <application> tag of your AndroidManifest.xml:
<application> ... <meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true" /> </application>
For more details, see Google Payβs Set up Google Pay API for Android.
Create a PaymentIntent
Server-side
Create a PaymentIntent on your server with an amount and currency. Always decide how much to charge on the server side, a trusted environment, as opposed to the client side. This prevents malicious customers from choosing their own prices.
Client-side
A PaymentIntent includes a client secret. You can use the client secret in your Android app to securely complete the payment process instead of passing the entire PaymentIntent object. In your app, request a PaymentIntent from your server and store its client secret.
Add the Google Pay button
Add the Google Pay button to your app by following Googleβs tutorial. This ensures youβre using the correct assets.
Instantiate GooglePayLauncher
Next, create an instance of GooglePayLauncher in your Activity or Fragment. This must be done in Activity#onCreate().
GooglePayLauncher. exposes both required and optional properties that configure GooglePayLauncher. See GooglePayLauncher. for more details on the configuration options.
After instantiating GooglePayLauncher, the GooglePayLauncher. instance is called with a flag indicating whether Google Pay is available and ready to use. This flag can be used to update your UI to indicate to your customer that Google Pay is ready to be used.
Launch GooglePayLauncher
After Google Pay is available and your app has obtained a PaymentIntent or SetupIntent client secret, launch GooglePayLauncher using the appropriate method. When confirming a PaymentIntent, use GooglePayLauncher#presentForPaymentIntent(clientSecret). When confirming a SetupIntent, use GooglePayLauncher#presentForSetupIntent(clientSecret).
Handle the result
Finally, implement GooglePayLauncher. to handle the result of the GooglePayLauncher operation.
The result can be GooglePayLauncher., GooglePayLauncher., or GooglePayLauncher..
Going live with Google Pay
Follow Googleβs instructions to request production access for your app. Choose the integration type Gateway when prompted, and provide screenshots of your app for review.