Simple PHP PayPal Buy Now and PayPal IPN Classes
So as promised, I’m releasing the Paypal classes I used recently on a side project. There are two classes, the Paypal class creates a “Buy Now” button with or without encryption and the IPN class takes care of the IPN requests.
You should already have some knowledge of Paypal website payments standard and IPN requests before using these classes.
Included are three example files that pretty much describe how to use the classes so check them out as I think they are pretty self-explanatory. Also included in the scripts folder is the addevent javascript function (that you must include in your pages if you wish to use automatic submission) and the database table structure where you will store the ipn requests.
The IPN class allows you to log to a file, email or database. Any problems the script encounters are also logged because IPN requests are not so easy to debug because they happen on the background.
A very useful link for testing ipn is: http://www.eliteweaver.co.uk/testing/ipntest.php which is down at the moment but I’m hoping is just a temporary problem. You should also test on PayPal’s own sandbox before putting it in production.
I should warn you that I will obviously not be held responsible for any problems you have with Paypal using these classes, I’m releasing them under the GPL so there is no warranty of any kind.
If you do use these classes and make a bunch of money please consider making a small donation. Thanks.
Any problems, doubts or bug reports please use the comments form below and I’ll try to help in any way I can. Download the files below.

Hey,
Thanks for the great classes. In all honesty they seem to be best Paypal classes I’ve come across and definitely the most flexible.
I got the Paypal button working perfectly on my test site and am now playing around with the IPN with sandbox.
I always seem to get WARNING: Invalid IPN detected, in my emails after making a payment via a sandbox buyer account. I’ve taken a look at your code and found that the error occurs if “VERIFIED” is not found in the IPN. What field in the IPN is supposed to contain “VERIFIED”?
nevermind, found the answer by doing more reading into IPN
IMPORTANT: sandbox users should update the line:
$socket = fsockopen($url_parsed['host'],80,$err_num,$err_str,30);
to
$socket = fsockopen($url_parsed['host'],443,$err_num,$err_str,30);
Paypal sandbox no longer uses port 80, although the live sites do. If you don’t update then you’ll never get a VERIFIED IPN response
PS: sorry to keep posting comments, you can delete the previous two if you like
Thanks for the comments biffster, i’m glad someone found the classes useful. No worries about the comments, they’re on topic and informational, so post as much as you want.
That PayPal change must be recent, while I was working on the classes i was using port 80 just fine. Hopefully your comment will aid others if they get the same problem.
As for the VERIFIED question you asked, i’m sure you already found out but i’ll answer it anyway, the VERIFIED response should be in the body in plain text as soon as you post your IPN back to paypal.