#gje-subscription usage records
1 messages · Page 1 of 1 (latest)
what do you mean by overage? do you the mean the usage records?
yup usage record
overages for my app is the qty of emails sent that exceeds the user's limit
im currently using create_usage_record in the invoice.created event, but as mentioned, when upgrading a plan by modifying the subscription (setting billing_cycle_anchor = now), the invoice generated from updating the subscription does not include the usage records added, but instead the usage records were added to the upcoming invoice
im currently using create_usage_record in the invoice.created event
that's too late, at the point you get that event, the new billing cycle already started. If you want to add usage it has to be done before the subscription cycles.
so if you're updating the subscription to reset the billing cycle, then listening for the invoice.created event, and then creating the usage record, it's too late and that usage is not going to be reported on that invoice(since that invoice was for the period that just ended), and will be on the next one. Exactly as you've seen.
i see, may ik then, which event should i consider?
there's no specific event unfortunately, you just have to make sure your systems submits any usage before the end of the period. The end of the period is always current_period_end on the subscription object so you might want to set up cron jobs or so on to make sure you submit in time if needed.
There is an invoice.upcoming event that can fire a few days before the start of a new cycle, but nothing really closer than that.
ahhh i see, thats unfortunate, so i have to do a scheduled updating of usage for my users then... can i confirm if this is also the case for typical renewal of subscriptions? as in, invoice.created will also be too late to add on the usage records
yes, it's the same thing