top | item 38248996

Ask HN: How did you set up usage-based billing?

4 points| Dwolb | 2 years ago

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?

6 comments

order

rogerkirkness|2 years ago

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

Dwolb|2 years ago

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.

lucasbedout|2 years ago

You should check https://hyperline.co, does everything (metering, subs, invoicing) and it's self-serve if needed

Dwolb|2 years ago

Great I’ll check them out!