Subject: | Business-PayPal-API-0.50 - Multiple Line Items |
Date: | Tue, 31 Jul 2007 16:13:57 -0500 |
To: | <bug-Business-PayPal-API [...] rt.cpan.org> |
From: | "Simpson" <drewsimpson [...] bellsouth.net> |
PaymentItem is an array when multiple items in cart:
$VAR1 = {
'Body' => {
'GetTransactionDetailsResponse' => {
'Build' => '1.0006',
'Version' =>
'2.000000',
'Timestamp' =>
'2007-07-31T20:42:03Z',
'PaymentTransactionDetails' => bless( {
'PaymentItemInfo' => bless( {
'PaymentItem' => [
bless( {
'Number' => '20952',
'SalesTax' => '',
'Quantity' => '1',
'Name' => 'line item description for 20952'
},
'PaymentItemType' ),
bless( {
'Number' => '11473',
'SalesTax' => '',
'Quantity' => '2',
'Name' => 'line item description for 11473'
},
'PaymentItemType' )
],
'Memo' => '',
Possible solution:
sub getFields {
my $self = shift;
my $som = shift;
my $path = shift;
my $response = shift;
my $fields = shift;
return unless $som;
for my $field ( keys %$fields )
{
# 7/31/07 - comment out original
#if( my $value = $som->valueof("$path/$fields->{$field}") ) {
# $response->{$field} = $value;
#}
# 7/31/07 - set to array if multiple matches
my @vals = ();
for my $value ( $som->valueof("$path/$fields->{$field}") )
{
push @vals, $value;
$response->{$field} = $value;
}
$response->{$field} = \@vals if $#vals > 0;
}
}
Message body is not shown because it is too large.