woocommerce / woocommerce-gateway-stripe

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

Potential duplicate webhook actions #2331

Closed ryanr14 closed 2 months ago

ryanr14 commented 2 years ago

Describe the bug This issue already exists within WooCommerce Payments, could the same thing also be happening in the Stripe extension itself?

I worked on a ticket this morning( 4902272-zen ) where they have said most of their recent Stripe orders have these duplicate order notes from Stripe regarding the charge. For example they see this twice or more on their orders.

Stripe charge complete (Charge ID: ch_XXXXXX)

To Reproduce I am not finding a specific way to replicate this as it doesn't happen on my local site in test mode, but it's happening just about every order on this customers site.

Expected behavior No duplicate order notes. The customer thought customers were being charged twice, it doesn't seem that way since the charge IDs are the same in any duplicated or triplicated order notes.

Screenshots https://d.pr/i/zDbDvh Image link: https://d.pr/i/zDbDvh

dreamtooloud commented 2 years ago

The user from zd-4902272 mentioned that they have the same plugins set up on a different server and they don't see the duplicate notes problem. I've asked for some additional information about the configuration and if they've reached out to their server at all (on the problem site we are currently troubleshooting) to see if it's a server related issue.

dreamtooloud commented 2 years ago

Another update from the same user. I had suggested (as a work around for their downloadable content issue) turning on the function to access download upon purchase, but they corrected what they said before about the payment statuses:

"Seems the status is not in "Processing" after the Stripe payment is finished. It is in "Waiting for payment"."

That means second status is triggering a push back to "pending payment" even though the payment has already been made.

They also mentioned this about their other server's settings: For the other server, we are using the same version of WooCommerce Plugin and Stripe gateway plugin. Seems everything work normally on the server.

They have included the System status in their ticket. Let me know if you want me to add it here.

shaunkuschel commented 2 years ago

I took a look at 4902272-zen and noticed that there are quite a fatal errors occurring around when this duplicate note/status change is happening:

2022-04-09T03:57:37+00:00 CRITICAL Uncaught Error: Call to a member function get_sku() on null in /wordpress/plugins/woocommerce/6.3.1/templates/single-product/meta.php:28
Stack trace:
#0 /wordpress/plugins/woocommerce/6.3.1/includes/wc-core-functions.php(345): include()
#1 /wordpress/plugins/woocommerce/6.3.1/includes/wc-template-functions.php(1646): wc_get_template('single-product/...')
#2 /wordpress/core/5.9.3/wp-includes/class-wp-hook.php(307): woocommerce_template_single_meta('')
#3 /wordpress/core/5.9.3/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
#4 /wordpress/core/5.9.3/wp-includes/plugin.php(474): WP_Hook->do_action(Array)
#5 /srv/htdocs/wp-content/themes/flatsome/woocommerce/content-single-product-lightbox.php(57): do_action('woocommerce_sin...')
#6 /wordpress/plugins/woocommerce/6.3.1/includes/wc-core-functions.php(345): include('/srv/htdocs/wp-...')
#7 /srv/htdocs/wp-content/themes/flatsome/inc/extensions/flatsome-wc-quick-view/flatsome-quick-view.php(41): wc_get_template('content-single-...')
#8 /wordpress/core/5.9.3/wp-includes/class-wp-hook.php(307): flatsome_quickview('')
#9 /wordpress/core/5.9.3/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array)
#10 /wordpress/core/5.9.3/wp-includes/plugin.php(474): WP_Hook->do_action(Array)
#11 /wordpress/core/5.9.3/wp-admin/admin-ajax.php(202): do_action('wp_ajax_nopriv_...')
#12 {main}
  thrown 於 /wordpress/plugins/woocommerce/6.3.1/templates/single-product/meta.php on line 28

I suggested that they address that fatal error and see if that resolves the issue.

thracefulton commented 2 years ago

Another possible case in 4940814-zen.

ryanr14 commented 2 years ago

I was working again on 4940814-zen and they don't have any fatal error logs available as in @shaunkuschel's case. Just as an FYI. They enabled Stripe logging once they noticed this happening, but I don't believe it's happened again since April 8th for their site.

joaodante commented 2 years ago

Another case here: 4965600-zen

The merchant commented it's not happening with ALL orders (but with most of them).

