#jeff-sexton_invoice-preview-updates
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/1306020879867838534
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi ๐
This is a preview invoice. You cannot make any direct changes to it because it's a read only object
In order to make any changes you would need to change the Subscription
or wait until the generated Invoice is in draft state and make changes then
What is the specific flow you are trying to enable?
The main issue is that we need to preview proposed changes to a subscription but we also need to update that preview to include some additional lines. e.g. we have a third party tax integration outside of stripe so we need to add the taxation lines to the invoice preview as well.
This means we need to:
- generate a preview with the changed subscription items
- use that preview to generate taxation amounts
- re-generate a new preview with both the changed subscription items AND the tax lines
Okay so none of that is possible since the Preview Invoice doesn't actually exist as an object in Stripe
currently we're using Stripe::Invoice.upcoming and we were hoping that we could reduce the number of calls by persisting the preview
Obviously our use cases doesn't match with the Stripe functionality here.
So I'm assuming you are not using Stripe Tax to automatically compute and collect taxes here
Exactly
Would I be correct to assume these are specific tax lines and not something you could just include on the Subscription itself?
That's correct. We need the first preview response in order to calculate the tax with the third party integration
and then feed that back into a new preview with all the lines
What you would instead is, after you have generated the tax amounts, you would add those as line items to the upcoming invoice. YOu can do it for the preview by using this parameter invoice_items
https://docs.stripe.com/api/invoices/upcoming#upcoming_invoice-invoice_items
You can't skip more API calls this way but it will work
Once you are ready to add the line items to the actual invoice, then you would pass these items to the Subscription using the add_invoice_items parameter here: https://docs.stripe.com/api/subscriptions/update#update_subscription-add_invoice_items
Ok. Thanks for the clarification
Happy to shed what ๐ก I can ๐
