flutter_stripe_payment icon indicating copy to clipboard operation
flutter_stripe_payment copied to clipboard

Payment cancelled exception whenever I call paymentRequestWithNativePay

Open FilledStacks opened this issue 4 years ago • 7 comments

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.

  • Stripe payment has the cert and merchant id
  • identifier has the correct capabilities
  • The capabilities has been added to the runner and the correct merchant id is set
  • All associated certs and everything is correct
  • The strip publishable key works because I use it for card payments

FilledStacks avatar Jan 26 '21 10:01 FilledStacks

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

raudinm avatar Feb 13 '21 06:02 raudinm

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.

epiphanatic avatar Feb 24 '21 01:02 epiphanatic

Seeing the same is there any update on this issue?

jonsamwell avatar Mar 30 '21 23:03 jonsamwell

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 avatar Mar 31 '21 04:03 jonsamwell

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.

jonsamwell avatar Mar 31 '21 07:03 jonsamwell

Same issue here. Are there any solutions?

ldemyanenko avatar Jul 28 '21 08:07 ldemyanenko

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

ldemyanenko avatar Jul 28 '21 12:07 ldemyanenko