-
Notifications
You must be signed in to change notification settings - Fork 137
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
[POS] Custom Payment UI — Part 3 | Emitting UI–agnostic payment states in CardReaderPaymentController
#12877
Conversation
…tController` The goal is to remove viewStateData property and map paymentState to ViewState in the target [ViewModel]
The goal is to make payment controller return UI-agnostic payment state and map the payment state to UI state in the target VM.
Generated by 🚫 Danger |
📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
|
CardReaderPaymentController
CardReaderPaymentController
CardReaderPaymentController
CardReaderPaymentController
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
...woocommerce/android/ui/payments/cardreader/payment/controller/CardReaderPaymentController.kt
Show resolved
Hide resolved
CardReaderPaymentController
CardReaderPaymentController
...commerce/android/ui/payments/cardreader/payment/controller/CardReaderPaymentOrRefundState.kt
Show resolved
Hide resolved
...commerce/android/ui/payments/cardreader/payment/controller/CardReaderPaymentStateProvider.kt
Show resolved
Hide resolved
Thanks for the reviews @kidinov and @malinajirka 🙇🏼 As discussed, we're going to keep the callbacks in the In the current PR, I extracted Let me know what you think! |
...woocommerce/android/ui/payments/cardreader/payment/controller/CardReaderPaymentController.kt
Outdated
Show resolved
Hide resolved
else -> null | ||
} | ||
if (nameForTracking == null) { | ||
WooLog.e(WooLog.T.CARD_READER, "Invalid state received") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, I'd consider to track this case too, just instead of passing hard coded string we could pass state's name there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea, but I would prefer to implement it out of this PR, and refactoring process because it would affect the existing business logic—it would require modifying unit tests.
...woocommerce/android/ui/payments/cardreader/payment/controller/CardReaderPaymentController.kt
Show resolved
Hide resolved
...woocommerce/android/ui/payments/cardreader/payment/controller/CardReaderTrackCanceledFlow.kt
Outdated
Show resolved
Hide resolved
...woocommerce/android/ui/payments/cardreader/payment/controller/CardReaderTrackCanceledFlow.kt
Outdated
Show resolved
Hide resolved
...woocommerce/android/ui/payments/cardreader/payment/controller/CardReaderTrackCanceledFlow.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @samiuelson !
The changes look good to me. I haven't run thorough tests since I believe we'll run them on the final PR of this chain of PRs anyway. I haven't discovered any issues when smoke testing the changes with my WisePad 3 (including interac refunds).
Thanks for review, @malinajirka!
That's correct. The build used in the Call for testing (pdfdoF-5Rg-p2) is generated from the next PR that includes payment state to UI state mapping — [POS] Custom payment UI — Part 4 | Switching from viewStateData to paymentState. |
Closes: #12825
This is part 3 of 5 PRs refactoring the Payment flow:
Description
This PR introduces a new class modeling a "payment state" —
CardReaderPaymentOrRefundState
. It is emitted by thepaymentState: StateFlow<CardReaderPaymentOrRefundState>
property inCardReaderPaymentController
, allowing observing the payment state in POS.The goal of the
paymentState
property is to replace theviewStateData: LiveData<ViewState>
that emits "UI model" instances, designed specifically for the existing dialog-based payment flow UI. For now, theviewStateData
is marked deprecated, and supposed to be used only by the existing IPP flow.Coming up in the next PR:
paymentState
toViewState
inCardReaderPaymentViewModel
Testing information
As a result of the refactoring done within this PR, the app should work without any change. It's crucial to test the IPP flow in the store management and POS modes against regression. It may be useful to base on the test plan (pdfdoF-5Jz-p2).
The tests that have been performed
This PR will be followed up by removing the
viewStateData
property from the controller, adding unit tests, and mapping thepaymentState
toViewState
. That said, this PR should not cause any regression in the existing IPP flow, however, the most important part to test is the code changes.RELEASE-NOTES.txt
if necessary. Use the "[Internal]" label for non-user-facing changes.Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: