Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Gabotronix's avatar

Stripe webhooks. Actions to take in the frontend?

Hi everybody, I want to implement a payment gateway with Stripe, it will also be SCA compliant (2019 european law).

Stripe docs it says sometimes users may leave the page before confirmCardPayment callback finishes, because of this I want to implement stripe webhooks, I'm wondering about how to deal with stripe webhooks completing a transaction in an async way (user may not even be with their phone), what action should I take in the frontend while confirmCardAction is running to show the transaction was completed (or is waiting to, and this may tae several minutes/hours), showing a spinner for an infinite ammount of time seems like a bad idea to me.

What I know for sure is I will be sending an email when webhook is reveived AND proccesed but my confusion comes in how to deal with it in the frontend and user checkout flow.

0 likes
4 replies
bugsysha's avatar

Yeah, spinner is a bad idea. Just put some kind of label with status text like pending and change it to completed.

martinbean's avatar

@gabotronix Yeah, with SCA you need to handle payments asynchronously, which can be a problem!

The simplest solution would be, if you’re going to send an email when the webhook is processed, to just display a success message on your payment page when the payment intent succeeds. You can just say something like, “Thanks! Your payment was successful. Please check your email for access instructions” or something.

If you need to get the order to the front-end, then you could use something like broadcasting. Create a unique value that you then send as metadata when creating the payment intent and listen on a channel with that ID. Then have your webhook create the order and send the order on that channel when it completes. Your front-end will pick up the broadcast message and you can then show the order details, show a link to redirect to the order page, etc.

Snapey's avatar

I used Livewire to watch the status column on a transactions table and then used Livewire poll to show the user that we were still waiting for the transaction confirmation.

Then the webhook updates the transaction table, and it is seen by the front end and the user is redirected to their account dashboard.

It does mean showing a pending state on the front end (because you don't yet know if payment was successful) If the webhook never happens for some technical issue then the user is left hanging. Not sure what you can do about that apart from showing an error after some timeout?

Sorry, should also say that the amount of time you need to wait could be quite a long time. Because of the two factor authorisation being applied, the bank may SMS the customer with a code then wait for them to get that and key it into the payment confirmation. You could need to wait a number of minutes before the webhook is returned.

bugsysha's avatar

I used Livewire to watch the status column on a transactions table and then used Livewire poll to show the user that we were still waiting for the transaction confirmation.

Yeah, but that does not make sense when the wait time is anything from several minutes to several hours. Just let customers see it on refresh.

Please or to participate in this conversation.