1

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="Beantownaquatics@gmail.com">
    <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.

1 Answers1

2

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>
Charles Robertson
  • 1,760
  • 16
  • 21
  • 1
    Thanks for the idea, it was a potential of a lot of data. I actually went through storing it in a database in JSON format and passing a Key to Paypal and I just restore all the session variables that matter to me. – Thomas Nichols Jan 27 '19 at 00:53
  • OK. Cool. Yes, my approach only really works for a few simple values, although, I guess you could actually pass JSON in that field. You could Base64 the JSON first & then add it to the field. This would have the effect of escaping double quotes etc. The max char length for a hidden field is about 65,000... – Charles Robertson Jan 27 '19 at 23:52