google-pay / flutter-plugin

Apache License 2.0
145 stars 129 forks source link

google pay button not visble without any error #270

Open osama300 opened 4 months ago

osama300 commented 4 months ago

i use string json config here print error but not print any thing

onError: (e){ print('this error $e'); },

augustineonu commented 3 months ago

I have same issue. i don't get an error from the method or plugin, what I get is the childOnError widget which is from the package. ALso, I want to know if it possible to integrate for Countries like Nigeria. I successfully see the button on ios simulator, but not on ios real device. Below is a code that doesn't display for android.

FutureBuilder( future: _googlePayConfigFuture, builder: (context, snapshot) { return snapshot.hasData ? GooglePayButton(

                      paymentConfiguration: snapshot.data!,
                      paymentItems: _paymentItems,
                      type: GooglePayButtonType.buy,
                      margin: const EdgeInsets.only(top: 15.0),
                      onPaymentResult: (result) {
                        print("result:: ${result}");
                      },
                      width: phoneWidth,
                      childOnError: const Text("Google Pay not supported"),
                      loadingIndicator: const Center(
                        child: CircularProgressIndicator(),
                      ),
                    )
                  : snapshot.hasError
                      ? textWidget(context,
                          title: "Erro: ${snapshot.error.toString()}")
                      : textWidget(context, title: "unknown error");
            }),
TetrixGauss commented 2 months ago

Make sure you have a card in your google wallet! This has happened to me and when i added a card in the google wallet the button appeared. The same issues can be fixed with the same way in the ios platform.

JlUgia commented 1 month ago

Hello, the error object contains information about the issue. What do you see there?

justoke commented 1 month ago

I had this issue and it was ultimately down to ensuring that the state of widget holding the button was correctly set. I had user actions that were determining when the pay button would show, but button would not show and this caused it always to attempt to access the childOnError property. I used this function every time state was changed and it resolved the issue:

updateAppState() async {
    int value = 0;
    await Future.doWhile(() async {
      value++;
      await Future.delayed(const Duration(milliseconds: 700));
      if (value == 5) {
        if (mounted) {
          setState(() {});
        }
        return false;
      }
      if (mounted) {
        setState(() {});
      }
      return true;
    });
  }

And then wherever state was changed I made a call to that function:

image