#eirik-billing-period
1 messages · Page 1 of 1 (latest)
eirik-billing-period
@tight fjord it's done after
The idea is that the period is for example 2023-07-01 00:00:00 UTC - 2023-08-01 00:00:00 UTC
When the period ends is when the new cycle starts. This is done by a background job on our end so it doesn't happen at the exact millisecond and depends on overall load at that time. But at that point, we will start a new period which means sending customer.subscription.updated to show the new period and also creating an Invoice object for that new period. That Invoice is not finalized immediately (because lots of businesses need to add extra fees to each Invoice). A couple of hours or so later it gets finalizes and later paid async (and it might fail payment)
So you see (i hope) how the timeline works
OK, so it seems the charge happens, in practice, some short time after the beginning of the billing cycle? (And in particular, some time after the customer.subscription.updated event happens)
mostly yes, and might fail, and you need to handle that
sure
A follow-up question: Is there a way to get the end date of the latest "paid-up" billing period?
i.e. the same as current_period_end most of the month, except at the beginning of the period the date would not change until the charge actually succeeds
You're better off tracking this locally in your own database honestly. But you can use the List Invoices API https://stripe.com/docs/api/invoices/list, pass subscription: 'sub_123' and look at each one to find the most recently paid and then look at its period (in the past) and its line items' period (current billing cycle).
But really, way easier to track this in your database
ok, thank you!