本文介绍了从Rails控制器发布并重定向到外部站点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在用户注册页面之后,Web客户端将进入此页面,其中仅包含一个继续按钮。但我想跳过此页面并进入付款页面。有没有办法在控制器中完全执行此操作?
After the user registration page, web clients will come to this page, which contains only a proceed button. But I want to skip this page and proceed to the payment page. Is there any way to do this action completely in the controller?
<form method="post" action="https://www.ccavenue.com/shopzone/cc_details.jsp">
<input type=hidden name=Merchant_Id value="<%= @Merchant_id %>">
<input type=hidden name=Amount value="<%= @Amount %>">
<input type=hidden name=Order_Id value="<%= @user_id %>">
<input type=hidden name=Redirect_Url value="<%= @redirect_url %>">
<input type=hidden name=Checksum value="<%= @checksum %>">
<input type="submit" class="Register_button" value="Proceed to payment">
</form>
推荐答案
你应该 POST 控制器的请求。
You should do POST request from controller.
uri = URI.parse("https://www.ccavenue.com/shopzone/cc_details.jsp")
http = Net::HTTP.new(uri.host, uri.port)
form_data = {
"Merchant_Id" => @Merchant_id,
"Amount" => @Amount,
"Order_Id" => @user_id,
"Redirect_Url" => @redirect_url,
"Checksum" => @checksum
}
request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data(form_data)
response = http.request(request)
您可以使用 gem来发布请求。
You can use httparty gem to do post request.
这篇关于从Rails控制器发布并重定向到外部站点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!