Chase Paymentech / CFHTTP Problem

I was working on implementing a ColdFusion payment processor for Chase Paymentech, but I kept running into the same error (which I’ve formatted so nicely using my ruby clipboard format utility!)

<?xml version='1.0' encoding='UTF-8'?>
<Response>
    <QuickResp>
        <ProcStatus>05</ProcStatus>
        <StatusMsg>PTI43,TEXT/XML; CHARSET=UTF-8 is not supported</StatusMsg>
    </QuickResp>
</Response>

I knew that PTI43 was part of the MIME Header Content-Type I was passing, so I did a little bit of poking around in the docs and came upon this. Apparently setting a cfhttpparam type of “xml” “identifies the request as having a content-type of text/xml.”.

In order to send a valid message to chase you have to specify a particular MIME header setting “Content-Type”, which ColdFusion was garbling. Thankfully all I had to do to fix it was switch the cfhttpparam type attribute to “body” in order to fix it.

<cffunction name="Authorize" output="no">
    <cfargument name="vars" required="yes"/>

    <cfset var cfhttp = ""/>
    <cfset var i = ""/>

    <cfheader name="POST /AUTHORIZE HTTP/1.1">
    <cfhttp url="#GetURL()#" port="#GetPort()#" method="POST">
        <cfloop collection="#arguments.vars#" item="i">
            <!--- header variables --->
            <cfif i NEQ "XML">
                <cfhttpparam
                    type="header"
                    name="#i#"
                    value="#arguments.vars[i]#"
                />
            </cfif>
        </cfloop>

        <!--- set the type to "body" NOT "xml"!!! --->
        <cfhttpparam
            type="body"
            value="#arguments.vars["XML"]#"
        />
    </cfhttp>

    <cfreturn cfhttp/>
</cffunction>

I hadn’t run into this problem before, so I thought I’d share!