#feetscha
1 messages · Page 1 of 1 (latest)
hello, just getting to this, server's been busy
hey, all good, thanks
can you explain your example a bit more? with some clear dates like Jan 1 - X happens, Jan 10 Y happens, bill for $100 etc
not sure I grasp it
sure. I have a subscription based SaaS with recurring payments each month (fixed price). I also charge the users for each active item additional 1€. everytime you activate an item, I create a usageRecord. When a new billing cycle starts, I want to go through all active items and create usage records again for all items that are already active (because otherwise I only charge when you activate items, but not for items that are already active)
I hope thats easy to understand 😄
lets say you subscribe on aug.7 and you activate 7 items this month, then I charge you the fixed price + 7€. before the next cycle starts you deactivate 3 of them. As soon as the new billing cycle starts, theres still 4 active items so I want to create usageRecords with quantity: 4 asap.
I thought of just listening to invoice.created webhook and count all active items and subscriptionItems.createUsageRecords() when that event occurs
so in your metered billing scenario, the invoice would be created close to end of your billing period
so when your Invoice is paid for current period i.e. end of Aug 7th period, after that you can add new (3) usage records to that sub for the next period
is it better to listen in that scenario for invoice.paid ?
and only then create the new usageRecords? I'm not exactly sure when these events fire
I'm not exactly sure when these events fire
https://stripe.com/docs/billing/subscriptions/webhooks
and yes invoice.paid would be at the end of current billing cycle