28, May 2012

Paypal IPN script by feha - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Paypal IPN script by feha
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: Paypal IPN script by feha  (Read 2558 times)
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« on: Sep 15, 2006, 05: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.


Last blog : Are You Stumbling Yet?
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Sep 15, 2006, 07:37:53 pm »

I would like to know about this too.

I had made a modified version of IPN which is not working right.

I think there is a need for a good payments gateway script.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Community Supporter ?
Cyberpunk Wannabe
*
Posts: 48
336 credits
Members referred : 0


« Reply #2 on: Sep 16, 2006, 02: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: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #3 on: Sep 16, 2006, 02: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!


Last blog : Are You Stumbling Yet?
Community Supporter ?
Cyberpunk Wannabe
*
Posts: 48
336 credits
Members referred : 0


« Reply #4 on: Sep 16, 2006, 02:36:58 pm »

here is the original:
Code:
PHP 4.1

// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);

// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];

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: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #5 on: Sep 16, 2006, 03: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.


Last blog : Are You Stumbling Yet?
Community Supporter ?
Cyberpunk Wannabe
*
Posts: 48
336 credits
Members referred : 0


« Reply #6 on: Sep 16, 2006, 03:09:28 pm »

No Paypal does not send you e-mail , paypal calls your script ...

please login into your paypal account and read more how to setup your IPN
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #7 on: Sep 16, 2006, 03:12:36 pm »

oke, I'll have a look. Thanks!


Last blog : Are You Stumbling Yet?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #8 on: Sep 16, 2006, 04:23:06 pm »

oke, I'll have a look. Thanks!
you should also ask wineo, his integration of paypal in his directory is really "smooth"

Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #9 on: Sep 16, 2006, 05:18:31 pm »

care to share your secrets here wineo?


Last blog : Are You Stumbling Yet?
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1525
6359 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #10 on: Sep 16, 2006, 05:33:58 pm »

Hi
sorry for this but when someone else start a thread i do not get any automatic e-mails on someoneelse treads ...

Ditto... LOL.

I will have to have a closer look at this thread and the script in question and get back to you.


Last blog : Canonical URL Links / Tags
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1525
6359 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #11 on: Sep 16, 2006, 05: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.


Last blog : Canonical URL Links / Tags
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #12 on: Sep 16, 2006, 06:11:03 pm »

Of course you can try something like this Wink

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #13 on: Sep 16, 2006, 08:01:30 pm »

Of course you can try something like this Wink

google bookmarked Wink

Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #14 on: Sep 17, 2006, 01:13:36 pm »

Of course you can try something like this Wink
I've downloaded that script and played with it for a bit. Looks like I've got a working paypal option on my site now!


Last blog : Are You Stumbling Yet?
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #15 on: Sep 17, 2006, 02:46:05 pm »

Yeah it is the most complete script for paypal, but of course it require some time to make it work

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=4113
Tags : tutorials databases email Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Paypal IPN script by feha
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 02:18:32 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.