Upgrading the Paypal IPN Script
My Paypal IPN script like any computer program needs to be upgraded on occasion to fix problems with the script and perhaps to add functionality. All updates within 12 months of your original purchase are included in the purchase price.
Since I first published the script in April 2004 I have applied a number of fixes and enhancements as listed below. The current version number is 4.5 The current version of the Product/Discount database extension is 1.7.
- Amended the code to correct an error that stopped the debug facility from being able to be turned off.
- Amended the code to accept the new 216.113 ip addresses.
- Amended to add $ipt to allow ip address testing to be turned off.
- Added validProcess() function to allow further custom processing to be performed before the email with the attachment is sent.
- Amended the script to allow advertised discount codes to be entered.
- Amended the code to allow emails to be sent without attachments.
- Added startProcess() function to allow custom processing before Paypal is called. A unique invoice number is passed to both the startProcess and validProcess functions allowing you to match information from a database before and after payment. Sample code to add a log table to a mySQL database is now also included.
- Version 2.0
- Added paypal.php as an alternative to paypal1.php.
- Added pendProcess() and endProcess() functions.
- Extracted product lookup into a separate function getProd() and placed it into a new file payprod.php along with the discount() function.
- extracted the main validation processing into separate function accept_web().
- added quantity field processing.
- example custom code for setting up a log database table to record product purchases now includes additional validation for duplicate transactions.
- Corrections to paypal.php processing to ensure item_number gets passed.
- Version 3.0
- Add shopping cart functionality
- Script modified to allow for easy testing in Paypal Sandbox
- Add buy.htm giving samples of code for the different Paypal calls that the script supports
- included modules moved to inc subdirectory
- additional parameters passed to custom processing functions
- additional images for shopping cart
- New function setInvoice() added to payprod.php
- paypal.php and paypal1.php changed to allow invoice to be passed from a preceding page of processing
- New function initIPN added to paycust.php to allow for custom code to be added to modify the selected product (eg, to change the product code after a certain date to pick up a different price).
- Additional page paypal4.php added for use with the customized version of paycust to allow previous purchasers to resend themselves updated versions of the script based on the information recorded in the database log table.
- Extension script to move the product and discount data into mySQL database tables available for separate purchase.
- Updated paypal2.php to automatically disable ip address test for sandbox testing and updated paypal.php and paypal1.php to allow new parameter "noship" to disable shipping for entries where shipping is not required even though there is no attachment.
- Minor code change to payinc to make it easy to turn off the blind copy of the email sent to you. Simply change the line at the top that reads $copytoyou = $premail; to read $copytoyou = '';
- Make IPN script independent of email script
- Move logging functionality from sample code in IPN script to supported code in DB extension script.
- Extension script updated to include log display, pawword protected area timed access purchase and to allow unique unlock codes / PINs to be allocated to purchasers.
- Additional code added to call a separate user customisable function for subscription processing.
- Extension script updated to support multiple membership levels and one time access. Also sample code to show how to set membership level based on the size of a donation.
- Version 4.0Security update, note that your serial number now needs to be added to the payconf.php file to help secure your script
- Enhancement to extension script to allow an emailtobefirstsentasking the buyertoconfirm that they intended topurchase and giving themthe option of cancelling their order before theemail with their script is sent.
- Minor change to allow product code to be built up to allow multiple product combinations. Instead of having name="prod" value="A" and name="prod" value="B" as separate purchases you can now use checkboxes with name="prods" and the values so as to built prod="A", prod="B" and prod="AB" depending on which checkboxes are selected.
- Now uses HTTP 1.1.
The easiest way to implement these changes to your copy of the script is to resend the script (you will need the item and invoice numbers from your original purchase to request a resend).
Note that full number upgrades usually require alterations to be made to the payconf file.
This article written by Stephen Chapman, Felgall Pty Ltd.