如何在Ruby中的Authorize.NET中使用中继响应URL

时间:2014-11-25 09:44:57

标签: ruby-on-rails ruby authorize.net

我目前正致力于将我的示例网站与Authorize.NET集成。

所以我在Authorize.NET中创建了一个Sandbox帐户。

使用此测试帐户,我正在测试DPM并使用中继响应URL。

我有公共IP

我正在设置x_relay_response =“TRUE”; x_relay_url = “http://182.180.157.5:3000/payments/relay_response”;

控制器

class PaymentsController < ApplicationController

layout 'authorize_net'
helper :authorize_net
protect_from_forgery :except => :relay_response

# GET
# Displays a payment form.
def payment
   @amount = 125.00
   @sim_transaction = AuthorizeNet::SIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], @amount, :relay_response => true, :relay_url => "http://182.180.157.5:3000/payments/relay_response")
end

# POST
# Returns relay response when Authorize.Net POSTs to us.
def relay_response
   puts "In Relay Response"
   puts "Params: #{params}"
   sim_response = AuthorizeNet::SIM::Response.new(params)
   if sim_response.success?(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['merchant_hash_value'])
     render :text => sim_response.direct_post_reply("http://182.180.157.5:3000/payments/receipt", :include => true)
  else
      render
  end
end

# GET
# Displays a receipt.
def receipt
    @auth_code = params[:x_auth_code]
end

end

获取此错误

尝试向商家报告此交易时发生错误。已向商家发送电子邮件,通知他们错误。以下是尝试从您的信用卡中扣款的结果。

  This transaction has been approved.

建议您与商家联系以确认您是否会收到产品或服务。

任何解决方案

0 个答案:

没有答案