Skip to main content
Inspiring
January 29, 2007
Question

CFHTTP to get response variable

  • January 29, 2007
  • 1 reply
  • 24009 views
Hi all,

I am integrating the HSBC CPI to a site at the moment, and am having some difficulty in getting the value of the CPI hash. I am attempting to use CFHTTP to post form variables to a page to get the variables converted to a hash then returned to my page to submit.

I am using the following code:

<!--- GET ORDER --->
<cfinvoke component="cfc.shoppingCart" method="getSavedOrder" returnvariable="getSavedOrder">

<cfhttp method="get" redirect="yes" url="OrderHash.cfm">
<cfhttpparam type="formfield" name="OrderId" value="#getSavedOrder.orderRef#">
<cfhttpparam type="formfield" name="TimeStamp" value="">
<cfhttpparam type="formfield" name="CpiReturnUrl" value="https://www.mysite.com/results.cfm">
<cfhttpparam type="formfield" name="CpiDirectResultUrl" value="https://www.mysite.com/results.cfm">
<cfhttpparam type="formfield" name="StorefrontId" value="UK12345678GBP">
<cfhttpparam type="formfield" name="OrderDesc" value="Online Shop">
<cfhttpparam type="formfield" name="PurchaseAmount" value="#replace(decimalFormat(getSavedOrder.orderTotal), ".", "", "All")#">
<cfhttpparam type="formfield" name="PurchaseCurrency" value="826">
<cfhttpparam type="formfield" name="TransactionType" value="Auth">
<cfhttpparam type="formfield" name="UserId" value="">
<cfhttpparam type="formfield" name="Mode" value="T">
<cfhttpparam type="formfield" name="MerchantData" value="">
<cfhttpparam type="formfield" name="BillingFirstName" value="#getSavedOrder.uFirstName#">
<cfhttpparam type="formfield" name="BillingLastName" value="#getSavedOrder.uLastName#">
<cfhttpparam type="formfield" name="ShopperEmail" value="">
<cfhttpparam type="formfield" name="BillingAddress1" value="#getSavedOrder.billAddr1#">
<cfhttpparam type="formfield" name="BillingAddress2" value="#getSavedOrder.billAddr2#">
<cfhttpparam type="formfield" name="BillingCity" value="#getSavedOrder.billAddr3#">
<cfhttpparam type="formfield" name="BillingCounty" value="">
<cfhttpparam type="formfield" name="BillingPostal" value="#getSavedOrder.billPoco#">
<cfhttpparam type="formfield" name="BillingCountry" value="826">
<cfhttpparam type="formfield" name="ShippingFirstName" value="#getSavedOrder.delFirstName#">
<cfhttpparam type="formfield" name="ShippingLastName" value="#getSavedOrder.delLastName#">
<cfhttpparam type="formfield" name="ShippingAddress1" value="#getSavedOrder.delAddr1#">
<cfhttpparam type="formfield" name="ShippingAddress2" value="#getSavedOrder.delAddr2#">
<cfhttpparam type="formfield" name="ShippingCity" value="#getSavedOrder.delAddr3#">
<cfhttpparam type="formfield" name="ShippingCounty" value="">
<cfhttpparam type="formfield" name="ShippingPostal" value="#getSavedOrder.delPoco#">
<cfhttpparam type="formfield" name="ShippingCountry" value="826">
</cfhttp>

To post to a page that consumes tyhose fields to create a hash.

How can I return the hash to my page using cfhttp? Is it possible?

TIA,
Paul
    This topic has been closed for replies.

    1 reply

    Participating Frequently
    January 29, 2007
    what does <cfdump var="#cfhttp#"> (after that code) give you?
    Inspiring
    January 29, 2007
    Hi A3gis,

    It says:

    Charset [empty string]
    ErrorDetail Unknown host: orderhash.cfm: orderhash.cfm
    Filecontent Connection Failure
    Header [undefined struct element]
    Mimetype Unable to determine MIME type of file.
    Responseheader struct [empty]
    Statuscode Connection Failure. Status code unavailable.
    Text YES

    I am unsure of how reliable the system is as it requests the amount to be charged as a form variable, but I know it is possible for the user to save the page and enter their own desired amount as a form var, so I was looking to re-do it using query variables instead to make it more secure.

    My problem is that the spec only gives a guide for using form variables.

    I assume by the look of the CFDump that the order hash generation is not happy with the cfhttp. Is this correct?

    Thanks, Paul
    Inspiring
    January 29, 2007
    Ok, I now have it so that the hash is set by the cfhttp, but I am unable to reference the variable in the calling page.

    I have page 1 with a cfhttp to page 2 where the hash is set and should be returned to page 1 which will use the hash.

    How would I reference the variable set in page 2? I can see the value of the variable in the cfdump of cfhttp, but cannot reference it in the calling page.

    Any help appreciated.

    Paul