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
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Scot
Scot3y ago
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
venus
venusOP3y ago
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?
Amos
Amos3y ago
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
Amos
Amos3y ago
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
venus
venusOP3y ago
sweet didn't know about this repo
shaaah
shaaah3y ago
@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
venus
venusOP3y ago
I left it in the /api route folder. I use their CLI to get it working on local
shaaah
shaaah3y ago
ah ok so I guess you dint test the "add endpoint" option yet
venus
venusOP3y ago
What's that exactly?
shaaah
shaaah3y ago
shaaah
shaaah3y ago
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
venus
venusOP3y ago
Oh yeah. No, I didn't test it in production
Amos
Amos3y ago
Keep in mind you also have to forward it with the Stripe CLI when running it locally
Amos
Amos3y ago
Test a webhooks integration with the Stripe CLI
Test that your webhook endpoint is working properly before taking it live.
Want results from more Discord servers?
Add your server