flutter-plugin icon indicating copy to clipboard operation
flutter-plugin copied to clipboard

Google Play button not visible

Open HaardikBhagtani opened this issue 2 years ago • 31 comments

this error seems to be coming in adb logcat and Google Pay button not visible instead childOnError triggered.

04-01 02:23:13.308 3020 15516 W TapAndPay: shouldEnableGooglePay: false [CONTEXT service_id=79 ] 04-01 02:23:13.308 3020 15516 I TapAndPay: Disabling TapAndPay HCE service [CONTEXT service_id=79 ] 04-01 02:23:13.375 3020 15516 W TapAndPay: shouldEnableGooglePay: false [CONTEXT service_id=79 ] 04-01 02:23:13.376 3020 15516 I TapAndPay: Disabling TapAndPay HCE service [CONTEXT service_id=79 ] 04-01 02:23:13.400 3020 15516 W TapAndPay: shouldEnableGooglePay: false [CONTEXT service_id=79 ] 04-01 02:23:13.400 3020 15516 I TapAndPay: Disabling TapAndPay HCE service [CONTEXT service_id=79 ] 04-01 02:23:13.409 3020 15516 W TapAndPay: shouldEnableGooglePay: false [CONTEXT service_id=79 ] 04-01 02:23:13.409 3020 15516 I TapAndPay: Disabling TapAndPay HCE service [CONTEXT service_id=79 ] 04-01 02:23:39.243 3020 15516 W TapAndPay: shouldEnableGooglePay: false [CONTEXT service_id=79 ] 04-01 02:23:39.243 3020 15516 I TapAndPay: Disabling TapAndPay HCE service [CONTEXT service_id=79 ] 04-01 02:23:39.267 3020 15516 W TapAndPay: shouldEnableGooglePay: false [CONTEXT service_id=79 ]

HaardikBhagtani avatar Apr 18 '22 05:04 HaardikBhagtani

How does your UI code look like?

JlUgia avatar Apr 21 '22 19:04 JlUgia

