#evan_subs-pause-collection-resume
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1498368331487383593
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi ๐
I"m trying to piece together what is going on here but, from looking at the history, it seems like this Invoice was kept in draft until you (or someone) explicitly set auto_advance to "true"
From my read of your question, that seems like the behavior you are trying to achieve
Then, after 1 hour when it should have finalized it was set back to auto_advance: false
There's no corresponding API call so I think its some stripe logic triggering that update
turned on by my app at 11:29, then turned back off at 12:30
then in the dashboard today at 9:54 I turned it back on, then it turned itself back off again immediately
only 1 API POST call from the 25th registered
Oh yeah I can see there is an invoice.updated event immediately after that which flips the auto-advance back to false.
This is new logic for us, what were trying to do is add a custom line item to the invoice while retaining all of the subscription status behavior for failed payments.
$0 invoices would auto finalize, so in order to ammend it I needed to find a way to hold the invoice by default - this was the only way I could find.
It's definitely feels messy, so if there's a better way to accomplish that goal, I'm open to it!
That is why all recurring Invoices generated by Subscriptions (essentialy every one after the first one) have a 1 hour draft period baked in.
The idea is that you have a webhook endpoint that listens for the invoice.created event which will include the full Invoice object. You can then perform whatever logic on your server to identify what custom line item should apply to this Customer/Subscription and add the custom line item.
So, our app generates $0 invoices (for free subscription, for example), and those get auto finalized
but we still want to ammend those 0$ invoices
The issue I'm noticing is that we are treating your "keep_as_draft" logic as absolute. You toggle auto_advance on and our billing engine says "Nuh uh, you said keep as draft"
AH okay
Unfortunately, I think in that case you would need to add the explicit finalization step as part of the flow. So you would add the custom line item via one API call and, as soon as that succeeds, you would finalize the Invoice.
Both via the API
Okay, I can just hit the finalize API instead of flip auto advance!
the docs explicitly call out what I'm doing currently as the standard approach: https://docs.stripe.com/billing/subscriptions/pause-payment#collect-payment-later
in case you want to submit a ticket internally to get that updated
Yeah we will need to do that. I found several internal issues where we point out that our billing engine will flip this back to draft.
I guess I'm glad I'm not the only one ๐
Is there any alternative approach to the $0 invoice? I would much prefer to have the 1h gap because pausing collection kills the MRR chart...
I couldn't find an account level setting to turn that behavior off or something
Well can I ask what the custom line items are for?
metered billing is probably the better answer...
we have a cumulative "lab capacity" metric that we charge overages for (they can select different size plans for 100, 500, etc)
So if they went 10 over on lab capacity, we want to add that to their invoice. We just run a DB query to calculate it right now on invoice.created and add it into the invoice.
metered billing would be a decent amount of migration & a lot more touch points around our codebase hence the quick and dirty approach, at least for now
Yeah I was going to say that metered billing also bills in arrears so you that might address this issue more cleanly but 100% agree it's a BIG migration effort
Unfortunately I don't have a good work-around to allow you get that 1 hour draft period other than charging more that $0 by default
if.... I made the price of the monthly item $0.01 could I amend that line item down to $0? At least in the dashboard I think it wouldn't let me edit a line item tied to a subscription
I think we'd need you to charge at least $0.50 since that is our minimum charge amount
Yeah makes sense
that's also super janky, and I kind of hate it
but it just might work lol
๐
Yeah.... some use cases are not as easy as they should be