stripe-android icon indicating copy to clipboard operation
stripe-android copied to clipboard

[BUG] [Google Pay] Google pay no show in test environment

Open ningkanggithub opened this issue 2 years ago • 8 comments

Summary

The google account has been added to the Google Pay API Test Cards Allowlist. In the Test environment, the Google pay option is not displayed.

Code to reproduce

Android version

Impacted devices

Installation method

Dependency Versions

kotlin: stripe-android: Android Gradle Plugin: Gradle:

SDK classes

Video

Other information

ningkanggithub avatar Aug 31 '23 09:08 ningkanggithub

@ningkanggithub can you provide more details, such as code to reproduce, the android version and device you are using?

james-woo avatar Aug 31 '23 16:08 james-woo

I use Finalize payments on the server + SetupIntent + FlowController flow.

At present, the google pay button cannot be displayed in the test environment. Looking at the source code, it seems to be caused by the default value of existingPaymentMethodRequired being true, but I have no way to modify it.

This question is not directly related to android version and device

ningkanggithub avatar Sep 01 '23 01:09 ningkanggithub

My question is why does the google play option show that it is directly related to whether there is a card under the account? And it cannot be changed

ningkanggithub avatar Sep 01 '23 01:09 ningkanggithub

Please take a look at this question Because I think it is unreasonable to only display the Google pay button when the user actually adds a valid credit card. It is more reasonable to let the user add a card manually if there is no card when the user clicks.

ningkanggithub avatar Sep 05 '23 08:09 ningkanggithub

@ningkanggithub can you please provide sample code? It is hard to diagnose the issue without any example code.

jameswoo-stripe avatar Sep 12 '23 18:09 jameswoo-stripe

val googlePayConfiguration = PaymentSheet.GooglePayConfiguration(
            environment = PaymentSheet.GooglePayConfiguration.Environment.Test,
            countryCode = "US",
            currencyCode = localCurrency // Required for Setup Intents, optional for Payment Intents
        )
val configResult = suspendCancellableCoroutine { coroutine ->
            flowController.configureWithIntentConfiguration(
                intentConfiguration = PaymentSheet.IntentConfiguration(
                    mode = PaymentSheet.IntentConfiguration.Mode.Setup(
                        currency = localCurrency,
                    ),
                ),
                configuration = configuration,
                callback = { success, error ->
                    val option = flowController.getPaymentOption()
                    paymentOptionCallback.invoke(option)
                    if (success) {
                        Tracker.v("config flow success:$option")
                        configSuccess = true
                        coroutine.resume(true)
                    } else {
                        Tracker.e("config flow fail:${error?.localizedMessage}")
                        configSuccess = false
                        configFailCallback.invoke(error, echoFail)
                        coroutine.resume(false)
                    }
                },
            )
        }

My google account has been added to the Google Pay API Test Cards Allowlist. In the Test environment, The Google Pay options are never shown.

ningkanggithub avatar Sep 13 '23 02:09 ningkanggithub

See Google Pay API docs here:

Note: In the TEST environment, if you set existingPaymentMethodRequired to true 
in an IsReadyToPay() request, the response always returns true.

Currently the Stripe only supports the case where the user has an existing card. If you are having trouble seeing the Google Pay button, make sure that your Google Pay account has existing payment methods. If it has existing payment methods make sure that the following is true:

For PAN_ONLY (alone or with CRYPTOGRAM_3DS), 'IsReadyToPay' will return a) true if 'existingPaymentMethodRequired' is not set or false (as the user can log in / add a card), b) true if 'existingPaymentMethodRequired' is true and the user has a matching card type.

For DPAN only - CRYPTOGRAM_3DS, 'IsReadyToPay' will return a) false if the user has no matching device DPAN (regardless of 'existingPaymentMethodRequired' status), b) true if the user has a matching device DPAN (regardless of 'existingPaymentMethodRequired' status).

If all of the above is true and you are still not seeing the Google Pay button, try using a real device, as I have also noticed issues seeing the Google Pay button on emulators.

jameswoo-stripe avatar Sep 13 '23 20:09 jameswoo-stripe

As for my case, Google Pay option didn't show if I use PaymentSheet.GooglePayConfiguration.Environment.Test with PaymentSheet.

paymentSheet.presentWithPaymentIntent(
    paymentIntentClientSecret = ...,
    configuration = PaymentSheet.Configuration(
        merchantDisplayName = ...,
        customer = ...,
        googlePay = PaymentSheet.GooglePayConfiguration(
            environment = PaymentSheet.GooglePayConfiguration.Environment.Test,    // <--
            countryCode = "US",
        ),
    )
)

The solution was to 1) install Google Pay app (https://play.google.com/store/search?q=google+pay&c=apps) and 2) add a payment to Google Pay app.

Note that Google Pay app doesn't work on a rooted device nor an emulator, even if the emulator has Play Store app.

If you want to handle Google Pay transaction yourself (i.e. not as a part of PaymentSheet) consider using GooglePayLauncher (https://github.com/stripe/stripe-android/blob/master/example/src/main/java/com/stripe/example/activity/GooglePayLauncherComposeActivity.kt).

solamour avatar Dec 14 '23 19:12 solamour

Thanks for the response solamour. We ensure google pay is setup before showing it.

jaynewstrom-stripe avatar Jun 17 '24 18:06 jaynewstrom-stripe