summaryrefslogtreecommitdiff
path: root/billing/config/initializers/braintree.rb
diff options
context:
space:
mode:
Diffstat (limited to 'billing/config/initializers/braintree.rb')
-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