#vik-backdate-sub
1 messages · Page 1 of 1 (latest)
nono, all good!
Are you setting the billing cycle anchor to the future?
Or you are just backdating?
And you want the proration to be on the following renewal?
right. So when the subscription is created, I don't want to create an invoice immediately. Instead, I want the invoice that will automatically be generated on the first of the following month to include the proration generated due to the backdating.
For example: if I create a subscription on June 15, with the start date backdated to April 1, and the billing cycle anchor set to July 1. I want the first invoice to be the one on July 1, and have it include the proration for April 1-July 1
Got it, thanks for clarifying. Don't think this is possible to do explicitly, but there may be a workaround. Give me a moment to think
Okay
So
Here is the workaround
You create the Sub and pass proration_behavior: 'none'
This will stop the first invoice from occurring.
So the Sub is active but no invoice is generated until the billing_cycle_anchor
Then you use the retrieve an upcoming invoice endpoint (https://stripe.com/docs/api/invoices/upcoming) to preview what the proration would have been if you had not passed proration_behavior: 'none'
Then you add an invoice item (https://stripe.com/docs/api/invoiceitems/create) to the Sub for that amount
That invoice item will then be picked up with the invoice at the billing_cycle_anchor
So the actual first invoice will include the Price amount plus the proration amount
okay that sounds like it would work! How would one preview the proration that would have been created for backdating though?
When you use the retrieve an upcoming invoice endpoint you can simulate creating a Sub
So it would look something like: ```const invoice = await stripe.invoices.retrieveUpcoming({
subscription_items: [{
price: 'price_123'
}],
customer: "cus_123",
subscription_billing_cycle_anchor: "1656054000",
subscription_start_date: "1655103600",
})```
Those are arbitrary timestamps
Then the invoice that is returned will tell you the proration amount
Amazing! Okay let me try doing some sample requests to try it out
👍
Yup it returns a sample invoice with the correct amount. Thanks for your help!