views:

291

answers:

2

I'm having an issue getting authorize.net to run credit card transactions from my rails app.

Here 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'm 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've debugged the output and everything seems to be properly sent but it's returning 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've checked the API Key and Trans Key and both are correct. Authorize.net is set to test mode on their end but i don't think that should cause the issue...

any help would be greatly appreciated...

+1  A: 

Since I can't see what URL you are submitting your transactions to it makes it hard to say for sure what the problem is.

If you are using the live server in test mode you have to use your live credentials. These are different from the account login and password you use to get into the control panel.

If you have a developer account it only works when you are using the test server. Using your developer credentials on the live server, even if it is in test mode, won't work.

John Conde
this is a live server in live mode. i'm using the api and trans key generated in the authorize.net control panel. i've integrated AN w/ cakePHP, symfony, PHP, and Rails in the past so i'm familiar w/ the procedure - something weird is happening though and not quite sure...
BandsOnABudget
actually - just figured it out - ActiveMerchant::Billing::Base.mode = :test needs to be removed - it causes issues w/ Authorize.net. Just a note - this probably won't cause an issue in production - just in development... anyway - thanks for the suggestions...
BandsOnABudget
A: 

Removing ActiveMerchant::Billing::Base.mode = :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)

Nick