Open LevinMedia opened 5 years ago
Can you see if there's a _stripe_refund_id
in the order meta (e.g. with "Post Meta Inspector" plugin)?
Edit: if there isn't, that would explain the refund being re-processed in response to the webhook – though if there is, we still won't know if it was set in process_refund
or process_webhook_refund
.
I have also come across with similar issue. I can see _stripe_refund_id
in the order meta but it has been added twice and with same refund id. I am also facing an issue with the completed order. On completion of order, I can see two _stripe_charge_captured
in the order meta and also woocommerce_order_status_changed
hook has been called twice.
This is still an issue in the current release of WooCommerce
Interesting that even though the refund was done through the WooCommerce dashboard, the comment sent with the refund is only on one of the refunds and the second refund says stripe dashboard.
Looks like a race condition in which the request [code] immediately triggers the webhook event, the handler for which could run the condition on order meta [code] before it actually gets set upon refund response [code]. Seems we need a more robust check for whether the refund has already been initiated in WooCommerce.
+1 to this still occurring. Had it happen for several orders on a site today with WP 5.3.2, WC 3.9.1 and Stripe 4.3.1.
Another report of this in 18057092-hc
Screenshot direct link: https://d.pr/i/Z0Rkhr
Now happens for every refund since update to 4.0
Tested with 4.0 and was unable to reproduce the behavior, but was able to after adding a short sleep
following the request [code].
One fix that comes to mind is setting a transitory state during the request and then blocking the webhook handling. For example, _stripe_refund_id
order meta could be set to some special "pending" value before the request (and unset on error), which can be checked for when the webhook comes in [here].
Another approach would be to just check if that refund ID was already stored, before proceeding with the rest of the refund processing, but the note would inaccurately say "via Stripe Dashboard".
Another instance: 4579950-zen
Another instance in 25341799-hc
Does anybody know how these issues were resolved? I am facing the same issue with one of our sites.
@ArvindKumar08 my project is actually built on Roots Bedrock/Sage and all I had to do from my end was rebuild and redeploy. The issue hasn't resurfaced since. Definitely a strange one :/
in case it helps, the duplicates are getting assigned to the root user instead of the person who actually processed the refund. I assume this will be the case for all other examples, but it goes unnoticed because it's the same user.
There is a 1s difference between the two and i think this might be because of the stripe webhook (charge.refunded) firing back to us and doubles up to the API request made from the plugin to stripe
This would also explain why one of them is attributed to the root user. The plugin receives the webhook and thinks the order was refunded via the stripe dashboard, but doesn't know who to attribute this to, so it reverts to user id 1 or whoever is the first user of the site.
I would also imagine this only affects partial refunds because on full refunds, it can't really refund any more. I might be wrong on this however.
one solution is to stop those specific webhooks from Stripe since we never process refunds from there, however, I don't think that's the right approach, because we might process the odd one.
Ideally, the plugin should be checking the webhooks and see if the same refund id has already been recorded. if it has, it should ignore it. I can see there is an attempt to do this but i think it's probably not working correctly?
Also, the order meta have two records with the same refund id
Reported on 4579950-zen.
We have the same problem:
Funny enough, that we have the exact same problem with the PayPal integration too: https://github.com/woocommerce/woocommerce-paypal-payments/issues/522 Might this be a problem with WooCommerce itself?
Another instance: 5206513-zen
We're also encountering this issue. I see that this was originally opened several years ago, and is still open--is there any workaround for this, until it is fixed? And/or any timeframe for it to be fixed?
Also encountering this issue. The refund is only processed once on Stripe but showing twice on the website. Once by the user who initiated the refund and the 2nd by the root user.
Now my baby is almost 1 year old, but this 2018/9 issue is still not resolved ... 😭
Also encountering this issue in the same way @samholguin mentioned. Is there a workaround?
Also encountering this issue in the same way @samholguin mentioned. Is there a workaround?
The workaround we came across was to disable the refund events on the webhook while leaving the other events enabled. This has the downside that any other refund (for example triggered via the Stripe Dashboard) won't be registered by WooCommerce See https://github.com/woocommerce/woocommerce-paypal-payments/issues/522#issuecomment-1098909297
EDIT: I'm sorry, just saw that @glagonikas already mentioned this approach.
6191782-zen
6359414 - zen
:)
6639400-zen
8152570-zen
Same problem here. I wish there was a way through the interface to disable the refund webhook, but I don’t see one and I am hesitant to disable in code.
Zen-8273116
I tried to reproduce the issue here with no success. I tried using the latest versions of WC and the Stripe extension. With the "legacy checkout experience" enabled and disabled. Webhook calls are received, but the double refund does not happen because of this line (includes/class-wc-stripe-webhook-handler.php#603
):
// If the refund ID matches, don't continue to prevent double refunding.
if ( $refund_object->id === $refund_id ) {
return;
}
It was added on this PR. So maybe some of the users affected above had an older version of the extension. Still, does not explain the latest reports.
Another report here: 8377624-zd
Affected ticket(s)
N/A
What I expected
When I issue a refund, it should only be refunded once.
What happened instead
The refund doubled up
Steps to reproduce the issue
I'm running an WP.com ecomm plan, admining the order through WP-admin - Stripe is in test mode. I'm using card 4242 4242 4242 4242
I placed an order on the front end for one product with multiple items, then visited the edit order screen:
I refunded 1 item:
I clicked "Refund 98 cents via stripe" which resulted in a double refund
I also see a double refund in my order notes, although the refund ID appears to be the same: