2010-04-22 100 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)