Skip to content

Conversation

@samiuelson
Copy link
Contributor

@samiuelson samiuelson commented Nov 8, 2024

Switching from viewStateData to paymentState

Closes: #12825

Description

This PR:

  1. Removes val viewStateData: LiveData<ViewState> from CardReaderPaymentController
  2. Maps CardReaderPaymentController.paymentState to ViewState in CardReaderPaymentViewModel, using the CardReaderPaymentStateToViewStateMapper use case class

The goal of that PR is to make the payment controller independent of the ViewState class, and extract mapping of the CardReaderPaymentOrRefundState emitted by controller to ViewState (UI state of the existing IPP flow) in the target VM. Thanks to such separation, the controller will allow flexible reuse of the payment flow in the POS.

This is part 4 of 5 PRs refactoring the Payment flow:

  1. [POS] Custom payment UI — Part 1 | Separating payment collection management from Android Framework
  2. [POS] Custom payment UI — Part 2 | Separating CardReaderPaymentController's events from MultiLiveEvent
  3. [POS] Custom Payment UI – Part 3 | Emitting UI–agnostic payment states in CardReaderPaymentController
  4. [POS] Custom payment UI — Part 4 | Switch from viewStateData to paymentState
  5. [POS] Custom payment UI — Part 5 | Unit tests clean up

⚠️ Don't merge — the branch will be merged together with the above ones after additional testing of the whole refactor.

Next steps

I'll add unit tests for CardReaderPaymentController, in the next PR.

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

  • 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.

  • I wasn't able to test Interac payments/refunds.

  • The build from this PR will be used for call for testing – extra manual testing focused on regression.

  • I have considered if this change warrants release notes and have added them to 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:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on big (tablet) and small (phone) in case of UI changes, and no regressions are added.

@dangermattic
Copy link
Collaborator

dangermattic commented Nov 8, 2024

2 Warnings
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ Class BuiltInReaderFailedPayment is missing tests, but unit-tests-exemption label was set to ignore this.

Generated by 🚫 Danger

@samiuelson samiuelson changed the title [WIP][POS] Custom payment UI — Part 4 | Switch from viewStateData to paymentState [WIP][POS] Custom payment UI — Part 4 | Switching from viewStateData to paymentState Nov 8, 2024
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Nov 8, 2024

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit9f747a8
Direct Downloadwoocommerce-wear-prototype-build-pr12898-9f747a8.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Nov 8, 2024

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit9f747a8
Direct Downloadwoocommerce-prototype-build-pr12898-9f747a8.apk

@codecov-commenter
Copy link

codecov-commenter commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 99.32660% with 2 lines in your changes missing coverage. Please review.

Project coverage is 40.16%. Comparing base (71e5b37) to head (9f747a8).
Report is 785 commits behind head on feature/custom-payment-ui.

Files with missing lines Patch % Lines
...payment/CardReaderPaymentStateToViewStateMapper.kt 99.47% 0 Missing and 1 partial ⚠️
.../payment/controller/CardReaderPaymentController.kt 93.33% 1 Missing ⚠️
Additional details and impacted files
@@                       Coverage Diff                       @@
##             feature/custom-payment-ui   #12898      +/-   ##
===============================================================
- Coverage                        40.65%   40.16%   -0.50%     
- Complexity                        5808     6073     +265     
===============================================================
  Files                             1251     1274      +23     
  Lines                            71210    73783    +2573     
  Branches                          9937    10089     +152     
===============================================================
+ Hits                             28952    29635     +683     
- Misses                           39624    41580    +1956     
+ Partials                          2634     2568      -66     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@samiuelson samiuelson marked this pull request as ready for review November 14, 2024 21:19
@samiuelson samiuelson changed the title [WIP][POS] Custom payment UI — Part 4 | Switching from viewStateData to paymentState [POS] Custom payment UI — Part 4 | Switching from viewStateData to paymentState Nov 19, 2024
Copy link
Contributor

@malinajirka malinajirka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @samiuelson ! Overall, it LGTM. I've left a couple questions. As with the previous PR, I just smoke tested the flow - I haven't ran thorough tests as I assume we'll run those anyway on the final PR of this chain of PRs.

Base automatically changed from custom-payment-ui-3 to feature/custom-payment-ui November 19, 2024 15:28
This way we can avoid not-null assertion operator (!!) in prod code.
@wpmobilebot wpmobilebot modified the milestones: 21.2, 21.3 Nov 22, 2024
@wpmobilebot
Copy link
Collaborator

Version 21.2 has now entered code-freeze, so the milestone of this PR has been updated to 21.3.

This way we can avoid not-null assertion operator (!!) in prod code.
@samiuelson samiuelson marked this pull request as draft November 25, 2024 11:13
@samiuelson samiuelson marked this pull request as ready for review November 25, 2024 12:44
@samiuelson samiuelson removed the status: do not merge Dependent on another PR, ready for review but not ready for merge. label Nov 25, 2024
@samiuelson samiuelson merged commit 5b75c92 into feature/custom-payment-ui Nov 25, 2024
18 checks passed
@samiuelson samiuelson deleted the custom-payment-ui-4 branch November 25, 2024 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants