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

Send ipp_channel metadata in payment intent from store management/POS use cases #14479

Merged
merged 7 commits into from
Nov 27, 2024

Conversation

jaclync
Copy link
Contributor

@jaclync jaclync commented Nov 21, 2024

Closes: #14478

Why

As we are launching POS to external merchants soon, we want to identify if a transaction is from POS or IPP in the mobile apps for data analysis purposes.

How

As shared in pdfdoF-5QB-p2 > Apps, we want to add a new metadata ipp_channel: mobile_store_management | mobile_pos to the payment intent from IPP and POS respectively.

I thought about giving the channel parameter a default value of .storeManagement, but I'm afraid that this parameter will be forgotten and be the wrong value if we add more use cases in the future. I'm open to adding a default value if you think it will simplify the code though.

Steps to reproduce

  1. Create a new Jurassic Ninja site – include Jetpack, WooCommerce, WooPayments, and WooPayments Dev Tools
  2. Set up Jetpack to link the site to WPCOM user in the app (or skip this if you're loggin in with site credentials)
  3. Add a US address in WooCommerce settings
  4. Activate WooPayments. Go through the onboarding steps in WP-Admin > Payments > Activate. Alternatively, you can go through the onboarding in the app
  5. Launch the app and switch to your new site
  6. Create a purchasable product
  7. Go to the orders tab. Create an order and collect payment with a card reader --> the payment collection should succeed. after that, verify that the payment intent metadata includes ipp_channel: mobile_store_management in the Stripe account (* check instructions below)
  8. Go to the menu tab > Point of Sale mode. Add product to the cart and pay for the order --> the payment collection should succeed. after that, verify that the payment intent metadata includes ipp_channel: mobile_pos in the Stripe account (* check instructions below)

* How to check the transaction payment intent

Prerequisite: you have access to the WooPayments Stripe account (ask in #payment-operations if not)

  • In wp-admin > WCPay Dev, tap MC WCPay to see the payments info for the site
  • Under Stripe account details > Account ID, tap on the link to open the Stripe account (make sure you're logged in to WooPayments in Stripe, with test mode enabled)
  • Tap Payments, find the payment that was just made
  • On the payment details page, search for ipp_channel and verify the value is as expected

Testing information

I also tested with local server-side changes.

Screenshots

Screenshot 2024-11-21 at 2 03 28 PM
  • 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

@jaclync jaclync added type: task An internally driven task. feature: mobile payments Related to mobile payments / card present payments / Woo Payments. feature: POS labels Nov 21, 2024
@jaclync jaclync added this to the 21.2 milestone Nov 21, 2024
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Nov 21, 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 Numberpr14479-b601a7c
Version21.2
Bundle IDcom.automattic.alpha.woocommerce
Commitb601a7c
App Center BuildWooCommerce - Prototype Builds #11752
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@jaclync jaclync marked this pull request as ready for review November 21, 2024 06:19
Copy link
Collaborator

@staskus staskus left a comment

Choose a reason for hiding this comment

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

✅ Thanks, works as described!

POS Store Management
mobile_pos mobile_store_management

One note is that ipp_channel appears twice within payment details:

  • charges -> data -> metadata -> ipp_channel
  • metadata -> ipp_channel

On a technical note, I was thinking if passing a channel all around could be avoided. If POS and Store Management would rely on different instances of dependencies, then we could inject the channel through an initializer. However, that's not an option now so I don't have good suggestions. Given this code rarely has a new entry point maybe thats a non-issue.

@@ -106,7 +111,8 @@ public extension PaymentIntent {
siteURL: String? = nil,
orderID: Int64? = nil,
orderKey: String? = nil,
paymentType: PaymentTypes? = nil
paymentType: PaymentTypes? = nil,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit;

There's broken alignment for the rest of the parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the indentation of these misaligned parameters in b601a7c

* trunk: (132 commits)
  Update tests
  Make sure self is weakly captured
  Add a clarifiyng comment regarding the nullability of site
  customPackageViewModel as StateObject
  Simplify expression
  Add a release note
  Make sure to wait for site to be available before handling the magic link
  Rename to WooShippingAccountSettings
  Make bindings private
  Freeze strings for localization
  Update metadata strings
  Update release notes with @joshheald's thoughtful rewrite.
  Do not dismiss success modals automatically when email receipt action is selected
  Restructure presentBackendReceiptAlert to align implementation for success and failed alerts
  Use CardPresentModalBuiltIn modals for BuiltInCardReaderPaymentAlertsProvider
  Restructure the code to set paymentSuccessEmailSent when presentSendReceiptAfterPayment succeeds
  Add missing weak self when presentSendReceiptAfterPayment is called
  Update closure naming in CardPresentModalErrorTests
  Clarify closure naming for CardPresentModalNonRetryableError
  Clarify closure naming for CardPresentModalErrorEmailSent and Clarify closure naming for CardPresentModalErrorWithoutEmail
  ...

# Conflicts:
#	WooCommerce/Classes/ViewRelated/Orders/Collect Payments/CollectOrderPaymentUseCase.swift
#	WooCommerce/WooCommerceTests/ViewModels/CardPresentPayments/CollectOrderPaymentUseCaseTests.swift
@jaclync
Copy link
Contributor Author

jaclync commented Nov 26, 2024

On a technical note, I was thinking if passing a channel all around could be avoided. If POS and Store Management would rely on different instances of dependencies, then we could inject the channel through an initializer. However, that's not an option now so I don't have good suggestions. Given this code rarely has a new entry point maybe thats a non-issue.

Yea I agree that it's not pretty seeing a bunch of places where the channel is passed around. Initially, I tried DI'ing the channel to the initializers but decided to move it to the collectPayment function worrying that the dependencies could become a singleton in the app in the future. As the channel value isn't something we test normally, it might be worth making this parameter explicit in every payment collection use case.

@jaclync
Copy link
Contributor Author

jaclync commented Nov 27, 2024

Merging this PR as it's approved to avoid merge conflicts, with the possibility of adding a feature flag or condition on the WooPayments version per decision pdfdoF-5UW-p2#comment-6983.

@jaclync jaclync merged commit 6024bea into trunk Nov 27, 2024
14 checks passed
@jaclync jaclync deleted the feat/tpv-tracking-channel branch November 27, 2024 05:39
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: task An internally driven task.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[POS TPV Tracking] Send ipp_channel metadata in payment intent for IPP/POS
3 participants