-
Notifications
You must be signed in to change notification settings - Fork 117
[Migrate simple payments] Fix card reader payment methods from Menu > Payments > Collect Payment #12801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Migrate simple payments] Fix card reader payment methods from Menu > Payments > Collect Payment #12801
Conversation
…ethodsWrapperHosted` (SwiftUI) to provide a root view controller to `PaymentMethodsView` to fix card reader payment method flow.
|
Looks good!
I agree with asserting, perhaps through an Unit Test? At least to assert that the root is not nil. Additionally, I'd also say that we should think of crashing on purpose in production if we land in this scenario, if we can: The weak reference to |
A simpler/more effective check would probably be requiring the vc at init:
That works but it's a bit annoying because requires the chain of SwiftUI callers to unwrap their I think the main issue is that we're passing view controllers around :( |
…ewController` is missing on view appearance.
Re @iamgabrielma:
Hmm as the problem is
I agree some form of crashing/logging would be helpful for us to detect this misconfiguration early. In 6e205a0, when
Lemme know if you think crashing in production would be better! Re @joshheald:
This would be ideal, but in the wrapper hosting controller,
Soo true! I'm planning to merge the PR today, but I can open another PR for any further suggestions. |
In this case, since we haven't seen the problem while developing I think I gravitate more towards crashing in prod and having this recorded explicitly than allowing for undefined behaviour and crashing somewhere else pointing to the wrong trace just because it's using the same memory block. But since since we're logging the case anyway in Sentry I have no strong preference. |
Okay let's go with logging a non-fatal error in Sentry for now, it's a tradeoff where the app won't crash but we don't get alerted right away. Non-fatal events should still appear as issues in each release. |
Closes: #12790
Why
A merchant reported that the IPP flow from Menu > Payments > Collect Payment entry point stopped working, while the same flow in the orders tab worked. With @joshheald's helpful information peaMlT-Ec-p2#comment-1526, the issue was from not passing a
rootViewController
toPaymentMethodsView
. It was probably missed from the beginning, but the card reader flow wasn't tested before the release since "card reader" and "Tap to Pay" are the only two payment methods that use therootViewController
with UIKit views (I thought I tested this but maybe at an early stage).How
To fix this, I created
PaymentMethodsWrapperHostingController
(UIKit) andPaymentMethodsWrapperHosted
(SwiftUI) to provide a root view controller toPaymentMethodsView
to fix card reader payment method flow (as suggested in Josh's first point peaMlT-Ec-p2#comment-1526). There is also another existing hosting controller and its SwiftUI version inPaymentMethodsHostingController
/PaymentMethodsHostingView
, but there's more logic in it than what's needed in the Payments menu flow so I created "wrapper" versions (feel free to suggest other names).It's quite dangerous how
PaymentMethodsView.rootViewController
isn't easy to enforce and missing it could result in a broken IPP flow. I thought aboutassertionFailure
somewhere but couldn't find a good place to do it. Not mixing SwiftUI and UIKit with optional view controller setup would be great in the future.Testing instructions
Prerequisite: a card reader is available
Collect Payment
in the order formCard Reader
--> the card reader flow should startScreenshots
Simulator.Screen.Recording.-.iPad.10th.generation.-.2024-05-21.at.13.24.22.mp4
RELEASE-NOTES.txt
if necessary.