Topic: Paypal IPN script by feha (Read 1349 times)
Global Moderator
Internet Junkie
Gender:
Posts: 1807
9006 credits Members referred : 6
« on: Sep 15, 2006, 06:45:35 PM »
Feha, I just found this script on your site. How much did you modify? Are you using this script on any of your sites? I'm looking for an easy way to incorporate Paypal into a new site I'm working on and the payment status will have to be added to my database so the customer can download what he paid for right after paying.
Community Supporter?
Cyberpunk Wannabe
Posts: 48
336 credits Members referred : 0
« Reply #2 on: Sep 16, 2006, 03:04:20 PM »
Hi sorry for this but when someone else start a thread i do not get any automatic e-mails on someoneelse treads ... Than is better to start in comments at: http://www.vision.to/CMS/Home/Comments.php?pid=301 This is a bit more enhanced version of original PayPal IPN. As is it does not handle DB ... There might be later some tutorial update on this, else i do paid custom work for those who needs ...
Global Moderator
Internet Junkie
Gender:
Posts: 1807
9006 credits Members referred : 6
« Reply #3 on: Sep 16, 2006, 03:11:18 PM »
So what exactly did you enhance and how do we use your script. Writing the results of the transaction to a database is something I can do if I understand how to use your script. Thanks!
if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { // check the payment_status is Completed // check that txn_id has not been previously processed // check that receiver_email is your Primary PayPal email // check that payment_amount/payment_currency are correct // process payment } else if (strcmp ($res, "INVALID") == 0) { // log for manual investigation } } fclose ($fp); } ?> Back to top
Copmare your self ... You get more information that you want to process with my modified version ...
Global Moderator
Internet Junkie
Gender:
Posts: 1807
9006 credits Members referred : 6
« Reply #5 on: Sep 16, 2006, 04:04:22 PM »
Oke and how do we use the script? The top says 'read the post from paypal' Is paypal sending a mail that needs to be processed or is this script being called by paypal? Please share a little bit on how to implement this sollution.
Global Moderator
Internet Junkie
Gender:
Posts: 1523
6847 credits Members referred : 8
Gimme all your cookies!!!
« Reply #11 on: Sep 16, 2006, 06:53:22 PM »
Well feha is right... the PayPal documents explain it all. Though it isn't very difficult at all.
The PayPal button that you make posts the script name that you want PayPal to reply to using "notify_url". You can add GET variables to the script like this... script.php?secret=blahblah. Once the transaction is successful, PayPal notifies this script with a reply. The code above, then checks with PayPal to see if it is correct and to make sure that it is a legit transaction. If it is correct, you can then do what you like in the section of the code that has "// process payment". You can update the transaction in your database and allow the person to download their file.
I think that you should start with the default code from PayPal and work into that code what you need for your system.