2

我在让 authorize.net 从我的 rails 应用程序运行信用卡交易时遇到问题。

这是我的环境中的内容.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 

我正在关注 Ryan Bates 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 最终设置为测试模式,但我认为这不会导致问题...

任何帮助将不胜感激...

4

2 回答 2

2

由于我看不到您向哪个 URL 提交交易,因此很难确定问题所在。

如果您在测试模式下使用实时服务器,则必须使用您的实时凭据。这些与您用于进入控制面板的帐户登录名和密码不同。

如果您有开发人员帐户,则它仅在您使用测试服务器时有效。在实时服务器上使用您的开发人员凭据,即使它处于测试模式,也无法正常工作。

于 2010-04-22T15:28:04.880 回答
0

删除 ActiveMerchant::Billing::Base.mode = :test 对我有用。我只是在创建网关时设置 :test => true

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

于 2010-09-08T15:25:07.453 回答