I am trying to use Prorations to update the quantity on a subscription, to calculate the cost for the remainder of the year. (subscription is billed yearly)
When I try to follow the docs https://stripe.com/docs/billing/subscriptions/prorations I am getting this error
Cannot specify proration date outside of current subscription period
Can anyone please explain where I went wrong??
const subscription = await stripe.subscriptions.retrieve(subId)
const prorationDate = Math.floor(Date.now() / 1000)
// quantity was 3
const items = [
{
id: subscription.items.data[0].id,
quantity: 7,
},
]
const invoice = await stripe.invoices.retrieveUpcoming({
customer: subscription.customer,
subscription: license.subscriptionId,
subscription_items: items,
subscription_proration_date: prorationDate,
})
Edit: This is how i created the subscription at the beginning
const session = await stripe.checkout.sessions.create({
customer: customer.id,
mode: 'subscription',
line_items: [
{
price: priceId,
quantity: 3,
},
],
})