Sign in
An image of the Stripe logo
Create account
Sign in
Home
Payments
Business operations
Financial services
Developer tools
No-code
All products
Home
Payments
Business operations
Home
Payments
Business operations
Financial services
Developer tools
Overview
Online payments
Products and prices
Invoicing
Subscriptions
Quotes
In-person payments
Multiparty payments
After the payment
Add payment methods
    Overview
    Payment method integration options
    Bank debits
    Bank redirects
    Bank transfers
    Buy now, pay later
    Credit transfers (Sources)
    Real-time payments
    Vouchers
    Wallets
      Alipay
      Apple Pay
      Cash App Pay
      Google Pay
      GrabPay
      MobilePay
      Secure Remote Commerce
      WeChat Pay
Payment Links
Stripe Checkout
Stripe Elements
About the APIs
Regulation support
Implementation guides
Testing
HomePaymentsWallets

Google Pay

Learn how to accept payments using Google Pay.

Google Pay terms

By integrating Google Pay, you agree to Google’s terms of service.

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, subscriptions), 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 more.

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.

Set up your integration

To use Google Pay, first enable the Google Pay API by adding the following to the <application> tag of your AndroidManifest.xml:

AndroidManifest.xml
<application> ... <meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true" /> </application>

This guide assumes you’re using the latest version of the Stripe Android SDK.

build.gradle
dependencies { implementation 'com.stripe:stripe-android:20.21.1' }

For more details, see Google Pay’s Set up Google Pay API for Android.

Instantiate GooglePayLauncher

Next, create an instance of GooglePayLauncher in your Activity or Fragment. This must be done in Activity#onCreate().

GooglePayLauncher.Config exposes both required and optional properties that configure GooglePayLauncher. See GooglePayLauncher.Config for more details on the configuration options.

class CheckoutActivity : AppCompatActivity() { // fetch client_secret from backend private lateinit var clientSecret: String private lateinit var googlePayButton: Button override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.checkout_activity) PaymentConfiguration.init(this, PUBLISHABLE_KEY) googlePayButton = findViewById<Button>(R.id.google_pay_button) val googlePayLauncher = GooglePayLauncher( activity = this, config = GooglePayLauncher.Config( environment = GooglePayEnvironment.Test, merchantCountryCode = "US", merchantName = "Widget Store" ), readyCallback = ::onGooglePayReady, resultCallback = ::onGooglePayResult ) googlePayButton.setOnClickListener { // launch `GooglePayLauncher` to confirm a Payment Intent googlePayLauncher.presentForPaymentIntent(clientSecret) } } private fun onGooglePayReady(isReady: Boolean) { // implemented below } private fun onGooglePayResult(result: GooglePayLauncher.Result) { // implemented below } }

After instantiating GooglePayLauncher, the GooglePayLauncher.ReadyCallback 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.

class CheckoutActivity : AppCompatActivity() { // continued from above private lateinit var googlePayButton: Button private fun onGooglePayReady(isReady: Boolean) { googlePayButton.isEnabled = isReady } }

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).

class CheckoutActivity : AppCompatActivity() { // fetch client_secret from backend private lateinit var clientSecret: String private lateinit var googlePayButton: Button override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // instantiate `googlePayLauncher` googlePayButton.setOnClickListener { // launch `GooglePayLauncher` to confirm a Payment Intent googlePayLauncher.presentForPaymentIntent(clientSecret) } } }

Handle the result

Finally, implement GooglePayLauncher.ResultCallback to handle the result of the GooglePayLauncher operation.

The result can be GooglePayLauncher.Result.Completed, GooglePayLauncher.Result.Canceled, or GooglePayLauncher.Result.Failed.

class CheckoutActivity : AppCompatActivity() { // continued from above private fun onGooglePayResult(result: GooglePayLauncher.Result) { when (result) { GooglePayLauncher.Result.Completed -> { // Payment succeeded, show a receipt view } GooglePayLauncher.Result.Canceled -> { // User canceled the operation } is GooglePayLauncher.Result.Failed -> { // Operation failed; inspect `result.error` for the exception } } } }

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.

After your app has been approved, test your integration in production by setting the environment to GooglePayEnvironment.Production, and launching Google Pay from a signed, release build of your app. Remember to use your live mode API keys. You can use a PaymentIntent with capture_method = manual to process a transaction without capturing the payment.

Creating a PaymentMethod

If you confirm your payment on your server, you can use GooglePayPaymentMethodLauncher to only collect a PaymentMethod instead of confirm payment.

class CheckoutActivity : AppCompatActivity() { private lateinit var googlePayButton: Button override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.checkout_activity) PaymentConfiguration.init(this, PUBLISHABLE_KEY) googlePayButton = findViewById<Button>(R.id.google_pay_button) val googlePayLauncher = GooglePayPaymentMethodLauncher( activity = this, config = GooglePayPaymentMethodLauncher.Config( environment = GooglePayEnvironment.Test, merchantCountryCode = "FR", merchantName = "Widget Store" ), readyCallback = ::onGooglePayReady, resultCallback = ::onGooglePayResult ) googlePayButton.setOnClickListener { googlePayLauncher.present( currencyCode = "EUR", amount = 2500 ) } } private fun onGooglePayReady(isReady: Boolean) { googlePayButton.isEnabled = isReady } private fun onGooglePayResult( result: GooglePayPaymentMethodLauncher.Result ) { when (result) { is GooglePayPaymentMethodLauncher.Result.Completed -> { // Payment details successfully captured. // Send the paymentMethodId to your server to finalize payment. val paymentMethodId = result.paymentMethod.id } GooglePayPaymentMethodLauncher.Result.Canceled -> { // User canceled the operation } is GooglePayPaymentMethodLauncher.Result.Failed -> { // Operation failed; inspect `result.error` for the exception } } } }
Was this page helpful?
Need help? Contact Support.
Watch our developer tutorials.
Check out our product changelog.
Questions? Contact Sales.
Powered by Markdoc
You can unsubscribe at any time. Read our privacy policy.
On this page
Accept a payment using Google Pay in your Android app
Set up your integration
Instantiate GooglePayLauncher
Launch GooglePayLauncher
Handle the result
Going live with Google Pay
Creating a PaymentMethod
Stripe Shell
Test mode
Welcome to the Stripe Shell! Stripe Shell is a browser-based shell with the Stripe CLI pre-installed. Login to your Stripe account and press Control + Backtick on your keyboard to start managing your Stripe resources in test mode. - View supported Stripe commands: - Find webhook events: - Listen for webhook events: - Call Stripe APIs: stripe [api resource] [operation] (e.g. )
The Stripe Shell is best experienced on desktop.
$