1

So a follow up to this question: getting bad request from ruby on rails ssl post.

I fixed that problem and I make the next step in the transaction no problem. The problem I am facing is that their response is sent to an iFrame as a hidden form on an html document. The form then posts to a url that I provide them.

I have tried giving them localhost:3000/policies/complete making a controller action and a route resource for the post but it doesn't ever show anything. - It just says javascript error unable to load resource: localhost:3000/policies/complete

So then I tried just /policies/complete (with the coresponding method in my policies controller complete) but for some reason instead of posting to that action - it posted to theirwebserver.com/policies/complete which obviously doesn't exist.

So since it looks like I have to pass in a whole url for it to work correctly the form is going to look like: <form method='Post' action='whatever whole url I give them'>

The form looks like this:

<form name="frmReturn" method="Post" action="localhost:3000/policies/hosted_checkout_complete">
    <input name="PaymentID" type="hidden" value="the value you need really badly!">
    <input name="ReturnCode" type="hidden" value="0">
    <input name="ReturnMessage" type="hidden" value="Your transaction has been approved."> 
</form>

Tl:DC How do I set up my app to handle that?

I can request that they use get to send the information back to me. If that would be easier to set up and accept please let me know!

Community
  • 1
  • 1
Ryan
  • 5,644
  • 3
  • 38
  • 66

1 Answers1

0

You need to add the protocol (either http:// or https://) to the front of the action=

<form name="frmReturn" method="Post" action="http://localhost:3000/policies/hosted_checkout_complete">

However, I would NOT recommend doing this... You have completely missed the point of Rails routing. You should be doing something like this:

<form name="frmReturn" method="Post" action="<%= resource_url %>">

Ideally, you'd use the Rails form builders:

<%= form_for :resource, :action => 'hosted_checkout_complete' do %>
sethvargo
  • 26,739
  • 10
  • 86
  • 156
  • 1
    you have missed the point of my question. The form is coming from a different site which they are putting in an iframe on my site. I have NO control over the form! I would LOVE to use rails helpers and do on a daily basis. The whole reason I am stuck right now is because I CAN'T USE RAILS HELPERS. (sorry for yelling/caps but I have been at this for 2 days that the api I am being forced to use is well.... yea) – Ryan Oct 12 '12 at 21:03
  • And yet you still helped me out! thanks a bunch! I did need the http:// for it to resolve to the right host. – Ryan Oct 12 '12 at 21:30