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

Location pre-alert view for card reader payments #14672

Merged

Conversation

staskus
Copy link
Collaborator

@staskus staskus commented Dec 12, 2024

Closes: #14168

Description

Add location permission pre-alert modal before requesting location permission and handle the location denied state during the card reader connection process.

This PR builds on top of the functionality already developed for TTP:

POS doesn't show any new permission modals. If the location is not determined it immediately shows a native alert and continues with the payment flow regardless of the response. I created a task to implement the functionality:

Steps to reproduce

Prerequisites

  • Install a fresh app or go to Settings -> Privacy & Security -> Location Services -> Woo and set to "Ask Next Time Or When I Share"
  • Store eligible for IPP
  • Card Reader
  1. Make an order with product or custom amount
  2. Select Card Reader
  3. Confirm Location pre-alert appears
  4. Tap Continue
  5. Confirm native iOS alert appears
  6. Not Allow the permission
  7. Confirm Location required alert appears
  8. Dismiss
  9. Confirm the modal closes
  10. Select Card Reader again
  11. Confirm Location required alert appears
  12. Select Open Settings
  13. Change Location access to 'While Using the App'
  14. Return to the app
  15. Confirm the payment flow proceeds

Testing information

Tested on iOS 18 simulators, and iOS 17 devices. Tested POS for regressions. Tested alternative flows during the reader discovery process - selecting a list of multiple readers, or canceling the search.

Videos

Card Reader Connection

iOS.-.Location.mp4

POS regression testing - location allowed

POS.-.Location.Allowed.mp4

POS regression testing - location denied

POS.-.Location.Denied.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.

…Controller

Mirror a similar solution to built-in card reader. Ask for permission before Stripe Terminal SDK to have a full control of it:

- Before connecting to reader check permission using LocationService
- For allowed state, proceed with connection
- For not determined state display location pre-alert explaining the native alert that follows
- Fot denied state display a location required alert allowing to access device settings
@staskus staskus added type: task An internally driven task. feature: mobile payments Related to mobile payments / card present payments / Woo Payments. labels Dec 12, 2024
@staskus staskus added this to the 21.3 milestone Dec 12, 2024
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 12, 2024

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 Numberpr14672-eb3cc2e
Version21.2
Bundle IDcom.automattic.alpha.woocommerce
Commiteb3cc2e
App Center BuildWooCommerce - Prototype Builds #12126
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@jaclync jaclync self-assigned this Dec 13, 2024
Copy link
Contributor

@jaclync jaclync left a comment

Choose a reason for hiding this comment

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

LGTM :shipit: I'm guessing unit testing CardReaderConnectionController isn't straightforward on the state transitions, originally to .connectToReader?

@staskus
Copy link
Collaborator Author

staskus commented Dec 13, 2024

I'm guessing unit testing CardReaderConnectionController isn't straightforward on the state transitions, originally to .connectToReader?

Thanks! Good point, I'll check how to be safer and cover these changes with unit tests.

Update:

I noticed that these tests are disabled #10536

However, I added additional tests and ran them. When the location is authorized, all the previous tests pass.
image

@staskus staskus enabled auto-merge December 13, 2024 13:11
@staskus staskus merged commit 003a5de into trunk Dec 13, 2024
10 of 12 checks passed
@staskus staskus deleted the task/14168-location-pre-alert-screen-for-card-reader-connection branch December 13, 2024 13:27
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. type: task An internally driven task.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TTPReq] Location pre-alert screen
3 participants