#issaias
1 messages · Page 1 of 1 (latest)
Hi there!
Can you clarify what you are trying to achieve? I'm not sure I follow your question.
In my backend I've got some code to create/renew subscriptions etc. How should I store the price IDs within that subscription? As an environment variables, or find it by name using stripe API?
As in price_1LXoGtAR3e8t...
const { id, latest_invoice, status } = await stripe.subscriptions.create({
customer: customer.id,
items: [{ price }],
payment_behavior: "default_incomplete",
payment_settings: { save_default_payment_method: "on_subscription" },
expand: ["latest_invoice.payment_intent"],
})
What do you mean by
How should I store the price IDs within that subscription?
You just pass the price ID (price_xxx) when creating the subscription in theitemsproperty. Then if you want to store the price ID on your end, then it's completely up to know how/where to store it.
Is there an issue with the code you just shared?
I'm asking if there's a convention/advised way to store the price ID on my end
Not really, this is completely up to you. If you need to access it regularely, you could store it in a database. Otherwise you can always retrieve the price with the Stripe API: https://stripe.com/docs/api/prices/list