thelogicwizards commented 2 years ago

4940814-zen reports that the issue persists, but they recently shared that:

Interesting to note that the doubling of logged ticket numbers on Order Details is no longer present on the affected orders, as far as we can tell, but the duplicate emails (obviously) and duplicate Stripe notices (but not charges) remain.

aheckler commented 2 years ago

12595841-hc which led to 5083355-zen was this. Merchant solved it by disabling this in the Stripe settings:

Screenshot taken on 2022-04-25 at 19 27 07 UTC@2x
lovo-h commented 2 years ago

Just to clarify, this is not a case of duplicate webhook actions. Instead, it's the following:

  1. The webhook action payment_intent.succeeded being called.
  2. add_action( 'wp', [ $this, 'maybe_process_upe_redirect' ] ) being called when UPE is enabled.

That's why the merchant that @aheckler brought up had success in solving the issue when they disabled UPE: they removed pathway 2 (i.e. maybe_process_upe_redirect call).

1. The webhook action payment_intent.succeeded stacktrace:

abstract-wc-stripe-payment-gateway.php:539, WC_Stripe_Payment_Gateway->process_response()
class-wc-stripe-webhook-handler.php:854, WC_Stripe_Webhook_Handler->process_payment_intent_success()
class-wc-stripe-webhook-handler.php:990, WC_Stripe_Webhook_Handler->process_webhook()
class-wc-stripe-webhook-handler.php:70, WC_Stripe_Webhook_Handler->check_for_webhook()

2. add_action( 'wp', [ $this, 'maybe_process_upe_redirect' ] ) being called when UPE is enabled:

abstract-wc-stripe-payment-gateway.php:539, WC_Stripe_Payment_Gateway->process_response()
class-wc-stripe-upe-payment-gateway.php:923, WC_Stripe_UPE_Payment_Gateway->process_order_for_confirmed_intent()
class-wc-stripe-upe-payment-gateway.php:853, WC_Stripe_UPE_Payment_Gateway->process_upe_redirect_payment()
class-wc-stripe-upe-payment-gateway.php:822, WC_Stripe_UPE_Payment_Gateway->maybe_process_upe_redirect()
class-wc-stripe-intent-controller.php:680, WC_Stripe_Intent_Controller->maybe_process_upe_redirect()

These two pathways will need to be debugged and either the "Stripe charge complete" note needs to get removed from one or it may be a bit more involved and both of the pathways will need to be reevaluated.

thisissandip commented 2 years ago

5175398-zen

stuartduff commented 2 years ago

5202573-zen The particular customer within this support ticket is finding that due to the duplication stock quantities are being reduced twice.

Gabriel-Denys commented 2 years ago

I am actually experiencing the exact same issue. It happened to me exactly after I deleted a webhook and configured a new one.

I get duplicate order notes, duplicate emails, and stock being reduced twice.

The issue does not occour when a customer pays via Apple Pay. I have the new checkout experience enabled.

I can share the logs if needed.

Are there any solutions other than switching back to the old checkout?

mouligreenlaw commented 2 years ago

Hi there! I'd like to update the merchant on 4940814-zen as to a possible release of this fix. Is there anything I can tell them?

solstudioim commented 2 years ago

It was reported in 5334483-zen and 5339700-zen too.

dreamtooloud commented 2 years ago

Have another report of this here: 36018895-hc and follow up here: 5202573-zen

Got creds to confirm relation to this bug--but I'm 99% sure it is connected base on the information the user provided.

nicholasjeberlin commented 2 years ago

5360179-zen

LaurenceKay commented 2 years ago

I am having this issue as well on 2 websites

Have just tried turning off new check out see if that resolves the issue.

jos22 commented 2 years ago

5453836-zen. User is facing duplicate stock reduction on top of duplicate order notes just as @stuartduff mentioned.

dreamtooloud commented 2 years ago

Working on 5468298-zen where we have duplicate charge complete order notes plus duplicate points being awarded via WooCommerce Points and Rewards. Trying to confirm if it's related to this or not.

mouligreenlaw commented 2 years ago

