John Doe
John Doe

Reputation: 1172

how to listen to response from a webhook?

I am implementing webhooks with my payment solution (stripe), and I set up basic webhook server responses. So, upon various events, such as updating a subscription, a server request is sent to a specific endpoint (/webhooks), and a 200 response is fired.

Now, I would like to listen to this server with my saga, but I'm not sure how to do that. The idea is I have a redux-saga event channel listening, and such an async request as updating a subscription status, would trigger a new saga. If for instance, the user updated his subscription status from paid to unpaid, his new status could reflect immediately in the UI.

Implementing this is not an issue when the event is triggered by the user. However, stripe allows me (as an admin) to trigger such events from Stripe's dashboard. If let's say I update one user's subscription status from Stripe's dashboard (because there is a bug with the UI for example), that will send a request to the webhooks endpoint on my server, but I'm not sure how to "intercept" it on the front-end, in order to then do what's needed for that user.

Do you have any suggestion ? I read about service workers, about pub/sub services. But I'm not sure they are the right way to do what i'm trying to do.

Upvotes: 0

Views: 703

Answers (1)

floatingLomas
floatingLomas

Reputation: 8737

You'd need to implement either websockets or long polling from your frontend to your backend that looks for the updated response/data in your backend.

Upvotes: 0

Related Questions