Skip to content
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

[Woo POS] Update connection status when reader turned off #14994

Merged

Conversation

joshheald
Copy link
Contributor

@joshheald joshheald commented Jan 28, 2025

Closes: #14992
Merge after: #14990

Description

When we get a reader status change from the underlying CardPresentPaymentStore, we should always republish that to POS.

Previously, we would treat empty arrays of readers from the store (nil in the connectedReaderPublisher) as something we don’t have to pass on, when in reality they likely represent a disconnection originating outside the app (e.g. turning the reader off, bluetooth failure, or the battery running out.)

This PR updates the handling to treat these cases as a disconnected reader, so now the UI will update accordingly.

Steps to reproduce

  1. Launch the app and open POS
  2. Connect your card reader
  3. Turn the reader off
  4. Observe that the status updates to show Connect your reader again.

Testing information

This makes other bugs reproducible: #13738 and #13876 (which are probably the same issue) – I'll tackle these separately.

I attempted to add unit tests for this, but the nature of the facade layer made this unfeasible without major changes. It's a problem with the combination of async and combine...

Screenshots

update.card.reader.status.when.turned.off.mp4

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

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 all devices (phone/tablet) and no regressions are added.

When we get a reader status change from the underlying `CardPresentPaymentStore`, we should always republish that to POS.

Previously, we would treat empty arrays of readers from the store (nil in the `connectedReaderPublisher`) as something we don’t have to pass on, when in reality they likely represent a disconnection originating outside the app (e.g. turning the reader off, bluetooth failure, or the battery running out.)

This commit updates the handling to treat these cases as a `disconnected` reader, so now the UI will update accordingly.
@joshheald joshheald added type: bug A confirmed bug. feature: mobile payments Related to mobile payments / card present payments / Woo Payments. feature: POS labels Jan 28, 2025
@joshheald joshheald added this to the 21.6 milestone Jan 28, 2025
@joshheald joshheald marked this pull request as ready for review January 28, 2025 09:59
@joshheald joshheald changed the base branch from trunk to issue/13778-improve-retry-handling-of-card-reader-update-errors January 28, 2025 10:00
…e-errors' into issue/14992-update-connection-status-when-reader-turned-off
@wpmobilebot
Copy link
Collaborator

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

App NameWooCommerce iOS WooCommerce iOS
Build Numberpr14994-e525195
Version21.5
Bundle IDcom.automattic.alpha.woocommerce
Commite525195
App Center BuildWooCommerce - Prototype Builds #12714
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

Base automatically changed from issue/13778-improve-retry-handling-of-card-reader-update-errors to trunk January 28, 2025 15:46
@iamgabrielma iamgabrielma self-assigned this Jan 28, 2025
Copy link
Contributor

@iamgabrielma iamgabrielma left a comment

Choose a reason for hiding this comment

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

LGTM 🚢

Tested on iPad Pro 12.9 w/ iOS 17.6.1

@joshheald joshheald merged commit fd038cf into trunk Jan 29, 2025
13 checks passed
@joshheald joshheald deleted the issue/14992-update-connection-status-when-reader-turned-off branch January 29, 2025 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: mobile payments Related to mobile payments / card present payments / Woo Payments. feature: POS type: bug A confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Woo POS] Card reader connection status isn't updated when the reader is turned off
3 participants