我想将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]}.
答案 0 :(得分:1)
您无法使用帖子请求进行重定向。您需要发送您的帖子请求,然后重定向到页面。
您应该在控制器方法的末尾使用redirect_to :some_page
。
现在rails正在尝试渲染&#34;默认&#34;,这就是您收到该错误的原因。
尝试this
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)