Thanks, its getting there :)
my $user = 'xxxx';
my $password = 'xxx';
my $signature = 'xxx';
my $application_id = 'APP-80W284485P519543T';
my $url = 'https://svcs.sandbox.paypal.com/AdaptivePayments
+/Pay';
my $ua = LWP::UserAgent->new();
my $headers = HTTP::Headers->new(
'X-PAYPAL-SECURITY-USERID' => $user,
'X-PAYPAL-SECURITY-PASSWORD' => $password,
'X-PAYPAL-SECURITY-SIGNATURE' => $signature,
'X-PAYPAL-APPLICATION-ID' => $application_id,
'X-PAYPAL-DEVICE-IPADDRESS' => $ENV{REMOTE_ADDR},
'X-PAYPAL-REQUEST-DATA-FORMAT' => 'JSON',
'X-PAYPAL-RESPONSE-DATA-FORMAT' => 'JSON'
);
my $json_var = {
requestEnvelope => {
detailLevel => "ReturnAll",
errorLanguage => "en_US",
},
actionType => "PAY",
currencyCode => "USD",
receiverList => {
receiver => [
{
amount => 5,
email => 'andy.newby@gmail.com',
totalShipping => 10
},
{
amount => 15,
email => 'foobar@gmail.com'
}
],
},
returnUrl => 'http://paypal.angelleye.com/paypal/class/1.2/Pay
+_Return.php',
cancelUrl => 'http://paypal.angelleye.com/paypal/class/1.2/Pay
+_Cancel.php'
};
use JSON;
my $new_json = JSON::to_json($json_var);
# print "FOO: $new_json \n\n";
my $request = HTTP::Request->new( 'POST', $url, $headers, $new_json )
+;
my $response = $ua->request( $request );
#print $response->status_line, "\n";
my $json_returned = decode_json($response->decoded_content);
print qq|Location: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_
+ap-payment&paykey=$json_returned->{payKey} \n\n|;
The only thing I can't figure out now, is how to get a shipping price in per person. I guess I could just add it into the total cost, but I think people would prefer to see it as a separate field.
Any ideas on that one? (not sure how familiar you are with this payment system) |