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

$res->content always blank Options
tofletch
#1 Posted : Thursday, July 17, 2003 9:01:04 PM
Rank: Starting Member

Groups: Registered

Joined: 7/17/2003
Posts: 3
Location: ,
I'm using the paypal supplied Perl code, with very minor changes (see below). $res->content is always blank, but the other fields have valid data, including $payment_status. Help is much appreciated. Mike #!/usr/bin/perl require LWP::UserAgent; my ($pending_reason); # read post from PayPal system and add 'cmd' read (STDIN, $query, $ENV{'CONTENT_LENGTH'}); $query .= '&cmd=_notify-validate'; $file = "/tmp/paypalstep1.dbg"; open(DEBUG, ">$file"); print DEBUG "query = $query\n"; # post back to PayPal system to validate use LWP::UserAgent; $ua = new LWP::UserAgent; $req = new HTTP::Request 'POST','http://www.paypal.com/cgi-bin/webscr'; $req->content_type('application/x-www-form-urlencoded'); $req->content($query); $res = $ua->request($req); # split posted variables into pairs @pairs = split(/&/, $query); $count = 0; 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++; } # assign posted variables to local variables $item_name = $variable{'item_name'}; $item_number = $variable{'item_number'}; $payment_status = $variable{'payment_status'}; $payment_gross = $variable{'payment_gross'}; $txn_id = $variable{'txn_id'}; $receiver_email = $variable{'receiver_email'}; $payer_email = $variable{'payer_email'}; $invoice = $variable{'invoice'}; $affno = $variable{'affno'}; $pending_reason = $variable{'pending_reason'}; $status = $res->content; print DEBUG "res->content = $status\n"; print DEBUG "item_name = $item_name\n"; print DEBUG "item_number = $item_number\n"; print DEBUG "payment_status = $payment_status\n"; print DEBUG "payment_gross = $payment_gross\n"; print DEBUG "txn_id = $txn_id\n"; print DEBUG "receiver_email = $receiver_email\n"; print DEBUG "payer_email = $payer_email\n"; print DEBUG "invoice = $invoice\n"; print DEBUG "affno = $affno\n"; print DEBUG "pending_reason = $pending_reason\n"; # Not doing anything unless 'VERIFIED' is received if ($res->content eq 'VERIFIED') { if ($receiver_email eq 'george@uvox.net') { $tmp = 'txn_id=' . $txn_id; $tmp = $tmp . '+payer_email=' . $payer_email; $tmp = $tmp . '+affno=' . $affno; $tmp = $tmp . '+invoice=' . $invoice; $tmp = $tmp . '+status=' . $payment_status; $tmp = $tmp . '+reason=' . $pending_reason; chomp($fname = `date +'%Y%m%d%H%M%S'`); $fname = "/met/ux/authorizations/paypalstep1.$fname"; system("(export TERM=dumb ; /met/bin/dbshell -a UX -u UX -s 1 -b N /met/bin/run paypal1.run[1/ux] $tmp 2>$fname)"); } } close(DEBUG); print "content-type: text/plain";
Sponsor  
 
paypal_pb
#2 Posted : Thursday, July 17, 2003 9:09:39 PM
Rank: Starting Member

Groups: Registered

Joined: 9/16/2002
Posts: 2,960
Location: ,
Can you check for:

if ($res->is_error) {
# HTTP error
}


Patrick Breitenbach
PayPal, Inc.
Dev Net: https://www.paypal.com/pdn
tofletch
#3 Posted : Thursday, July 17, 2003 9:14:30 PM
Rank: Starting Member

Groups: Registered

Joined: 7/17/2003
Posts: 3
Location: ,
$res->is_error = 1
tofletch
#4 Posted : Thursday, July 17, 2003 9:23:27 PM
Rank: Starting Member

Groups: Registered

Joined: 7/17/2003
Posts: 3
Location: ,
I should add, that I don't know what that means. I understand it is an HTTP error, but I don't know what a 1 means. Could it have something to do with the fact that I'm using IP instead of domain name?
webwiseguys
#5 Posted : Sunday, January 11, 2004 11:28:49 AM
Rank: Starting Member

Groups: Registered

Joined: 1/7/2004
Posts: 3
Location: ,
I also have this problem. I discovered that $res->content can't be read if it's saved as a variable, consist of any scalar or hashes.
If you saved $content=$res->content; and print it, it would be just blank. I suspect the $res->content, is a hash. Somehow, it has to be dereferenced, in order to be seen. I am still looking through my books to figure this out. Hopefully I'll find an answer soon.

