PayPal IPN handler is a set of 2 PHP scripts that can handle the IPN
sent by PayPal for every transaction. Instant Payment Notification (IPN) is
PayPal's interface for handling real-time purchase confirmation and server-to-server
communications. IPN delivers immediate notification and confirmation of PayPal
payments you receive and provides status and additional data on pending, cancelled,
or failed transactions.
Instant Payment Notification (IPN) allows you to integrate your PayPal payments
with your website's back-end operations, so you get immediate notification and
authentication of the PayPal payments you receive. IPN can be used for many
purposes but the primary reason people use it, is for providing instant download
of their downloadable products or registration codes etc. to their customers.
If you don't want to bother with coding yourself and are looking for a PayPal
IPN handler service for doing automated downloads/online fulfillment, you
should consider e-junkie.com.
Process
IPN process is quite simple. PayPal send all the transaction data as POST
to any script you specify on your web server. This script has to post all the
data back to PayPal as it is. If the transaction is valid, PayPal will return
a response "VERIFIED". Then you can perform few more checks to see
if it is not a duplicate transaction, the payment amount is same as the price
of your product, the currency is same as you expect and last but not the least,
if the payment made to your account :)
Code
I have provided the PHP scripts and SQL files for all this. You do NOT require
cURL or SSL or any other fancy thing. You should just have plain old PHP and
mySQL running on your webserver. I have written some code, picked up some code
from some places, modified and added to it, tested a LOT. Finally, this works
perfect. Please let me know if you need any installation help or if you find
any bug. Please note, this code will do all the verification for you, you can
modify ipn_res.php to add code for anything that you want to happen after the
payment is successfully verified.
Instructions
1.
Open ipn_res.php and change the configuration settings.
2.
Copy ipn_res.php and ipn_cls.php in your web folder.
3.
Create paypal_table and item_table using the SQL files provided.
4.
Enter your product price and item_number in item_table.
5.
Login to your PayPal account and create the "Buy Now"
button for your product.
6.
For IPN to work, either put the complete link to ipn_res.php as your
IPN URL in your PayPal account settings OR in your "Buy Now"
button code, specify
This will make PayPal post all the transaction data (that it sends as
IPN) to ipn_res.php in the browser window so you can see any error message
etc., if things are not working for you.
IPN notifications posted by: ian on:Aug 24, 08 11:24 am
IPN technology is typically hard to get working and is especially painful to test. If you don't feel like reinventing the wheel (and you are obviously considering doing that if you are checking this page out) just have a quick look at a prebuilt solution such as http://www.scrobbld.com.
Having problem with fsockopen ( "www.paypal.com") posted by: gil on:May 29, 08 11:16 am
I'm testing using sandbox, do I need to change this to 'www.sandbox.paypal.com' or with 'https://' ? any help is appreciated.
this is my error by the way
Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of fsockopen(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file in /home/content/k/e/n/kendra1/html/dev/ipn_class.php on line 18
Strange problem with ereg not finding verified posted by: mark on:Jun 6, 08 2:02 pm
if (ereg("VERIFIED",$this->paypal_response))
always returns false.
However when the email is sent I get it telling me that
Bad order (PayPal says it's invalid) but inside in the email the content of paypal_response is listed as:
payer_status: verified
I'm using the sandbox to test btw.
Anyone any ideas, why I'm not getting the verification as true ?
Its driving me nuts :)