?
Solved

cfhttp

Posted on 2004-09-11
9
Medium Priority
?
2,384 Views
Last Modified: 2013-12-24
Can someone give me an example on how to use cfhttp

I'm trying to post some information from my site (hidden form fields) to an online processor,
so i have a page where the hidden form fields are populated with data, then the form submits to a page which contains only a cfhttp tage, but nothing happens.
here is the cfhttp tage that i wrote

<cfhttp  redirect="yes"  url="https://www....." method="post" resolveurl="yes" >
                                          
                                          <cfhttpparam name="sid" type="formfield" value="#form.sid#">
                                          <cfhttpparam name="total" type="formfield" value="#form.Total1#">
                                          <cfhttpparam name="cart_order_id" type="formfield" value="#form.cart_order_id# ">
                                          <cfhttpparam name="demo" type="formfield" value="#form.demo#">
                                    </cfhttp>  
                                    </cfif>
thanks
0
Comment
Question by:MMsabry
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 21

Expert Comment

by:pinaldave
ID: 12034954
value="#form.cart_order_id# "
there is a space at the end of this variable before " does that matter...
0
 

Author Comment

by:MMsabry
ID: 12035082
thanks, but nop nothing happens, no redirection!
0
 
LVL 17

Expert Comment

by:Tacobell777
ID: 12035647
have you tried creating a normal form and post to this page?
example
<form method="post" action="http://..">
<input ype="text" name="sid" value="test">
etc.....
</form>
0
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 12

Assisted Solution

by:jyokum
jyokum earned 2000 total points
ID: 12035650
cfhttp doesn't do redirection. It just sends a request from your cf server to the url in the tag.

To relocate after doing your cfhttp call, you'd have to do something like

<cfhttp ...>
     ...
</cfhttp>

<cflocation url="http://go.somewhere.com">
0
 
LVL 12

Expert Comment

by:jyokum
ID: 12035653
if you want to see what was returned from the cfhttp call, put this after it.

<cfdump var="#cfhttp#">

After you make a cfhttp call, you will get back a structure called "cfhttp" that contains all the return information
0
 

Author Comment

by:MMsabry
ID: 12035779
Jyokum,
what is the use of the "redirect" attribute of the cfhttp tag then?

Tacobell777'
i have tried that, but nop it does not work.

you see the page i'm posting the info to is the first page of an online processor, and they need the info to be appended to the url, which is easy, my only problem with this, is that the user can see and edit the info on the url and the processor will make him pay the edited amount, which is something i do not want to happen. they indicated to me that their security against that is to send back a hashed key with some information that would allow me to verify that the user has payed the correct amount. but i want to try to avoid this from the start, since if this happens (user editing the total amount) and pays, it will be up to me to chase him to get the correct amount from the start.

now i have once managed to get the cfhttp tag to work (which i do not remember how) and passed all the information correctly without the  rest of the url showing the info. as url param. but at that one time, only the first page on the processor got the information (this page asks the user how does he want to pag) then it moves to the second page where the payment itself occurs. this second page did not get the information and thus displayed a total of "0".

so one thing i was trying to do, is to pass the information using the cfhttp tag, and append the variables to it as hidden form fields. this is where i'm stuck at the moment.

any solutions or work arounds??
thanks
sabry
0
 
LVL 12

Accepted Solution

by:
jyokum earned 2000 total points
ID: 12036512
according to the documentation (http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-p58.htm) the redirect attribute:
-------------------------------------
If the response header includes a Location field, determines whether to redirect execution to the URL specified in the field.

Yes redirects execution to the specified page.
No stops execution and returns the response information in the cfhttp variable, or throws an error if the throwOnError attribute is True.

The cfhttp.responseHeader.Location variable contains the redirection path. ColdFusion follows a maximum of four redirects on a request. If there are more, ColdFusion functions as if redirect ="no".
-------------------------------------

The important thing to remember about cfhttp is that the SERVER (not the client) is making a request to the url specified. The redirect attribute just controls how the server handles the request.

What payment service is this? A little more info may help  us get you a solution.
0
 

Author Comment

by:MMsabry
ID: 12039985
the payment service is 2checkout.com
I have got the the payment processor to work, but only if the user presses a submit button (hidden form fields are submitted then), i would still like to get it to just redirect. so the user does not have to press submit three times through the process
first submit, then verify and submit then pay. I would like to take that last step out, and just diplay a page for about 10s. then it goes to the processor.

I would like also to know how to use the cfhttp tag, and why it is not redirecting in my case!
thanks
0
 
LVL 1

Expert Comment

by:TimDg
ID: 12047014
You mention that the service you are submitting to requires the information appended to the URL.  The way you are executing your cfhttp it is submitting form POST data.  What you want to do is submit form GET data.  Adjusting your code it would look like the following:

<cfhttp  url="https://www....." method="get" resolveurl="yes">
     <cfhttpparam name="sid" type="URL" value="#form.sid#">
     <cfhttpparam name="total" type="URL" value="#form.Total1#">
     <cfhttpparam name="cart_order_id" type="URL" value="#form.cart_order_id# ">
     <cfhttpparam name="demo" type="URL" value="#form.demo#">
</cfhttp>

You will receive the http response back from the server in the #cfhttp.FileContent# variable.  After your cfhttp block you will need to parse this variable to get your payment status code.

The redirect parameter in cfhttp is defaulted to YES.  This parameter allows the cfhttp request to accept and execute redirects from the url requested up to 4 times.  It DOES NOT perform any kind of redirection for the page user.

After you parse your status code then you will want to do one of two things:
Execute a <cflocation url="statuspageX.cfm"> tag that redirects the user to a special status explanation page -or-
if you want to show them their status and redirect them after 10 seconds or so then you will have to use a javascript timer.

0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question