package PayPalNVP; # Name Value Pair API use strict; use warnings; use LWP::UserAgent; use HTTP::Request::Common qw(POST); use CGI; use Data::Dumper; sub new{ my $class = shift; my %in = ( USER => 'sdk-three_api1.sdk.com', PWD => 'QFZCWN5HZM8VBG7Q', VERSION => '2.3', SIGNATURE => 'A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU', URL => 'https://api-3t.sandbox.paypal.com/nvp', @_ ); my $self = bless{}, $class; return eval{ $self->{BASE} = \%in; $self->{UA} = LWP::UserAgent->new; $self; }; } sub test{ my $self = shift; my $req = POST $self->{BASE}{URL}, Content => [ USER => $self->{BASE}{USER}, PWD => $self->{BASE}{PWD}, VERSION => $self->{BASE}{VERSION}, SIGNATURE => $self->{BASE}{SIGNATURE}, METHOD => 'SetExpressCheckout', AMT => '10.00', CURRENCYCODE => 'EUR', RETURNURL => 'http://example.com', CANCELURL => 'http://example.com', ]; my $res = $self->{UA}->request($req); # res = Response my $query = CGI->new($res->content); # parse name value pairs my %h = map{ $_ => $query->param($_) }$query->param; print Dumper \%h; } 1;################################################################################################## package main; use strict; use warnings; my $ppa = PayPalNVP->new or die $@; $ppa->test;