#kamal-singh_api
1 messages · Page 1 of 1 (latest)
👋 Welcome to your new thread!
⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1346792592930504794
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
hi there!
can you share the request ID (req_xxx)? you can find it here https://dashboard.stripe.com/test/logs
req_5NTQz6WzKoqvpr
the error message is pretty clear: you can't change the price itself
so what can i do to update the price?
you can't. but you could add a new line item to the Invoice.
can you explain in more detail what is your use case?
i want to update the invoice if there is any change in price with a new price id whenever our server receive invoice.created event
I don't really understand. but like mentioned above, you can't change the price itself, but you coudl add a new price to the invoice if needeD.
i checked this docs, which mentions the price parameter here https://docs.stripe.com/api/invoiceitems/update
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
but how was your invoice created? by a subscription?
yes with subscription cycle
then yes, you can't update the price
When a customer is charged in a subscription cycle, but what if we've updated price for a subscription so we are fetching the subscription from our DB and if there is updated price then on every invoice.created webhook, we want to update the price.
on invoice.created event we checks if there is any updated price from our DB and if its there, then we want to update the invoice with the new price
Is this clear now?
but what if we've updated price for a subscription so we are fetching the subscription from our DB and if there is updated price then on every invoice.created webhook, we want to update the price.
I don't understand. can you explain, step-by-step, with a concrete example?
For example, let’s say we are currently charging $10 per subscription cycle. If we decide to increase the amount to $15 starting from the next cycle, we want to make sure that the next invoice reflects the updated amount instead of the old $10 charge.
To achieve this, whenever we update the subscription price, we create a new price object with the new amount (to maintain reference to previous price). When Stripe generates the next invoice for the upcoming subscription cycle, we update the subscription to use the new price, ensuring the customer is charged the correct, updated amount.
You'd need to update the subscription to the new price before the next billing cycle invoice
You're doing it the wrong way
Is this a user chosen upgrade, or are you just increasing the subscription price?
we are increasing the subscription price
OK so if you want that to happen on a specific date (e.g. end of the next cycle) you should probably leverage a schedule to handle that: https://docs.stripe.com/billing/subscriptions/subscription-schedules
But you shouldn't wait for the subscription to transition into a new period, generate the invoice and then update the sub
ok . got it
so does this method allows us to update all subscription with a price id?
Yes, you'd 'schedule' the upgrade to occur at the end of a phase (i.e. current period)
ok