Solved

cfhttp

Posted on 2004-09-11
9
2,099 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
Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

 
LVL 12

Assisted Solution

by:jyokum
jyokum earned 500 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 500 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

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
json_decode return null? 8 105
Internal DNS Zone Issue 13 92
Asp.net Hosting Plan security, reliable, stable 1 86
SonicWall port forward 4 31
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

710 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