Skip to main content
Inspiring
June 9, 2010
Question

Place Order Button

  • June 9, 2010
  • 1 reply
  • 1927 views

I need to do two tasks with the place order button:

1. Insert the order row into table 'orders'

2. Submit a form to the payment gateway

The first item is fine, I can just submit the form and perform the SQL insert

The second item is a bit trickier. Our payment provider issue us with an example form, containing hidden inputs (order value, etc...). The form is submitted and jumps to their secure server where credit card info is entered.

Is there a way to perform step 2 automatically after I've done step 1 ? eg. auto submit their form ?

This topic has been closed for replies.

1 reply

ilssac
Inspiring
June 9, 2010

Check out the <cfhttp....> tag.  That is its purpose.  To make requests to an server, complete with get or post values if you like.

Inspiring
June 9, 2010

Will do. Thanks Ian

Inspiring
June 9, 2010

Ian

I've checked out CFHTTP and it appears it's used to generate an HTTP request then receive the response. Is this what a form does ?

At present I don't need any response, I just need to submit form to their secure address. This takes the user from our site to the secure payment gateway, where they enter their c/card.

eg.

<!-- The first line of code specifies the URL for our test environment.-->                            

<form action="https://secure-payment-gateway" method=POST>

    <!-- This next line contains the testMode parameter - it specifies that the submission is a test submission -->

    <input type=hidden name="testMode" value="100">

    <!-- This next line contains a mandatory parameter, our userID ->

    <input type=hidden name="instId" value="xxxxx">

    <!-- Another mandatory parameter. Put your own reference identifier for the item purchased inside the quotes after value= -->

    <input type=hidden name="cartId" value="#order_ref#">

    <!-- Another mandatory parameter. Put the total cost of the item inside the quotes after value= -->

    <input type=hidden name="amount" value="#grandTotal#">

    <!-- Another mandatory parameter. Put the code for the purchase currency inside the quotes after value= -->

    <input type=hidden name="currency" value="GBP">

    <!-- This creates the button. When it is selected in the browser, the form submits the purchase details to us. -->

    <input type=submit value="PLACE ORDER">

</form>

So step 1, I create a form with submit button "place order" which when clicked takes the user to a page on my site which dumps the order to the database tables

Are you saying step 2, submit the above form is carried out by CFHTTP ? I was just thinking of some javascript that could auto submit the above form ?