3

我想将 PayuMoney 支付网关集成到我的 rails 应用程序中。我想通过发布请求重定向到支付网关 URL,所以我使用 HTTparty 重定向和 POST 请求到 payumoney URL。

我的控制器:

class ClientFeePaymentsController < ApplicationController
 include HTTParty

 def fee_payment
   uri = URI('https://test.payu.in/_payment.php')
   res = Net::HTTP.post_form(uri, 'key' => 'fddfh', 'salt' => '4364')
   puts res.body    
 end 
end

路线:

resources :client_fee_payments do
    collection do
      get :fee_payment
      post :fee_payment
    end
  end

当我运行这个时,我得到了,

Missing template client_fee_payments/fee_payment, application/fee_payment with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :axlsx, :jbuilder]}.
4

1 回答 1

1

您不能使用发布请求重定向。您需要发送您的发布请求,然后重定向到一个页面。

您应该redirect_to :some_page在控制器方法的末尾使用。

现在 rails 正在尝试呈现“默认”,这就是您收到该错误的原因。

试试这个

require "net/http"
require "uri"

uri = URI.parse("http://example.com/search")

# Shortcut
response = Net::HTTP.post_form(uri, {"q" => "My query", "per_page" => "50"})

# Full control
http = Net::HTTP.new(uri.host, uri.port)

request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data({"q" => "My query", "per_page" => "50"})

# Tweak headers, removing this will default to application/x-www-form-urlencoded 
request["Content-Type"] = "application/json"

response = http.request(request)
于 2015-11-04T06:49:36.957 回答