0

I have simple paypal form to submit and make a payment inside in paypal. Once I saved user data, I want to initiate form submit action.

Here is a half solution - it posts data, but doesn't bring user on paypal checkout window as html form would do. Submitting POST data from the controller in rails to another website

HTML form:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<INPUT TYPE="hidden" NAME="return" value="http://back">
<input type="hidden" name="cmd" value="_cart">
...
<input type="submit" >
</form>

So I need initiate submit button click from the controller with taking user to the same page where data has been posted, same as HTML form basically does.

Community
  • 1
  • 1
Gediminas Šukys
  • 7,101
  • 7
  • 46
  • 59
  • 1
    Is your value for 'return' actually `"http://back"`? If so you probably need to make it an actual end-point in your application - like `www.yourapp.com/payment_succeeded` or whatever. – omnikron Feb 10 '14 at 11:16
  • @omnikron thanks for your comment. Nope, it is only for this example. This form works well as html, but I don't know how to submit it from the controller. – Gediminas Šukys Feb 10 '14 at 11:21
  • Are you getting a response from paypal, with a token or similar? If I understand your case correctly, I would probably wait for this response and then redirect the user explicitly in your controller with `redirect_to ` - does that help? – omnikron Feb 10 '14 at 11:33

1 Answers1

1

Well, here's a link to a related question. To be short - you can't make a redirect + POST request in HTTP.

Community
  • 1
  • 1
marvelousNinja
  • 1,510
  • 9
  • 15