piesync / billbo

Easy to use billing service for Stripe with VAT support
MIT License
73 stars 3 forks source link

Simple config #10

Closed challengee closed 10 years ago

challengee commented 10 years ago

Go for zero config. Get the selling country from Stripe.

challengee commented 10 years ago

Go for one selling country for now? And implement multi-country later?

We still need to add VAT percentages somewhere for this.

@mohawke

mohawke commented 10 years ago

Get a primary default selling country from Stripe, other selling countries can be added to config?

challengee commented 10 years ago

seems good, as done in #21.

Thinking about it some more, as opposed to what I said on chat, I think we to eager load configuration. If some config call like getting the selling country fail, they would fail on startup and not on the first transaction, which is better I think.

Maybe we can make ConfigurationService a Singleton (http://www.ruby-doc.org/stdlib-1.9.3/libdoc/singleton/rdoc/Singleton.html). To eager load the configuration we can call ConfigurationService.instance.load somewhere in the boot sequence.

We can also use the service to automatically enable/disable features based on ENV vars. Like if a segment io key is set, we enable analytics.

With this approach we can also easily stub certain configuration methods. Testing vat calculation would not need a cassette then + we can test it more easily for other countries (ConfigurationService.instance.stubs(:primary_country).returns('NL').

@mohawke any thoughts?

mohawke commented 10 years ago

green light

challengee commented 10 years ago

Need to finish these ones first: https://github.com/piesync/billbo/issues?milestone=1&page=1&state=open

challengee commented 10 years ago

I think a better approach would be to just create Billbo#configuration= to set a new configuration (Configuration). And implement a shortcut Billbo#configure which initializes a Configuration and passes it to the given block. We could maybe also implement it like Configuration.new(options = ENV).