Jump to content


Photo

LWP::UserAgent never replies


  • This topic is locked This topic is locked
5 replies to this topic

#1 eno

eno

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 17 April 2003 - 11:58 PM

I've set up an IPN script based on the sample PayPal code and when I try to test it with the test environment at http://www.eliteweav...ing/ipntest.php I always get the same error:

"IPN Received: Your script did not reply!"

Anybody else seen this? LWP:UserAgent is definitely installed on my machine, and the Perl script is running without errors. Here's the code which is supposed to be doing the replying...

my $query;

# read post from PayPal system and add 'cmd'
read (STDIN, $query, $ENV{'CONTENT_LENGTH'});
$query .= '&cmd=_notify-validate';

# post back to PayPal system to validate
my $ua = new LWP::UserAgent;
my $req = new HTTP::Request 'POST','http://www.eliteweaver.co.uk/testing/ipntest.php';
$req->header('Host', 'www.eliteweaver.co.uk');
$req->content_type('application/x-www-form-urlencoded');
$req->content($query);
my $res = $ua->request($req);

# split posted variables into pairs
my @pairs = split(/&/, $query);
my $count = 0;

my $pair;
my $name;
my $value;
my %variable;

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$variable{$name} = $value;
$count++;
}

$res->content always returns 'INVALID', and I never get $res->is_error...

#2 eno

eno

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 18 April 2003 - 08:02 AM

More information:

If I add in a "print $query;", I see that I am not getting anything in the $query variable...

#3 paypal_pb

paypal_pb

    Advanced Member

  • Members
  • 2,960 posts

Posted 18 April 2003 - 09:22 AM

Are you able to do this: http://www.paypaldev...p?TOPIC_ID=1658

Patrick Breitenbach
PayPal, Inc.
Dev Net: https://www.paypal.com/pdn

#4 eno

eno

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 18 April 2003 - 09:37 AM

Interesting.... In answer to your question, I get success when I paste that form in a web page (returns "VERIFIED").

Perhaps there is something wrong with the test engine at https://ssl.uksecure...ng/ipntest.php?

Perhaps I should just try a "real" paypal payment and see what happens now? Can't see how I am going to get the other test engine working... Still not sure if it's a problem at my end or at theirs..

In any case I was able to get around the empty "$query" problem by replacing PayPal's sample code with this:

my $cgi = new CGI;

my %variable = $cgi->Vars();

my $query;

$query = join('&', map { $_ . "=" . uri_escape($variable{$_} )} keys %variable);

$query .= '&cmd=_notify-validate';

So now $query isn't empty any more... but I am still getting the following message from the test script at https://ssl.uksecure...ng/ipntest.php:

IPN Sent:
PDT

HTTP Status:
HTTP/1.1 200 OK

IPN Received:
Your script did not reply!

Post Back:
N/A

#5 paypal_pb

paypal_pb

    Advanced Member

  • Members
  • 2,960 posts

Posted 18 April 2003 - 11:04 AM

I'm not sure what the issue would be with EliteWeaver.

This is a fairly repliable means for accessing the whole POST string:

read (STDIN, $query, $ENV{'CONTENT_LENGTH'});


Patrick Breitenbach
PayPal, Inc.
Dev Net: https://www.paypal.com/pdn

#6 eno

eno

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 19 April 2003 - 04:06 AM

Final result:

- It's all working;

- There is some kind of problem, presumably a transitory one, with the eliteweaver test scripts; my IPN script always fails with the test scripts (which claim I am not posting a reply) and succeeds with the live PayPal system;

- The sample code didn't work on my system; don't know why.... perhaps because I had it set to "use strict" it wasn't getting the environment variables or something? I was getting an empty $query string no matter what I did until I replaced the sample code with the new code;

- It's wonderful to have all this fully automated! Thankyou PayPal! :-)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users