2010-04-22 99 views
2

我有一個問題得到authorize.net從我的Rails應用程序運行信用卡交易。API登錄/ trans密鑰與ActiveMerchant和Authorize.net的問題

下面是在我的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 

我下面的瑞恩·貝茨Railscast集成 - 這是在命令模式

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 

我已經調試了輸出和一切似乎正確發送,但它返回以下錯誤:

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}> 

我已經檢查了API Key和Trans Key,兩者都是正確的。 Authorize.net設置爲自己的最終測試模式,但我不認爲這應該引起這個問題...

任何幫助,將不勝感激......

+0

什麼是你的整個「response.message」時>真的嗎? – Salil 2010-04-22 15:28:25

回答

2

因爲我看不到有什麼網址您正在向您提交交易,因此很難確切地說出問題所在。

如果您在測試模式下使用實時服務器,則必須使用您的實時憑證。這些與用於進入控制面板的帳戶登錄名和密碼不同。

如果您有一個開發人員帳戶,它僅適用於使用測試服務器的情況。在實時服務器上使用開發人員憑據,即使它處於測試模式也不起作用。

+0

這是實時模式下的實時服務器。我使用的是authorize.net控制面板中生成的api和trans鍵。我已經在過去集成了w/cakePHP,symfony,PHP和Rails,所以我很熟悉w /程序 - 奇怪的事情正在發生,但並不確定... – BandsOnABudget 2010-04-22 15:59:36

+0

其實 - 只是想出了它 - ActiveMerchant :: Billing :: Base.mode =:test 需要刪除 - 它會導致問題w/Authorize.net。只是一個註釋 - 這可能不會導致生產中的問題 - 只是在開發......無論如何 - 感謝您的建議...... – BandsOnABudget 2010-04-22 16:00:53

0

刪除ActiveMerchant :: Billing :: Base.mode =:test爲我工作。我只是設置:測試=創建網關

::PAYMENT_GATEWAY = ActiveMerchant::Billing::AuthorizeNetGateway.new(:login => SiteCredentials.authorize_net_api_login, :password => SiteCredentials.authorize_net_api_transaction_key, :test => true)