google-pay / flutter-plugin

Apache License 2.0
145 stars 130 forks source link

Throws MissingPluginException #245

Open shahzaibdev1 opened 9 months ago

shahzaibdev1 commented 9 months ago

I have setup the pay package in flutter to implement google pay in my flutter app for android. but this error is thrown: MissingPluginException(No implementation found for method userCanPay on channel plugins.flutter.io/pay_channel)

This is the google pay button

GooglePayButton(
                              paymentConfiguration:
                                  PaymentConfiguration.fromJsonString(googlePayConfiguration),
                              paymentItems: _paymentItems,
                              type: GooglePayButtonType.buy,
                              margin: const EdgeInsets.only(top: 15.0),
                              onPaymentResult: onGooglePayResult,
                              onError: (err) {
                                print("ErrorObj: $err ErrorObject");
                              },
                              loadingIndicator: const Center(
                                child: CircularProgressIndicator(),
                              ),
                            )

and this is the configuration:

const String googlePayConfiguration = '''{
  "provider": "google_pay",
  "data": {
    "apiVersion": 2,
    "apiVersionMinor": 0,
    "merchantInfo": {
      "merchantName": "Example Merchant"
    },
    "allowedPaymentMethods": [
      {
        "type": "CARD",
        "parameters": {
          "allowedAuthMethods": ["PAN_ONLY", "CRYPTOGRAM_3DS"],
          "allowedCardNetworks": ["AMEX", "DISCOVER", "INTERAC", "JCB", "MASTERCARD", "VISA"]
        },
        "tokenizationSpecification": {
          "type": "PAYMENT_GATEWAY",
          "parameters": {
            "gateway": "example",
            "gatewayMerchantId": "exampleGatewayMerchantId"
          }
        }
      }
    ],
    "transactionInfo": {
      "totalPriceStatus": "FINAL",
      "totalPrice": "1.2",
      "currencyCode": "USD"
    }
  }
}''';

this is the _paymentItems:

const _paymentItems = [
  PaymentItem(
    label: 'Total',
    amount: '1.2',
    status: PaymentItemStatus.final_price,
  )
];
JlUgia commented 6 months ago

Hello @shahzaibdev1 this appears to be a registry staleness issue. Take a look at this comment in the flutter repo.

aggeloskoutanis commented 3 months ago

I also get this error, while, for example, showPaymentSelector works well. I have tried also the flutter comment @JlUgia and did some steps there that people mentioned that might solve the problem, but I had no luck.