Skip to content

Conversation

@iamgabrielma
Copy link
Contributor

@iamgabrielma iamgabrielma commented Jan 4, 2023

Part of #8530

Description

This PR adds the logic to discern which in-app feedback banner we should show to the merchant, based on if the Store is eligible ( has COD enabled, and the country is IPP-supported ), and three conditions:

  • Haven't collected any IPP payments.
  • Have collected less than 10 IPP transactions in the last 30 days.
  • Have collected more than 10 IPP transactions in the last 30 days.

At the moment we're not displaying or populating any specific content when any of the 3 conditions occur, this will be dealt with on a different PR.

Changes

  • Call to displayIPPFeedbackBannerIfEligible() in OrderListViewController's init, which will perform the logic to check if COD is enabled, and fetch IPP transactions from storage (if any) as well as those within 30 days.

Testing instructions

  1. On a Store with IPP transactions, and COD enabled. Navigate to Menu > Orders
  2. Check Xcode console and confirm that transactions within 30 days are logged:
hasResults? true
IPP transactions within 30 days: 3

[
  "OrderID: 1475 - PaymentMethodID: woocommerce_payments (WooCommerce In-Person Payments - DatePaid: Optional(2023-01-02 01:55:33 +0000)", 
  "OrderID: 1481 - PaymentMethodID: woocommerce_payments (WooCommerce In-Person Payments - DatePaid: Optional(2023-01-05 10:45:27 +0000)", 
  "OrderID: 1488 - PaymentMethodID: woocommerce_payments (WooCommerce In-Person Payments - DatePaid: Optional(2023-01-10 10:00:19 +0000)"
]

< 10 transactions within 30 days. Banner 2 shown

Due to the nature of fetching orders from Storage and how we use this layer as a sort of caching mechanism rather than as a source of truth, in some cases you may encounter 0 IPP transactions despite that these exist, for example if you install the app and go directly to the payments view without visiting the Orders view first. This is "expected" at this time, as we're looking for a fast solution to get us 90% there. The solution is to go to Orders > wait until are fetched > go back to Payments.

One potential way to smooth this problem is to add pull-to-refresh, this can be worked on a different PR or in i2 ( tracked here )

Edit: As new requirements have changed the logic from Payments to Orders, this may no longer be a problem.

@iamgabrielma iamgabrielma added type: enhancement A request for an enhancement. feature: mobile payments Related to mobile payments / card present payments / Woo Payments. labels Jan 4, 2023
@iamgabrielma iamgabrielma added this to the 11.8 milestone Jan 4, 2023
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 4, 2023

You can test the changes from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr8549-c3fef0d on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@iamgabrielma iamgabrielma modified the milestones: 11.8, 11.9 Jan 5, 2023
@iamgabrielma iamgabrielma marked this pull request as ready for review January 6, 2023 06:25
@iamgabrielma iamgabrielma requested a review from joshheald January 6, 2023 06:33
iamgabrielma and others added 3 commits January 9, 2023 19:51
Previously we considered IPP orders just based on their `paymetMethodID` or `paymentMethodTitle`, but this would not differentiate between IPP orders processed through the website vs the app. In order to have a more reliable solution, we add a second check to the Order `meta_data`, as IPP Orders processed through the app should have a `receipt_url` field, unlike their website counterpart.
@iamgabrielma
Copy link
Contributor Author

iamgabrielma commented Jan 11, 2023

Thanks for the pairing session yesterday @joshheald , this PR is ready for review 🙇

As discussed, in fe967c7 I've added an extra check to be sure that the IPP transactions we're getting are coming from the app, and not the web, by checking if their metadata contains a receipts_url key.

I couldn't find an easy way to do so directly via the resultsController predicate, so I opted for filtering the fetched objects once we get back the results from Storage.

@malinajirka malinajirka modified the milestones: 11.9, 12.0 Jan 12, 2023
@iamgabrielma iamgabrielma added status: draft This is a draft, still need more work but can be reviewed and commented if asked. and removed status: draft This is a draft, still need more work but can be reviewed and commented if asked. labels Jan 13, 2023
@iamgabrielma iamgabrielma changed the title [IPPInAppFeedback] Banner business logic and merchant eligibility [IPPInAppFeedback] Banner business logic and merchant eligibility in Orders screen Jan 16, 2023
@joshheald
Copy link
Contributor

