woocommerce / woocommerce-android

WooCommerce Android app
https://www.woocommerce.com/mobile
GNU General Public License v2.0
277 stars 135 forks source link

[POS] Custom payment UI — Part 2 | Separating `CardReaderPaymentController`'s events from `MultiLiveEvent` #12870

Closed samiuelson closed 2 days ago

samiuelson commented 2 weeks ago

Separating CardReaderPaymentController's events from MultiLiveEvent

Closes: #12823

This is part 2 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.

Description

This PR refactors the way CardReaderPaymentController emits events:

  1. CardReaderPaymentController emits now sealed class CardReaderPaymentEvent instances. This is safer to operate on a set of (sealed) classes bound to the parent class. Additionally, this removes the dependency on the MultiLiveEvent.Event and MultiLiveEvent in CardReaderPaymentController. These classes are not needed and desirable in Woo POS.
  2. The existing CardReaderPaymentViewModel subscribes to the controller's events observable, maps it, and exposes in the form of the old model (extending MultiLiveEvent.Event) emitted by LiveData—retrofitting the existing UI implementation.

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; and verified that the IPP flow works and is not changed. Configurations:

  1. CA — payment collection/refund with Stripe test card (WisePad)
  2. US — payment collection/refund with Stripe test card (TTP, M2)
  3. Stripe and Woo Payments plugins

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:

dangermattic commented 2 weeks ago
1 Error
:no_entry_sign: This PR is tagged with status: do not merge label(s).
1 Warning
:warning: Class CardReaderPaymentEvent is missing tests, but unit-tests-exemption label was set to ignore this.

Generated by :no_entry_sign: Danger

wpmobilebot commented 2 weeks ago
📲 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
Commit9f7c8a251838423a8da9a093b132b2bb3ca11951
Direct Downloadwoocommerce-wear-prototype-build-pr12870-9f7c8a2.apk
wpmobilebot commented 2 weeks ago

📲 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
Commit9f7c8a251838423a8da9a093b132b2bb3ca11951
Direct Downloadwoocommerce-prototype-build-pr12870-9f7c8a2.apk