Created
July 9, 2009 02:09
-
-
Save janx/143368 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# application/moneyhats/config/environments/development.rb | |
# We want to use the BraintreeGateway in test mode so | |
# that we can simulate real transactions during development. The code | |
# needs to be placed in the to_prepare block so that it is executed on | |
# each reload of the OrderTransaction model in development mode. If | |
# the code had been placed in the after_initialize block then Order- | |
# Transaction.gateway would be properly set on the first request to the | |
# application, but would be nil on all subsequent requests. | |
config.after_initialize do | |
ActiveMerchant::Billing::Base.mode = :test | |
end | |
config.to_prepare do | |
OrderTransaction.gateway = | |
ActiveMerchant::Billing::BraintreeGateway.new( | |
:login => 'demo', | |
:password => 'password' | |
) | |
end | |
# application/moneyhats/config/environments/test.rb | |
# BogusGateway is a double provided by ActiveMerchant | |
config.after_initialize do | |
ActiveMerchant::Billing::Base.mode = :test | |
OrderTransaction.gateway = | |
ActiveMerchant::Billing::BogusGateway.new | |
end | |
# application/moneyhats/config/environments/production.rb | |
config.after_initialize do | |
# ActiveMerchant is in prod mode by default | |
# so this line is just for clarity | |
ActiveMerchant::Billing::Base.mode = :production | |
OrderTransaction.gateway = | |
ActiveMerchant::Billing::BraintreeGateway.new( | |
:login => 'LIVE_LOGIN', | |
:password => 'LIVE_PASSWORD' | |
) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment