Jump to Page:   1 · 2 · 3 · 4 · 5 · 6 · 7 · 8 · 9 · »  |  Next Page
PHP Template for IPN - Good Starting Point   [ Edited ]
Options    Options  
angelleye
Ace Developer
Posts: 3154
Registered: 06-25-2006


angelleye

Message 1 of 365

Viewed 25,580 times


I developed this little template to use for PayPal's IPN using PHP/MySQL.

 

This isn't quite done yet but I've attached a ZIP of my complete solution for this.

1) Create a MySQL DB to store the data in if you don't already have one available.

2) Extract the zip file

3) Edit the /admin/config.php file with your credentials

4) Upload all files to a directory on your web host.

5) Load /admin/install/index.php in a web browser to install the DB tables.

6) Set your IPN to point to the ipn-listener.php
7) Start hitting it with IPN's from the simulator or live and watch the data arrive!

Message Edited by angelleye on 08-31-2009 06:15 PM

 


 

Attachment Angell EYE PayPal IPN Solution.zip (332 kb)

23
Kudos!
10-17-2008 02:54 PM  
Re: Here's a PHP template for handling IPN's that has been helpful for me and maybe you to.   [ Edited ]
Options    Options  
grimholtz
Contributor
Posts: 14
Registered: 10-13-2006


grimholtz

Message 2 of 365

Viewed 25,528 times


This is great! Thanks for sharing. Any chance you could share your DDL scripts that create MySQL tables which store this data?
Message Edited by grimholtz on 10-18-2008 12:56 PM
1
Kudos!
10-18-2008 09:56 AM  
Re: Here's a PHP template for handling IPN's that has been helpful for me and maybe you to.   [ Edited ]
Options    Options  
angelleye
Ace Developer
Posts: 3154
Registered: 06-25-2006


angelleye

Message 3 of 365

Viewed 25,498 times


I never went as far as created any type of table creator to mirror all of these fields in a database.  Never really thought that.  I may go ahead and throw that together.  This simply prepares all of the data in PHP so that you can easily drop it anywhere you need it without the need to parse it all yourself.  If you want the payer_email field shown in the documentation, for example, just use $payer_email.  It'll either have the value that was returned or it'll be blank if that value wasn't returned for some reason, but it won't throw any errors which is nice.  If you're getting a blank value somewhere you think you should be getting data you can look at $res or the $_POST array to see the full response and check it out.
Message Edited by angelleye on 10-18-2008 05:34 PM

 

1
Kudos!
10-18-2008 05:32 PM  
Re: Here's a PHP template for handling IPN's that has been helpful for me and maybe you to.
Options    Options  
grimholtz
Contributor
Posts: 14
Registered: 10-13-2006


grimholtz

Message 4 of 365

Viewed 25,478 times


Yes, I understand what the code does. But you don't put any of this into a database? How do you track transactions?
Kudos!
10-19-2008 08:46 AM  
Re: Here's a PHP template for handling IPN's that has been helpful for me and maybe you to.   [ Edited ]
Options    Options  
angelleye
Ace Developer
Posts: 3154
Registered: 06-25-2006


angelleye

Message 5 of 365

Viewed 25,448 times


I do put it in a database but generally those DB's are never the same.  I use this with lots of different clients.  It's just a starting point for me so I can begin immediatly with all possible data available to me in PHP variables.

 

Usually what I do is then add include files to handle each particular task the listener might handle.  For example, I use this with one client of mine to handle their eBay checkouts and get those orders into their database.  I have an include that runs if the IPN came from an eBay checkout.  I can easily add the IPN data to their system using this template.  I just had to add in the actual database inserts.  Another client might have completely different tables and fields names.

 

Another include could be used to handle disputes, and another to handle echecks, etc.  Some of my clients use mysql, some use Access, some use FileMaker...can't really handle the DB end of things for everybody.

Message Edited by angelleye on 10-19-2008 03:28 PM

 

Kudos!
10-19-2008 03:25 PM  
Re: Here's a PHP template for handling IPN's that has been helpful for me and maybe you to.
Options    Options  
Citizen
Regular Visitor
Posts: 10
Registered: 02-18-2008


Citizen

Message 6 of 365

Viewed 25,353 times


Is it better to use ssl or not?

 

Also, which of these variables do I need to check out in order to know that I receieved money?

 

Basically, I need to know that no matter what method that they used, that I actually got paid and that its actually in my account so that my php script can alter their info on my site. I also have one custom variable that needs to give me their account id from my site, which I have in my form.

Kudos!
10-21-2008 11:47 AM  
Re: Here's a PHP template for handling IPN's that has been helpful for me and maybe you to.
Options    Options  
angelleye
Ace Developer
Posts: 3154
Registered: 06-25-2006


angelleye

Message 7 of 365

Viewed 25,333 times


If SSL is available I recommend using it. 

To ensure a payment has been completed you can use a combination of the following fields: $txn_type, $payment_type, $payment_status, $pending_reason.  Study those fields here and you should be able to figure it out.


 

2
Kudos!
10-21-2008 04:26 PM  
Re: Here's a PHP template for handling IPN's that has been helpful for me and maybe you to.
Options    Options  
GreatBigBore
Contributor
Posts: 15
Registered: 10-21-2008


GreatBigBore

Message 8 of 365

Viewed 25,329 times


This is an excellent script, thanks. Since you do this for many of your customers, I imagine that you have a lot of experience setting up "Buy Now" buttons, as well as setting up the account profile settings such as the IPN, PDT, and auto-reply settings. Could you advise me on how you do that? Specifically, do you set things up such that as soon as the user clicks "Pay" on the Paypal site, Paypal sends him back to your script? Or do you have some other mechanism that runs your script? I've been fighting this system for days and haven't come up with anything yet that works. Thanks for any help you can give me.
Kudos!
10-21-2008 05:18 PM  
Re: Here's a PHP template for handling IPN's that has been helpful for me and maybe you to.
Options    Options  
grimholtz
Contributor
Posts: 14
Registered: 10-13-2006


grimholtz

Message 9 of 365

Viewed 25,325 times


Angeleye,

 

Why can't you simply check if $payment_status equals  "Completed" to ensure payment has been completed? You don't need to know txn_type,  payment_type, and pending_reason... do you?

 

grimholtz

Kudos!
10-21-2008 05:47 PM  
Re: Here's a PHP template for handling IPN's that has been helpful for me and maybe you to.
Options    Options  
GreatBigBore
Contributor
Posts: 15
Registered: 10-21-2008


GreatBigBore

Message 10 of 365

Viewed 25,313 times


It's not that I want to check whether the transaction was completed. It's that I want to make sure that if the transaction was completed, the user comes back to my site and my script. What I'm worried about is that they'll go to Paypal, complete the transaction, and then go to some other random site. Then I'd never know that they paid for my product. Does that make any sense? Basically if I don't have Paypal sending the user back to me, then I'll never know that anything happened. Unless I have Paypal send me an email, something I'd rather not bother with if there's an easier way, such as getting Paypal to send the user back to me automatically.
Kudos!
10-21-2008 05:50 PM  
Jump to Page:   1 · 2 · 3 · 4 · 5 · 6 · 7 · 8 · 9 · »  |  Next Page
Copyright © PayPal. All Rights Reserved. By using this site, you agree to be bound by PayPal's Legal Disclaimer, User Agreement, and Privacy Policy. This site is subject to change without notice. All other products and company names are trademarks of their respective corporations.