Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple Paypal IPN examples? [closed]

I would like to have a text input form with a submit button that goes to paypal, upon payment the contents of the form should go in a mysql database..

This sounds trivial, but I'm having such a hard time with paypal's IPN.

Can anyone point in me in the right direction?

Thanks!

like image 852
dot Avatar asked Mar 25 '09 20:03

dot


People also ask

How do I fix PayPal Instant Payment Notification IPN?

Step 1: In your PayPal Account, go to my account –> profile – my setting tools – instant payment notifications – update – choose IPN settings. Step 2: Paste the notification URL given and enable the option “* Recive IPN messages”.

What is PayPal IPN URL?

APICurrent. Instant Payment Notification (IPN) is a message service that notifies you of events related to PayPal transactions. You can use IPN messages to automate back-office and administrative functions, such as fulfilling orders, tracking customers, or providing status and other transaction-related information.

How do I find my PayPal IPN?

View IPN messages and details. Use the IPN History page on the PayPal website to view IPN messages sent to your listener URL from PayPal, and to request that messages be resent. Select the IPN messages to review. You can specify a date range, delivery status, and PayPal transaction ID.

What is a IPN code?

The International Performer Number (IPN) is a unique universal identifier allocated to every single PPL-registered performer as well as performers registered with other collective management organisations (CMOs). This ID number is used to identify a performer in exchanges with other CMOs around the world.


5 Answers

PayPal has some sample code on their website. However the bigger problem you'll face is that the user will probably want a real-time response. This is usually done by processing the PDT data that is submitted to your site when the user clicks the link to return to your site. At some point later PayPal will post to your IPN url similar data. You need to avoid processing the data twice.

Also the data in question is only PayPal's data about the transaction. It does not contain arbitrary data. You should probably record the customer's order before sending them to paypal, or else look for a pass-through variable. For example, when creating a billing agreement, there is a variable called custom which is passed back to you as you created it. You can store an order id or whatever you want in that variable. Be careful to validate its contents to make sure it's still correct for the transaction details.

like image 107
Mr. Shiny and New 安宇 Avatar answered Oct 05 '22 16:10

Mr. Shiny and New 安宇


You don't, and can't, get the entire contents of the form back from Paypal. What you will get is a postback to the address you sent in the "return" field. The best way to pass arbitrary information through the process from your form to the postback is in the "item_number" field (preferably by using it as an ID in your database linked to whatever information you want to track).

like image 43
chaos Avatar answered Oct 05 '22 14:10

chaos


I know this question was already answered years ago, but for those who stumble upon it in the future...

I found this class + example to be particularly useful, so much so that I've re-used it for countless projects: http://www.micahcarrick.com/php-paypal-ipn-integration-class.html

Update: The page is offline now, but there's an archived version here which still has a working download link: https://web.archive.org/web/20140210202247/http://www.micahcarrick.com/php-paypal-ipn-integration-class.html

And here's a direct link to the archived download: https://web.archive.org/web/20140210202247/http://www.micahcarrick.com/files/paypal-1.3.0.zip

From the archived page, the author also links to a new version of his library, which is probably the better option now: https://github.com/Quixotix/PHP-PayPal-IPN

like image 37
Josh1billion Avatar answered Oct 05 '22 15:10

Josh1billion


This PHP sample should help you get started with IPN.

Here you can find the PHP API for PayPal, which might be useful even though it doesn't include sample that deals with IPN.

like image 42
Sire Avatar answered Oct 05 '22 15:10

Sire


You will find some examples of IPN Script if you follow this link

https://paypaltech.com/SG2/

Just select your programming language and the type of script that you are loonking for.

like image 30
Jazz009 Avatar answered Oct 05 '22 15:10

Jazz009