Adding to @dreamtooloud comments relating to 5468298-zen I looked at the orders received today, 11 Aug, and found that duplicate points were only awarded when Stripe was used and the customer had an account. Out of 5 orders using Stripe, only one did not duplicate the Stripe note, and the two that had points applied show the duplicate points. All orders that used PayPal awarded points once as expected. My thinking is that this is not a bug in Points & Rewards and it is caused by this bug in Stripe. Note: EPU features are disabled on this site.

LaurenceKay commented 2 years ago

I have spent some time looking into this seems 99% sure its some thing to do with the Try the new checkout experience (early access)

i have 4 websites 2 which had this activated had the issue, since turning off haven't seemed to have the problem.

dreamtooloud commented 2 years ago

We mentioned to the user that we didn't think there duplicate notes/inventory reduction was related to this issue because they don't have UPE enabled but after looking through all the notes here and the other tickets I do want to add this to the list, because everything else about it is similar: 5539401-zen.

Asking them to conduct a conflict test now to confirm the above.

AbhinavSakalle commented 2 years ago

5612750-zen Duplicate order emails are also being sent.

thisissandip commented 2 years ago

Merchant from 5612750-zen deep dived into the issue and shared the below details:

I found that not all orders were affected by the problem, so I analyzed the last 50 orders to try to see if the orders that have the problem have similarities between them, and this will allow you to analyze them too. I did not notice anything at the level of users (whether guest or registered), nor at the level of the amount of the order. So I looked for Stripe and the nature of the payments (issuing bank, type of bank card, etc.). The result is here: https://docs.google.com/spreadsheets/d/14pmlKeMCBfHLh5LHUcRTq6IqQwdBDa36gKJ0zvV_OlM/edit?usp=sharing

Unfortunately neither the issuing bank nor the type of card seems to affect the problem. However, I notice that the problem is less present for CB type cards. 3D secure, sometimes requested from the customer and sometimes exempted, does not seem to have any influence either.

On the other hand, I noticed that the 3D secure information did not always appear in the logs. That is to say that for certain payments, I do not have the information if the exemption or the submission took place. And in this specific case, the problem is systematically present. The only exception is an iDEAL payment, but that's surely particular for this payment method. On the other hand, it seems important to me to note that the problem can exist for an alternative payment to the bank card (here iDEAL), contrary to what I had announced to you following the SOFORT payment which had worked.

Here is an image: https://diamant-strass-dmc.com/3dsecure_test.png

In my Drive table, the red terms in the image are listed in the "3D Secure" column.

Finally, I would like to point out that I have activated all possible Webhooks in my Stripe account.

joashrajin commented 2 years ago

+1 at 5628841-zd-woothemes

In this case, the customer also noticed the order received email was being sent twice

roryWolf commented 2 years ago

This merchant is also experiencing duplicate emails being sent: 4940814-zen

nekszt commented 1 year ago

I am experiencing the same issue ! With this issue our users have a bad experience, pages refresh, duplicated emails, and also for us, data tracking, notifications ...

Is the issue well identified ? Has anyone identified a quick fix ?

nekszt commented 1 year ago

Do you have feedback about translations, WPML ? A redirection caused by the translation and/or cookie setting about translation ?

thisissandip commented 1 year ago

While the team is looking into the issue, please use the workaround mentioned here

lTKV1o.png

marissaexplores commented 1 year ago

5693996-zen

MartijnKaimea commented 1 year ago

Thanks for the information thus far. I have the same issue. Be interested to see when this gets resolved. My contact with Woo Support resulted in this:

Although this is a high-priority bug, we are unable to give an exact timeline for the fix at this time. While the developers are working on this, their official workaround is to disable the "New Checkout Experience" under WooCommerce > Settings > Payments > Stripe > Settings > Advanced Settings, as you mentioned in your findings.

For me, it doesn't really feel like a high-priority bug if it has been documented since April. I'll switch back to the 'old' checkout experience.

wyter commented 1 year ago

5936844-zen

orhanfernandes commented 1 year ago

5941928-zen

darcie commented 1 year ago

6293912-zen was facing duplicate order complete notifications. Disabling the new payment experience resolved the issue.

ramshengale commented 7 months ago

We're getting this exact same issue with new payment experience option enabled. This issue has been Open since last years. Can you please look into this?

ryanr14 commented 6 months ago

8017760-zen

sverleis commented 6 months ago

8014478-zen

TullariS commented 6 months ago