@iamgabrielma Initial testing: all of my IPP stores say this –

COD enabled? true - Eligible Country? true
hasResults? false
IPP transactions within 30 days: 0
[]
0 transactions. Banner 1 shown

It was not possible to sync local orders settings: noOrdersSettings

However... some of those stores are full of recent IPP transactions, and all have at least some. I pulled to refresh and it says the same thing.

We can pair on why it's doing that if you like?

@joshheald
Copy link
Contributor

Hmm. I had to launch it again to hit a breakpoint (because I wanted to hit the one in viewDidLoad) and the second time round, it came up with

COD enabled? true - Eligible Country? true
hasResults? true
IPP transactions within 30 days: 10
["OrderID: 440 - PaymentMethodID: woocommerce_payments (WooCommerce In-Person Payments - DatePaid: Optional(2023-01-11 18:49:54 +0000)", "OrderID: 445 - PaymentMethodID: woocommerce_payments (WooCommerce In-Person Payments - DatePaid: Optional(2023-01-13 14:24:28 +0000)", "OrderID: 450 - PaymentMethodID: woocommerce_payments (WooCommerce In-Person Payments - DatePaid: Optional(2023-01-16 10:50:36 +0000)", "OrderID: 451 - PaymentMethodID: woocommerce_payments (WooCommerce In-Person Payments - DatePaid: Optional(2023-01-13 17:40:57 +0000)", "OrderID: 452 - PaymentMethodID: woocommerce_payments (WooCommerce In-Person Payments - DatePaid: Optional(2023-01-13 16:48:11 +0000)", "OrderID: 455 - PaymentMethodID: woocommerce_payments (WooCommerce In-Person Payments - DatePaid: Optional(2023-01-13 17:45:11 +0000)", "OrderID: 456 - PaymentMethodID: woocommerce_payments (WooCommerce In-Person Payments - DatePaid: Optional(2023-01-16 10:49:15 +0000)", "OrderID: 457 - PaymentMethodID: woocommerce_payments (WooCommerce In-Person Payments - DatePaid: Optional(2023-01-16 10:37:57 +0000)", "OrderID: 458 - PaymentMethodID: woocommerce_payments (WooCommerce In-Person Payments - DatePaid: Optional(2023-01-16 10:22:59 +0000)", "OrderID: 459 - PaymentMethodID: woocommerce_payments (WooCommerce In-Person Payments - DatePaid: Optional(2023-01-16 11:06:49 +0000)"]
>= 10 transactions within 30 days. Banner 3 shown

So that's correct, there are exactly 10 paid IPP transactions in the last 30 days.

I think the fix is probably to refresh the results on viewWillAppear, or when we fetch orders, or something like that.

Copy link
Contributor

@joshheald joshheald left a comment

Choose a reason for hiding this comment

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

Second time round it worked for me: I suspect there's something about the first time run for each site which means it's not quite working right. Worth investigating but can be done as follow on work if you want to merge this – it's feature flagged.

Consider adding tests for this logic too: it could help you work faster on it, even though this is a temporary addition to the app.

@iamgabrielma
Copy link
Contributor Author

Thanks for the review!

some of those stores are full of recent IPP transactions, and all have at least some. I pulled to refresh and it says the same thing.

That's interesting, from these 2 lines would seem that not only failed to fetch IPP orders but also to sync stored Orders settings:

hasResults? false
It was not possible to sync local orders settings: noOrdersSettings

I've opened a new issue here to investigate this further, happy to pair at any time 🙇

Consider adding tests for this logic too: it could help you work faster on it, even though this is a temporary addition to the app.

Will do!

@iamgabrielma iamgabrielma merged commit 7fd57f2 into trunk Jan 17, 2023
@iamgabrielma iamgabrielma deleted the task/ippiaf-eligibility branch January 17, 2023 02:03
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: enhancement A request for an enhancement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants