jonasbark / flutter_stripe_payment

[DISCONTINUED] A flutter plugin with stripe payment plugin integration
MIT License
308 stars 245 forks source link

Payment cancelled exception whenever I call paymentRequestWithNativePay #243

Open FilledStacks opened 3 years ago

FilledStacks commented 3 years ago

I'm trying to make use of the native pay functionality for ApplePay only. When I call the function it throws an exception that says cancelled by User but I didn't cancel the payment. In fact it never shows the payment sheet.

I'm on flutter 1.22.5 using version 1.0.9

Here's all the relevant code

// Setup called when the service is initialised
StripePayment.setOptions(StripeOptions(
      publishableKey: FlavorConfig.instance.values.stripePublishableKey,
      merchantId: FlavorConfig.instance.values.stripePublishableKey,
      androidPayMode: 'test',
    ));

Call made when we need to get the charge token from ApplePay

final token = await StripePayment.paymentRequestWithNativePay(
      // not supplied properly because not relevant
      androidPayOptions: AndroidPayPaymentRequest(
        totalPrice: "1.20",
        currencyCode: "USD",
      ),
      applePayOptions: ApplePayPaymentOptions(
        countryCode: 'US',
        currencyCode: 'USD',
        items: [
          ApplePayItem(
            label: merchant,
            amount: (subtotal + tip + tax).toString(),
          )
        ],
      ),
    );

The function above throws an exception with code cancelled. It never even shows the sheet for me to cancel. I've ensured everything is setup correctly.

raudinm commented 3 years ago

Same here, i just ran the example code in the docs, and i got the same error using the method paymentRequestWithCardForm.

Version 1.0.10 still crash

epiphanatic commented 3 years ago

This or something similar is happening across at least 3 different Stripe plugins when attempting to use Apple Pay. Although stripe_native works in debug but then fails in release mode.

jonsamwell commented 3 years ago

Seeing the same is there any update on this issue?

jonsamwell commented 3 years ago

I think this is some issue to do with when the lib calls the native PKPaymentAuthorizationViewController.canMakePayments as it always seems to return false on a real iOS device.

Perhaps the Stripe SDK version needs to be updated?

jonsamwell commented 3 years ago

After lots of looking my issue was that I did not have the merchant id in the entitlements file and I was using the string 'master_card' not 'mastercard' in the array for the method StripePayment.canMakeNativePayPayments. Fixing those issues it now works well.

ldemyanenko commented 3 years ago

Same issue here. Are there any solutions?

ldemyanenko commented 3 years ago

What should be the next steps in Apple Pay after a successful call for paymentRequestWithNativePay?