2
votes

I am using stripe for creating payments. After the payment is done user is redirected to payment status page. Payment status page is supposed show the latest plan user has subscribed for. Problem is I get the webhook from stripe after sometime which updates the user plan table. but user is redirected to user plan page immediately after the payment.

How can i show updated status after user is redirected. Is there any way to halt the redirect till webhook request is complete

1

1 Answers

1
votes

There should be no need on your end to wait for the webhook event to arrive before updating your customer here. Stripe API calls are synchronous which means that when you create a charge you either get an error back which indicates the payment failed or a charge object back which indicates that the payment succeeded. Depending on those you can update your customer immediately without having to wait for the event to reach you.

The same logic applies for a new subscription here so when you create one you get a subscription object back indicating it was successful and you can update your database immediately before redirecting the customer.

Most events should be seen as a way to verify the information you already have on your end and make sure your data is up to date and not validate a charge and update your customer directly.