#mark-invoice-upcoming
1 messages · Page 1 of 1 (latest)
Hi!
So sorry, I missed this message
Reading!
So when you update a Subscription, a new invoice will always be cut if the billing cycle changes.
However, if the billing cycle does not change, then you can force an invoice via proration_behavior: 'always_invoice' - https://stripe.com/docs/api/subscriptions/update#update_subscription-proration_behavior
Hi. A new invoice for the proration is always created when calling update as follows:
subscription = await stripe.subscriptions.update(
subscriptionId,
{
items: Object.values(updatedItems),
payment_behavior: 'default_incomplete',
proration_behavior: 'always_invoice',
expand: ['latest_invoice.payment_intent'],
proration_date: currentPeriodStart + (daysSincePeriodStart * 86400),
},
);
However, if I try to preview the update via
const invoice = await stripe.invoices.retrieveUpcoming({
customer: customerId,
subscription: subscriptionId,
subscription_items: Object.values(updatedItems),
subscription_proration_behavior: 'always_invoice',
subscription_proration_date: currentPeriodStart + (daysSincePeriodStart * 86400),
});
I only get the immediate invoice if there is a positive proration.
Right because otherwise the proration becomes a credit on the customer. However, there should still be a $0 invoice if I remember correctly.
No invoice is being generated at all?
For zero or negative prorations, retrieveUpcoming seems to be giving me the invoice for the next subscription cycle.
Gotcha. Let me check on something
thanks
👋
if you pass proration_behavior: 'always_invoice' you explicitly say "Please make the change and invoice now (your first example). If you don't, the default is to prorate and wait for the next cycle
Whether it's a downgrade or upgrade doesn't matter and it always works the same way
But it doesn't seem to for me when using invoices.retrieveUpcoming. It does for subscriptions.update. Both have 'always_invoice' set.
I'm going to need way more specific details to be able to help you debug this. I need the exact customer and subscription ids and the exact value you are passing in subscription_items and subscription_proration_date + the raw JSON you get back from that call
Can you do it from the request IDs?
kind of
Successful positive proration: req_uUIZfGMHI3nQSt
Unsuccessful negative proration: req_uUIZfGMHI3nQSt
those are the exact same ids
Sorry - give me a sec.
Debugging this can be really tricky, my recommendation is to write really simple/basic code that will
1/ Create a Subscription
2/ Update that Subscription with the right settings and look at the Invoice
and do this for both changes separately
@brave light did you find more details?
Sorry - just trying now to get the JSON output in the two situations.
all good
I don't really need the JSON if you use the update path instead of the upcoming invoice
Annoyingly it seems to be behaving as expected now, so I think I'm going to have to leave this unless I can work out why it was happening. Thanks for your help though!
I do think you likely were mixing up the subscription ids or not really making changes to the subscription
that's often what causes confusion like this
Yes, probably got confused. Thanks again.