woocommerce / woocommerce-gateway-stripe

The official Stripe Payment Gateway for WooCommerce
https://wordpress.org/plugins/woocommerce-gateway-stripe/
232 stars 203 forks source link

Express Checkouts break order attribution metadata #3022

Open seanconklin opened 6 months ago

seanconklin commented 6 months ago

Describe the bug We use the Checkout Block and have noticed that all of our Apple Pay and Google Pay orders show Unknown (empty) metadata for WooCommerce Order Attribution Tracking.

To Reproduce Steps to reproduce the behavior:

  1. Log into a production site that runs this WooCommerce Stripe plugin and uses the Checkout Block.
  2. Click on Woo > Orders to see the list of orders, maybe using Screen Options to expand to 100 in view.
  3. Ensure that you have Order Attribution enabled (default it is) in Woo > Settings > Advanced > Features > Order Attribution and that this Origin column is enabled in your Screen Options (default it is).
  4. Look at each and every Apple Pay and Google Pay order (via the Billing column) and notice Unknown is displayed in the Origin column for these orders specifically.

Expected behavior My client and I would expect to see order Origins for the most part (Google, Facebook, Direct, etc.), as we do when people pay via Credit Card.

Screenshots Orders

Environment (please complete the following information): WordPress 6.4.3 running Best Chinese Medicines Block Theme theme. Plugins are as follows: Advanced Custom Fields Advanced Database Cleaner Advanced Order Export For WooCommerce Akismet Anti-spam: Spam Protection Blocks Animation: CSS Animations for Gutenberg Blocks Bot Protection Breeze Cloudflare Code Snippets Facebook for WooCommerce FiboSearch - AJAX Search for WooCommerce (Pro) Google Analytics for WooCommerce Google Listings and Ads Judge.me Product Reviews for WooCommerce Klaviyo Mailgun Microsoft Advertising Universal Event Tracking (UET) Phoenix Media Rename Pinterest for WooCommerce Redirection SimpleTOC - Table of Contents Block Smush Up-sell Trio for WooCommerce User Switching WooCommerce WooCommerce - ShipStation Integration WooCommerce Address Validation WooCommerce Quick View WooCommerce Stripe Gateway Yoast SEO Yoast SEO: WooCommerce

wyter commented 6 months ago

Reported on 7914523-zen

james-allan commented 5 months ago

So after a quick investigation I believe the order attribution is missing from orders placed with Express Payment Buttons (eg Google Pay) because WC core sets this meta on the woocommerce_checkout_order_created hook. That hook is fired when orders are placed using an Express Payment button, however WC core only attempts to generate the Order Attribution data from the $_POST.

It goes without saying but the $_POST data when processing a express payments doesn't include the same wc_order_attribution_ data and hence no attribution is made.

I think we have a couple of possible approaches here.

  1. Somehow replicate the $_POST data necessary to record the attribution when we process the payment. ie somewhere here: https://github.com/woocommerce/woocommerce-gateway-stripe/blob/8.2.0/includes/payment-methods/class-wc-stripe-payment-request.php#L1698
  2. Do something similar to the Blocks checkout which appears to fetch the attributes (I still need to look into that) and then trigger the woocommerce_order_save_attribution_data hook themselves when the woocommerce_store_api_checkout_update_order_from_request hook is fired.
    • ie we could also fire the woocommerce_order_save_attribution_data hook but we'd need to fetch the attribution data.
  3. Notify the WC core of this gap in the order attribution feature in case they want to address it on their end.
    • This is a good course of action anyway because there is likely other gateways impacted by this and they may want to approach it from their end rather than have all gateways attempt to fix it on their end in a piecemeal way.
james-allan commented 5 months ago

Notify the WC core of this gap in the order attribution feature

This has been filed with WC core here: https://github.com/woocommerce/woocommerce/issues/46309.

james-allan commented 5 months ago

I've given this issue the blocked status while we work out with the WC core team what the right path forward is here.

github-actions[bot] commented 4 days ago

Hi, This issue has gone 150 days (5 months) without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest version, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.

james-allan commented 3 days ago

Just noting that this issue also affects the ECE update we're doing. See my comment here for how this is impacted: https://github.com/woocommerce/woocommerce-gateway-stripe/issues/3022#issuecomment-2054879444

ECE button payments are still largely processed the same via a request without the $_POST args necessary to make the attribution links.