Jump to content


Photo

#form.fieldnames#


  • This topic is locked This topic is locked
25 replies to this topic

#21 MAGSGQ

MAGSGQ

    Member

  • Members
  • PipPip
  • 13 posts

Posted 08 May 2003 - 05:16 AM

Good morning.

Patricks test code exists in this thread posted a while ago. As for what is happening and what's not working, I'll try to explain as best I can.

I have(had since I made a change this morning) one file....success.cfm which includes my IPN code.

I have created two files now: ipn.cfm and success.cfm

ipn.cfm is my URL for PayPal setup and it is my notify_url.
success.cfm is my 'return' url

Anyways, what I did was output the CFHTTP.FileContent and the FORM.Vars sent by PP and basically wrote the URL to see what VARS were being passed. Of course, not matter what I did for testing; IE: Patricks code contained in this thread and Eliteweaver, it always came back as invalid.

I finally convinced someone to test it out live for me. PayPal recorded the transaction but for some reason I was getting those CFusion errors.

Where do I stand now? Not sure! I have ipn.cfm and success.cfm and I really do not know where to go from here now.

Thanks in advance.

PS...how would I write using CFFILE again? I'm going to include the IPN code.





<!-- read post from PayPal system and add 'cmd' -->
<CFSET str="cmd=_notify-validate">
<CFLOOP INDEX="TheField" list="#Form.FieldNames#">
<CFSET str = str & "#LCase(TheField)#=#URLEncodedFormat(Evaluate(TheField))#">
</CFLOOP>
<CFIF IsDefined("FORM.payment_date")>
<CFSET str = str & "&payment_date=#URLEncodedFormat(Form.payment_date)#">
</CFIF>
<CFIF IsDefined("FORM.subscr_date")>
<CFSET str = str & "&subscr_date=#URLEncodedFormat(Form.subscr_date)#">
</CFIF>




<!-- post back to PayPal system to validate -->
<CFHTTP URL="https://www.paypal.com/cgi-bin/webscr?#str#" METHOD="GET" RESOLVEURL="false">
</CFHTTP>


<!-- check notification validation -->

<CFIF #CFHTTP.FileContent# is "VERIFIED">
<!-- check that payment_status=Completed -->
<cfif FORM.payment_status eq "Completed">
<!-- check that receiver_email is your email address -->
<cfif #FORM.RECEIVER_EMAIL# eq "tmergl@pacmsolutions.com">

<!-- process payment -->
<cftry>

<cfquery name="AddOrder" datasource="COTTAGE">
INSERT INTO InsertOrder(
business,
receiver_email,
item_name,
item_number,
invoice,
payment_status,
payment_date,
txn_id,
txn_type,
payment_type,
payer_id,
first_name,
last_name
)
VALUES(
'#FORM.BUSINESS#',
'#FORM.RECEIVER_EMAIL#',
'#FORM.ITEM_NAME#',
'#FORM.ITEM_NUMBER#',
'#FORM.INVOICE#',
'#FORM.PAYMENT_STATUS#',
#CreateODBCDateTime(Now())#,
'#FORM.TXN_ID#',
'#FORM.TXN_TYPE#',
'#FORM.PAYMENT_TYPE#',
'#FORM.PAYER_ID#',
'#FORM.FIRST_NAME#',
'#FORM.LAST_NAME#'
)
</cfquery>
<cfcatch>
<!--- let's log all errors --->
<cffile action="append"
file="D:\webserver\coastcottages.com\www\paypal_log.txt"
output="Error order info">
</cfcatch>
</cftry>
<cfset password = #Evaluate("#RandRange(1,10000)# * #RandRange(1,10000)#")#>
<cfset serial_number = "#RandRange(1,10000)#-0-#Left(first_name,1)#">
<cftry>

<cfquery name="AddCustomer" datasource="COTTAGE">
INSERT INTO InsertCustomer(
first_name,
last_name,
email,
address,
city,
state,
zip,
payer_id,
password
)
VALUES(
'#FORM.first_name#',
'#FORM.last_name#',
'#FORM.payer_email#',
'#FORM.address_street#',
'#FORM.address_city#',
'#FORM.address_state#',
'#FORM.address_zip#',
'#FORM.payer_id#',
'#password#'
)
</cfquery>
<cfcatch>
<!--- log any errors when inserting this customer --->
<cffile action="append"
file="D:\webserver\coastcottages.com\www\paypal_log.txt"
output="Error inserting customer">
</cfcatch>
</cftry>

<!--- send user an email --->
<cftry>
<cfmail from="terry.mergl@coastcottages.com"
to="#FORM.payer_email#"
bcc="tmergl@pacmsolutions.com"
server="smtp.coastcottages.com"
subject="CoastCottages.com Registration">
Thank you for subscribing #item_name# with CoastCottages.com

You may login and add your listing(s) at the following URL:
http://www.coastcottages.com/

Your username is: #payer_email#
Your password is: #password#

If you have questions or need help, please go to:
http://www.coastcottages.com/support/

Thanks again for your subscription!
CoastCottages.com
PACM Solutions LLC
http://www.coastcottages.com
</cfmail>
<!--- Now send yourself an email alerting that there was a sale done --->
<cfmail server="smtp.coastcottages.com" from="registered@coastcottages.com" to="tmergl@pacmsolutions.com" subject="There was a new REGISTRATION on CoastCottages.com!">
An order was placed by: #FORM.first_name#' #FORM.last_name#

