API login / trans key issues with ActiveMerchant and Authorize.net
I am having a problem getting authorize.net to run credit card transactions from my rails app.
This is what is in my environment. rb
if ENV['RAILS_ENV'] != 'production'
::GATEWAY = gateway = ActiveMerchant::Billing::Base.gateway(:authorize_net).new(
:login => "scrubbed",
:password => "scrubbed")
else
::GATEWAY = gateway = ActiveMerchant::Billing::Base.gateway(:authorize_net).new(
:login => "scrubbed",
:password => "scrubbed", :test => 'true')
end
I am following Ryan Bates Railscast for integration - this is what is in the order model
def purchase
response = GATEWAY.purchase(price_in_cents, credit_card, purchase_options)
transactions.create!(:action => "purchase", :amount => price_in_cents, :response => response)
cart.update_attribute(:purchased_at, Time.now) if response.success?
response.success?
end
I debugged the output and everything seems to be posted correctly, but it returns the following error:
GATEWAY.purchase(price_in_cents, credit_card, purchase_options)#<ActiveMerchant::Billing::Response:0x1066efda0 @fraud_review=false, @params={"response_reason_text"=>"The merchant login ID or password is invalid or the account is inactive.", "transaction_id"=>"0", "response_code"=>3, "response_reason_code"=>"13", "avs_result_code"=>"P", "card_code"=>nil}, @message="The merchant login ID or password is invalid or the account is inactive", @avs_result={"code"=>"P", "postal_match"=>"Y", "street_match"=>"N", "message"=>"Postal code matches, but street address not verified."}, @test=true, @authorization="0", @success=false, @cvv_result={"code"=>nil, "message"=>nil}>
I have checked the API Key and Trans Key and both are correct. Authorize.net is set to test mode at their end, but I don't think that should cause the problem ...
any help would be greatly appreciated ...
a source to share
Since I can't see what url you are sending in your transactions, it makes it difficult to be sure what the problem is.
If you are using a live server in test mode, you must use your credentials. These are different from the account login and password you use to log into your control panel.
If you have a developer account, it only works when using a test server. Using your developer's credentials on a live server, even if it is in test mode, will not work.
a source to share
Removing ActiveMerchant :: Billing :: Base.mode =: The test worked for me. I just set: test => true when creating the gateway
::PAYMENT_GATEWAY = ActiveMerchant::Billing::AuthorizeNetGateway.new(:login => SiteCredentials.authorize_net_api_login, :password => SiteCredentials.authorize_net_api_transaction_key, :test => true)
a source to share