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

[POS][Custom payment UI] – Reader not connected error handling #13053

Conversation

samiuelson
Copy link
Collaborator

@samiuelson samiuelson commented Dec 3, 2024

Closes: #13005

Description

This PR:

  1. Shows the "Reader not connected" error in POS Totals screen in case the order draft is created but reader is not connected.
  2. Reader status is now observed, and the collect payment action is started automatically after the reader connects, allowing to tap the card to the reader.

Design specs: TfaZ4LUkEwEGrxfnEFzvJj-fi-2530_13218

⚠️ Don't merge until the base branch is merged into trunk.

Steps to reproduce

  1. Go to Woo POS (Menu more > Point of Sale)
  2. Ensure reader is not connected
  3. Add items to cart and click "Checkout"
  4. After order draft is created, verify that "Reader not connected" error is displayed above totals table
  5. Click "Connect to reader" button, and verify payment action starts automatically once the reader connects

Testing information

  1. "Reader not connected" error should be displayed in case order draft is created successfully, but reader is not connected.
  2. In case order draft is not created successfully (e.g. try checking out in airplane mode), "Couldn't load totals" error is shown instead
  3. "Connect to reader" button triggers reader connection flow
  4. When reader connects, payment action should be started automatically, allowing to collect payment by tapping the card, and showing "Payment successful" screen

The tests that have been performed

  • Tested the "Reader not connected" shows up when reader is not connected
  • Tested the "Reader not connected" shows up when reader suddenly disconnects (e.g. bluetooth gets turned off)
  • Tested that "Connect to reader" action button works
  • Tested the payment action starts automatically when reader connects

Images/gif

Light Dark
Screenshot_20241203_164059 Screenshot_20241203_164044
  • 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.

given reader not connected, when VM checkout clicked, then should show error
given reader connected, when checkout clicked, then should hide error
given reader not connected, when checkout clicked and error CTA clicked, then should try connecting to reader
given order draft created, when reader connects, then start payment automatically
1. given order draft created, when reader connects, then start payment automatically

2. given order draft created, when reader disconnects, then should abort payment action
@dangermattic
Copy link
Collaborator

dangermattic commented Dec 3, 2024

1 Error
🚫 This PR is tagged with status: do not merge label(s).

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 3, 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
Commite90dfa3
Direct Downloadwoocommerce-wear-prototype-build-pr13053-e90dfa3.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 3, 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
Commite90dfa3
Direct Downloadwoocommerce-prototype-build-pr13053-e90dfa3.apk

@samiuelson samiuelson changed the base branch from trunk to custom-payment-ui-7-payment-cancelation December 3, 2024 13:30
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 78.57143% with 12 lines in your changes missing coverage. Please review.

Project coverage is 40.23%. Comparing base (3248e1d) to head (6db93e2).

Files with missing lines Patch % Lines
...oid/ui/woopos/home/totals/WooPosTotalsViewModel.kt 86.04% 2 Missing and 4 partials ⚠️
.../android/ui/woopos/common/composeui/WooPosTheme.kt 0.00% 3 Missing ⚠️
...oid/ui/woopos/home/totals/WooPosTotalsViewState.kt 70.00% 3 Missing ⚠️
Additional details and impacted files
@@                              Coverage Diff                              @@
##             custom-payment-ui-7-payment-cancelation   #13053      +/-   ##
=============================================================================
+ Coverage                                      40.20%   40.23%   +0.02%     
- Complexity                                      6064     6073       +9     
=============================================================================
  Files                                           1272     1272              
  Lines                                          73782    73829      +47     
  Branches                                       10089    10094       +5     
=============================================================================
+ Hits                                           29666    29706      +40     
- Misses                                         41541    41548       +7     
  Partials                                        2575     2575              

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

@samiuelson samiuelson added the status: do not merge Dependent on another PR, ready for review but not ready for merge. label Dec 3, 2024
@samiuelson samiuelson marked this pull request as ready for review December 3, 2024 15:59
@samiuelson samiuelson added this to the 21.3 milestone Dec 3, 2024
@AnirudhBhat AnirudhBhat self-assigned this Dec 9, 2024
Copy link
Contributor

@AnirudhBhat AnirudhBhat left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @samiuelson. Looks and tests well. I have just left one non-blocking comment.

@@ -186,6 +190,8 @@ private val DarkCustomColors = CustomColors(
border = WooPosColors.oldGrayMedium,
success = WooPosColors.greenNotFromPalette,
error = WooPosColors.darkCustomColorsError,
totalsErrorBackground = WooPosColors.darkQuaternaryBackground,
totalsBackground = Color(0xFF1C1C1E),
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ Do we want to give this color a symantic name and use that name here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed – ca31607

Base automatically changed from custom-payment-ui-7-payment-cancelation to custom-payment-iu-remove-collect-payment-button December 11, 2024 15:44
Base automatically changed from custom-payment-iu-remove-collect-payment-button to custom-payment-ui-6-use-payment-controller-in-pos December 11, 2024 15:44
@samiuelson samiuelson merged commit 4c58cf9 into custom-payment-ui-6-use-payment-controller-in-pos Dec 11, 2024
2 of 4 checks passed
@samiuelson samiuelson deleted the custom-payment-ui-8-reader-not-connected branch December 11, 2024 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: do not merge Dependent on another PR, ready for review but not ready for merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[UI] Show "reader not connected" prompt in Totals
5 participants