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
<input type="hidden" name="notify_url" value="http://your.domain/path.to.ipn_res.php">
|
| |
|
| NOTE: Your PayPal account must be verified to
accept credit cards. |
| |
| How to test? |
| |
|
|
In your "Buy Now" button code, specify
<input type="hidden" name="return" value="http://your.domain/path.to.ipn_res.php">
<input type="hidden" name="rm" value="2">
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.
|