Filip
Filip
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Filip on 6/20/2023 in #questions
How to invalidate routes/router in backend/webhook?
Hello, I'm making an app using T3 that uses Stripe for subscription and payment. I have made purchase and manage billing routes that all work as expected. Now, in this app there is going to be different subscription tiers and I want to allow users to upgrade/downgrade (update) their subscriptions. I've set up the webhook and tRPC routes to handle this and it's working--however, because the particular update does not send the user to an external page (like stripe portal) and back, the UI does not refresh to reflect the subscription update (once the webhook has completed its thing). Using onSuccess() in the useMutation() doesn't work, and I suspect that's because the mutation finishes well before the webhook receives the confirmation from stripe. I tried (foolishly) to use utils and api.useContext() to call the routes inside the webhook after the handler function had done its thing--but this, of course, only works in a react component. TL;DR: What's a good way to trigger a invalidate on some tRPC routes from the backend such that the frontend then refreshes? Appreciate any help with this. Cheers
8 replies