#itsqwerty

1 messages · Page 1 of 1 (latest)

peak riverBOT
runic bane
#

Can you clarify the ask? Not sure I understand in the context of your previous thread

royal vessel
runic bane
#

Ok, still not sure what the ask is

#

Which API additional API requests?

royal vessel
#

So for subscriptions, if it is reccomedned to create 1 product and give it multiple differnt prices for e.g

I have 3 plans (Starter, Advance, Elite)
and each plan has 2 pricing options (monthly & yearly). If I am storing a product in my database with what is included in each plan so the BE can deliver those services depending on the plan the customer has. and the front end wants to request an Elite plan that is yearly, I need to fetch the yearly priceId from stripe npm in order to create the susbcription?

runic bane
#

Yes, you need to provide the price_xxx when creating the Subscription. Whether you retrieve that fro our API, or persist that in state or a database is an implementation detail

#

If you're storing product data in your database, then maybe there's a field that maps to the corresponding price_xxx IDs in Stripe

royal vessel
runic bane
#

You just said:

If I am storing a product in my database with what is included in each plan so the BE can deliver those services depending on the plan the customer has
So maybe in your database you also store the related Stripe price_xxx IDs that belong to that product and then you can retrieve them from your DB when you create the Subscription

#

It's an implementation detail. The API requires the price_xxx ID so you need to retrieve it from somewhere

royal vessel
#

so would you reccomend something like this?

stripeProductId: '',
stripePriceIds: [{ type: 'YEARLY', id: 123 }, { type: 'MONTHLY', id: 456'}]```
runic bane
#

Seems reasonable yep

royal vessel
#

Sweet, thank you. Is priceId something I can pass to the FE freely, or is it recommend the FE passes something like { plan: 'ELITE', isAnnual: true}

runic bane
#

Yep, you can use price_xxx IDs on the front-end

#

Alternatively you could you a lookup_key, but then there's more overhead

royal vessel
#

sweet thank you, legend