Stripe - can I use tRPC for Stripe's webhook?
I'm building a Strip checkout and I am wondering if it is possible to use tRPC endpoint for handling Stripe's webook.
I have one more question regarding to Strapi, how can I verify what custom has paid for the product? (I am using T3 stack)
15 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Trpc pretty much only makes sense for when you control both sides of the request and they live very close to eathother as they become super highly coupled. If you don't have either or those then you very likely shouldn't be using trpc
Yeah that's true.
Yeah I did the same. Quick question. Do you use subscription? If so, how do you verify that the payment came from specific logged user, since webhooks doesn't provide sessions.
I thought of two approaches:
1. Create customer object in Stripe for each user on login customer and assign customerId to user model in prisma.
2. Redirect go success page after the payment, retrieve that given session on server and store the transaction in DB.
I am currently using the 2nd approach
Same with subscription, should I listen to webhook and then update user's
isSubscribed
on each subscription event change?Just save the stripe customer id to the user and use that
Check https://github.com/vercel/nextjs-subscription-payments, it has all you need
GitHub
nextjs-subscription-payments/webhooks.ts at main · vercel/nextjs-su...
Clone, deploy, and fully customize a SaaS subscription application with Next.js. - nextjs-subscription-payments/webhooks.ts at main · vercel/nextjs-subscription-payments
sweet
didn't know about this repo
@venus
Where you able to get the Stripe Webhook end point to work?
There are two options, test in local, and add end point
Local works, but when I added the end point, it says 500: Signature payload missing
I left it in the
/api
route folder. I use their CLI to get it working on localah ok so I guess you dint test the "add endpoint" option yet
What's that exactly?
Here you can see, local and Hosted endpoints
Local would be for testing in local env, and hosted is I believe when you want to test it on a server
Oh yeah. No, I didn't test it in production
Keep in mind you also have to forward it with the Stripe CLI when running it locally
Test a webhooks integration with the Stripe CLI
Test that your webhook endpoint is working properly before taking it live.