stripe-terminal-ios icon indicating copy to clipboard operation
stripe-terminal-ios copied to clipboard

Tap to Pay on iPhone readCancelled error on reader connection

Open koenpunt opened this issue 10 months ago • 6 comments

Summary

Last week I asked about some issues we have with Tap to Pay on iPhone in the Discord channel, and there I was asked to open an issue on the repo.

We see some inexplicable connection errors.

~The one that we only seem to be able to recover from by restarting the app is Error Domain=com.stripe-terminal Code=2900 "Operation not permitted. Verify the app has the necessary entitlements and that the application bundle is valid.". Obviously we have the entitlements, and is the application bundle valid, because this only happens incidental.~ From Stripe: moved this issue to #302 to track separately

Another issue we see is unexpected cancellation; when we try to start a payment, we see the screen transitioning to the Tap to Pay UI, but then gets cancelled automatically. This can happen a couple of times after each other, which then often can be solved by moving the app to background for a moment. The error logged in this case is Error (read): readCancelled. Often after this happens, trying to reconnect again results in the ReadError.readNotAllowed being logged. To resolve this issue restarting the app works, or keeping the app in the background for a bit longer usually works as well.

Code to reproduce

There aren't clear reproduction steps, but I've seen more issues when I move the app to background right after I invoke the start payment method.

iOS version

17.x

Installation method

Swift PM

SDK version

3.5.0

koenpunt avatar Apr 23 '24 16:04 koenpunt

I am also getting a Error (read): readCancelled when trying to collectPaymentMethod

yllaw avatar May 01 '24 04:05 yllaw

Maybe good to elaborate; the cancelation indeed happens shortly after calling collectPaymentMethod.

koenpunt avatar May 01 '24 15:05 koenpunt

We're having this issue too. ~For some reason though it works fine when using one of our accounts, but we get these errors with all the other accounts.~

Edited: We did think this affected some accounts and not others, but it seems it affects any account.

iaibai avatar May 02 '24 08:05 iaibai

Verbose logging from the test environment:

[StripeTerminal] m Stripe trace identifier: retrievePaymentIntent!175740733900001714641423523
[StripeTerminal] s scope=SCPTerminal event=retrievePaymentIntent_start command=retrievePaymentIntent
[StripeTerminal] t scope=SCPAPIRequest event=api_request_get api_endpoint=payment_intents.pi_3PBaSGKo27ACZLjH0vdTjQkZ
[StripeTerminal] t scope=SCPAPIRequest event=api_response_success api_endpoint=payment_intents.pi_3PBaSGKo27ACZLjH0vdTjQkZ http_method=GET http_status_code=200 request_id=req_rwbV0TR00NFxQZ
[StripeTerminal] m Stripe trace identifier: collectPaymentMethod!175740733900001714641423870
[StripeTerminal] x scope=scpterminal outcome=http_status_code_200 event=get_payment_intents_id time=1714641423869 domain=api_request
[StripeTerminal] e scope=SCPTerminal event=retrievePaymentIntent amount=3500 capture_method=automatic currency=usd intent_status=requires_payment_method payment_intent_id=pi_3PBaSGKo27ACZLjH0vdTjQkZ status=requires_payment_method total_time_ms=360 update_pi=false
[StripeTerminal] x scope=scpterminal outcome=success event=retrievepaymentintent time=1714641423970 domain=terminal_request
[StripeTerminal] s scope=SCPTerminal event=collectPaymentMethod_start amount=3500 capture_method=automatic command=collectPaymentMethod currency=usd intent_status=requires_payment_method payment_intent_id=pi_3PBaSGKo27ACZLjH0vdTjQkZ status=requires_payment_method update_pi=false
[StripeTerminal] l scope=SCPTerminal event=state_change command_in_progress=collectPaymentMethod
[StripeTerminal] t scope=SCPTerminal event=state_change payment_status=Waiting_For_Input
[StripeTerminal] t scope=SCPTerminal event=terminal_didChangePaymentStatus
[StripeTerminal] l scope=SCPTransactionSession event=initWithResource_reader_adapter_apiClient adapter_class=SCPAppleBuiltInReaderAdapter resource_class=SCPPaymentIntent
[StripeTerminal] l scope=SCPTransactionSession event=prepareAdapterForCollectWithCancelable adapter_class=SCPAppleBuiltInReaderAdapter resource_class=SCPPaymentIntent
[StripeTerminal] l scope=SCPTransactionSession event=collectPaymentMethod adapter_class=SCPAppleBuiltInReaderAdapter resource_class=SCPPaymentIntent
[StripeTerminal] l scope=SCPAppleBuiltInReaderAdapter event=collectPaymentMethodForResource
[StripeTerminal] l scope=SCPAppleBuiltInReaderAdapter event=applicationDidBecomeActiveNotification
[StripeTerminal] l scope=SCPReader event=applicationDidBecomeActive
Error (read): readCancelled
[StripeTerminal] l scope=SCPAppleBuiltInReaderAdapter event=appleBuiltInReader_didFailToPerformTransaction error=De_bewerking_kon_niet_worden_voltooid._-SCPAppleBuiltInReaderErrorDomain_fout_39. error_code=39 error_domain=SCPAppleBuiltInReaderErrorDomain
[StripeTerminal] l scope=SCPCancelable event=cancelationFailedWithError command=collectPaymentMethod
[StripeTerminal] l scope=SCPAppleBuiltInReaderAdapter event=appleBuiltInReader_didReportTransactionEvent transaction_event=ReadNotCompleted
[StripeTerminal] l scope=SCPTerminal event=state_change command_in_progress=none
[StripeTerminal] t scope=SCPTerminal event=state_change payment_status=Ready
[StripeTerminal] t scope=SCPTerminal event=terminal_didChangePaymentStatus
[StripeTerminal] e scope=SCPTerminal event=collectPaymentMethod error=The_command_was_canceled error_code=2020 error_domain=com.stripe-terminal exception=USER_ERROR.Canceled total_time_ms=1183

