Publish and redirect to an external site from a Rails controller?

After the user registration page, web clients containing only the "Continue" button will appear on this page. But I want to skip this page and go to the payment page. Is there a way to fully perform this action 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>
+3
source share
3 answers

You must execute a POST request from the 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)

You can use httparty gem to execute the request by mail.

+3
source

No, not the way you want to.

, POST , , , . javascript. .

<body onload="document.forms['myform'].submit();">
    <form id="myform">
        …
    </form>
</body>
+1

All Articles