<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sean&#039;s Blog &#187; fsockopen</title>
	<atom:link href="http://seanbehan.com/tag/fsockopen/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanbehan.com</link>
	<description>Web Programming, Ruby on Rails, Wordpress, PHP from Burlington, Vermont</description>
	<lastBuildDate>Wed, 18 Jan 2012 21:44:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHP Paypal IPN Script</title>
		<link>http://seanbehan.com/php/php-paypal-ipn-script/</link>
		<comments>http://seanbehan.com/php/php-paypal-ipn-script/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 21:45:42 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[fsockopen]]></category>
		<category><![CDATA[ipn]]></category>
		<category><![CDATA[paypal]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=776</guid>
		<description><![CDATA[Simple script for posting a valid response back to Paypal service after a sale is completed using the Paypal Instant Checkout payment method. &#38;lt;?php // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key =&#62; $value) { $value = urlencode(stripslashes($value)); $req .= &#34;&#38;$key=$value&#34;; } // post back to [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fphp%2Fphp-paypal-ipn-script%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="PHP Paypal IPN Script" data-url="http://seanbehan.com/php/php-paypal-ipn-script/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>Simple script for posting a valid response back to Paypal service after a sale is completed using the Paypal Instant Checkout payment method.</p>
<pre class="wp-code-highlight prettyprint">
&amp;lt;?php
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';

foreach ($_POST as $key =&gt; $value) {
  $value = urlencode(stripslashes($value));
  $req .= &quot;&amp;$key=$value&quot;;
}

// post back to PayPal system to validate
$header .= &quot;POST /cgi-bin/webscr HTTP/1.0\r\n&quot;;
$header .= &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;;
$header .= &quot;Content-Length: &quot; . strlen($req) . &quot;\r\n\r\n&quot;;
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

// assign posted variables to local variables
$item_name        = $_POST['item_name'];
$item_number      = $_POST['item_number'];
$payment_status   = $_POST['payment_status'];
$payment_amount   = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id           = $_POST['txn_id'];
$receiver_email   = $_POST['receiver_email'];
$payer_email      = $_POST['payer_email'];

if (!$fp) {
// HTTP ERROR
} else {
  fputs ($fp, $header . $req);
  while (!feof($fp)) {
    $res = fgets ($fp, 1024);
    if (strcmp ($res, &quot;VERIFIED&quot;) == 0) {
      // check the payment_status is 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
    } else if (strcmp ($res, &quot;INVALID&quot;) == 0) {
      // log for manual investigation
    }
  }
fclose ($fp);
}
</pre>
<p>I grabbed this script from Paypal Docs&#8230; I never can find the info I need w/in their site so I&#8217;m posting here for reference.  <a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=p/pdn/ipn-codesamples-pop-outside#php">https://www.paypal.com/us/cgi-bin/webscr?cmd=p/pdn/ipn-codesamples-pop-outside#php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/php/php-paypal-ipn-script/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

