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

Google pay integration using GooglePayLauncher

Open shubhamrb opened this issue 4 years ago • 32 comments

Summary

onGooglePayReady always returns false.

Code to reproduce

final GooglePayLauncher googlePayLauncher = new GooglePayLauncher( this, new GooglePayLauncher.Config( GooglePayEnvironment.Test, "IN", "Widget Store" ), this::onGooglePayReady, this::onGooglePayResult ); private void onGooglePayReady(boolean isReady) { // implemented below binding.btnGPay.setEnabled(isReady); }

Android version

Android version : 9

Impacted devices

Device : MI A1

Installation method

as per the stripe doc https://stripe.com/docs/google-pay

SDK version

SDK version : implementation 'com.stripe:stripe-android:17.1.0'

Other information

shubhamrb avatar Aug 12 '21 11:08 shubhamrb

@shubhamrb I am sorry that onGooglePayReady is always returning false.

In order to test and use Google Pay on a phone you must have the Google Pay App installed, and a payment method added as described here.

Sometime users worry that during testing the payment method attached to their Google Pay account will be charged. If you set the GooglePay configuration to GooglePayEnvironment.Test as shown below, your card will NOT be charged.

        val googlePayLauncher = GooglePayLauncher(
            activity = this,
            config = GooglePayLauncher.Config(
                environment = GooglePayEnvironment.Test,
                merchantCountryCode = "US",
                merchantName = "Widget Store"
            ),
            readyCallback = ::onGooglePayReady,
            resultCallback = ::onGooglePayResult
        )

michelleb-stripe avatar Aug 12 '21 11:08 michelleb-stripe

i've Google pay installed in my phone,

also i've added following lines in my manifest :

meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true"

still facing this issue

shubhamrb avatar Aug 12 '21 11:08 shubhamrb

@shubhamrb Can you share the following values being set in the GooglePayLauncher.Config?

  • environment (GooglePayEnvironment) - Test or Production?
  • merchantCountryCode
  • isEmailRequired - True or False?
  • BillingAddressConfig
    • isRequired - True or False?
    • format - Min or Full?
    • isPhoneNumberRequired - True or False
  • existingPaymentMethodRequired - True or False?

michelleb-stripe avatar Aug 12 '21 13:08 michelleb-stripe

this is in my GooglePayLauncher.Config

new GooglePayLauncher.Config(
                        GooglePayEnvironment.Test,
                        "IN",
                        "Widget Store",
                        false,
                        new GooglePayLauncher.BillingAddressConfig(
                                false, GooglePayLauncher.BillingAddressConfig.Format.Min,
                                true
                        ),true
                )


shubhamrb avatar Aug 12 '21 13:08 shubhamrb

FYI i am using it inside Fragment.

shubhamrb avatar Aug 12 '21 16:08 shubhamrb

@shubhamrb Google Pay is not available across all countries and devices. I am curious if you would be able to test it out on an emulator?

michelleb-stripe avatar Aug 12 '21 20:08 michelleb-stripe

@michelleb-stripe can you please confirm if it is available in India?

and as you suggest for emulator, I will try but i guess in emulator Google pay app won't work

shubhamrb avatar Aug 13 '21 05:08 shubhamrb

@shubhamrb I currently have PaymentSheet from the Stripe SDK working with Google Pay on my emulator, so you shouldn't have any trouble. Specifically I am using Android 10.0 (Google Play), I have also associated my Google account with the phone. I am happy to help if you have any trouble getting it set up.

Based on this page provided by google, I believe it should work in India.

michelleb-stripe avatar Aug 13 '21 12:08 michelleb-stripe

@michelleb-stripe can you please help me with the pseudocose for paymentsheet integration, because i used it previously and it didn't work.

shubhamrb avatar Aug 13 '21 12:08 shubhamrb

@shubhamrb Since you already have GooglePayLauncher configured and setup you can continue to use it. I have verified that GooglePayLauncher will also work on the emulator: Android 10.0 (Google Play).

michelleb-stripe avatar Aug 13 '21 12:08 michelleb-stripe

@michelleb-stripe i tried in emulator also but it didn't work, i don't know i am doing something wrong

shubhamrb avatar Aug 13 '21 13:08 shubhamrb

@shubhamrb I am continue to troubleshoot your issue.

When setting up my account on GooglePay I had to add a card on a real phone, and then use the same GooglePay account on the emulator. (This is because the GooglePay standalone could not be opened on the emulator to setup the card).

Could you share how you configured GooglePay for your account? Which type of card network you associated with your GooglePay account on the emulator. Was it one of these: "AMEX", "DISCOVER", "INTERAC", "JCB", "MASTERCARD", "VISA"? Or did you connect Google Pay to your bank account and using the wallet functionality?

michelleb-stripe avatar Aug 13 '21 14:08 michelleb-stripe

@michelleb-stripe i didn't have any card in my Google pay account, i have connected by bank account using registered mobile number.

shubhamrb avatar Aug 13 '21 14:08 shubhamrb

@shubhamrb Google Pay lists the supported PaymentMethods here. As of today, they support a limited number of Cards or PayPal. Unfortunately a connected bank account is not supported.

Today the SDK works with a subset of what Google Pay supports. It should work with the following cards: "AMEX", "DISCOVER", "MASTERCARD", "VISA". It should work for pre-paid cards as well.

michelleb-stripe avatar Aug 13 '21 18:08 michelleb-stripe

@michelleb-stripe that's really unfortunate and strange bcz most no. of user in India uses their bank account in GPay not cards. anyways thanks for the help. hope Stripe resolve it soon.

shubhamrb avatar Aug 14 '21 05:08 shubhamrb

@shubhamrb Unfortunately we will not be able to resolve this issue until Google supports this in their API. We will keep watching for when they publish new support and add it when it becomes available.

michelleb-stripe avatar Aug 16 '21 21:08 michelleb-stripe

Hello @michaelc-stripe

onGooglePayReady always returns false. And My G-Pay Account "MASTERCARD" and "VISA" Card are both links but still always return false. Can you please guide me?

googlePayLauncher = GooglePayLauncher( activity = this, config = GooglePayLauncher.Config( environment = GooglePayEnvironment.Test, merchantCountryCode = "US", merchantName = "Widget Store" ), readyCallback = ::onGooglePayReady, resultCallback = ::onGooglePayResult )

      private fun onGooglePayReady(isReady: Boolean) {
  
         btngooglePayButton.isEnabled = isReady
      }

private fun onGooglePayResult(
    result: GooglePayLauncher.Result
) {
    when (result) {
        is GooglePayLauncher.Result.Completed -> {
              }
        GooglePayLauncher.Result.Canceled -> {
          }
        is GooglePayLauncher.Result.Failed -> {
            }
    }
}

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.

Always returns false.

bridgingamit18 avatar Aug 18 '21 10:08 bridgingamit18

Hello @michaelc-stripe

onGooglePayReady always returns false. And My G-Pay Account "MASTERCARD" and "VISA" Card are both links but still always return false. Can you please guide me?

googlePayLauncher = GooglePayLauncher( activity = this, config = GooglePayLauncher.Config( environment = GooglePayEnvironment.Test, merchantCountryCode = "US", merchantName = "Widget Store" ), readyCallback = ::onGooglePayReady, resultCallback = ::onGooglePayResult )

      private fun onGooglePayReady(isReady: Boolean) {
  
         btngooglePayButton.isEnabled = isReady
      }

private fun onGooglePayResult(
    result: GooglePayLauncher.Result
) {
    when (result) {
        is GooglePayLauncher.Result.Completed -> {
              }
        GooglePayLauncher.Result.Canceled -> {
          }
        is GooglePayLauncher.Result.Failed -> {
            }
    }
}

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.

Always returns false.

I have the same problem, but I guess it might be because I don't have a payment card in my Google account (I can't add a payment card to my account), so I decided to let my customer test it out

