<?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>USBSwiper &#187; paypal ipn</title>
	<atom:link href="http://www.usbswiper.com/blog/tag/paypal-ipn/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.usbswiper.com/blog</link>
	<description>Updated News and Information</description>
	<lastBuildDate>Wed, 10 Jun 2009 17:57:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>PayPal Instant Payment Notification (IPN) PHP Template</title>
		<link>http://www.usbswiper.com/blog/2008/12/26/paypal-instant-payment-notification-ipn-php-template/</link>
		<comments>http://www.usbswiper.com/blog/2008/12/26/paypal-instant-payment-notification-ipn-php-template/#comments</comments>
		<pubDate>Sat, 27 Dec 2008 03:03:22 +0000</pubDate>
		<dc:creator>Andrew Angell</dc:creator>
				<category><![CDATA[eBay / PayPal]]></category>
		<category><![CDATA[instant payment notification]]></category>
		<category><![CDATA[ipn integration]]></category>
		<category><![CDATA[ipn template]]></category>
		<category><![CDATA[paypal]]></category>
		<category><![CDATA[paypal ipn]]></category>

		<guid isPermaLink="false">https://www.usbswiper.com/blog/?p=34</guid>
		<description><![CDATA[Using this PHP template you can easily configure PayPal Instant Payment Notification and get started right away!]]></description>
			<content:encoded><![CDATA[<p><em><strong>NOTE: </strong>This template has been turned into an installable solution available at <a href="http://developer.paypal-portal.com/pdn/board/message?board.id=ipn&amp;thread.id=14078">PayPalDeveloper.com</a>.  The template here will still work fine, but you might like the full solution better.</em></p>
<p>PayPal&#8217;s IPN feature is a great way to easily integrate standard payment buttons or automate back-end procedures for <a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=_wp-pro-overview-outside&amp;pal=M5VRAQYEFCSK6">Payments Pro solutions</a>. While it&#8217;s actually very simple, the process can be confusing when you first begin developing and I&#8217;ve seen people give up before they even truly get started.</p>
<p>The following script is a basic PHP template that handles everything you need to get started with <a href="https://www.usbswiper.com/paypalipn.php">PayPal Instant Payment Notification</a>. There are a couple of simple options at the top of the script for handling test servers and SSL. The template handles verifying the POST data with PayPal&#8217;s servers to ensure it&#8217;s valid and then stores every possible IPN value in PHP variables that are ready for use. If a particular field was not included in the IPN received then it&#8217;s simply populated with an empty value, but it&#8217;s still available within the script.</p>
<p>You can begin at the very bottom and simply do whatever you want with the store data, whether it&#8217;s update a database, format an email and send it to customers, send a text message notification to customers or yourself, etc.</p>
<p>I&#8217;ve also included a SQL file you can  use to easily create database tables for use with PayPal&#8217;s IPN system.  Later I&#8217;ll be completing this entire solution as an easily installed all-in-one package.</p>
<p>Happy scripting!</p>
<pre class="brush: php">

&lt;?php
////////////////////////////////////////////////////////////
// Angell EYE : PayPal IPN Template : 02.01.2009 //////////
//////////////// angelleye.com  //////////////////////
/////////////////////////////////////////////////////////
// PayPal now provides a variable called test_ipn on sandbox IPN&#039;s for simple flagging of sandbox IPN vs. production IPN
$sandbox = isset($_POST[&#039;test_ipn&#039;]) ? true : false;
$ssl = $sandbox ? false : false;
$ppHost = $sandbox ? &#039;www.sandbox.paypal.com&#039; : &#039;www.paypal.com&#039;;

// read the post from PayPal system and add &#039;cmd&#039;
$req = &#039;cmd=_notify-validate&#039;;

// Store each $_POST value in a NVP string: 1 string encoded and 1 string decoded
$IPNDecoded = &#039;&#039;;
foreach ($_POST as $key =&gt; $value)
{
$value = urlencode(stripslashes($value));
$req .= &quot;&amp;amp;$key=$value&quot;;
$IPNDecoded .= $key . &quot; = &quot; . urldecode($value) .&quot;&lt;br /&gt;&lt;br /&gt;&quot;;
}

// post back to PayPal system to validate using SSL or not based on flag set above.
if($ssl)
{
$header = &#039;&#039;;
$header .= &quot;POST /cgi-bin/webscr HTTP/1.0\r\n&quot;;
$header .= &quot;Host: &quot; . $ppHost . &quot;:443\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 (&#039;ssl://&#039; . $ppHost, 443, $errno, $errstr, 30);
}
else
{
$header = &#039;&#039;;
$header .= &quot;POST /cgi-bin/webscr HTTP/1.0\r\n&quot;;
$header .= &quot;Host: &quot; . $ppHost . &quot;:80\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 ($ppHost, 80, $errno, $errstr, 30);
}

if (!$fp)
{
$IsValid = false;
}
else
{
// Response from PayPal was good.  Now check to see if it returned verified or invalid.  Simply set $IsValud to true/false accordingly.
fputs ($fp, $header . $req);
while(!feof($fp))
{
$res = fgets ($fp, 1024);
if(strcmp ($res, &quot;VERIFIED&quot;) == 0)
$IsValid = true;
elseif (strcmp ($res, &quot;INVALID&quot;) == 0)
$IsValid = false;
}
fclose ($fp);
}

// Buyer Information
$address_city = isset($_POST[&#039;address_city&#039;]) ? $_POST[&#039;address_city&#039;] : &#039;&#039;;
$address_country = isset($_POST[&#039;address_country&#039;]) ? $_POST[&#039;address_country&#039;] : &#039;&#039;;
$address_country_code = isset($_POST[&#039;address_country_code&#039;]) ? $_POST[&#039;address_country_code&#039;] : &#039;&#039;;
$address_name = isset($_POST[&#039;address_name&#039;]) ? $_POST[&#039;address_name&#039;] : &#039;&#039;;
$address_state = isset($_POST[&#039;address_state&#039;]) ? $_POST[&#039;address_state&#039;] : &#039;&#039;;
$address_status = isset($_POST[&#039;address_status&#039;]) ? $_POST[&#039;address_status&#039;] : &#039;&#039;;
$address_street = isset($_POST[&#039;address_street&#039;]) ? $_POST[&#039;address_street&#039;] : &#039;&#039;;
$address_zip = isset($_POST[&#039;address_zip&#039;]) ? $_POST[&#039;address_zip&#039;] : &#039;&#039;;
$first_name = isset($_POST[&#039;first_name&#039;]) ? $_POST[&#039;first_name&#039;] : &#039;&#039;;
$last_name = isset($_POST[&#039;last_name&#039;]) ? $_POST[&#039;last_name&#039;] : &#039;&#039;;
$payer_business_name = isset($_POST[&#039;payer_business_name&#039;]) ? $_POST[&#039;payer_business_name&#039;] : &#039;&#039;;
$payer_email = isset($_POST[&#039;payer_email&#039;]) ? $_POST[&#039;payer_email&#039;] : &#039;&#039;;
$payer_id = isset($_POST[&#039;payer_id&#039;]) ? $_POST[&#039;payer_id&#039;] : &#039;&#039;;
$payer_status = isset($_POST[&#039;payer_status&#039;]) ? $_POST[&#039;payer_status&#039;] : &#039;&#039;;
$contact_phone = isset($_POST[&#039;contact_phone&#039;]) ? $_POST[&#039;contact_phone&#039;] : &#039;&#039;;
$residence_country = isset($_POST[&#039;residence_country&#039;]) ? $_POST[&#039;residence_country&#039;] : &#039;&#039;;

// Basic Information
$notify_version = isset($_POST[&#039;notify_version&#039;]) ? $_POST[&#039;notify_version&#039;] : &#039;&#039;;
$charset = isset($_POST[&#039;charset&#039;]) ? $_POST[&#039;charset&#039;] : &#039;&#039;;
$business = isset($_POST[&#039;business&#039;]) ? $_POST[&#039;business&#039;] : &#039;&#039;;
$item_name = isset($_POST[&#039;item_name&#039;]) ? $_POST[&#039;item_name&#039;] : &#039;&#039;;
$item_number = isset($_POST[&#039;item_number&#039;]) ? $_POST[&#039;item_number&#039;] : &#039;&#039;;
$quantity = isset($_POST[&#039;quantity&#039;]) ? $_POST[&#039;quantity&#039;] : &#039;&#039;;
$receiver_email = isset($_POST[&#039;receiver_email&#039;]) ? $_POST[&#039;receiver_email&#039;] : &#039;&#039;;
$receiver_id = isset($_POST[&#039;receiver_id&#039;]) ? $_POST[&#039;receiver_id&#039;] : &#039;&#039;;

// Cart Items
$num_cart_items = isset($_POST[&#039;num_cart_items&#039;]) ? $_POST[&#039;num_cart_items&#039;] : &#039;&#039;;

$i = 1;
$cart_items = array();
while(isset($_POST[&#039;item_number&#039; . $i]))
{
$item_number = isset($_POST[&#039;item_number&#039; . $i]) ? $_POST[&#039;item_number&#039; . $i] : &#039;&#039;;
$item_name = isset($_POST[&#039;item_name&#039; . $i]) ? $_POST[&#039;item_name&#039; . $i] : &#039;&#039;;
$quantity = isset($_POST[&#039;quantity&#039; . $i]) ? $_POST[&#039;quantity&#039; . $i] : &#039;&#039;;
$mc_gross = isset($_POST[&#039;mc_gross_&#039; . $i]) ? $_POST[&#039;mc_gross_&#039; . $i] : &#039;&#039;;
$mc_handling = isset($_POST[&#039;mc_handling&#039; . $i]) ? $_POST[&#039;mc_handling&#039; . $i] : &#039;&#039;;
$mc_shipping = isset($_POST[&#039;mc_shipping&#039; . $i]) ? $_POST[&#039;mc_shipping&#039; . $i] : &#039;&#039;;
$custom = isset($_POST[&#039;custom&#039; . $i]) ? $_POST[&#039;custom&#039; . $i] : &#039;&#039;;
$option_name1 = isset($_POST[&#039;option_name1_&#039; . $i]) ? $_POST[&#039;option_name1_&#039; . $i] : &#039;&#039;;
$option_selection1 = isset($_POST[&#039;option_selection1_&#039; . $i]) ? $_POST[&#039;option_selection1_&#039; . $i] : &#039;&#039;;
$option_name2 = isset($_POST[&#039;option_name2_&#039; . $i]) ? $_POST[&#039;option_name2_&#039; . $i] : &#039;&#039;;
$option_selection2 = isset($_POST[&#039;option_selection2_&#039; . $i]) ? $_POST[&#039;option_selection2_&#039; . $i] : &#039;&#039;;

$current_item = array(
&#039;item_number&#039; =&gt; $item_number,
&#039;item_name&#039; =&gt; $item_name,
&#039;quantity&#039; =&gt; $quantity,
&#039;mc_gross&#039; =&gt; $mc_gross,
&#039;mc_handling&#039; =&gt; $mc_handling,
&#039;mc_shipping&#039; =&gt; $mc_shipping,
&#039;custom&#039; =&gt; $custom,
&#039;option_name1&#039; =&gt; $option_name1,
&#039;option_selection1&#039; =&gt; $option_selection1,
&#039;option_name2&#039; =&gt; $option_name2,
&#039;option_selection2&#039; =&gt; $option_selection2
);

array_push($cart_items, $current_item);
$i++;
}

// Advanced and Custom Information
$custom = isset($_POST[&#039;custom&#039;]) ? $_POST[&#039;custom&#039;] : &#039;&#039;;
$invoice = isset($_POST[&#039;invoice&#039;]) ? $_POST[&#039;invoice&#039;] : &#039;&#039;;
$memo = isset($_POST[&#039;memo&#039;]) ? $_POST[&#039;memo&#039;] : &#039;&#039;;
$option_name1 = isset($_POST[&#039;option_name1&#039;]) ? $_POST[&#039;option_name1&#039;] : &#039;&#039;;
$option_selection1 = isset($_POST[&#039;option_selection1&#039;]) ? $_POST[&#039;option_selection1&#039;] : &#039;&#039;;
$option_name2 = isset($_POST[&#039;option_name2&#039;]) ? $_POST[&#039;option_name2&#039;] : &#039;&#039;;
$option_selection2 = isset($_POST[&#039;option_selection2&#039;]) ? $_POST[&#039;option_selection2&#039;] : &#039;&#039;;
$tax = isset($_POST[&#039;tax&#039;]) ? $_POST[&#039;tax&#039;] : &#039;&#039;;

// Website Payments Standard, Website Payments Pro, and Refund Information
$auth_id = isset($_POST[&#039;auth_id&#039;]) ? $_POST[&#039;auth_id&#039;] : &#039;&#039;;
$auth_exp = isset($_POST[&#039;auth_exp&#039;]) ? $_POST[&#039;auth_exp&#039;] : &#039;&#039;;
$auth_amount = isset($_POST[&#039;auth_amount&#039;]) ? $_POST[&#039;auth_amount&#039;] : &#039;&#039;;
$auth_status = isset($_POST[&#039;auth_status&#039;]) ? $_POST[&#039;auth_status&#039;] : &#039;&#039;;

// Fraud Management Filters
$i = 1;
$fraud_management_filters = array();
while(isset($_POST[&#039;fraud_management_filters_&#039; . $i]))
{
$filter_name = isset($_POST[&#039;fraud_management_filter_&#039; . $i]) ? $_POST[&#039;fraud_management_filter_&#039; . $i] : &#039;&#039;;

array_push($fraud_management_filters, $filter_name);
$i++;
}

$mc_gross = isset($_POST[&#039;mc_gross&#039;]) ? $_POST[&#039;mc_gross&#039;] : &#039;&#039;;
$mc_handling = isset($_POST[&#039;mc_handling&#039;]) ? $_POST[&#039;mc_handling&#039;] : &#039;&#039;;
$mc_shipping = isset($_POST[&#039;mc_shipping&#039;]) ? $_POST[&#039;mc_shipping&#039;] : &#039;&#039;;
$mc_fee = isset($_POST[&#039;mc_fee&#039;]) ? $_POST[&#039;mc_fee&#039;] : &#039;&#039;;
$num_cart_items = isset($_POST[&#039;num_cart_items&#039;]) ? $_POST[&#039;num_cart_items&#039;] : &#039;&#039;;
$parent_txn_id = isset($_POST[&#039;parent_txn_id&#039;]) ? $_POST[&#039;parent_txn_id&#039;] : &#039;&#039;;
$payment_date = isset($_POST[&#039;payment_date&#039;]) ? $_POST[&#039;payment_date&#039;] : &#039;&#039;;
$payment_status = isset($_POST[&#039;payment_status&#039;]) ? $_POST[&#039;payment_status&#039;] : &#039;&#039;;
$payment_type = isset($_POST[&#039;payment_type&#039;]) ? $_POST[&#039;payment_type&#039;] : &#039;&#039;;
$pending_reason = isset($_POST[&#039;pending_reason&#039;]) ? $_POST[&#039;pending_reason&#039;] : &#039;&#039;;
$protection_eligibility  = isset($_POST[&#039;protection_eligibility&#039;]) ? $_POST[&#039;protection_eligibility&#039;] : &#039;&#039;;
$reason_code = isset($_POST[&#039;reason_code&#039;]) ? $_POST[&#039;reason_code&#039;] : &#039;&#039;;
$remaining_settle = isset($_POST[&#039;remaining_settle&#039;]) ? $_POST[&#039;remaining_settle&#039;] : &#039;&#039;;
$shipping_method = isset($_POST[&#039;shipping_method&#039;]) ? $_POST[&#039;shipping_method&#039;] : &#039;&#039;;
$shipping = isset($_POST[&#039;shipping&#039;]) ? $_POST[&#039;shipping&#039;] : &#039;&#039;;
$tax = isset($_POST[&#039;tax&#039;]) ? $_POST[&#039;tax&#039;] : &#039;&#039;;
$transaction_entity = isset($_POST[&#039;transaction_entity&#039;]) ? $_POST[&#039;transaction_entity&#039;] : &#039;&#039;;
$txn_id = isset($_POST[&#039;txn_id&#039;]) ? $_POST[&#039;txn_id&#039;] : &#039;&#039;;
$txn_type = isset($_POST[&#039;txn_type&#039;]) ? $_POST[&#039;txn_type&#039;] : &#039;&#039;;
// Currency and Currency Exchange Information
$exchange_rate = isset($_POST[&#039;exchange_rate&#039;]) ? $_POST[&#039;exchange_rate&#039;] : &#039;&#039;;
$mc_currency = isset($_POST[&#039;mc_currency&#039;]) ? $_POST[&#039;mc_currency&#039;] : &#039;&#039;;
$settle_amount = isset($_POST[&#039;settle_amount&#039;]) ? $_POST[&#039;settle_amount&#039;] : &#039;&#039;;
$settle_currency = isset($_POST[&#039;settle_currency&#039;]) ? $_POST[&#039;settle_currency&#039;] : &#039;&#039;;

// Auction Variables
$auction_buyer_id = isset($_POST[&#039;auction_buyer_id&#039;]) ? $_POST[&#039;auction_buyer_id&#039;] : &#039;&#039;;
$auction_closing_date = isset($_POST[&#039;auction_closing_date&#039;]) ? $_POST[&#039;auction_closing_date&#039;] : &#039;&#039;;
$auction_multi_item = isset($_POST[&#039;auction_multi_item&#039;]) ? $_POST[&#039;auction_multi_item&#039;] : &#039;&#039;;
$for_auction = isset($_POST[&#039;for_auction&#039;]) ? $_POST[&#039;for_auction&#039;] : &#039;&#039;;

// Mass Payments
$i = 1;
$mass_payments = array();
while(isset($_POST[&#039;masspay_txn_id_&#039; . $i]))
{
$masspay_txn_id = isset($_POST[&#039;masspay_txn_id_&#039; . $i]) ? $_POST[&#039;masspay_txn_id_&#039; . $i] : &#039;&#039;;
$mc_currency = isset($_POST[&#039;mc_currency_&#039; . $i]) ? $_POST[&#039;mc_currency_&#039; . $i] : &#039;&#039;;
$mc_fee = isset($_POST[&#039;mc_fee_&#039; . $i]) ? $_POST[&#039;mc_fee_&#039; . $i] : &#039;&#039;;
$mc_gross = isset($_POST[&#039;mc_gross_&#039; . $i]) ? $_POST[&#039;mc_gross_&#039; . $i] : &#039;&#039;;
$receiver_email = isset($_POST[&#039;receiver_email_&#039; . $i]) ? $_POST[&#039;receiver_email_&#039; . $i] : &#039;&#039;;
$status = isset($_POST[&#039;status_&#039; . $i]) ? $_POST[&#039;status_&#039; . $i] : &#039;&#039;;
$unique_id = isset($_POST[&#039;unique_id_&#039; . $i]) ? $_POST[&#039;unique_id_&#039; . $i] : &#039;&#039;;

$current_payment_data_set = array(
&#039;masspay_txn_id&#039; =&gt; $masspay_txn_id,
&#039;mc_currency&#039; =&gt; $mc_currency,
&#039;mc_fee&#039; =&gt; $mc_fee,
&#039;mc_gross&#039; =&gt; $mc_gross,
&#039;receiver_email&#039; =&gt; $receiver_email,
&#039;status&#039; =&gt; $status,
&#039;unique_id&#039; =&gt; $unique_id
);

array_push($mass_payments, $current_payment_data_set);
$i++;
}
// Recurring Payments Information
$initial_payment_status = isset($_POST[&#039;initial_payment_status&#039;]) ? $_POST[&#039;initial_payment_status&#039;] : &#039;&#039;;
$initial_payment_txn_id = isset($_POST[&#039;initial_payment_txn_id&#039;]) ? $_POST[&#039;initial_payment_txn_id&#039;] : &#039;&#039;;
$recurring_payment_id = isset($_POST[&#039;recurring_payment_id&#039;]) ? $_POST[&#039;recurring_payment_id&#039;] : &#039;&#039;;
$product_name = isset($_POST[&#039;product_name&#039;]) ? $_POST[&#039;product_name&#039;] : &#039;&#039;;
$product_type = isset($_POST[&#039;product_type&#039;]) ? $_POST[&#039;product_type&#039;] : &#039;&#039;;
$period_type = isset($_POST[&#039;period_type&#039;]) ? $_POST[&#039;period_type&#039;] : &#039;&#039;;
$payment_cycle = isset($_POST[&#039;payment_cycle&#039;]) ? $_POST[&#039;payment_cycle&#039;] : &#039;&#039;;
$outstanding_balance = isset($_POST[&#039;outstanding_balance&#039;]) ? $_POST[&#039;outstanding_balance&#039;] : &#039;&#039;;
$amount_per_cycle = isset($_POST[&#039;amount_per_cycle&#039;]) ? $_POST[&#039;amount_per_cycle&#039;] : &#039;&#039;;
$initial_payment_amount = isset($_POST[&#039;initial_payment_amount&#039;]) ? $_POST[&#039;initial_payment_amount&#039;] : &#039;&#039;;
$profile_status = isset($_POST[&#039;profile_status&#039;]) ? $_POST[&#039;profile_status&#039;] : &#039;&#039;;
$amount = isset($_POST[&#039;amount&#039;]) ? $_POST[&#039;amount&#039;] : &#039;&#039;;
$time_created = isset($_POST[&#039;time_created&#039;]) ? $_POST[&#039;time_created&#039;] : &#039;&#039;;
$next_payment_date = isset($_POST[&#039;next_payment_date&#039;]) ? $_POST[&#039;next_payment_date&#039;] : &#039;&#039;;
$rp_invoice_id = isset($_POST[&#039;rp_invoice_id&#039;]) ? $_POST[&#039;rp_invoice_id&#039;] : &#039;&#039;;

// Subscription Variables
$subscr_date = isset($_POST[&#039;subscr_date&#039;]) ? $_POST[&#039;subscr_date&#039;] : &#039;&#039;;
$subscr_effective = isset($_POST[&#039;subscr_effective&#039;]) ? $_POST[&#039;subscr_effective&#039;] : &#039;&#039;;
$period1 = isset($_POST[&#039;period1&#039;]) ? $_POST[&#039;period1&#039;] : &#039;&#039;;
$period2 = isset($_POST[&#039;period2&#039;]) ? $_POST[&#039;period2&#039;] : &#039;&#039;;
$period3 = isset($_POST[&#039;period3&#039;]) ? $_POST[&#039;period3&#039;] : &#039;&#039;;
$amount1 = isset($_POST[&#039;amount1&#039;]) ? $_POST[&#039;amount1&#039;] : &#039;&#039;;
$amount2 = isset($_POST[&#039;amount2&#039;]) ? $_POST[&#039;amount2&#039;] : &#039;&#039;;
$amount3 = isset($_POST[&#039;amount3&#039;]) ? $_POST[&#039;amount3&#039;] : &#039;&#039;;
$mc_amount1 = isset($_POST[&#039;mc_amount1&#039;]) ? $_POST[&#039;mc_amount1&#039;] : &#039;&#039;;
$mc_amount2 = isset($_POST[&#039;mc_amount2&#039;]) ? $_POST[&#039;mc_amount2&#039;] : &#039;&#039;;
$mc_amount3 = isset($_POST[&#039;mc_amount3&#039;]) ? $_POST[&#039;mc_amount3&#039;] : &#039;&#039;;
$mc_currency = isset($_POST[&#039;mc_currency&#039;]) ? $_POST[&#039;mc_currency&#039;] : &#039;&#039;;
$recurring = isset($_POST[&#039;recurring&#039;]) ? $_POST[&#039;recurring&#039;] : &#039;&#039;;
$reattempt = isset($_POST[&#039;reattempt&#039;]) ? $_POST[&#039;reattempt&#039;] : &#039;&#039;;
$retry_at = isset($_POST[&#039;retry_at&#039;]) ? $_POST[&#039;retry_at&#039;] : &#039;&#039;;
$recur_times = isset($_POST[&#039;recur_times&#039;]) ? $_POST[&#039;recur_times&#039;] : &#039;&#039;;
$username = isset($_POST[&#039;username&#039;]) ? $_POST[&#039;username&#039;] : &#039;&#039;;
$password = isset($_POST[&#039;password&#039;]) ? $_POST[&#039;password&#039;] : &#039;&#039;;
$subscr_id = isset($_POST[&#039;subscr_id&#039;]) ? $_POST[&#039;subscr_id&#039;] : &#039;&#039;;

// Dispute Notification Variables
$case_id = isset($_POST[&#039;case_id&#039;]) ? $_POST[&#039;case_id&#039;] : &#039;&#039;;
$case_type = isset($_POST[&#039;case_type&#039;]) ? $_POST[&#039;case_type&#039;] : &#039;&#039;;
$case_creation_date = isset($_POST[&#039;case_creation_date&#039;]) ? $_POST[&#039;case_creation_date&#039;] : &#039;&#039;;
?&gt;
</pre>
<p>And here is a SQL file you can use to easily create the database tables.</p>
<pre class="brush: sql">

-- phpMyAdmin SQL Dump
-- version 3.1.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Feb 20, 2009 at 11:17 PM
-- Server version: 5.0.67
-- PHP Version: 5.2.6

SET SQL_MODE=&quot;NO_AUTO_VALUE_ON_ZERO&quot;;

--
-- Database: `paypal_ipn`
--

-- --------------------------------------------------------

--
-- Table structure for table `paypal_disputes`
--

CREATE TABLE IF NOT EXISTS `paypal_disputes` (
`id` tinyint(10) NOT NULL auto_increment,
`txn_id` varchar(25) collate utf8_bin NOT NULL,
`case_id` varchar(25) collate utf8_bin NOT NULL,
`case_type` varchar(25) collate utf8_bin NOT NULL,
`case_creation_date` varchar(100) collate utf8_bin NOT NULL,
`payment_date` varchar(100) collate utf8_bin NOT NULL,
`receipt_id` varchar(25) collate utf8_bin NOT NULL,
`verify_sign` varchar(255) collate utf8_bin NOT NULL,
`payer_email` varchar(127) collate utf8_bin NOT NULL,
`payer_id` varchar(20) collate utf8_bin NOT NULL,
`invoice` varchar(127) collate utf8_bin NOT NULL,
`reason_code` varchar(25) collate utf8_bin NOT NULL,
`custom` varchar(255) collate utf8_bin NOT NULL,
`notify_version` varchar(25) collate utf8_bin NOT NULL,
`creation_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;

--
-- Dumping data for table `paypal_disputes`
--

-- --------------------------------------------------------

--
-- Table structure for table `paypal_ipn_log`
--

CREATE TABLE IF NOT EXISTS `paypal_ipn_log` (
`id` tinyint(4) NOT NULL auto_increment,
`created_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
`ipn_data_serialized` text collate utf8_bin NOT NULL,
PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;

--
-- Dumping data for table `paypal_ipn_log`
--

-- --------------------------------------------------------

--
-- Table structure for table `paypal_mass_payments`
--

CREATE TABLE IF NOT EXISTS `paypal_mass_payments` (
`id` tinyint(4) NOT NULL auto_increment,
`masspay_txn_id` varchar(25) collate utf8_bin NOT NULL,
`mc_currency` varchar(50) collate utf8_bin NOT NULL,
`mc_fee` double NOT NULL,
`mc_gross` double NOT NULL,
`receiver_email` varchar(127) collate utf8_bin NOT NULL,
`status` varchar(25) collate utf8_bin NOT NULL,
`unique_id` varchar(20) collate utf8_bin NOT NULL,
`creation_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;

--
-- Dumping data for table `paypal_mass_payments`
--

-- --------------------------------------------------------

--
-- Table structure for table `paypal_orders`
--

CREATE TABLE IF NOT EXISTS `paypal_orders` (
`id` tinyint(10) unsigned NOT NULL auto_increment,
`receiver_email` varchar(127) collate utf8_bin NOT NULL,
`payment_status` varchar(25) collate utf8_bin NOT NULL,
`pending_reason` varchar(25) collate utf8_bin NOT NULL,
`payment_date` varchar(100) collate utf8_bin NOT NULL,
`mc_gross` double NOT NULL,
`mc_fee` double NOT NULL,
`tax` double NOT NULL,
`mc_currency` varchar(10) collate utf8_bin NOT NULL,
`txn_id` varchar(25) collate utf8_bin NOT NULL,
`txn_type` varchar(25) collate utf8_bin NOT NULL,
`first_name` varchar(75) collate utf8_bin NOT NULL,
`last_name` varchar(75) collate utf8_bin NOT NULL,
`address_street` varchar(200) collate utf8_bin NOT NULL,
`address_city` varchar(50) collate utf8_bin NOT NULL,
`address_state` varchar(40) collate utf8_bin NOT NULL,
`address_zip` varchar(20) collate utf8_bin NOT NULL,
`address_country` varchar(64) collate utf8_bin NOT NULL,
`address_status` varchar(25) collate utf8_bin NOT NULL,
`payer_email` varchar(127) collate utf8_bin NOT NULL,
`payer_status` varchar(25) collate utf8_bin NOT NULL,
`payment_type` varchar(25) collate utf8_bin NOT NULL,
`notify_version` varchar(50) collate utf8_bin NOT NULL,
`verify_sign` varchar(255) collate utf8_bin NOT NULL,
`address_name` varchar(130) collate utf8_bin NOT NULL,
`protection_eligibility` varchar(50) collate utf8_bin NOT NULL,
`ipn_status` varchar(25) collate utf8_bin NOT NULL,
`subscr_id` varchar(25) collate utf8_bin NOT NULL,
`custom` varchar(255) collate utf8_bin NOT NULL,
`reason_code` varchar(25) collate utf8_bin NOT NULL,
`contact_phone` varchar(25) collate utf8_bin NOT NULL,
`item_name` varchar(127) collate utf8_bin NOT NULL,
`item_number` varchar(127) collate utf8_bin NOT NULL,
`invoice` varchar(127) collate utf8_bin NOT NULL,
`for_auction` tinyint(10) NOT NULL,
`auction_buyer_id` varchar(75) collate utf8_bin NOT NULL,
`auction_closing_date` varchar(100) collate utf8_bin NOT NULL,
`auction_multi_item` double NOT NULL default &#039;1&#039;,
`creation_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
`address_country_code` varchar(2) collate utf8_bin NOT NULL,
PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;

--
-- Dumping data for table `paypal_orders`
--

-- --------------------------------------------------------

--
-- Table structure for table `paypal_order_items`
--

CREATE TABLE IF NOT EXISTS `paypal_order_items` (
`id` tinyint(10) NOT NULL auto_increment,
`order_id` tinyint(10) NOT NULL,
`subscr_id` varchar(25) collate utf8_bin NOT NULL,
`item_name` varchar(130) collate utf8_bin NOT NULL,
`item_number` varchar(130) collate utf8_bin NOT NULL,
`os0` varchar(200) collate utf8_bin NOT NULL,
`on0` varchar(75) collate utf8_bin NOT NULL,
`os1` varchar(200) collate utf8_bin NOT NULL,
`on1` varchar(75) collate utf8_bin NOT NULL,
`quantity` double NOT NULL default &#039;0&#039;,
`custom` varchar(255) collate utf8_bin NOT NULL,
`mc_gross` double NOT NULL default &#039;0&#039;,
`mc_handling` double NOT NULL default &#039;0&#039;,
`mc_shipping` double NOT NULL default &#039;0&#039;,
`creation_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;

--
-- Dumping data for table `paypal_order_items`
--

-- --------------------------------------------------------

--
-- Table structure for table `paypal_recurring_payments`
--

CREATE TABLE IF NOT EXISTS `paypal_recurring_payments` (
`id` tinyint(10) NOT NULL auto_increment,
`mc_gross` double NOT NULL default &#039;0&#039;,
`protection_eligibility` varchar(50) collate utf8_bin NOT NULL,
`payment_date` varchar(100) collate utf8_bin NOT NULL,
`payment_status` varchar(25) collate utf8_bin NOT NULL,
`mc_fee` double NOT NULL default &#039;0&#039;,
`notify_version` varchar(25) collate utf8_bin NOT NULL,
`payer_status` varchar(25) collate utf8_bin NOT NULL,
`currency_code` varchar(10) collate utf8_bin NOT NULL,
`verify_sign` varchar(255) collate utf8_bin NOT NULL,
`amount` double NOT NULL default &#039;0&#039;,
`txn_id` varchar(25) collate utf8_bin NOT NULL,
`payment_type` varchar(25) collate utf8_bin NOT NULL,
`receiver_email` varchar(130) collate utf8_bin NOT NULL,
`receiver_id` varchar(15) collate utf8_bin NOT NULL,
`txn_type` varchar(25) collate utf8_bin NOT NULL,
`mc_currency` varchar(25) collate utf8_bin NOT NULL,
`residence_country` varchar(2) collate utf8_bin NOT NULL,
`receipt_id` varchar(50) collate utf8_bin NOT NULL,
`transaction_subject` varchar(150) collate utf8_bin NOT NULL,
`shipping` double NOT NULL default &#039;0&#039;,
`product_type` varchar(50) collate utf8_bin NOT NULL,
`time_created` varchar(100) collate utf8_bin NOT NULL,
`rp_invoice_id` varchar(127) collate utf8_bin NOT NULL,
`ipn_status` varchar(25) collate utf8_bin NOT NULL,
`creation_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;

--
-- Dumping data for table `paypal_recurring_payments`
--

-- --------------------------------------------------------

--
-- Table structure for table `paypal_recurring_payment_profiles`
--

CREATE TABLE IF NOT EXISTS `paypal_recurring_payment_profiles` (
`id` tinyint(10) NOT NULL auto_increment,
`payment_cycle` varchar(50) collate utf8_bin NOT NULL,
`txn_type` varchar(30) collate utf8_bin NOT NULL,
`last_name` varchar(75) collate utf8_bin NOT NULL,
`first_name` varchar(75) collate utf8_bin NOT NULL,
`next_payment_date` varchar(100) collate utf8_bin NOT NULL,
`residence_country` varchar(2) collate utf8_bin NOT NULL,
`initial_payment_amount` double NOT NULL default &#039;0&#039;,
`rp_invoice_id` varchar(127) collate utf8_bin NOT NULL,
`currency_code` varchar(10) collate utf8_bin NOT NULL,
`time_created` varchar(100) collate utf8_bin NOT NULL,
`verify_sign` varchar(255) collate utf8_bin NOT NULL,
`period_type` varchar(25) collate utf8_bin NOT NULL,
`payer_status` varchar(25) collate utf8_bin NOT NULL,
`payer_email` varchar(130) collate utf8_bin NOT NULL,
`receiver_email` varchar(130) collate utf8_bin NOT NULL,
`payer_id` varchar(20) collate utf8_bin NOT NULL,
`product_type` varchar(50) collate utf8_bin NOT NULL,
`payer_business_name` varchar(130) collate utf8_bin NOT NULL,
`shipping` double NOT NULL default &#039;0&#039;,
`amount_per_cycle` double NOT NULL default &#039;0&#039;,
`profile_status` varchar(25) collate utf8_bin NOT NULL,
`notify_version` varchar(25) collate utf8_bin NOT NULL,
`amount` double NOT NULL default &#039;0&#039;,
`outstanding_balance` double NOT NULL default &#039;0&#039;,
`recurring_payment_id` varchar(50) collate utf8_bin NOT NULL,
`product_name` varchar(130) collate utf8_bin NOT NULL,
`ipn_status` varchar(25) collate utf8_bin NOT NULL,
`creation_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;

--
-- Dumping data for table `paypal_recurring_payment_profiles`
--

-- --------------------------------------------------------

--
-- Table structure for table `paypal_subscriptions`
--

CREATE TABLE IF NOT EXISTS `paypal_subscriptions` (
`id` tinyint(10) NOT NULL auto_increment,
`custom` varchar(255) collate utf8_bin NOT NULL,
`subscr_id` varchar(25) collate utf8_bin NOT NULL,
`sub_event` varchar(50) collate utf8_bin NOT NULL,
`subscr_date` varchar(100) collate utf8_bin NOT NULL,
`subscr_effective` varchar(100) collate utf8_bin NOT NULL,
`period1` varchar(50) collate utf8_bin NOT NULL,
`period2` varchar(50) collate utf8_bin NOT NULL,
`period3` varchar(50) collate utf8_bin NOT NULL,
`amount1` double NOT NULL default &#039;0&#039;,
`amount2` double NOT NULL default &#039;0&#039;,
`amount3` double NOT NULL default &#039;0&#039;,
`mc_amount1` double NOT NULL default &#039;0&#039;,
`mc_amount2` double NOT NULL default &#039;0&#039;,
`mc_amount3` double NOT NULL default &#039;0&#039;,
`recurring` varchar(10) collate utf8_bin NOT NULL,
`reattempt` varchar(10) collate utf8_bin NOT NULL,
`retry_at` varchar(100) collate utf8_bin NOT NULL,
`recur_times` varchar(25) collate utf8_bin NOT NULL,
`username` varchar(70) collate utf8_bin NOT NULL,
`password` varchar(30) collate utf8_bin NOT NULL,
`txn_id` varchar(25) collate utf8_bin NOT NULL,
`payer_email` varchar(130) collate utf8_bin NOT NULL,
`residence_country` varchar(2) collate utf8_bin NOT NULL,
`mc_currency` varchar(10) collate utf8_bin NOT NULL,
`verify_sign` varchar(255) collate utf8_bin NOT NULL,
`payer_status` varchar(25) collate utf8_bin NOT NULL,
`first_name` varchar(75) collate utf8_bin NOT NULL,
`last_name` varchar(75) collate utf8_bin NOT NULL,
`receiver_email` varchar(130) collate utf8_bin NOT NULL,
`payer_id` varchar(15) collate utf8_bin NOT NULL,
`notify_version` varchar(25) collate utf8_bin NOT NULL,
`item_name` varchar(130) collate utf8_bin NOT NULL,
`item_number` varchar(130) collate utf8_bin NOT NULL,
`ipn_status` varchar(25) collate utf8_bin NOT NULL,
`creation_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;

--
-- Dumping data for table `paypal_subscriptions`
--

-- --------------------------------------------------------

--
-- Table structure for table `paypal_subscription_payments`
--

CREATE TABLE IF NOT EXISTS `paypal_subscription_payments` (
`id` tinyint(10) NOT NULL auto_increment,
`first_name` varchar(75) collate utf8_bin NOT NULL,
`last_name` varchar(75) collate utf8_bin NOT NULL,
`payer_email` varchar(130) collate utf8_bin NOT NULL,
`memo` text collate utf8_bin NOT NULL,
`item_name` varchar(130) collate utf8_bin NOT NULL,
`item_number` varchar(130) collate utf8_bin NOT NULL,
`os0` varchar(200) collate utf8_bin NOT NULL,
`on0` varchar(65) collate utf8_bin NOT NULL,
`os1` varchar(200) collate utf8_bin NOT NULL,
`on1` varchar(65) collate utf8_bin NOT NULL,
`quantity` double NOT NULL default &#039;0&#039;,
`payment_date` varchar(100) collate utf8_bin NOT NULL,
`payment_type` varchar(25) collate utf8_bin NOT NULL,
`txn_id` varchar(25) collate utf8_bin NOT NULL,
`mc_gross` double NOT NULL default &#039;0&#039;,
`mc_fee` double NOT NULL default &#039;0&#039;,
`payment_status` varchar(25) collate utf8_bin NOT NULL,
`pending_reason` varchar(25) collate utf8_bin NOT NULL,
`txn_type` varchar(30) collate utf8_bin NOT NULL,
`tax` double NOT NULL default &#039;0&#039;,
`mc_currency` varchar(25) collate utf8_bin NOT NULL,
`reason_code` varchar(25) collate utf8_bin NOT NULL,
`custom` varchar(255) collate utf8_bin NOT NULL,
`address_country` varchar(50) collate utf8_bin NOT NULL,
`subscr_id` varchar(25) collate utf8_bin NOT NULL,
`payer_status` varchar(25) collate utf8_bin NOT NULL,
`ipn_status` varchar(25) collate utf8_bin NOT NULL,
`creation_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;

--
-- Dumping data for table `paypal_subscription_payments`
--
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.usbswiper.com/blog/2008/12/26/paypal-instant-payment-notification-ipn-php-template/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
	</channel>
</rss>
