balanced / billy

Billy - The open source recurring billing system, powered by Balanced.
Other
172 stars 45 forks source link

Metered invoicing support #36

Open mahmoudimus opened 11 years ago

mahmoudimus commented 11 years ago

Balanced internally has built its own (very simple) metered billing system to instrument our customer's use of the API.

We collect some statistics on their usage and at 0:00 UTC every day, we generate an invoice for that business day and then settle it.

I want to move this logic out of Balanced and into Billy. Ergo, Billy should support metered billing support and the Balanced dashboard should use Billy to display the invoices for our customers.

/cc @victorlin @mjallday @kleinsch

mjallday commented 11 years ago

How would this work? Would Balanced generate a list of customers and amounts and then call out to Billy's API in order to handle billing?

Billy would need to support pushing notifications to customers via email since Balanced currently does this to notify of failed invoice charges. Possibly Billy could support webhooks instead and call back on failed charge attempts as an interim step.

mahmoudimus commented 11 years ago

The idea is that the pricing page (https://github.com/balanced/www.balancedpayments.com/issues/14) should be implemented using Billy. How can we integrate Balanced into Billy?

Since Balanced puts a ton of focus on eating its own dog-food, Billy should be used as its invoicing tool. How can we do this via Billy?

That logic should be in Balanced, where Balanced queries Billy for instrumented events (for each customer) and then Balanced should tell Billy to generate the invoice for each customer. Billy can then handle the invoicing part.

fangpenlin commented 11 years ago

@mahmoudimus My understanding here is, billy monitors and collects events from balanced (via the web hook). Then billy generates invoices for customer everyday. Is this correct?

As the balanced service is already doing invoicing, and I think it is doing it correctly. So, I can make billy to generate invoices, run it for a while, compare the output to see is billy working correctly. And eventually migrate the invoicing to billy.

However, I would like to know the rationale for moving the invoicing logic from balanced to billy. Is that for reducing complexity of balanced? With the rationale, I can do better design to meet the reason behind this change. Also, I would like to know what do you what to keep in balanced? What to keep in billy then? For example, should I put pricing logic (the part for determining amount of invoice to charge customer) in balanced or billy? With clear role responsibility definition, I can also do a better design then.