#itsqwerty
1 messages · Page 1 of 1 (latest)
We don't have a good practise on how you manage prices and plans. It's entirely up to you.
is there a list of most popular methods that devs tend to ussaly do/follow?
What methods do you refer to?
It is fine to fetch them from Stripe. It is also fine to store them in a DB or a file. I don't think there is a best practice here it just depends on your needs and whether you need that information for other purposes or to combine it with other data, for use in SQL queries for example.
Yes you are right.
i appreciate it thank you 😄
I was planning on storing the data as metadata on stripe products. Technically to acheive this I would need to make 3 requests every time, fetch price list, product list and plan list?
What data you want to store as metadata?
plan name enum, what the plan offers (key: value like FOLLOWERS_PER_MONTH: 10000)
link to plan image
REAL_TIME_ANALYTICS: true/false, etc
I believe these are some custom data that is unrelated to Stripe, am I right?
yeah correct, technically this was my plan, BE route: to make 3 api requestst to stripe (get plans, pricices, products) and format the data for the FE to render something like the image i showed. and when FE wants to make a subscription it passes in customer email (which creates customerId) and the priceId to create the susbcription, the FE pays then every 24hours to see what services need to be delivered (so find all active plans, there metadata, and dlivery services accordinaly based on plan metadata like REAL_TIME_ANALYTICS)
I'd just save these data in my own DB if I were you.
yeah I think you are right ahaha - I was just being a bit lazy
would you reccomend storing the planId or the priceId for a subscription as an idetifier
Neither, you should use subsecripion ID as the identifier.
not for the subscription sorry I just meant the site I am building only offers subscriptions but to store the data that goes along with the plan their subscription to, would you reccomend storing the product or planId. This is a seperate table that keeps track of what is offered with each plan/service
are you using prices api or plans api?
in creating the subscription with the priceId currently but happy to change that if you reccomend doing it another way?
const subscription = await stripe.subscriptions.create({
customer: customer.id,
items: [{ price: priceId }],
payment_behavior: 'default_incomplete',
payment_settings: {
save_default_payment_method: 'on_subscription',
},
expand: ['latest_invoice.payment_intent'],
});
Ok, so you are using prices API