Search code examples
paypalcoldfusionsession-variablescfmlpaypal-pdt

ColdFusion (CFML) Losing Session Variables ONLY on Mobile devices with Paypal API


OK I seem to be losing session variables when the buyer returns from Paypal for the PDT payment. This does not happen with any normal browser. My question is how can I send over the session information to Paypal and have them return it when they send the user back to the site. Please see the code below that might offer more info.

<cfform name="CustomerInfo" action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <!--- Paypal cart setup ---> 
    <input type="hidden" name="cmd" value="_cart">
    <input type="hidden" name="upload" value="1">
    <input type="hidden" name="business" value="[email protected]">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="return" value="http://www.beantownaquatics.com/checkoutcomplete.cfm">

<cfset ppHostname = "www.paypal.com">
<CFHTTP url="https://#ppHostname#/cgi-bin/webscr" method="POST" resolveurl="no"> 
    <cfhttpparam name="Host" type="header"    value="#ppHostname#">
    <cfhttpparam name="cmd"  type="formField" value="_notify-synch">
    <cfhttpparam name="tx"   type="formField" value="#txToken#">
    <cfhttpparam name="at"   type="formField" value="#authToken#">
</CFHTTP>

I think passing the session to Paypal would be easiest but, I cannot get it to work. Also I have thought about inserting a JSON string to the database and just passing it back to the user when they return. to process my inventory updates.

Any advise would be great been stuck here a couple days.


Solution

  • You need to use a field named 'custom'.

    <input type="hidden" name="custom" value="value1|value2|value3">
    

    I usually split my values with a pipe, like '|', and then separate them, once they return, using:

    <cfset content = URLdecode(cfhttp.FileContent)>
    
    <cfloop list="#content#" index="curLine" delimiters="#chr(10)#">
        <cfif listGetAt(curLine,1,"=") is "custom">
            <cfset values=listGetAt(curLine,2,"=")>
            <cfset value1=listGetAt(values,1,"|")>
            <cfset value2=listGetAt(values,2,"|")>
            <cfset value3=listGetAt(values,3,"|")>
        </cfif>
    </cfloop>