So it seems reader error 39 to cause this, but can't tell what that code would mean. In the module ABI file, and the generated Swift interface for AppleBuiltInReaderErrorCode I see invalidAmount being code 39, but this seems unlikely, since it randomly fails for the same payment intent.

koenpunt avatar May 02 '24 09:05 koenpunt

We're having this issue too. For some reason though it works fine when using one of our accounts, but we get these errors with all the other accounts.

Interesting... it's odd I also found when testing collectPaymentMethod the iOS Tap to Pay sheet will work on rare hard-to-reproduce cases.

yllaw avatar May 03 '24 18:05 yllaw

Just to update, after trying on another device we did encounter this error on an account that we thought the issue wasn't happening on. So, it's possibly not account-specific after all.

iaibai avatar May 07 '24 10:05 iaibai

Just to update, after trying on another device we did encounter this error on an account that we thought the issue wasn't happening on. So, it's possibly not account-specific after all.

did you find any solution for this issue

Roniy08 avatar May 08 '24 09:05 Roniy08

Hi,

We are having the same issue on a RN - iOS version

[Stripe terminal]:didChangePaymentStatus notReady [Stripe terminal]:didChangePaymentStatus ready ====> intent res:{ paymentIntent: ... error: undefined } [Stripe terminal]: didChangePaymentStatus waitingForInput [Stripe terminal]: didChangePaymentStatus ready ===> payment intent step2: undefined {code: 'Canceled', message: T'he command was canceled. ' } Errors: { errorCode: 'Canceled', errorMessage: 'The command was canceled.' }

tzecheng avatar May 08 '24 14:05 tzecheng

Just to update, after trying on another device we did encounter this error on an account that we thought the issue wasn't happening on. So, it's possibly not account-specific after all.

did you find any solution for this issue

No we haven't found a solution I'm afraid.

iaibai avatar May 08 '24 14:05 iaibai

We're having this issue too. For some reason though it works fine when using one of our accounts, but we get these errors with all the other accounts.

Interesting... it's odd I also found when testing collectPaymentMethod the iOS Tap to Pay sheet will work on rare hard-to-reproduce cases.

did you find solution for this ?

Roniy08 avatar May 09 '24 12:05 Roniy08

We're having this issue too. For some reason though it works fine when using one of our accounts, but we get these errors with all the other accounts.

Interesting... it's odd I also found when testing collectPaymentMethod the iOS Tap to Pay sheet will work on rare hard-to-reproduce cases.

did you find solution for this ?

Unfortunately no, this may be a problem with iOS 17 and/or stripe terminal.

yllaw avatar May 09 '24 15:05 yllaw

Apologies for the slow response on this one but thanks everyone for chiming in and providing a lot of useful context! We're looking into this issue but based on our logs, it appears to be an issue with iOS 17.4.1. If you're still encountering this issue, we recommend upgrading iOS version to see if that resolves the issue. In the meantime, we're working with Apple to get more clarity on this.

gliu-stripe avatar May 20 '24 21:05 gliu-stripe

Hey everyone, Apple confirmed that this is a known bug with iOS 17.4.1. It should be patched if you upgrade to iOS 17.5. Thanks again for all the details!

gliu-stripe avatar May 22 '24 21:05 gliu-stripe