#pavan-upcoming-invoice
1 messages · Page 1 of 1 (latest)
what's the specific issue you're having?
/ what does your code to call the upcoming invoices api look like so far?
There is one subscription and 2 products in it. It is yearly subscription. Suppose 1 product quantity increased by some units. How to calculate due for that product and also total due.
you'd update the quantity of the 1st product with https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-subscription_items
that api endpoint will return what the invoice will look like on the next billing cycle (depending on what other params you pass to the upcoming invoice endpoint, that cycle might be now)
so you can then look at the line item on the invoice for that subscription item, and get the amount for that line: https://stripe.com/docs/api/invoices/line_item
and also get the invoice total https://stripe.com/docs/api/invoices/object#invoice_object-total
But in the response i got 3 line items for 1 product. Those are mentioned in screenshot
With 3 different descriptions.
right - those are prorations for the used / unused time
I guess, first of all - do you want to be prorating subscription quantity updates by time of use?
Yes, proration amount that needs to be paid should be retrieved
those will show up as separate line items
there's a negative line item crediting the customer for the unused time on the old quantity, a positive line item for the remaining time on the new quantity, and a 3rd line item for the next billing period on the new quantity
presumably you've doing this with subscription_proration_behavior=create_prorations, which won't bill immediately, so the extra cost won't be billed until the following period's invoice, per https://stripe.com/docs/billing/subscriptions/prorations
I am using subscription_proration_behavior=Always_invoice.
Are you guys also provide call support ?
not in this discord
do you have a sample request ID for one of the upcoming invoice requests you're making?
/v1/invoices/upcoming/lines?subscription\u003dsub_1JgmOVCuLjRTHyU30k13mo8w
is this the one ?
you're not passing any subscription_proration_behavior in that call
Thanks.
What does this 2 items represent
and also amount definitely seems wrong
In a year for 100 endpoints it should be 120 * 100 = 12000
Why it is showing more than that ?
Total due should be 5396
It is coming when we add both and divided by 100
what this models is eg: I sign up for 50 endpoints on jan 1
I upgrade to 100 endpoints on oct 1 (let's say this is exactly 75% of the way through the year, to keep the math simple)
at that point, I receive a credit for 120 * 50 * 0.25, and an additional line item for 120 * 100 * 0.25
because I should be paying for 100 endpoints from oct 1 through dec 31
however, if you don't specify anything for subscription_proration_behavior, I'm not charged anything on oct 1
on my next bill, I'll see 3 line items
the two proration items described above
and then also an item for 100 endpoints from jan 1 to dec 31 of the following year
so my bill the first year is 120 * 50 = $6000, as though I'd only used 50 endpoints for the entire year
then on the 2nd year, I pay 120 * 100 + 120 * 100 * 0.25 - 120 * 50 * 0.25 = $13500
which is the full bill for the 2nd year, plus the extra for the upgrade that I did partway through the first year