#vik-backdate-sub

1 messages · Page 1 of 1 (latest)

torpid grail
#

Hi there! Sorry for the delay

rapid blade
#

nono, all good!

torpid grail
#

Are you setting the billing cycle anchor to the future?

#

Or you are just backdating?

rapid blade
#

yes, to the first day of the next month

#

as well as backdating

torpid grail
#

And you want the proration to be on the following renewal?

rapid blade
#

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

torpid grail
#

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

#

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

rapid blade
#

okay that sounds like it would work! How would one preview the proration that would have been created for backdating though?

torpid grail
#

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

rapid blade
#

Amazing! Okay let me try doing some sample requests to try it out

torpid grail
#

👍

rapid blade
#

Yup it returns a sample invoice with the correct amount. Thanks for your help!