Problem with PayPal IPN, please help
Hello;
I am using this code to grab the users information from paypal, I have the correct IPN and it brings it in fine, BUT here is my issues. I have 2 of them I can't figure out.
1. When the information comes back it is URL Encoded, how do I change it back to normal format so the email address actually uses the @ sign and not %004, and other issues with the information it brings back.
2. I get an error. In this page, I have a form that is populated by the information that comes back from paypal, when the user submits this form to send that info as well as the new info we need from them I get this error:
Element TX is undefined in URL. | |
| The error occurred in C:\Inetpub\wwwroot\paypal\step2.cfm: line 60 | |
58 : <p align="left"><img src="../images/bridalText.jpg" width="257" height="59"></p> | |
I know this is a lot of code, but it is pretty simple. How do I define TX in the form? and how do I unencode the information back from paypal?
My code: (I'm cutting a lot out, so you can see the main portion of what I am doing)
<!--- paypal IPN and code --->
<cfset authToken="MYIPN NUMBER GOES HERE">
<cfset txToken = url.tx>
<cfset query="cmd=_notify-synch&tx=" & txToken & "&at=" & authToken>
<CFHTTP url="https://www.paypal.com/cgi-bin/webscr?#query#" method="GET" resolveurl="false">
</CFHTTP>
<cfif left(cfhttp.FileContent,7) is "SUCCESS">
<cfloop list="#cfhttp.FileContent#"
index="curLine"
delimiters="#chr(10)#">
<cfif listGetAt(curLine,1,"=") is "first_name">
<cfset firstName=listGetAt(curLine,2,"=")>
</cfif>
<cfif listGetAt(curLine,1,"=") is "last_name">
<cfset lastName=listGetAt(curLine,2,"=")>
</cfif>
<cfif listGetAt(curLine,1,"=") is "payer_email">
<cfset email=listGetAt(curLine,2,"=")>
</cfif>
<cfif listGetAt(curLine,1,"=") is "address_street">
<cfset streetAdd=listGetAt(curLine,2,"=")>
</cfif>
<cfif listGetAt(curLine,1,"=") is "address_city">
<cfset city=listGetAt(curLine,2,"=")>
</cfif>
<cfif listGetAt(curLine,1,"=") is "address_state">
<cfset state=listGetAt(curLine,2,"=")>
</cfif>
<cfif listGetAt(curLine,1,"=") is "address_zip">
<cfset zip=listGetAt(curLine,2,"=")>
</cfif>
<cfif listGetAt(curLine,1,"=") is "item_name">
<cfset itemName=listGetAt(curLine,2,"=")>
</cfif>
<cfif listGetAt(curLine,1,"=") is "mc_gross">
<cfset mcGross=listGetAt(curLine,2,"=")>
</cfif>
<cfif listGetAt(curLine,1,"=") is "mc_currency">
<cfset mcCurrency=listGetAt(curLine,2,"=")>
</cfif>
</cfloop>
<cfoutput>
<p><h3>Your order has been successfully received.</h3></p>
<b>Details</b><br>
<li style="line-height:15px; margin-left:20px;">Name: #firstName# #lastName#</li>
<li style="line-height:15px; margin-left:20px;">Description: #itemName#</li>
<li style="line-height:15px; margin-left:20px;">Amount: #mcCurrency# #mcGross#</li>
<hr>
</cfoutput>
<cfelse>
ERROR: Check to make sure the authToken value set is EXACTLY what PayPal gave
</cfif>
<!--- end paypal IPN --->
<!--- My form using the IPN information --->
<cfparam name="FORM.firstName" default="#firstName#">
<cfparam name="FORM.lastName" default="#lastName#">
<cfparam name="FORM.email" default="#email#">
<cfparam name="FORM.cPhone" default="#phone#">
<cfparam name="FORM.streetAdd" default="#streetAdd#">
<cfparam name="FORM.city" default="#city#">
<cfparam name="FORM.state" default="#state#">
<cfparam name="FORM.zip" default="#zip#">
<cfparam name="FORM.mype" default="">
<cfparam name="FORM.bgName" default="">
<cfparam name="FORM.bgEmail" default="">
<cfparam name="FORM.bgAdd" default="">
<cfparam name="FORM.bgCity" default="">
<cfparam name="FORM.bgState" default="">
<cfparam name="FORM.bgZip" default="">
<cfparam name="FORM.message" default="">
<!--- this is where it checks to make sure all the required fields are filled in, if not it posts back a message requesting they fill it in, if it is all filled in, then it sends an email with all the info in it, and gives them a thank you message. I wanted to cut out this part, you don't need to proof it, the problem is in my paramiters and form--->
<cfoutput>
<cfform action="#cgi.script_name#" method="post" enctype="application/x-www-form-urlencoded">
<input type="text" name="firstName" id="firstName" value="#firstName#" />
<input type="text" name="lastName" id="lastName" value="#lastName#" />
<input type="text" name="email" id="email" value="#email#" />
<input type="text" name="streetAdd" id="streetAdd" value="#streetAdd#" />
<input type="text" name="city" id="city" value="#city#" />
<input type="text" name="state" id="state" value="#state#" />
<input type="text" name="zip" id="zip" value="#zip#" />
</cfform>
</cfoutput>
I also took out a bunch of fields I need to have the user fill out, but this is the meat of what I'm trying to do.
Can anyone help me??? Please? It's driving me nuts!
Thank you!
