home |  
Sell Downloads - Ejunkie
open db network by 19.5 degrees
LYRICS | FREE E-BOOKS | SELL DOWNLOADS WITH PAYPAL
 in   
contribute for fun & profit
brink

PayPal IPN Handler
-PayPal IPN Agen..
-PayPal IPN hand..
-Image to ASCII ..
-Image to ASCII ..
-PayPal IPN hand..
All Resources > Server Scripts > PHP
spread the word around  send this page to a friend   read/write comments/corrections/additions comments  rate this 

PayPal IPN handler

by 19.5 Degrees
 
 
views: 89807 | rating: 6/10 | downloads: 18194 download
 


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.



download


« PREVIOUS
  INDEX
NEXT »

spread the word around
read comments

Eval post vars eval("\$$key=\$value;")
posted by: Vadim Jacobi
on: Jan 27, 10 3:36 pm

Please, do not eval the $_POST vars. It's not javascript and this code is a potential security risk, in PHP you can write ${$key}=$value;

post reply | read replies (0)



Someone attempted a sale using a manipulated URL
posted by: Christian Smith
on: Jun 5, 06 12:18 pm

etting the aove error. i checkd to make sure the business from the email matched the $paypal_email variable. I checked to be sure the itemid and mc_Gross and mc_currency from the email match the db table. Any other ideas?

post reply | read replies (3)



does it handle after IPN msg received ?
posted by: John
on: Jan 13, 10 3:17 pm

Anyone know if this codes handle the requirement after ipn received as mention in the paypal IPN guideline below :

After PayPal verifies the message, there are additional checks that your listener or back-end or
administrative software must take:
- Verify that you are the intended recipient of the IPN message by checking the email address
in the message; this handles a situation where another merchant could accidentally or
intentionally attempt to use your listener.
- Avoid duplicate IPN messages. Check that you have not already processed the transaction
identified by the transaction ID returned in the IPN message. You may need to store
transaction IDs returned by IPN messages in a file or database so that you can check for
duplicates. If the transaction ID sent by PayPal is a duplicate, you should not process it
again.
- Because IPN messages can be sent at various stages in a transaction’s progress, make sure
that the transaction’s payment status is “completed” before enabling shipment of
merchandise or allowing the download of digital media.
- Verify that the payment amount actually matches what you intend to charge. Although not
technically an IPN issue, if you do not encrypt buttons, it is possible for someone to capture
the original transmission and change the price. Without this check, you could accept a
lesser payment than what you expected.

post reply | read replies (0)



Invalid
posted by: Joseph Nwachukwu
on: Dec 2, 09 12:06 pm

I am also getting invalid payments everytime. i am not sure exactly what the problem is. However i am using sandbox to test.

post reply | read replies (0)



always invalid?
posted by: yves
on: Nov 24, 09 1:29 am

Hi,

I always get an invalid returned and i don't know what's causing this.
I just setup the sql, created a page with only one pay button so as simple as possible for testing, but still no joy.
Any help is greatly appreciated.



This is the mail I receive after a payment.

Bad order (PayPal says it's invalid)HTTP/1.1 200 OK
Date: Tue, 24 Nov 2009 08:23:18 GMT
Server: Apache
Set-Cookie: cwrClyrK4LoCV1fydGbAxiNL6iG=-CL4kCgeMG9OKfoVlM65SjbcyC3pJPfpGn2_KO6qLt2HlTqwZW0xZFdirG6p-BBZWWPZ0Cj339iuCDVclkn-hJCWD-yGkEhDege0SJb9egPeG2aKvHtIY01Qq7vioTN7Rh2zVG%7cUkbImXe-M4CihEgvBQwejcJS23fRpEiiYBZXS7kaPeX7dm1cLj3o3uiTaiNZGX8qiNXgW0%7cQz4EJb4cA3DEcqOoGNyye24K-vR0_iBJ1He9ZKGI9wIVHkxfJWsFO-IO9pU476KMVUiWo0%7c1259050998; domain=.paypal.com; path=/
Set-Cookie: cookie_check=yes; expires=Fri, 22-Nov-2019 08:23:18 GMT; domain=.paypal.com; path=/
Set-Cookie: navcmd=_notify-validate; domain=.paypal.com; path=/
Set-Cookie: navlns=0; expires=Mon, 19-Nov-2029 08:23:18 GMT; domain=.paypal.com; path=/
Vary: Accept-Encoding
Connection: close
Content-Type: text/html; charset=UTF-8

INVALID

The following data was received from PayPal:

(here is nothing written)

post reply | read replies (0)



read more commentsread more comments   |   read more commentspost comment 



home | contact | contribute | terms of use | privacy policy |