Qiubeijun avatar Aug 19 '21 08:08 Qiubeijun

Hello @michaelc-stripe and @Qiubeijun In my G-Pay Account, I have added a payment card as well but still, I have received onGooglePayReady always returns false.

bridgingamit18 avatar Aug 19 '21 09:08 bridgingamit18

I think i got the issue

https://github.com/stripe/stripe-android/blob/master/payments-core/src/main/java/com/stripe/android/googlepaylauncher/GooglePayRepository.kt#L26-L53

In DefaultGooglePayRepository the value of existingPaymentMethodRequired is always true, the value is not taking from Config

bhomaramgtsinfo avatar Sep 01 '21 06:09 bhomaramgtsinfo

@michelleb-stripe hello , I have the same problem and visa in my google play account and "com.google.android.gms:play-services-wallet:18.1.3" "" is added please help me ,I don't know do something

xiuone avatar Oct 13 '21 09:10 xiuone

@bridgingamit18 hello ,are you solve?

xiuone avatar Oct 13 '21 09:10 xiuone

No @xiuone I have shared the source code with the striped team. During testing for my demo with the striped team it's working fine. But my end is not working still.

bridgingamit18 avatar Oct 13 '21 09:10 bridgingamit18

getting Google Pay is available in device even installed in app along with added payment method. getting this issue in some devices.

projects-mindiii avatar Oct 27 '21 13:10 projects-mindiii

any news?

periva101 avatar Dec 27 '21 06:12 periva101

In order to test and use Google Pay on a phone you must have the Google Pay App installed, and a payment method added as described here.

I think this assumption might not be entirely correct. In my scenario I have google account which uses Google provided Test Card suite. And if you are setting allowed auth methods to include PAN_ONLY, it should work WITHOUT actual Card saved in Google Pay app on phone. But when I test it on old emulator (API 23) I get onGooglePayReady returning value false. So it seems like PAN_ONLY auth method gets ignored?

onGooglePayReady returns true when real device is used which has the Google Pay app installed and card registered.

Vkalns avatar Feb 01 '22 11:02 Vkalns

any news here?

I have a same issue.

But, when I tested with a google wallet library not using stripe library, I can get a true value from ready callback listener.

I created a PaymentsClient directly with same Test Environment, and added cards listof (AMEX, DISCOVER, JCB, MASTERCARD, VISA), afterwards, I was able to get a true value.

Is it related with a Country Code?? It seems like It might affect list of available cards.

Please give me a clue for it

Pulit avatar Apr 13 '22 07:04 Pulit

I am facing the same issue. I have tried it on multiple android devices but the ready callback is always false. I have also tried multiple merchant ids including: US, IN, HK - same result.

dasprasky avatar Apr 19 '22 05:04 dasprasky

We found the solution of the ready callback returning false. Anyone who has trouble of ready callback always returns false, Please check the sim-card's country code. On our case, the google pay is only enabled with only sim-card of google pay available countries (such as JP). The device with sim-card of google pay not available country (such as KR), ready callback always returns false.

Pulit avatar Apr 25 '22 04:04 Pulit

I am still facing this issue. Any update on this?

milanvadhel-mi avatar May 10 '22 05:05 milanvadhel-mi