Testing Authorize.net with ActiveMerchant 3
I had some trouble testing Authorize.net with the excellent rails credit card processing gem ActiveMerchant. The documentation calls for the code ActiveMerchant::Billing::Base.mode = :test, however, this resulted in the following error:
The merchant login ID or password is invalid or the account is inactive.
To solve the problem, a key test with the String value true can be added to the gateway initialization hash, as follows:
if ENV['RAILS_ENV'] != 'production'
gateway = ActiveMerchant::Billing::Base.gateway(:authorize_net).new(
:login => "login",
:password => "transkey", :test => 'true')
else
gateway = ActiveMerchant::Billing::Base.gateway(:authorize_net).new(
:login => "login",
:password => "transkey")
end
Using this code, the account is placed into test mode when not run in production mode.
Trackbacks
Use the following link to trackback from your own site:
http://littlebitofcode.com/trackbacks?article_id=10
Thank you for this workaround. Learning all I can on Rails.
Sweet. Thanks for the pointer.
Thank you a lot man! ;)