-
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 1 | Separating payment collection management from Android Framework #12853
Conversation
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.
|
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
.../kotlin/com/woocommerce/android/ui/payments/cardreader/payment/CardReaderPaymentViewModel.kt
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #12853 +/- ##
============================================
+ Coverage 40.34% 40.38% +0.03%
- Complexity 5773 5783 +10
============================================
Files 1245 1246 +1
Lines 70799 70848 +49
Branches 9893 9892 -1
============================================
+ Hits 28563 28609 +46
- Misses 39604 39607 +3
Partials 2632 2632 ☔ View full report in Codecov by Sentry. |
.../kotlin/com/woocommerce/android/ui/payments/cardreader/payment/CardReaderPaymentViewModel.kt
Outdated
Show resolved
Hide resolved
private const val CANADA_FEE_FLAT_IN_CENTS = 15L | ||
|
||
@Suppress("LongParameterList", "LargeClass") | ||
class CardReaderPaymentController( |
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.
Maybe not in this PR but I think we'll need to move the tests from the VM to this class. Now we test it kinda as side effect from the tests from the VM
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 tested main flows - no regression found. We will need to retest it again when other PRs will be merged here
I left a couple of ideas, please take a look
Custom payment UI
Separating payment collection management from Android Framework
Closes: #12824
💡 I tried to keep this PR as small as possible, but I wasn't able to make it into the 300 loc limit. The code was only restructured though—extracted to a new class.
This is part 1 of 5 PRs refactoring the Payment flow:
Description
The intent of this PR is to separate the business logic controlling payment collection and processing process from the framework APIs (like
ViewModel.viewModelScope
,SavedStateHandle
,FragmentArgs
, andDialogFragment
-specific events).CardReaderPaymentViewModel: ScopedViewModel
toCardReaderPaymentController
— plain Kotlin class.5. Additionally,Moved to the next PRCardReaderPaymentController
emits its own events thatCardReaderPaymentViewModel
is mapping to its own ones. Thanks this separationCardReaderPaymentController
doesn't depend on theMultiLiveEvent
making it easier to decouple the whole POS mode from the existing app (e.g. making it easier to extract into a standalone app in the future).Testing information
The refactor introduced by this PR is mostly a code restructuring. As a result, 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
I tested the payment collection flow in both POS and store management modes, using card-present payment and TTP; verified that the IPP flow works and is not changed.
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: