YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Perl IPN Script without LWP or Crypt, please. Options
JoeReeves
#1 Posted : Thursday, June 17, 2004 2:14:11 AM
Rank: Starting Member

Groups: Registered

Joined: 6/17/2004
Posts: 4
Location: ,
My web host provides me with a plethora of Perl modules I can use to write Perl scripts with, but they won't give me the LWP or Crypt families. Support tells me to move to their parent host which costs twice as much and which I'm not about to do because I am otherwise quite satisfied with my current hosting plan. All of the examples I've seen of scripts for processing IPN require LWP::UserAgent and Crypt::SSLeay. Can someone show me an sample script that will work without using these modules? While I have a budding understanding of the HTTP transaction and some experience with Perl, I don't yet understand how to keep the connection open to receive a 'Valid' or 'Invalid' response after I send my http request ... or if i need to and/or how to collect that response when it hits the script. Any help would be appreciated. Joe
Sponsor  
 
PayPalStephen
#2 Posted : Thursday, June 17, 2004 8:36:43 PM
Rank: Starting Member

Groups: Registered

Joined: 10/17/2002
Posts: 2,139
Location: ,
Hello,

Have you thought about PHP then?

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);
}
?>


Stephen Ivaskevicius
PayPal/eBay, Inc.
www.paypal.com/pdn
JoeReeves
#3 Posted : Friday, June 18, 2004 12:30:58 AM
Rank: Starting Member

Groups: Registered

Joined: 6/17/2004
Posts: 4
Location: ,
Yes, I have considered using PHP. The problem with it is that I don't know the first thing about PHP or how to implement a script. Can you give me some pointers? I do have PHP in my webspace. I just get confused with it because I haven't spent any time trying to figure it out, hence, I'm not used to looking at it.



Joe
paypal_pb
#4 Posted : Saturday, June 19, 2004 3:25:59 AM
Rank: Starting Member

Groups: Registered

Joined: 9/16/2002
Posts: 2,960
Location: ,
The step that requires LWP is not strictly required but it leaves open a very small hole for someone to defraud you. Someone would need to fake an IPN which is quite difficult to do.

Patrick Breitenbach
PayPal, Inc.
Dev Net: https://www.paypal.com/pdn
JoeReeves
#5 Posted : Saturday, June 19, 2004 2:25:46 PM
Rank: Starting Member

Groups: Registered

Joined: 6/17/2004
Posts: 4
Location: ,
What basically, but exactly does LWP do?

Joe
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAFVision Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF | YAF © 2003-2009, Yet Another Forum.NET
This page was generated in 0.159 seconds.