-
Notifications
You must be signed in to change notification settings - Fork 130
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] Simultaneous cash and card payment handling #13277
Conversation
📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #13277 +/- ##
============================================
- Coverage 41.10% 41.09% -0.01%
+ Complexity 6421 6420 -1
============================================
Files 1321 1321
Lines 77177 77200 +23
Branches 10643 10650 +7
============================================
+ Hits 31722 31727 +5
- Misses 42646 42663 +17
- Partials 2809 2810 +1 ☔ View full report in Codecov by Sentry. |
@@ -49,6 +53,18 @@ fun NavGraphBuilder.cashPaymentScreen( | |||
} | |||
}, | |||
) { backStackEntry -> | |||
val homeViewModel = hiltViewModel<WooPosHomeViewModel>() | |||
LaunchedEffect(homeViewModel) { |
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.
Do you know if we need to have this code at all? Don't we handle the event in WooPosHomeScreen
already?
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.
The LaunchedEffect coroutine in WooPosHomeScreen is not active when we navigate to CashPayment screen. That's why I subscribed to the events in the CashPayment screen here again.
An alternative approach could be to move the subscription to navigation events up in the compose navigation hierarchy, to theWooPosRootHost
, in order to avoid duplicate subscriptions – 5f9d68e. Let me know what you think, @kidinov !
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/WooPosHomeViewModel.kt
Outdated
Show resolved
Hide resolved
...c/main/kotlin/com/woocommerce/android/ui/woopos/home/WooPosHomeChildToParentCommunication.kt
Outdated
Show resolved
Hide resolved
is ParentToChildrenEvent.OrderSuccessfullyPaid -> showSuccessfulPaymentState( | ||
event.paymentMethod | ||
) | ||
is ParentToChildrenEvent.OrderSuccessfullyPaid -> { |
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.
Just checking that it's ok that cancelation will be called also in the card reader payments cases
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.
The flow works correctly, but I switched to canceling payment intent only in case the payment success comes from cash payment to avoid redundant logic – 60ef6e2
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/WooPosHomeNavigation.kt
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.
Looks and works fine! I just left a few code improvements suggestions, please take a look!
Thanks for the review, @kidinov! I've addressed comments and pushed improvements. Let me know what you think. |
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/root/navigation/WooPosRootHost.kt
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.
Looks and tests good!
Closes: #13278 13278
Description
This PR adds improvements to the cash payment collection flow:
Steps to reproduce
Verify the following on
trunk
:Payment intent cancelation
Cash payment screen not closed when card payment initiated:
Testing information
It should be verified that the above scenarios are fixed.
The tests that have been performed
Images/gif
Screen_recording_20250109_173942.mp4
Screen_recording_20250109_173912.mp4
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: