summaryrefslogtreecommitdiff
path: root/billing/config
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2013-12-20 11:28:42 -0800
committerazul <azul@riseup.net>2013-12-20 11:28:42 -0800
commit9d1fdcb1d5a18c74776b43cb78e3dc305fdddffc (patch)
tree20a6789a80c0cdaa14623b9a809eccb122841f91 /billing/config
parent76517637ddf70577bd2a14bebb8a57552fbb1776 (diff)
parent5818a2a101cc89c778c5a5e62271ab42b1fa4c70 (diff)
Merge pull request #128 from elijh/feature/configure_billing
make billing configurable from platform
Diffstat (limited to 'billing/config')
-rw-r--r--billing/config/initializers/braintree.rb31
1 files changed, 23 insertions, 8 deletions
diff --git a/billing/config/initializers/braintree.rb b/billing/config/initializers/braintree.rb
index d6ae565..c0c89e2 100644
--- a/billing/config/initializers/braintree.rb
+++ b/billing/config/initializers/braintree.rb
@@ -1,16 +1,31 @@
-require 'braintree_test_app'
-
-Braintree::Configuration.logger = Logger.new('log/braintree.log')
+#
+# set logger
+#
+if APP_CONFIG[:logfile].blank?
+ require 'syslog/logger'
+ Braintree::Configuration.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new('webapp'))
+else
+ Braintree::Configuration.logger = Logger.new('log/braintree.log')
+end
+#
# we use fake braintree in tests
+#
if Rails.env.test?
+ require 'braintree_test_app'
Rails.application.config.middleware.use BraintreeTestApp
end
+#
# You can set these per environment in config/config.yml:
-if braintree_conf = APP_CONFIG[:braintree]
- Braintree::Configuration.environment = braintree_conf[:environment]
- Braintree::Configuration.merchant_id = braintree_conf[:merchant_id]
- Braintree::Configuration.public_key = braintree_conf[:public_key]
- Braintree::Configuration.private_key = braintree_conf[:private_key]
+#
+# Environment must be one of: :development, :qa, :sandbox, :production
+#
+if billing = APP_CONFIG[:billing]
+ if braintree = billing[:braintree]
+ Braintree::Configuration.environment = braintree[:environment].downcase.to_sym
+ Braintree::Configuration.merchant_id = braintree[:merchant_id]
+ Braintree::Configuration.public_key = braintree[:public_key]
+ Braintree::Configuration.private_key = braintree[:private_key]
+ end
end