develooper Front page | perl.libwww | Postings from January 2001

Need libwww guru help please. "Can't call method "request" on an undefined value at ....."

Thread Next
From:
Robert
Date:
January 15, 2001 17:34
Subject:
Need libwww guru help please. "Can't call method "request" on an undefined value at ....."
Message ID:
00be01c07f5b$89c11da0$1a6001cb@chalmers.com.au

Hi folks.
Seriously in need of some help from the Master here. I'll enclose the little
bit of sample code, and even a web address to test it out if you've a
mind...
I'm trying to set up an interface to a secure server to post creditcard
details, and on success, return to the interface. Easy? I though so. but was
wrong as usual.

As a standalone program, it works fine. As a subroutine in another program,
called from a webpage, it fails.
........................................
Can't call method "request" on an undefined value at
/usr/local/lib/perl5/site_perl/5.6.0/LWP/UserAgent.pm line 227.
.......................................
It appears to be failing at the [my $res = $ua->request($req);] part.... I
dunno. It's losing the contents of the $request variable fo some reason? I
think?


ok.

Working code.
Here's the stand alone code: much like the distribution sample in fact. If
you run this, you get the generated page back. The 'resultURL' points the
esec server back to the 'allvars.php3' program on my server.
=======================
#!/usr/local/bin/perl
use LWP::UserAgent;
use LWP::Debug qw(+conns +trace +debug);
$ua = new LWP::UserAgent;
$ua->agent("AgentName/0.1 " . $ua->agent);

#create request
my $req = new HTTP::Request POST =>
'https://sec.aba.net.au/cgi-bin/service/authorise/test';
$req->content_type('application/x-www-form-urlencoded');
$req->content('&secParams=https://sec.aba.net.au/merchant/test/testpayment.p
rops &referenceID=xxx &cardType=ABA Test &cardNumber=abasuccess
&nameOnCard=Robert &expiryMonth=3 &expiryYear=2002 &amount=45.00
&resultURL=http://www.chalmers.com.au/~robert/allvars.php3');

#Pass request and get response
my $res = $ua->request($req);

#Check response
if ($res->is_success) {
   print $res->content;
} else {
   print $res->status_line;
}
==================================================

Here is the code - almost exactly the same - from within the cgi program.
----------------------------------------------------------------------------
You can see this working, by calling
http://www.chalmers.com.au/~robert/cgi-bin/opensrs-test-client-2.21/cgi/reg_
system.cgi

Pick the same name as the sample. "chalmers ak" and register it as a new
user, put bogus info in the order form, and use "abasuccess" in place of a
VisaCard number. Leave the rest the same.

don't worry, its not live, and will crash after you click [ORDER] from the
Verify page. Thats the bit where the error is. The whol thing is in a test
env anyway,so don't worry.
The sequence.
check name
fill in details
verify
pay by visa. [ crash]
complete registration
end.

This is the code from the reg_system.cgi.

##############################  Makepayment via Visa
#################################################################
sub esecpay {
my (%HTML, $ua);
use LWP::UserAgent;
use LWP::Debug qw(+conns +trace +debug);
$ua = new LWP::UserAgent;
$ua->agent("AgentName/0.1 " . $ua->agent);

#create request
my $req = new HTTP::Request POST =>
'https://sec.aba.net.au/cgi-bin/service/authorise/test';
$req->content_type('application/x-www-form-urlencoded');
$req->content('&secParams=https://sec.aba.net.au/merchant/test/testpayment.p
rops &referenceID=xxx &cardType=ABA Test &cardNumber=abasuccess
&nameOnCard=Robert &expiryMonth=3 &expiryYear=2002 &amount=45.00
&resultURL=http://www.chalmers.com.au/~robert/allvars.php3');

#Pass request and get response
my $res = $ua->request($req);

#Check response
if ($res->is_success) {
   print $res->content;
} else {
   print $res->status_line;
}

}
#################################  end of esecpay
################################################################


thanks so much for any help in trying to understand why it wont proceed ?

Robert


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About