-
Notifications
You must be signed in to change notification settings - Fork 206
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
UPE payments and webhooks have a race condition #2536
Comments
#2540 has a stop-gap fix for this issue but it's not ideal; just an easy way to get the fix out so we can patch the issue. We should take some time to refactor the I'll bump the priority on this issue down to |
Looks like we've seen this here: 5986498-zen |
@jrick1229 what version of the plugin was the merchant using before the downgrade? And what version did you downgrade the merchant to? I ask because this was patched in 7.1.0 and shouldn't be an issue. If it is there's something more going on we need to look into further. |
That's interesting @reykjalin – I totally missed the merged PR, my bad. With that said, they were definitely using v7.1.0 and downgraded to the last major version available. |
It looks like they just responded back and said it happened again, so definitely not related like I had hoped. |
@reykjalin I might have found a situation where a similar (or the same) race condition is happening between UPE payments and Webhooks. Here are the details I have collected so far:
If you don't think it's related to this issue but you have some ideas of where should I take a look, I'd appreciate it. |
Hi team! The fix introduced on PR #2550 is causing the flow to I'm aware the actual solution involves refactoring the need for additional metadata, however, in the meantime, would something like this work?
I haven't tested the code above because I want to check with you first if this is a solution that you could potentially accept in a PR, or if it's a solution at all. We are seeing this issue every couple of days on one of our sites. From my point of view, waiting 1 or 2 extra seconds is better for customers than getting their order in a "Pending" state when they have already paid, because they need to contact the merchant, and the merchant has to do the manual validation and change the Order status manually. Note: this issue happens only to customers that already have a user account, I suspect that makes the purchase process go quicker and there's more chance for the race condition to manifest. Let me know your thoughts, if the code above is something that looks promising I can open the PR. |
Hi @reykjalin we're eager to hear your thoughts on the above ⬆️ One of our Team 51 partners has been experiencing repeated issues with this and we would be glad to collaborate on a solution with you. Thanks! |
@ecairol thank you for taking a look! We haven't had the time to look into this for a long time, but maybe @diegocurbelo and Quark can come back to this soon 🤔 @xpurichan unfortunately a complete fix here isn't all that simple, just like the discussion has revealed so far. The implementation is a bit flawed fundamentally and a significant bit of exploration and refactoring is needed to completely fix the issue. That doesn't mean there isn't any room for collaboration, but it does mean it's going to take some time to fix the issue. @diegocurbelo and @woocommerce/quark are going to be working more on Stripe going forward so I'd have to defer to them on how this will be prioritized and worked on. |
Completely understood @reykjalin What I wonder is if we can submit a PR with an updated patch while @woocommerce/quark works on a definite solution. The two ideas that I have are:
Ideally, also a We're more than glad to submit a PR with these suggestions but would like to hear the team's thoughts first. |
Hi @reykjalin would you be able to share input on @ecairol ideas above? ⬆️ |
Hi @reykjalin! We wanted to ping you to see if you had a chance to review @ecairol's PR #2638 above ⬆️ . Let us know how we can best assist, thank you! |
Sorry it took me a long time to get to it! I've been really busy after stepping in as interim lead of Fractal while working through several SIRTs, and adding to that the fact that ownership of the Stripe plugin was transferred to Quark put this low on my prioritization list. I apologize for the delay! I've replied to the PR and started a discussion in Slack with @diegocurbelo and Quark on how to proceed. |
Thank you very much @reykjalin! No worries at all and thank you for taking a look at the PR! @ecairol, I believe the Slack thread is at p1688179542591189-slack-CHG7MTCAF if it's easier to jump into there. 😄 It looks like @diegocurbelo has approved the changes so far too! 🎉 |
Thanks for the ping @crweiner, and thank you @reykjalin and @diegocurbelo. I was AFK this week, but I'll merge the PR after the base branch is updated (it's running some checks now) @crweiner Since this is going to be released on the product, I think we can go and patch the plugin ourselves, and then add a small fix at the |
@ecairol this sounds good, let us know once it's done. |
I'm reasonably certain we've got a case of this in 6688022-zen. Pertinent bits from the debug log:
|
@WillBrubaker yes, that seems to be the case! This is what I added to
|
7316233-zen |
7379266-zen |
Related GH issues: |
Closing this issue as it should have been solved by #3331 and released in Stripe 8.6.1. |
Describe the bug
When processing payments made via UPE (the new checkout experience) we do some initial processing, set the order status to
pending
and then redirect to the order received page. Once the customer is on the order received page we finalize the payment in WC_Stripe_UPE_Payment_Gateway::process_order_for_confirmed_intent.Independently from this we receive webhooks from Stripe and the
payment_intent.success
webhook calls WC_Stripe_Payment_Gateway::process_response where we call WC_Order::payment_complete if the intent status issucceeded
.Usually this isn't a problem, but when the webhook is processed before the customer loads the Order Received page we never finish processing the payment in the UPE gateway because the order status is wrong; it's been set to
processing
by the call toWC_Order::payment_complete
when processing the webhook.This usually doesn't cause a problem since the payment is completed and the order is marked as such. However, when it's necessary to save a card -- such as in the case of subscriptions -- the payment method ID is never saved to the order, causing subscription renewals to fail. This also makes it so that the card is never saved to the customer.
UPE::process_payment
method, perhaps by refactoring the webhook processing.To Reproduce
4242 4242 4242 4242
.continue
the debugger and stop it.Expected behavior
No race condition; the order is properly processed despite processing the webhook properly.
You can simulate the proper behavior by following these steps:
4242 4242 4242 4242
.processing
, orcompleted
).continue
the debugger and stop it.Screenshots
N/A
Environment (please complete the following information):**
develop
Additional context
p1673550580661099-slack-C01BZUL57SQ
The text was updated successfully, but these errors were encountered: