BreX900 / mek-packages

10 stars 13 forks source link

The operation couldn’t be completed. (mek_stripe_terminal.PlatformError error 1.) when using simulator or test card amounts on iOS. #72

Open lukesalter opened 1 month ago

lukesalter commented 1 month ago

Am I doing something wrong or is the package not handling simulated declines properly on iOS.

I'm getting the same results using Tap to Pay for all of the following on iOS:

I've been using the test card amounts listed here to simulate the failures: https://docs.stripe.com/terminal/references/testing#physical-test-cards for the following amounts I'm just seeing a generic failure when calling confirmPaymentIntent():

[log] PlatformException (PlatformException(mek_stripe_terminal.PlatformError:1, The operation couldn’t be completed. (mek_stripe_terminal.PlatformError error 1.), mek_stripe_terminal.PlatformError, null))
[log] #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651:7)
      #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
      <asynchronous suspension>
      #2      _$TerminalPlatform.confirmPaymentIntent (package:mek_stripe_terminal/src/platform/terminal_platform.api.dart:306:22)
      <asynchronous suspension>
      #3      Terminal.confirmPaymentIntent (package:mek_stripe_terminal/src/terminal.dart:368:7)
      <asynchronous suspension>
      #4      PaymentController.build.handlePayment (package:flutterdonate/controllers/payment_controller.dart:111:27)
      <asynchronous suspension>
      #5      _FutureBuilderState._subscribe.<anonymous closure> (package:flutter/src/widgets/async.dart:624:31)
      <asynchronous suspension>

All of these amounts give the error above:

However the following scenario amount is working as expecting (showing the PIN UI and then succeeding)

When I catch and swallow the PlatformException I can use the terminal to retrieve the the paymentIntent and successfully see that there is a failed charges on there in the charges list but this isn't ideal and doesn't behave like Android does. Android returns a proper TerminalExceptionCode.stripeApiError with a lovely apiError I can parse for a decline message to inform the user.

Essentially it looks like iOS isn't handling simulated scenarios properly with test values (either when simulated or using a physical test card). Is this something other people are finding? Can this be fixed in the package?

Hopefully the stack trace above will help you find the issue but if you need any more information let me know.

agarwalrohit2503 commented 1 month ago

I am also facing the same issue

StephanWalters commented 1 week ago

@lukesalter @agarwalrohit2503 i faced this issue a few weeks back. This is the solution:

https://github.com/BreX900/mek-packages/issues/56#issuecomment-1998654738

I am going to create a PR to address this.

lukesalter commented 1 week ago

@StephanWalters yes please - that would be amazing. Thanks for finding this and digging it out. We've got a contactless app ready to go in to the app store and this is one of the missing pieces.