If anybody knows the answer, pls. reply to this post.


<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">Originally posted by tofletch
[br]I'm using the paypal supplied Perl code, with very minor changes (see below). $res-&gt;content is always blank, but the other fields have valid data, including $payment_status.

Help is much appreciated.
Mike

#!/usr/bin/perl

require LWP::UserAgent;

my ($pending_reason);

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

$file = "/tmp/paypalstep1.dbg";
open(DEBUG, "&gt;$file");
print DEBUG "query = $query\n";

# post back to PayPal system to validate
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$req = new HTTP::Request 'POST','http://www.paypal.com/cgi-bin/webscr';
$req-&gt;content_type('application/x-www-form-urlencoded');
$req-&gt;content($query);
$res = $ua-&gt;request($req);

# split posted variables into pairs
@pairs = split(/&/, $query);
$count = 0;
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++;
}

# assign posted variables to local variables
$item_name = $variable{'item_name'};
$item_number = $variable{'item_number'};
$payment_status = $variable{'payment_status'};
$payment_gross = $variable{'payment_gross'};
$txn_id = $variable{'txn_id'};
$receiver_email = $variable{'receiver_email'};
$payer_email = $variable{'payer_email'};
$invoice = $variable{'invoice'};
$affno = $variable{'affno'};
$pending_reason = $variable{'pending_reason'};
$status = $res-&gt;content;

print DEBUG "res-&gt;content = $status\n";
print DEBUG "item_name = $item_name\n";
print DEBUG "item_number = $item_number\n";
print DEBUG "payment_status = $payment_status\n";
print DEBUG "payment_gross = $payment_gross\n";
print DEBUG "txn_id = $txn_id\n";
print DEBUG "receiver_email = $receiver_email\n";
print DEBUG "payer_email = $payer_email\n";
print DEBUG "invoice = $invoice\n";
print DEBUG "affno = $affno\n";
print DEBUG "pending_reason = $pending_reason\n";

# Not doing anything unless 'VERIFIED' is received
if ($res-&gt;content eq 'VERIFIED') {
if ($receiver_email eq 'george@uvox.net') {
$tmp = 'txn_id=' . $txn_id;
$tmp = $tmp . '+payer_email=' . $payer_email;
$tmp = $tmp . '+affno=' . $affno;
$tmp = $tmp . '+invoice=' . $invoice;
$tmp = $tmp . '+status=' . $payment_status;
$tmp = $tmp . '+reason=' . $pending_reason;
chomp($fname = `date +'%Y%m%d%H%M%S'`);
$fname = "/met/ux/authorizations/paypalstep1.$fname";
system("(export TERM=dumb ; /met/bin/dbshell -a UX -u UX -s 1 -b N /met/bin/run paypal1.run[1/ux] $tmp 2&gt;$fname)");
}
}

close(DEBUG);
print "content-type: text/plain";

<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">
shaundietrich
#6 Posted : Monday, October 25, 2004 10:47:27 AM
Rank: Starting Member

Groups: Registered

Joined: 10/25/2004
Posts: 2
Location: ,
[quote]Originally posted by webwiseguys
[br]I also have this problem. I discovered that $res-&gt;content can't be read if it's saved as a variable, consist of any scalar or hashes.
If you saved $content=$res-&gt;content; and print it, it would be just blank. I suspect the $res-&gt;content, is a hash. Somehow, it has to be dereferenced, in order to be seen. I am still looking through my books to figure this out. Hopefully I'll find an answer soon.

If anybody knows the answer, pls. reply to this post.
&gt;&gt;
Just pass the refrence by value into a subroutine. You could make another subroutine for your email as well. It did help to actualy see the value of $res-&gt;content and I found out the IPN testing site I had been using wasn't working right!

I hope someone finds this info usefull.

Don't use this IPN testing site : http://www.belahost.com/pp/

Use this IPN testing site: http://www.eliteweaver.co.uk/testing/ipntest.php

# refrencing info http://iis1.cps.unizar.e...erl/advprog/ch01_01.htm

&logstuff($res-&gt;content);

sub logstuff {
my ($content) = @_;
my ($output, $photoline);

open (LOG, "&gt;&gt;$logstuff");
print LOG ("\nNew Output for $content\n\n");
foreach $output (sort keys(%variable)) {
unless ($output eq '') {
$photoline = "$variable{$output}";
print LOG ("$output : $photoline\n");
}
}
close (LOG);
}
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.363 seconds.