My Paypal IPN script works somewhat differently from other IPN scripts in that the script emails the purchased product to the buyer once their payment clears rather than providing them with access to a special download area. This means that the script does not require a database in order to set it up and use it as there is no need to restrict access to any of the web pages.
Of course adding a database to the script allows additional functionality. A number of customizable functions are called from various points in the processing and this extension script sets up a database table that plugs into some of those functions to log purchases along with providing an extra page to allow purchasers to resend themselves the script at any time within a specified of the purchase date.
The base script puts the product and discount information in the payconf.php file (which apart from these arrays consists mainly of static variables that you configure once when you first set up the script). The extension script moves that information out of the configuration file and into database tables.
This extension adds database logging. Every purchase will be recorded in the paylog table. The payipnc.php page allows you to view the entries in this log file.
The paypal4.php page can be (optionally) used with this log to provide a means for your purchasers to obtain free upgrades to your electronic products for a specified period from the original purchase.
The payipna.php and payipnb.php pages perform the administration functions associated with updating the information in the product and discount tables. Access to this functionality is provided by accessing the payipna page and entering a previously defined userid and password (not necessarily those required to link to your database). You simply add/replace/delete the entries in the two tables via this administrator function instead of editing the $pa and $ds arrays as would be required without the extension.
The purchase.php page is for use with the Password Protection Toolkit script to allow Paypal to be used to purchase access time to password protected areas built with that script.
The lockcsv.php script provides a meas to upload (and download) unlock codes or PINs that are to be associated with a given product. The file to be uploade sconsists of comma separated values product,unlockcode that will be uploaded to the paylock table. Where entries exist in the paylock table an extra message will be added to the top of the email sent out advising of the unlock code. A different message will be sent if all of the unlock codes in the table for the purchased product have already been used and you need to manually send the person an unlock code in that instance. Alternatively you can add a test for if unlock codes exist before allowing the purchase. Unlock codes can be stored in an encrypted format in the database by adding a pass phrase to use for the encryption/decryption.
The script also provides a replacement inc/payprod.php file as a replacement for the one in the original script. This replacement file looks up the product and discount information in the tables instead of the arrays as well as adding the functionality to log the purchases. Functionality is also added to allow the lookup of the paylock table in order to add unique unlock codes to the email sent out when the purchase is made.
Simply follow the install instructions provided in the readme.txt file that comes with the script to install it over the Paypal IPN script. The original script must be installed first before installing this extension.
Unfortunately, I have to try to fund the running of this web site somehow and so I have decided to charge a nominal amount for server side scripts such as this one. Use the following form to purchase the Felgall Paypal IPN DB Extension script for just $36.20 USD (Australian residents price is $36.20 AUD including GST). All purchases include 12 months free support including all updates to the script released during that time. If you have a valid discount code then enter it to purchase this script at an even lower price otherwise just leave the discount field blank, select the currency to make your payment and then press the buy now button. The script will be automatically emailed to you as soon as Paypal verifies your payment
Note: You must have already purchased and installed the Paypal IPN script before installing this script. This script will not function without the main script. To use the purchase.php page you must also have purchased the password toolkit script.
Before you purchase this script you should reread the above information to ensure that the script will work on your server. If you cancel at any point during the payment process, you will be returned to this page.
Please make sure that the email account that you supply to Paypal will accept emails with attached zip files from addresses at this domain as otherwise your spam filtering may delete your purchase.
This article written by Stephen Chapman, Felgall Pty Ltd.