Stripe how to handle multiple price_id?
Hey folks,
I've been trying for the pass 3 days with my friend GPT to implement multiple price_ID for stripe checkout but in vain, I'd be actually happy to offer you a big coffee for a deep dive on how best to implement this. My current flow is working with 1 single price_ID but it seems I'm struggeling with the mutation / trpc to pass different stripe price_id associate to specific price card in the front end
here is the current code working with 1 price_ID (my price_id) is in my .env
checkout.ts (backend)
here is my stripe.ts (use to do my prisma increment of credits from the user db)
in my frontend I have a customs hook buyCredits
I believe I understand the logic, all I need is to map through a specific price_ID either on my .env or havng an object in the code to pass this on, in reality I'm unable to get the backend to work
I'd be happy once again to compensate your time helping me
3 Replies
I am a little bit confused about what exactly you are trying to do here, but let me see if I can help a bit. If you want to pass custom data to a stripe checkout page, instead of sending a price_ID, you can send an object with the data you want. This would be a price data object.
Here is about how I did it in my project.
I cant find the page in the docs that has the info for this, but this page should be helpful https://stripe.com/docs/payments/checkout/migrating-prices
If this does not work for you, you might have to pass the different price_id from the frontend into the backend in your request, so that you can send that to stripe. I did that through a checkout sessions handler that my cart pushes to. Hopefully some of this helps, if not let me know!
Checkout prices migration guide
Learn how to update your integration to use prices with Stripe Checkout.
this actually help! thank a lot Leisure!
Awesome, glad I could help!