#pavan-subscriptions
1 messages · Page 1 of 1 (latest)
@late bison you can use the upcoming invoice endpoint for this : https://stripe.com/docs/billing/subscriptions/prorations#preview-proration describes the approach.
Will it show the delta ?
Without changing quantities if i call this API it is still showing some amount as due instead of 0
it shows the upcoming invoice, which means it shows the next billing cycle
if you are on a $100x1 item/mo subscription and call that endpoint today to preview changing to $100x2 items/mo, it shows you $200 , plus the "delta" (the proration items). Not just the proration.
you can use https://stripe.com/docs/api/invoices/line_item#invoice_line_item_object-proration to tell the difference when looking at the response
It is not applying discounts also even after adding setCoupon to the params
can you give a complete description of the problem?
- the exact code you wrote to call that endpoint
- a request ID for the GET request involved https://support.stripe.com/questions/finding-the-id-for-an-api-request
- the exact response you received and any code you wrote to parse that response, indicating specifically what you see as the problem(a field you think should correspond to a discount that is not set or has a different value than you expected)
thanks.
Ok let me explain my use case. I have 2 products each with 10% discount on price for annual subscription. User will buy subscription, from the next time when user might increase/decrease the quantities of the subscription, we would like to exact amount that needs to pay now
makes total sense! You can preview that using th upcoming invoice endpoint, setting subscription_items set to the state you are upgrading the subscription to(so the increased quantities).
the proration line items returned are what would be charged if you made the update now(you can look for the items that have proration:true like I mentioned and add them up, that's the "delta" or "amount he need to pay extra").
Yes, upgrade is working fine. Suppose if pass the same with decreasing quantities with proration as immediate invoice the amount due should come as 0 right ? But it is not happening.
Got it, this is retrieving next billing cycle invoice is it ?
the amount due should come as 0 right ?
maybe, maybe not, it really depends on the exact prices of the items involved.
Now comes the trickiest scenario, suppose one quantity is upgraded and other quantity is downgraded. How do i know the amount due it is returning is for immediate or for next billing cycle ?
Not changing prices at all, only changing quantities
It's always the next billing cycle, that's what the upcoming invoice endpoint is.
if you are on a $100x1 item/mo subscription and call that endpoint today to preview changing to $100x2 items/mo, it shows you $200 , plus the "delta" (the proration items). Not just the proration.
i.e. you'd have an invoice with an item for 2x Product : $200 (which is the price for the upcoming billing period, an item for Unused time on 1x Product : -$x and remaining time on 2x Product : $y (those last two are the proration/delta/whatever you want to call it), I believe.
Thanks @feral cairn . Got the info one weird thing is happening. Current subscription api endpoints count is 200 and i also 200 to invoiceParams but the output is showing 150
Since there is scheduled subscription it is showing that values ?
can you share - the exact code you wrote to call that endpoint as I asked for earlier?
but yes I think you're right
you didn't share the info I asked for but e.g. the request ID is https://dashboard.stripe.com/test/logs/req_Z411tol1FUUo8s and you're right, that subscription https://dashboard.stripe.com/test/subscriptions/sub_1JjkyYCuLjRTHyU3364b7E1m has an update scheduled to change the quantity to 150, so I believe that overrides the preview, like the change from the schedule has precedence over the update you would attempt to preview here.