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

  • 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

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