@JlUgia This is the UI code

                       GooglePayButton(
                        paymentConfigurationAsset: 'gpay.json',
                        paymentItems: [
                          PaymentItem(
                            label: 'Pay',
                            amount: newPlanCost,
                            status: PaymentItemStatus.final_price,
                          )
                        ],
                        width: 200,
                        height: 50,
                        style: GooglePayButtonStyle.black,
                        type: GooglePayButtonType.pay,
                        margin: const EdgeInsets.only(top: 15.0),
                        onPaymentResult: (paymentResult) {
                          print(paymentResult);
                          voucherCheckoutHandler(
                            paymentCheckout.newPlanName,
                            paymentCheckout.newPlanDealAmount,
                            uid,
                          );
                        },

HaardikBhagtani avatar Apr 21 '22 20:04 HaardikBhagtani

@JlUgia please help with this issue asap.

HaardikBhagtani avatar May 06 '22 20:05 HaardikBhagtani

Can you share the error that you are receiving? You can capture the error details adding the onError property to your GooglePayButton widget. (see https://github.com/google-pay/flutter-plugin/blob/main/pay/lib/src/widgets/pay_button.dart#L40)

JlUgia avatar Jun 01 '22 11:06 JlUgia

This is the code I used.

                       GooglePayButton(
                        paymentConfigurationAsset: 'gpay.json',
                        paymentItems: [
                          PaymentItem(
                            label: 'Pay',
                            amount: newPlanCost!,
                            status: PaymentItemStatus.final_price,
                          )
                        ],
                        width: 200,
                        height: 50,
                        style: GooglePayButtonStyle.black,
                        type: GooglePayButtonType.pay,
                        margin: const EdgeInsets.only(top: 15.0),
                        onPaymentResult: (paymentResult) {
                          print(paymentResult);
                          voucherCheckoutHandler(
                            paymentCheckout.newPlanName!,
                            paymentCheckout.newPlanDealAmount,
                            uid,
                          );
                        },
                        onError: (error) {
                          print(error);
                        },
                        childOnError: Text('Error'),
                        loadingIndicator: const Center(
                          child: CircularProgressIndicator(),
                        ),
                      ),

Added onError, but it didn't print anything on the console. onError is not executed.

a0e992b2-629b-481f-a96f-8d581f547b5b

As shown in the image above, this is how the UI appears; childOnError is executed.

HaardikBhagtani avatar Jun 02 '22 10:06 HaardikBhagtani

same issue here also. But onError is printing package:pay_platform_interface/core/payment_configuration.dart': Failed assertion: line 55 pos 16: 'configuration.containsKey('provider')': is not true.

kalliattShibin avatar Jun 24 '22 10:06 kalliattShibin

my code is exactly like yours @HaardikBhagtani. any solution on this

kalliattShibin avatar Jun 24 '22 10:06 kalliattShibin

my code is exactly like yours @HaardikBhagtani. any solution on this

No, haven't found any solution.

HaardikBhagtani avatar Jun 24 '22 12:06 HaardikBhagtani

@HaardikBhagtani Please set the static height and width in Googlepaybutton.

       `SizedBox(
                width: Get.width*0.5,
                height: 50,
                child: GooglePayButton(
                  type: GooglePayButtonType.standard,
                onTap: (){},
              ),
            ),`
            
            

panchalAlpit avatar Jul 01 '22 07:07 panchalAlpit

@HaardikBhagtani Please set the static height and width in Googlepaybutton.

       `SizedBox(
                width: Get.width*0.5,
                height: 50,
                child: GooglePayButton(
                  type: GooglePayButtonType.standard,
                onTap: (){},
              ),
            ),`

no, it didn't work. @panchalAlpit

HaardikBhagtani avatar Jul 18 '22 21:07 HaardikBhagtani

Google Pay is not available in all countries.Please take a look at this : https://support.google.com/pay/india/answer/9023773?hl=en-GB#zippy=%2Cpay-online-or-in-apps

kennest avatar Jul 28 '22 18:07 kennest

Google Pay is not available in all countries.Please take a look at this : https://support.google.com/pay/india/answer/9023773?hl=en-GB#zippy=%2Cpay-online-or-in-apps

@kennest The link says that Google Pay is available in India, and it is where I am building the app, so why is the issue coming up?

HaardikBhagtani avatar Jul 28 '22 19:07 HaardikBhagtani

i'm having the same problem, did u find a solution for this ?

kldawad-wecan avatar Aug 01 '22 09:08 kldawad-wecan

i'm having the same problem, did u find a solution for this ?

No, not yet. @kldawad-wecan

HaardikBhagtani avatar Aug 01 '22 09:08 HaardikBhagtani

same problem, apple button and other options to pay showing error failed to open the config json file on real device

case: i tried clone example app, then i just change value assets/default_payment_profile_apple_pay.json => merchantIdentifier and then run the app on real device. showing error "fopen failed for data file: errno = 2 (No such file or directory)

Screen Shot 2022-08-05 at 09 40 08

teoprayoga avatar Aug 05 '22 01:08 teoprayoga

@codendtech in your case, the error is pointing to your configuration, which is missing the provider key. Take a look at the configuration in the example application as a reference.

@HaardikBhagtani @kldawad-wecan @teoprayoga, can you share the configuration you are using? (make sure to remove any secret value before doing so).

JlUgia avatar Aug 17 '22 11:08 JlUgia

I'm facing the same issue. The code doesn't throw any error and the GooglePayButton and ApplePayButton are being shown in WidgetInspector but not in the UI. I have tried wrapping the button inside sizedBox also and checked all configs for the plugin.

amn-rwt avatar Aug 29 '22 12:08 amn-rwt

i'm having the same problem, did anyone find a solution for this ?

mdzihad89 avatar Oct 09 '22 08:10 mdzihad89

I think this is also happening to me, but i found that its only happens on emulator with API 30 and my phone, i tested on a emulator with API 31 and 33 and the button show up. Any solution yet?

iUnknownWs avatar Dec 26 '22 20:12 iUnknownWs

Hello, I have the same problem. How did you solve it

Edion-Liu avatar Jun 13 '23 15:06 Edion-Liu

i'm having the same problem, did anyone find a solution for this ?

Hello, I have the same problem. How did you solve it

Edion-Liu avatar Jun 13 '23 15:06 Edion-Liu

The button is only shown if the userCanPay call returns true. That is, if the device and user can use Google Pay. Note that Google Play services needs to be installed on the device, and you need to be logged in with a valid account. See #207 for additional context.

JlUgia avatar Jul 31 '23 16:07 JlUgia

Same problem here, any solution

darul9061 avatar Dec 15 '23 06:12 darul9061

As mentioned above, there are multiple reasons why the Google Pay button does not show if you use the quick integration path. To test the integration make sure that:

  • You are operating in the TEST environment (check your configuration JSON).
  • You have a device with a recent version of Google Play services installed and a valid gmail/Google apps account set up in the device (more details).
  • Your payment configuration is valid

If you still don't see the Google Pay button, add a comment to this thread including the code that draws your button and your payment configuration JSON (redacting sensitive information before posting).

JlUgia avatar Jan 20 '24 12:01 JlUgia

@JlUgia can I show Google Pay Button on iOS device? the Google Pay button only show on Android device. so I assume it won't be available for iOS right?

AgungLaksana avatar Mar 05 '24 08:03 AgungLaksana

hell

Same problem here, any solution

i have the same problem also any solution with this , my code only showing on emulator , was not showing on real device, my location was nigeria please help

Ridwan093 avatar Mar 06 '24 19:03 Ridwan093

@JlUgia plz help what can i do to that

Ridwan093 avatar Mar 06 '24 19:03 Ridwan093

That's right @AgungLaksana, Apple Pay is only supported on iOS, and Google Pay is only supported on Android at the time.

JlUgia avatar May 09 '24 12:05 JlUgia

Hi @Ridwan093, can you verify that the requirements to use Google Pay are met in the device that you are using to test?

JlUgia avatar May 09 '24 12:05 JlUgia