0

I'm using authorize.net's SIM approach, which needs a normal form to be submitted to their TLS host from the user's browser. The setup is done on my server, I just need to create the form and auto-post it when the page loads.

I want it to be posted from the browser so that the user can then fill in the credit card information on authorize.net's host and process the payments. I don't want any of that credit card stuff on my server.

At this point in the process, there is no data for the user to enter, and no more choices, all that happened before we get to here.

Seems like a bit of jQuery to trigger the submit when onLoad() is done.

Is this the best way to approach the problem?

John Conde
  • 217,595
  • 99
  • 455
  • 496
fishtoprecords
  • 2,394
  • 7
  • 27
  • 38

1 Answers1

1

You don't even need jQuery for this because it is so simple. As soon as the page loads with your form on it you just need it to auto-submit the form you. Placing this code at the bottom of the page will do this for you (assuming the form is named myform):

<script type="text/javascript">
    document.myform.submit();
</script>

This can be easily adjusted to use jQuery if you'd like but it should give you the right idea.

John Conde
  • 217,595
  • 99
  • 455
  • 496
  • I'm doing something similar, but I'm nervous if it violates AuthNet TOS to do an auto form submit? Also, in my case I need inline form validation. So, I'm submitting to a script on my server, storing field values in session vars, doing the DPM auto form submit, and then letting the IPN spit back an error back to the payment form again, if there was one. And then I use the session vars to fill the form out the way it was, but then show an error back to the user. I had to do this because I couldn't get jQuery/AJAX working (http://stackoverflow.com/q/15873074/105539). – Volomike Apr 08 '13 at 07:26
  • 1
    BTW, this will generate an error on Google Chrome. You need to use either document.all.myform.submit(), or document.forms[0].submit() (if you only have one form on that page), or use document.getElementById('form1').submit(). – Volomike Apr 08 '13 at 07:47