Hi guys,

Having this issue as well. I've noticed in my case that if I use regular test cards you do not get a doubled-up order status change, but if you use a 3DSecure card, you do.

Hope this helps.

bdawson-ssapopka commented 5 months ago

We are also experiencing this error. We are using WooCommerce Stripe Gateway and WooCommerce Subscriptions, WooCommerce Memberships, and Teams for WooCommerce Memberships. We have the new checkout experience enabled and are running version 8.2.0 of WooCommerce Stripe Gateway.

The issue is more than just a charge note being applied twice to an order. We also see that the WC_Order->status_transition() function is being called twice by duplicate calls to WC_Order->save(). This is triggering the woocommerce_order_status_pending action hook to be fired twice, as seen here:

Screen Shot 2024-04-30 at 11 04 25 AM

The duplication stems from two processes that ultimately call a function in abstract WC_Stripe_Payment_Gateway. The following flows are the culprits according to my stack trace:

WooCommerce Checkout AJAX Flow

WC_Order->status_transition()
WC_Order->save()
WC_Order->payment_complete()
WC_Stripe_Payment_Gateway->process_response()  //This is where the duplicate call is!
WC_Stripe_UPE_Payment_Gateway->process_payment_with_deferred_intent()
WC_Stripe_UPE_Payment_Gateway->process_payment()
WC_Checkout->process_order_payment()
WC_Checkout->process_checkout()
WC_AJAX::checkout()

Stripe Gateway Webhook Flow

WC_Order->status_transition()
WC_Order->save()
WC_Order->payment_complete()
WC_Stripe_Payment_Gateway->process_response() //This is where the duplicate call is!
WC_Stripe_Webhook_Handler->process_payment_intent_success()
WC_Stripe_Webhook_Handler->process_webhook()
WC_Stripe_Webhook_Handler->check_for_webhook()

For now, I think we will have to disable the new checkout experience as we are trying to launch a website soon and this duplicate call to the woocommerce_order_status_pending hook causes significant problems for the WooCommerce Memberships for Teams team creation functionality. Hopefully this helps to fix the issue.

lunasera41 commented 5 months ago

8109500-zen

a-danae commented 3 months ago

👋 hey!

Are you still having this issue using Stripe 8.3.1 or newer?

We introduced changes related to the process behind this behavior that could have solved it.

menelaosc commented 3 months ago

Hi

We still have this issue with 8.4.0. Is there an intermediate solution (besides returning to legacy mode) until the problem is resolved?

Thanks

a-danae commented 3 months ago

Thanks for confirming the issue still is present after 8.3.1, @menelaosc !

Is there an intermediate solution (besides returning to legacy mode) until the problem is resolved?

We don't have a temporary solution as of now because we have to dive into what's causing the problem. We'll update both GH issues as soon as we have news on this.

For future reference, this issue seems to be related to this other one https://github.com/woocommerce/woocommerce-gateway-stripe/issues/2463

a-danae commented 3 months ago

Hey folks, could you please confirm if the following scenario applies to any of you?

  1. Go to your list of configured webhooks at https://dashboard.stripe.com/webhooks
  2. Check out the table under "Hosted endpoints"
  3. Do you have the same website URL in two rows or more? Like this image

I'm trying to understand what could be causing this behavior since things work as expected following the standard flows.

Update: To clarify, the main issue doesn't seem to be related to the double processing of webhooks, as mentioned above. Curious if that could be the case for some sites that could be easily solved.

menelaosc commented 3 months ago

Hi @a-danae

Thanks for your help.

We only have one endpoint defined under "hosted endpoints" but still get duplicate notes and notifications.

Thanks

carolframen commented 3 months ago

8481374-zen

Another user commented on the thread about having the same issue and it being fixed when switching to the legacy checkout.

The Thread Starter mentioned stock is also being reduced twice.

carolframen commented 3 months ago

8494517-zen

carolframen commented 3 months ago

Hey @a-danae I asked a user to check what you mentioned here, and here's the screenshot from their end: https://snipboard.io/dxuL2c.jpg

here's the thread.

sophiegyo commented 3 months ago

Just noting a potential report from 8497658-zen as the merchant is interested in the fix.

OmarFPG commented 3 months ago

8494517-zd

SSR for this one here.