使用 ActiveMerchant 和 Authorize.net 的 API 登录/交易密钥问题

发布于 2024-08-30 05:46:46 字数 1721 浏览 3 评论 0原文

我在让 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 设置为测试模式,但我认为这不会导致问题...

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽容 2024-09-06 05:46:46

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

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

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

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.

暖阳 2024-09-06 05:46:46

删除 ActiveMerchant::Billing::Base.mode = :test 对我有用。我刚刚设置:测试=>创建网关时为 true

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

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文