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

[Backend Receipts] Update store and actions to account for backend receipts #11848

Merged

Conversation

iamgabrielma
Copy link
Contributor

@iamgabrielma iamgabrielma commented Jan 30, 2024

Closes #11828
#11847 must be merged first.

Description

This PR updates the business logic in order to fetch a receipt from the new API endpoint when the proper action is invoked.

We also update the UI to display a temporary [Debug] See Backend Receipt button for all orders for developer builds. The existing See Receipt will be displayed as always, this means that if the local-generated receipt exists on the device, then its row will also be shown below (we don't change the legacy logic for locally-generated receipts).

This is only for testing purposes and to keep changes small, in following PRs we'll add further validation (feature flag + Woo version) and display only the local receipt or the backend receipt, but not both.

If local receipt doesn't exist If local receipt does exist
Simulator Screenshot - iPhone 15 - 2024-01-30 at 17 11 17 Simulator Screenshot - iPhone 15 - 2024-01-30 at 17 11 24

Changes

  • Added a new ReceiptAction which will either return a Receipt or an Error from the remote.
  • Added an additional seeReceipt row to the tableview datasource, this is feature flagged so will only be shown in dev builds.
  • When the button is tapped, we will reach the new endpoint and return either a Receipt or an Error. At the moment we just log the result to the console.
  • Updated unit tests

Testing instructions

Success:

  • In the app, log into mywootestingstore.mystagingwebsite.com (you will find the credentials in your email). This is necessary since the site runs a developer branch of WooCommerce needed to use the new receipts endpoint.
  • Go to Orders > tap on any order (at the moment doesn't matter it's status) > tap on [Debug] See Backend Receipt
  • Observe that Xcode console logs the receipt:
"Receipt(receiptURL: \"https://mywootestingstore.mystagingwebsite.com/wc/file/transient/7e811fa568e1102fe3bec19f0a2441cf116bf4\", expirationDate: \"2024-01-31\")"

Failure:

  • In the app, log into any other site that runs a production version of WooCommerce
  • Go to Orders > tap on any order > tap on [Debug] See Backend Receipt
  • Observe that Xcode console logs the error:
"Dotcom Invalid REST Route"

Screenshots

2024-01-30 debug new receipt button

@iamgabrielma iamgabrielma added type: task An internally driven task. feature: order details Related to order details. feature: mobile payments Related to mobile payments / card present payments / Woo Payments. labels Jan 30, 2024
@iamgabrielma iamgabrielma added this to the 17.2 milestone Jan 30, 2024
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 30, 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 Numberpr11848-d4bb8ce
Version17.1
Bundle IDcom.automattic.alpha.woocommerce
Commitd4bb8ce
App Center BuildWooCommerce - Prototype Builds #7843
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@iamgabrielma iamgabrielma marked this pull request as ready for review January 30, 2024 10:34
@iamgabrielma
Copy link
Contributor Author

As always, only one reviewer is needed 🙇

Base automatically changed from issue/11826-receipts-backend-rename-legacy-receipt to trunk January 30, 2024 11:51
@iamgabrielma
Copy link
Contributor Author

iamgabrielma commented Jan 31, 2024

@bozidarsevo if you keep having troubles to log into the testing site, an alternative is to create a new site that uses the WooCommerce development branch for the API:

  1. Create a fresh jurassic-ninja, Pressable (you can log with your a8c email for the free sites), or other non-managed self-hosted site. The WooCommerce install cannot be managed, otherwise the version used is set by the hosting.
  2. From the dev branch (Add the Receipts Rendering Engine woocommerce#43502), open the latest build and download the artifact (you might need to re-run the job if has expired: pdfdoF-4gx-p2#comment-5732 )
  3. Unzip it, install it in your site as a normal plugin, configure some payment methods (COD or bank transfer is enough), add a product, and create an order.
Screenshot 2024-01-31 at 08 22 56

*version might be different, but you'll see something similar in wp-admin

@iamgabrielma iamgabrielma merged commit 0ae56d4 into trunk Jan 31, 2024
25 of 27 checks passed
@iamgabrielma iamgabrielma deleted the issue/11828-receipts-backend-udpdate-store-and-actions branch January 31, 2024 10:18
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: order details Related to order details. type: task An internally driven task.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Backend Receipts] Update ReceiptStore and actions
3 participants