Ask HN: How did you set up usage-based billing?
For those who’ve built systems that need to charge by an ‘event’, like an API call, how did you meter usage and then bill customers?
How’s that system holding up today? We used Stripe to build it. Something like: - Set users to a subscription cadence once they upload a payment method - Add a backend job that aggregates usage in the form that you're metering (with lots of lots of unit tests to make sure you know what to expect) and post that as an invoice item to the customers' account in Stripe, but don't collect - Periodically have a subscription in Stripe (typically monthly) go and bill for all the open invoice items. This grabs all of the usage that hasn't been invoiced in the period and bills for it. If the total value is $0, skip that month. - Let users manage receipts and invoices in Stripe, and make sure the line items on the invoices correspond with user meaningful usage metering I wrote an article this year about how to setup UBP with Stripe.
I hope it helps: https://openmeter.io/blog/implementing-usage-based-pricing-w... This is really helpful thanks. Do you actively monitor how much customers owe you or even cap the size of their bill before they need to pay you? This would be in case they have a significant amount of usage in a period. Not at this point, usage never ends up being huge amounts of money because we have flat SaaS fees as well. You should check https://hyperline.co, does everything (metering, subs, invoicing) and it's self-serve if needed Great I’ll check them out!