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

Throws MissingPluginException

Open shahzaibdev1 opened this issue 1 year ago • 2 comments

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,
  )
];

shahzaibdev1 avatar Feb 06 '24 12:02 shahzaibdev1

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

JlUgia avatar May 09 '24 11:05 JlUgia

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.

aggeloskoutanis avatar Jul 23 '24 11:07 aggeloskoutanis