I am using the test ipn message to send to my .cfm file. I am logging the
incoming attributes, the resulting str varible from the sample code, and the
cfhttp response.
This is a fusebox 3 application, so incoming url and form variables are copied
to the attributes scope. Hope that makes sense.
First of all, here is my slightly modified script from the example code
provided by paypal:
-----------------------------------------------------------------
<cfparam name="attribute_values" default="" type="string">
<cfloop collection="#attributes#" item="name">
<cfset attribute_values = attribute_values & "#name# =
#StructFind(attributes,name)#;">
</cfloop>
<!-- read post from PayPal system and add 'cmd' -->
<CFSET str="cmd=_notify-validate">
<cfif isdefined("form.fieldnames")>
<CFLOOP INDEX="TheField" list="#Form.FieldNames#">
<CFSET str = str &
"&#LCase(TheField)#=#URLEncodedFormat(Form[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>
<CFIF IsDefined("FORM.auction_closing_date")>
<CFSET str = str &
"&subscr_date=#URLEncodedFormat(Form.auction_closing_date)#">
</CFIF>
</cfif>
<!-- post back to PayPal system to validate -->
<CFHTTP URL="https://www.sandbox.paypal.com/cgi-bin/webscr#str#" METHOD="GET"
RESOLVEURL="false"></CFHTTP>
<!-- assign posted variables to local variables -->
<!--- <CFSET item_name=FORM.item_name>
<CFSET payment_status=FORM.payment_status>
<CFSET payment_amount=FORM.mc_gross>
<CFSET payment_currency=FORM.mc_currency>
<CFSET txn_id=FORM.txn_id>
<CFSET receiver_email=FORM.receiver_email>
<CFSET payer_email=FORM.payer_email>
<CFIF IsDefined("FORM.item_number")>
<CFSET item_number=FORM.item_number>
</CFIF> --->
<!-- check notification validation -->
<CFIF #CFHTTP.FileContent# is "VERIFIED">
<!-- check that payment_status=Completed -->
<!-- check that txn_id has not been previously processed -->
<!-- check that receiver_email is your Primary PayPal email -->
<!-- check that payment_amount/payment_currency are correct -->
<!-- process payment -->
<CFELSEIF #CFHTTP.FileContent# is "INVALID">
<!-- log for investigation -->
<CFELSE>
<!-- error -->
</CFIF>
<cfinvoke
component="cfcs.qry"
method="qry_ipn_insert"
str="#str#"
attribute_values="#attribute_values#"
FileContent="#CFHTTP.FileContent#">
-----------------------------------------------------------------
You'll notice that I have commented out the foillowing section from the
provided sample code:
<!--- <CFSET item_name=FORM.item_name>
<CFSET payment_status=FORM.payment_status>
<CFSET payment_amount=FORM.mc_gross>
<CFSET payment_currency=FORM.mc_currency>
<CFSET txn_id=FORM.txn_id>
<CFSET receiver_email=FORM.receiver_email>
<CFSET payer_email=FORM.payer_email>
<CFIF IsDefined("FORM.item_number")>
<CFSET item_number=FORM.item_number>
</CFIF> --->
I do not understand why it expects form vlaues to be populated from a get
request. Won't they only be populated in a post?
The second problem I am having is that the cfhttp is getting back an html
document like this, instead of the expected "VERIFIED" or "INVALID" response:
------------------------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--
Script info: script: webscr, cmd: _home, template:
p/wel/sandbox-outside, date: Aug. 26, 2009 11:29:22 PDT; country: US, language:
en_US, xslt server:
web version: 59.0-1031221 branch: AHOD_590_0828_int
content version: -
pexml version: 59.0-1031684
page XSL: Merchant/default/en_US/homepage/SandBox-outside.xsl
hostname : qcKP1XNoJqrzRAV3BHjwSx5oKBCpCPQ1.DoCboTUELw
rlogid :
qcKP1XNoJqrzRAV3BHjwS5KqPy%2bFTJ8F4u0%2bJLKZBDDwniih9EGSeQ%3d%3d_123632c8436
-->
<title>Welcome - PayPal</title>
<!--googleoff: all-->
<meta name="description" content="PayPal is the safer, easier way to pay online
without revealing your credit card number.">
<!--googleon: all-->
<link media="screen" rel="stylesheet" type="text/css"
href="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/css/core/xptdev.css">
<link media="screen" rel="stylesheet" type="text/css"
href="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/css/core/global.css">
<!--[if IE 7]><link media="screen" rel="stylesheet" type="text/css"
href="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/css/browsers/ie7.css"><![endif]-->
<!--[if lte IE 6]><link media="screen" rel="stylesheet" type="text/css"
href="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/css/browsers/ie6.css"><![endif]-->
<link rel="stylesheet" type="text/css"
href="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/css/sandbox.css">
<link media="print" rel="stylesheet" type="text/css"
href="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/css/core/print.css">
<script type="text/javascript">
if (parent.frames.length > 0){
top.location.replace(document.location);
}</script><script type="text/javascript"
src="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/js/lib/min/global.js"></script><link
rel="shortcut icon"
href="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/en_US/i/icon/pp_favicon_x.ico">
<link rel="apple-touch-icon"
href="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/en_US/i/pui/apple-touch-icon.png">
</head>
<body class="xptSandbox">
<noscript><p class="nonjsAlert">NOTE: Many features on the PayPal Web site
require Javascript and cookies. You can enable both via your browser's
preference settings.</p></noscript>
<div class="" id="page">
<div id="content">
<div id="headline">
<h2 class="accessAid">Welcome</h2>
</div>
<div id="messageBox"></div>
<div id="main"><div class="layout1">
<p><img
src="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/en_US/i/logo/logo_sandbox_clr_289x39.gif"
border="0" alt=""></p>
<p align="center"><strong>Please login to use the <a
href="https://developer.paypal.com/">PayPal Sandbox</a> features.</strong></p>
</div></div>
</div>
<div id="navFull"><ul>
<li><a
href="https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_home-general&nav=0"
class="scTrack:SRD:Nav:L5">Home</a></li>
<li><a
href="https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_home-customer&nav=1"
class="scTrack:SRD:Nav:L8">Personal</a></li>
<li><a
href="https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_home-merchant&nav=2"
class="scTrack:SRD:Nav:O3">Business</a></li>
<li><a
href="https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_products-services-outside&nav=3"
class="scTrack:SRD:Nav:S9">Products & Services</a></li>
<li><a href="https://www.paypal.com/shopping_outside"
class="scTrack:SRD:Nav:k89">Shopping</a></li>
</ul></div>
<script type="text/javascript">if(typeof PAYPAL != 'undefined'){
PAYPAL.core.Navigation.init(); }</script>
</div>
<script type="text/javascript"
src="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/js/pp_naturalsearch.js"></script><script
type="text/javascript">mp_landing();</script>
<!-- SiteCatalyst Code
Copyright 1997-2005 Omniture, Inc.
More info available at http://www.omniture.com -->
<script type="text/javascript"
src="https://www.sandbox.paypal.com/WEBSCR-590-20090827-1/js/site_catalyst/pp_jscode_paypalsandboxdev.js"></script>
<script type="text/javascript">
<!--
/* SiteCatalyst Variables */
s.prop1="p/wel/sandbox-outside";
s.prop7="Unknown";
s.prop8="Unknown";
s.prop9="Unknown";
s.prop10="US";
s.prop34="PayPalCredit:Servicing:CO:NoTransactions";
s.pageName="p/wel/sandbox-outside::_home";
s.prop50="en_US";
s.prop18="";
/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
var s_code=s.t();if(s_code)document.write(s_code)//--></script>
<script type="text/javascript"><!--
if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-')
//-->
</script><noscript><img
src="//paypal.112.2O7.net/b/ss/paypalsandboxdev/1/H.6--NS/0?pageName=NonJavaScript"
height="1" width="1" border="0" alt="" /></noscript>
<!--/DO NOT REMOVE/-->
<!-- End SiteCatalyst Code -->
</body>
</html>
------------------------------------------------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:325842
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4