Item Purchased:
Item Name: #FORM.ITEM_NAME#
Item Number: #FORM.ITEM_NUMBER#
Purchase Price: #DOLLARFORMAT(FORM.PAYMENT_GROSS)#
PayPal Fee: #DollarFORMAT(FORM.PAYMENT_FEE)#
==========================
Profit Fee: #DollarFormat(Evaluate("#FORM.PAYMENT_GROSS# - #FORM.PAYMENT_FEE#"))#

A Reminder Email:
http://www.coastcottages.com
</cfmail>
<cfcatch>
<!--- Log Any Errors Sending Emails --->
<cffile action="append"
file="D:\webserver\coastcottages.com\www\paypal_log.txt"
output="Error sending email">
</cfcatch>
</cftry>
</cfif>
</cfif>


<CFELSEIF #CFHTTP.FileContent# is "INVALID">
<!-- log for investigation -->
<cftry>
<cfcatch>
<!--- let's log all errors --->
<cffile action="append"
file="D:\webserver\coastcottages.com\www\paypal_log.txt"
output="Error order info">
</cfcatch>
</cftry>
<CFELSE>
<!-- error -->
<cftry>
<cfcatch>
<!--- let's log all errors --->
<cffile action="append"
file="D:\webserver\coastcottages.com\www\paypal_log.txt"
output="Error order info">
</cfcatch>
</cftry>

</CFIF>
<html>
<head>
<title>CoastCottages.com - Membership Transaction In Process</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="/cottages.css" type="text/css">
</head>

<body bgcolor="#8D8950" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<cfoutput>#CFHTTP.FileContent#</cfoutput>
</body>
</html>


I suck at CFusion!

#22 RobertD

RobertD

    Member

  • Members
  • PipPip
  • 10 posts

Posted 08 May 2003 - 05:29 AM

Your sentence:"Anyways, what I did was output the CFHTTP.FileContent and the FORM.Vars sent by PP and basically wrote the URL to see what VARS were being passed. Of course, not matter what I did for testing; IE: Patricks code contained in this thread and Eliteweaver, it always came back as invalid." Forget about the passed form vars for now. Concentrate on the passed data stream if you are unable to get form vars. Dump the stream using CFFILE. Look up CFFILE's parameters in Studio (assuming you're using CF tools for your code). I also do not understand what invalid means. What's invalid?

R




Robert Dew
Web Agency, Inc.
Schaumburg, IL

Lead programmer
5 years plus:
- Cold Fusion
- SQL Server
- Javascript
- Windows
25 years coding non Web apps.


#23 MAGSGQ

MAGSGQ

    Member

  • Members
  • PipPip
  • 13 posts

Posted 08 May 2003 - 05:49 AM

CFHTTP.FileContent will either be VERIFIED or INVALID.

That's what I meant by invalid.

I suck at CFusion!

#24 joel@perpetualmedia.com

joel@perpetualmedia.com

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 13 May 2003 - 06:27 AM

What happened? This was working and I tested it thoroughly just a few days ago and now this.....

<!-- read post from PayPal system and add 'cmd' -->
<CFSET str="cmd=_notify-validate">

<cfoutput>
<CFLOOP INDEX="TheField" list="#Form.FieldNames#">
<CFSET str = str & "#LCase(TheField)#=#URLEncodedFormat(Evaluate(TheField))#">
</CFLOOP>
</cfoutput>

Gives Me This!!!

An error occurred while evaluating the expression:


"#Form.FieldNames#"


I'm an experienced Cold Fusion Developer and the problem is that PP is NOT sending the form variables necessary to process a completion. What gives?



#25 MAGSGQ

MAGSGQ

    Member

  • Members
  • PipPip
  • 13 posts

Posted 13 May 2003 - 08:09 AM

I gave up. I did it another way.

I suck at CFusion!

#26 paypal_pb

paypal_pb

    Advanced Member

  • Members
  • 2,960 posts

Posted 14 May 2003 - 12:46 PM

This code:

<!-- read post from PayPal system and add 'cmd' -->
<CFSET str="cmd=_notify-validate">
<CFLOOP INDEX="TheField" list="#Form.FieldNames#">
<CFSET str = str & "#LCase(TheField)#=#URLEncodedFormat(Evaluate(TheField))#">
</CFLOOP>
<CFIF IsDefined("FORM.payment_date")>
<CFSET str = str & "&payment_date=#URLEncodedFormat(Form.payment_date)#">
</CFIF>
<CFIF IsDefined("FORM.subscr_date")>
<CFSET str = str & "&subscr_date=#URLEncodedFormat(Form.subscr_date)#">
</CFIF>

<!-- post back to PayPal system to validate -->
<CFHTTP URL="https://www.paypal.com/cgi-bin/webscr?#str#" METHOD="GET" RESOLVEURL="false">
</CFHTTP>

<!-- check notification validation -->

<CFIF #CFHTTP.FileContent# is "VERIFIED">

Is a way for you to confirm that the IPN came from PayPal and not a hacker.

The only thing I can think of is that the <cfhttp> tag may not be available if you are on an older version of ColdFusion. I believe the tag was introduced in CF 4.5.


Patrick Breitenbach
PayPal, Inc.
Dev Net: https://www.paypal.com/pdn




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users