Tidy everything.

This commit is contained in:
Olaf Alders 2014-03-22 22:31:50 -04:00
parent a722bb555c
commit 3878e90817
24 changed files with 1520 additions and 1205 deletions

2
.gitignore vendored
View file

@ -1,4 +1,6 @@
.tidyall.d/
Business-PayPal-API-* Business-PayPal-API-*
auth.txt auth.txt
blib blib
perltidy.LOG
pm_to_blib pm_to_blib

View file

@ -4,7 +4,7 @@ use 5.008001;
use strict; use strict;
use warnings; use warnings;
use SOAP::Lite 0.67; # +trace => 'all'; use SOAP::Lite 0.67; # +trace => 'all';
use Carp qw(carp); use Carp qw(carp);
our $Debug = 0; our $Debug = 0;
@ -14,23 +14,23 @@ our $Debug = 0;
## NOTE: type definitions, at which point this module will become much ## NOTE: type definitions, at which point this module will become much
## NOTE: smaller (or non-existent). ## NOTE: smaller (or non-existent).
sub C_api_sandbox () { 'https://api.sandbox.paypal.com/2.0/' } sub C_api_sandbox () {'https://api.sandbox.paypal.com/2.0/'}
sub C_api_sandbox_3t () { 'https://api-3t.sandbox.paypal.com/2.0/' } sub C_api_sandbox_3t () {'https://api-3t.sandbox.paypal.com/2.0/'}
sub C_api_live () { 'https://api.paypal.com/2.0/' } sub C_api_live () {'https://api.paypal.com/2.0/'}
sub C_api_live_3t () { 'https://api-3t.paypal.com/2.0/' } sub C_api_live_3t () {'https://api-3t.paypal.com/2.0/'}
sub C_xmlns_pp () { 'urn:ebay:api:PayPalAPI' } sub C_xmlns_pp () {'urn:ebay:api:PayPalAPI'}
sub C_xmlns_ebay () { 'urn:ebay:apis:eBLBaseComponents' } sub C_xmlns_ebay () {'urn:ebay:apis:eBLBaseComponents'}
sub C_version () { '61.0' } ## 3.0 adds RecurringPayments sub C_version () {'61.0'} ## 3.0 adds RecurringPayments
## this is an inside-out object. Make sure you 'delete' additional ## this is an inside-out object. Make sure you 'delete' additional
## members in DESTROY() as you add them. ## members in DESTROY() as you add them.
my %Soap; my %Soap;
my %Header; my %Header;
my %H_PKCS12File; ## path to certificate file (pkc12) my %H_PKCS12File; ## path to certificate file (pkc12)
my %H_PKCS12Password; ## password for certificate file (pkc12) my %H_PKCS12Password; ## password for certificate file (pkc12)
my %H_CertFile; ## PEM certificate my %H_CertFile; ## PEM certificate
my %H_KeyFile; ## PEM private key my %H_KeyFile; ## PEM private key
sub import { sub import {
my $self = shift; my $self = shift;
@ -38,23 +38,26 @@ sub import {
for my $module ( @modules ) { for my $module ( @modules ) {
eval( "use Business::PayPal::API::$module;" ); eval( "use Business::PayPal::API::$module;" );
if( $@ ) { if ( $@ ) {
warn $@; warn $@;
next; next;
} }
## import 'exported' subroutines into our namespace ## import 'exported' subroutines into our namespace
no strict 'refs'; no strict 'refs';
for my $sub ( @{"Business::PayPal::API::" . $module . "::EXPORT_OK"} ) { for my $sub (
*{"Business::PayPal::API::" . $sub} = *{"Business::PayPal::API::" . $module . "::" . $sub}; @{ "Business::PayPal::API::" . $module . "::EXPORT_OK" } )
{
*{ "Business::PayPal::API::" . $sub }
= *{ "Business::PayPal::API::" . $module . "::" . $sub };
} }
} }
} }
sub new { sub new {
my $class = shift; my $class = shift;
my %args = @_; my %args = @_;
my $self = bless \(my $fake), $class; my $self = bless \( my $fake ), $class;
## if you add new args, be sure to update the test file's @variables array ## if you add new args, be sure to update the test file's @variables array
$args{Username} ||= ''; $args{Username} ||= '';
@ -62,35 +65,43 @@ sub new {
$args{Signature} ||= ''; $args{Signature} ||= '';
$args{Subject} ||= ''; $args{Subject} ||= '';
$args{sandbox} = 1 unless exists $args{sandbox}; $args{sandbox} = 1 unless exists $args{sandbox};
$args{timeout} ||= 0; $args{timeout} ||= 0;
$H_PKCS12File{$self} = $args{PKCS12File} || ''; $H_PKCS12File{$self} = $args{PKCS12File} || '';
$H_PKCS12Password{$self} = $args{PKCS12Password} || ''; $H_PKCS12Password{$self} = $args{PKCS12Password} || '';
$H_CertFile{$self} = $args{CertFile} || ''; $H_CertFile{$self} = $args{CertFile} || '';
$H_KeyFile{$self} = $args{KeyFile} || ''; $H_KeyFile{$self} = $args{KeyFile} || '';
my $proxy = ($args{sandbox} my $proxy = (
? ($args{Signature} $args{sandbox}
? C_api_sandbox_3t ? ( $args{Signature}
: C_api_sandbox) ? C_api_sandbox_3t
: ($args{Signature} : C_api_sandbox
? C_api_live_3t )
: C_api_live) : ( $args{Signature}
); ? C_api_live_3t
: C_api_live
)
);
$Soap{$self} = SOAP::Lite->proxy( $proxy, timeout => $args{timeout} )->uri( C_xmlns_pp ); $Soap{$self} = SOAP::Lite->proxy( $proxy, timeout => $args{timeout} )
->uri( C_xmlns_pp );
$Header{$self} = SOAP::Header $Header{$self} = SOAP::Header->name(
->name( RequesterCredentials => \SOAP::Header->value RequesterCredentials => \SOAP::Header->value(
( SOAP::Data->name( Credentials => \SOAP::Data->value SOAP::Data->name(
( SOAP::Data->name( Username => $args{Username} )->type(''), Credentials => \SOAP::Data->value(
SOAP::Data->name( Password => $args{Password} )->type(''), SOAP::Data->name( Username => $args{Username} )
SOAP::Data->name( Signature => $args{Signature} )->type(''), ->type( '' ),
SOAP::Data->name( Subject => $args{Subject} )->type(''), SOAP::Data->name( Password => $args{Password} )
), ->type( '' ),
)->attr( {xmlns => C_xmlns_ebay} ) SOAP::Data->name( Signature => $args{Signature} )
) ->type( '' ),
)->attr( {xmlns => C_xmlns_pp} )->mustUnderstand(1); SOAP::Data->name( Subject => $args{Subject} )->type( '' ),
),
)->attr( { xmlns => C_xmlns_ebay } )
)
)->attr( { xmlns => C_xmlns_pp } )->mustUnderstand( 1 );
return $self; return $self;
} }
@ -106,57 +117,65 @@ sub DESTROY {
delete $H_CertFile{$self}; delete $H_CertFile{$self};
delete $H_KeyFile{$self}; delete $H_KeyFile{$self};
my $super = $self->can("SUPER::DESTROY"); my $super = $self->can( "SUPER::DESTROY" );
goto &$super if $super; goto &$super if $super;
} }
sub version_req { sub version_req {
return SOAP::Data->name( Version => C_version ) return SOAP::Data->name( Version => C_version )->type( 'xs:string' )
->type('xs:string')->attr( {xmlns => C_xmlns_ebay} ); ->attr( { xmlns => C_xmlns_ebay } );
} }
sub doCall { sub doCall {
my $self = shift; my $self = shift;
my $method_name = shift; my $method_name = shift;
my $request = shift; my $request = shift;
my $method = SOAP::Data->name( $method_name )->attr( {xmlns => C_xmlns_pp} ); my $method
= SOAP::Data->name( $method_name )->attr( { xmlns => C_xmlns_pp } );
my $som; my $som;
{ {
$H_PKCS12File{$self} and local $ENV{HTTPS_PKCS12_FILE} = $H_PKCS12File{$self}; $H_PKCS12File{$self}
$H_PKCS12Password{$self} and local $ENV{HTTPS_PKCS12_PASSWORD} = $H_PKCS12Password{$self}; and local $ENV{HTTPS_PKCS12_FILE} = $H_PKCS12File{$self};
$H_CertFile{$self} and local $ENV{HTTPS_CERT_FILE} = $H_CertFile{$self}; $H_PKCS12Password{$self}
$H_KeyFile{$self} and local $ENV{HTTPS_KEY_FILE} = $H_KeyFile{$self}; and local $ENV{HTTPS_PKCS12_PASSWORD} = $H_PKCS12Password{$self};
$H_CertFile{$self}
and local $ENV{HTTPS_CERT_FILE} = $H_CertFile{$self};
$H_KeyFile{$self} and local $ENV{HTTPS_KEY_FILE} = $H_KeyFile{$self};
if( $Debug ) { if ( $Debug ) {
print STDERR SOAP::Serializer->envelope(method => $method, print STDERR SOAP::Serializer->envelope(
$Header{$self}, $request), "\n"; method => $method,
} $Header{$self}, $request
),
"\n";
}
# $Soap{$self}->readable( $Debug ); # $Soap{$self}->readable( $Debug );
# $Soap{$self}->outputxml( $Debug ); # $Soap{$self}->outputxml( $Debug );
no warnings 'redefine'; no warnings 'redefine';
local *SOAP::Deserializer::typecast = sub {shift; return shift}; local *SOAP::Deserializer::typecast = sub { shift; return shift };
eval { eval {
$som = $Soap{$self}->call( $Header{$self}, $method => $request ); $som = $Soap{$self}->call( $Header{$self}, $method => $request );
}; };
if( $@ ) { if ( $@ ) {
carp $@; carp $@;
return; return;
} }
} }
if( $Debug ) { if ( $Debug ) {
## FIXME: would be nicer to dump a SOM to XML, but how to do that? ## FIXME: would be nicer to dump a SOM to XML, but how to do that?
require Data::Dumper; require Data::Dumper;
print STDERR Data::Dumper::Dumper($som->envelope); print STDERR Data::Dumper::Dumper( $som->envelope );
} }
if( ref($som) && $som->fault ) { if ( ref( $som ) && $som->fault ) {
carp "Fault: " . $som->faultstring carp "Fault: "
. ( $som->faultdetail ? " (" . $som->faultdetail . ")" : '' ) . $som->faultstring
. ( $som->faultdetail ? " (" . $som->faultdetail . ")" : '' )
. "\n"; . "\n";
return; return;
} }
@ -165,27 +184,28 @@ sub doCall {
} }
sub getFieldsList { sub getFieldsList {
my $self = shift; my $self = shift;
my $som = shift; my $som = shift;
my $path = shift; my $path = shift;
my $fields = shift; my $fields = shift;
return unless $som; return unless $som;
my %trans_id = (); my %trans_id = ();
my @records = (); my @records = ();
for my $rec ( $som->valueof($path) ) { for my $rec ( $som->valueof( $path ) ) {
my %response = (); my %response = ();
@response{keys %$fields} = @{$rec}{keys %$fields}; @response{ keys %$fields } = @{$rec}{ keys %$fields };
## avoid duplicates ## avoid duplicates
if( defined $response{TransactionID}) { if ( defined $response{TransactionID} ) {
if( $trans_id{$response{TransactionID}}) { if ( $trans_id{ $response{TransactionID} } ) {
next; next;
} else { }
$trans_id{$response{TransactionID}} = 1; else {
} $trans_id{ $response{TransactionID} } = 1;
} }
}
push @records, \%response; push @records, \%response;
} }
@ -193,11 +213,11 @@ sub getFieldsList {
} }
sub getFields { sub getFields {
my $self = shift; my $self = shift;
my $som = shift; my $som = shift;
my $path = shift; my $path = shift;
my $response = shift; my $response = shift;
my $fields = shift; my $fields = shift;
return unless $som; return unless $som;
@ -221,10 +241,10 @@ sub getFields {
## it. ## it.
for my $field ( keys %$fields ) { for my $field ( keys %$fields ) {
my @vals = grep { defined } $som->valueof("$path/$fields->{$field}"); my @vals = grep {defined} $som->valueof( "$path/$fields->{$field}" );
next unless @vals; next unless @vals;
if( scalar(@vals) == 1 ) { if ( scalar( @vals ) == 1 ) {
$response->{$field} = $vals[0]; $response->{$field} = $vals[0];
} }
else { else {
@ -234,33 +254,36 @@ sub getFields {
} }
sub getBasic { sub getBasic {
my $self = shift; my $self = shift;
my $som = shift; my $som = shift;
my $path = shift; my $path = shift;
my $details = shift; my $details = shift;
return unless $som; return unless $som;
for my $field ( qw( Ack Timestamp CorrelationID Version Build ) ) { for my $field ( qw( Ack Timestamp CorrelationID Version Build ) ) {
$details->{$field} = $som->valueof("$path/$field") || ''; $details->{$field} = $som->valueof( "$path/$field" ) || '';
} }
return $details->{Ack} =~ /Success/; return $details->{Ack} =~ /Success/;
} }
sub getErrors { sub getErrors {
my $self = shift; my $self = shift;
my $som = shift; my $som = shift;
my $path = shift; my $path = shift;
my $details = shift; my $details = shift;
return unless $som; return unless $som;
my @errors = (); my @errors = ();
for my $enode ( $som->valueof("$path/Errors") ) { for my $enode ( $som->valueof( "$path/Errors" ) ) {
push @errors, { LongMessage => $enode->{LongMessage}, push @errors,
ErrorCode => $enode->{ErrorCode}, }; {
LongMessage => $enode->{LongMessage},
ErrorCode => $enode->{ErrorCode},
};
} }
$details->{Errors} = \@errors; $details->{Errors} = \@errors;

View file

@ -5,52 +5,57 @@ use strict;
use warnings; use warnings;
use SOAP::Lite 0.67; use SOAP::Lite 0.67;
#use SOAP::Lite +trace => 'debug'; #use SOAP::Lite +trace => 'debug';
use Business::PayPal::API (); use Business::PayPal::API ();
our @ISA = qw(Business::PayPal::API); our @ISA = qw(Business::PayPal::API);
our @EXPORT_OK = qw(DoAuthorizationRequest); our @EXPORT_OK = qw(DoAuthorizationRequest);
sub DoAuthorizationRequest { sub DoAuthorizationRequest {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my %types = ( TransactionID => 'xs:string', my %types = (
Amount => 'ebl:BasicAmountType',); TransactionID => 'xs:string',
Amount => 'ebl:BasicAmountType',
);
$args{currencyID} ||= 'USD'; $args{currencyID} ||= 'USD';
my @ref_trans = my @ref_trans = (
($self->version_req, $self->version_req,
SOAP::Data->name( TransactionID => $args{TransactionID} )->type($types{TransactionID}),); SOAP::Data->name( TransactionID => $args{TransactionID} )
->type( $types{TransactionID} ),
);
push @ref_trans, push @ref_trans,
SOAP::Data->name( Amount => $args{Amount} ) SOAP::Data->name( Amount => $args{Amount} )->type( $types{Amount} )
->type( $types{Amount} ) ->attr( { currencyID => $args{currencyID} } );
->attr( { currencyID => $args{currencyID} } );
my $request
= SOAP::Data->name(
my $request = SOAP::Data->name DoAuthorizationRequest => \SOAP::Data->value( @ref_trans ) )
( DoAuthorizationRequest => \SOAP::Data->value( @ref_trans ) ) ->type( "ns:AuthorizationRequestType" );
->type("ns:AuthorizationRequestType");
my $som = $self->doCall( DoAuthorizationReq => $request ) my $som = $self->doCall( DoAuthorizationReq => $request )
or return; or return;
my $path = '/Envelope/Body/DoAuthorizationResponse'; my $path = '/Envelope/Body/DoAuthorizationResponse';
my %response = (); my %response = ();
unless( $self->getBasic($som, $path, \%response) ) { unless ( $self->getBasic( $som, $path, \%response ) ) {
$self->getErrors($som, $path, \%response); $self->getErrors( $som, $path, \%response );
return %response; return %response;
} }
$self->getFields($som, $path, \%response, $self->getFields(
{ TransactionID => 'TransactionID', $som, $path,
Amount => 'Amount', } \%response,
); { TransactionID => 'TransactionID',
Amount => 'Amount',
}
);
return %response; return %response;
} }

View file

@ -5,10 +5,11 @@ use strict;
use warnings; use warnings;
use SOAP::Lite 0.67; use SOAP::Lite 0.67;
#use SOAP::Lite +trace => 'debug'; #use SOAP::Lite +trace => 'debug';
use Business::PayPal::API (); use Business::PayPal::API ();
our @ISA = qw(Business::PayPal::API); our @ISA = qw(Business::PayPal::API);
our @EXPORT_OK = qw(DoCaptureRequest); our @EXPORT_OK = qw(DoCaptureRequest);
sub DoCaptureRequest { sub DoCaptureRequest {
@ -16,66 +17,70 @@ sub DoCaptureRequest {
my %args = @_; my %args = @_;
my %types = ( my %types = (
AuthorizationID => 'xs:string', AuthorizationID => 'xs:string',
#The inclusion of the "ebl:CompleteCodeType" here, or any other reasonable type, #The inclusion of the "ebl:CompleteCodeType" here, or any other reasonable type,
#causes and error. Assigning a null string allows the module to work normally #causes and error. Assigning a null string allows the module to work normally
#with the exception that testing for "Success" fails, one must test for not #with the exception that testing for "Success" fails, one must test for not
#being a "Failure"... there may be a life lesson here. #being a "Failure"... there may be a life lesson here.
CompleteType => '', CompleteType => '',
Amount => 'ebl:BasicAmountType', Amount => 'ebl:BasicAmountType',
Note => 'xs:string', Note => 'xs:string',
); );
$args{currencyID} ||= 'USD'; $args{currencyID} ||= 'USD';
$args{CompleteType} ||= 'Complete'; $args{CompleteType} ||= 'Complete';
my @ref_trans = my @ref_trans = (
( $self->version_req,
$self->version_req, SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )->type($types{AuthorizationID}), ->type( $types{AuthorizationID} ),
SOAP::Data->name( CompleteType => $args{CompleteType} )->type($types{CompleteType}), SOAP::Data->name( CompleteType => $args{CompleteType} )
); ->type( $types{CompleteType} ),
);
if( $args{Amount} ) { if ( $args{Amount} ) {
push @ref_trans, push @ref_trans,
SOAP::Data->name( Amount => $args{Amount} ) SOAP::Data->name( Amount => $args{Amount} )
->type( $types{Amount} ) ->type( $types{Amount} )
->attr( { currencyID => $args{currencyID} } ) ->attr( { currencyID => $args{currencyID} } );
} }
my $request = SOAP::Data->name my $request
( DoCaptureRequest => \SOAP::Data->value( @ref_trans ) ) = SOAP::Data->name(
->type("ns:DoCaptureRequestType"); DoCaptureRequest => \SOAP::Data->value( @ref_trans ) )
->type( "ns:DoCaptureRequestType" );
my $som = $self->doCall( DoCaptureReq => $request ) my $som = $self->doCall( DoCaptureReq => $request )
or return; or return;
my $path = '/Envelope/Body/DoCaptureResponse'; my $path = '/Envelope/Body/DoCaptureResponse';
my %response = (); my %response = ();
unless( $self->getBasic($som, $path, \%response) ) { unless ( $self->getBasic( $som, $path, \%response ) ) {
$self->getErrors($som, $path, \%response); $self->getErrors( $som, $path, \%response );
return %response; return %response;
} }
$path .= '/DoCaptureResponseDetails/PaymentInfo'; $path .= '/DoCaptureResponseDetails/PaymentInfo';
$self->getFields($som, $path, \%response, $self->getFields(
{ $som, $path,
TransactionID => 'TransactionID', \%response,
ParentTransactionID => 'ParentTransactionID', { TransactionID => 'TransactionID',
ReceiptID => 'ReceiptID', ParentTransactionID => 'ParentTransactionID',
TransactionType => 'TransactionType', ReceiptID => 'ReceiptID',
PaymentType => 'PaymentType', TransactionType => 'TransactionType',
PaymentDate => 'PaymentDate', PaymentType => 'PaymentType',
GrossAmount => 'GrossAmount', PaymentDate => 'PaymentDate',
FeeAmount => 'FeeAmount', GrossAmount => 'GrossAmount',
SettleAmount => 'SettleAmount', FeeAmount => 'FeeAmount',
TaxAmount => 'TaxAmount', SettleAmount => 'SettleAmount',
ExchangeRate => 'ExchangeRate', TaxAmount => 'TaxAmount',
PaymentStatus => 'PaymentStatus', ExchangeRate => 'ExchangeRate',
PendingReason => 'PendingReason', PaymentStatus => 'PaymentStatus',
ReasonCode => 'ReasonCode', PendingReason => 'PendingReason',
} ReasonCode => 'ReasonCode',
); }
);
return %response; return %response;
} }

View file

@ -5,139 +5,199 @@ use strict;
use warnings; use warnings;
use SOAP::Lite; use SOAP::Lite;
#use SOAP::Lite +trace => 'debug'; #use SOAP::Lite +trace => 'debug';
use Business::PayPal::API (); use Business::PayPal::API ();
our @ISA = qw(Business::PayPal::API); our @ISA = qw(Business::PayPal::API);
our @EXPORT_OK = qw(DoDirectPaymentRequest); our @EXPORT_OK = qw(DoDirectPaymentRequest);
sub DoDirectPaymentRequest { sub DoDirectPaymentRequest {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my %types =( PaymentAction => '', my %types = (
# Payment Detail PaymentAction => '',
OrderTotal => 'xs:string',
ItemTotal => 'xsd:string',
ShippingTotal => 'xsd:string',
TaxTotal => 'xsd:string',
InvoiceID => 'xsd:string',
ButtonSource => 'xsd:string',
# Credit Card
CreditCardType => '',
CreditCardNumber => 'xsd:string',
ExpMonth => 'xs:int',
ExpYear => 'xs:int',
# CardOwner
Payer => 'ns:EmailAddressType',
# Payer Name
FirstName => 'xs:string',
LastName => 'xs:string',
# Payer Address
Street1 => 'xs:string',
Street2 => 'xs:string',
CityName => 'xs:string',
StateOrProvince => 'xs:string',
Country => 'xs:string',
PostalCode => 'xs:string',
# Shipping Address
ShipToName => 'xs:string',
ShipToStreet1 => 'xs:string',
ShipToStreet2 => 'xs:string',
ShipToCityName => 'xs:string',
ShipToStateOrProvince => 'xs:string',
ShipToCountry => 'xs:string',
ShipToPostalCode => 'xs:string',
# Misc
CVV2 => 'xs:string',
IPAddress => 'xs:string',
MerchantSessionId => 'xs:string',
);
$args{currencyID} ||= 'USD'; # Payment Detail
OrderTotal => 'xs:string',
ItemTotal => 'xsd:string',
ShippingTotal => 'xsd:string',
TaxTotal => 'xsd:string',
InvoiceID => 'xsd:string',
ButtonSource => 'xsd:string',
# Credit Card
CreditCardType => '',
CreditCardNumber => 'xsd:string',
ExpMonth => 'xs:int',
ExpYear => 'xs:int',
# CardOwner
Payer => 'ns:EmailAddressType',
# Payer Name
FirstName => 'xs:string',
LastName => 'xs:string',
# Payer Address
Street1 => 'xs:string',
Street2 => 'xs:string',
CityName => 'xs:string',
StateOrProvince => 'xs:string',
Country => 'xs:string',
PostalCode => 'xs:string',
# Shipping Address
ShipToName => 'xs:string',
ShipToStreet1 => 'xs:string',
ShipToStreet2 => 'xs:string',
ShipToCityName => 'xs:string',
ShipToStateOrProvince => 'xs:string',
ShipToCountry => 'xs:string',
ShipToPostalCode => 'xs:string',
# Misc
CVV2 => 'xs:string',
IPAddress => 'xs:string',
MerchantSessionId => 'xs:string',
);
$args{currencyID} ||= 'USD';
$args{PaymentAction} ||= 'Sale'; $args{PaymentAction} ||= 'Sale';
#Assemble Credit Card Information #Assemble Credit Card Information
my @payername = ( SOAP::Data->name(FirstName => $args{FirstName}), my @payername = (
SOAP::Data->name(LastName => $args{LastName}), SOAP::Data->name( FirstName => $args{FirstName} ),
); SOAP::Data->name( LastName => $args{LastName} ),
);
my @payeraddr = ( SOAP::Data->name(Street1 => $args{Street1} )->type($types{Street1}), my @payeraddr = (
SOAP::Data->name(Street2 => $args{Street2} )->type($types{Street2}), SOAP::Data->name( Street1 => $args{Street1} )
SOAP::Data->name(CityName => $args{CityName} )->type($types{CityName}), ->type( $types{Street1} ),
SOAP::Data->name(StateOrProvince => $args{StateOrProvince} )->type($types{StateOrProvince}), SOAP::Data->name( Street2 => $args{Street2} )
SOAP::Data->name(Country => $args{Country} )->type($types{Country}), ->type( $types{Street2} ),
SOAP::Data->name(PostalCode => $args{PostalCode} )->type($types{PostalCode}), SOAP::Data->name( CityName => $args{CityName} )
); ->type( $types{CityName} ),
SOAP::Data->name( StateOrProvince => $args{StateOrProvince} )
->type( $types{StateOrProvince} ),
SOAP::Data->name( Country => $args{Country} )
->type( $types{Country} ),
SOAP::Data->name( PostalCode => $args{PostalCode} )
->type( $types{PostalCode} ),
);
my @shipaddr = ( SOAP::Data->name(Name => $args{ShipToName})->type($types{ShipToName}), my @shipaddr = (
SOAP::Data->name(Street1 => $args{ShipToStreet1} )->type($types{ShipToStreet1}), SOAP::Data->name( Name => $args{ShipToName} )
SOAP::Data->name(Street2 => $args{ShipToStreet2} )->type($types{ShipToStreet2}), ->type( $types{ShipToName} ),
SOAP::Data->name(CityName => $args{ShipToCityName} )->type($types{ShipToCityName}), SOAP::Data->name( Street1 => $args{ShipToStreet1} )
SOAP::Data->name(StateOrProvince => $args{ShipToStateOrProvince} )->type($types{ShipToStateOrProvince}), ->type( $types{ShipToStreet1} ),
SOAP::Data->name(Country => $args{ShipToCountry} )->type($types{ShipToCountry}), SOAP::Data->name( Street2 => $args{ShipToStreet2} )
SOAP::Data->name(PostalCode => $args{ShipToPostalCode} )->type($types{ShipToPostalCode}), ->type( $types{ShipToStreet2} ),
); SOAP::Data->name( CityName => $args{ShipToCityName} )
->type( $types{ShipToCityName} ),
SOAP::Data->name( StateOrProvince => $args{ShipToStateOrProvince} )
->type( $types{ShipToStateOrProvince} ),
SOAP::Data->name( Country => $args{ShipToCountry} )
->type( $types{ShipToCountry} ),
SOAP::Data->name( PostalCode => $args{ShipToPostalCode} )
->type( $types{ShipToPostalCode} ),
);
my @ccard = ( SOAP::Data->name(CreditCardType => $args{CreditCardType})->type($types{CreditCardType}), my @ccard = (
SOAP::Data->name(CreditCardNumber => $args{CreditCardNumber})->type($types{CreditCardNumber}), SOAP::Data->name( CreditCardType => $args{CreditCardType} )
SOAP::Data->name(ExpMonth => $args{ExpMonth})->type($types{ExpMonth}), ->type( $types{CreditCardType} ),
SOAP::Data->name(ExpYear => $args{ExpYear})->type($types{ExpYear}), SOAP::Data->name( CreditCardNumber => $args{CreditCardNumber} )
); ->type( $types{CreditCardNumber} ),
SOAP::Data->name( ExpMonth => $args{ExpMonth} )
->type( $types{ExpMonth} ),
SOAP::Data->name( ExpYear => $args{ExpYear} )
->type( $types{ExpYear} ),
);
my @ccowner = ( SOAP::Data->name my @ccowner = (
(CardOwner => \SOAP::Data->value SOAP::Data->name(
( SOAP::Data->name(Payer => $args{Payer})->type($types{Payer}), CardOwner => \SOAP::Data->value(
SOAP::Data->name(PayerName => \SOAP::Data->value ( @payername )), SOAP::Data->name( Payer => $args{Payer} )
SOAP::Data->name(Address => \SOAP::Data->value( @payeraddr )), ->type( $types{Payer} ),
) SOAP::Data->name(
) PayerName => \SOAP::Data->value( @payername )
); ),
SOAP::Data->name(
Address => \SOAP::Data->value( @payeraddr )
),
)
)
);
push( @ccard, @ccowner); push( @ccard, @ccowner );
push( @ccard, SOAP::Data->name(CVV2 => $args{CVV2})->type($types{CVV2})); push( @ccard,
SOAP::Data->name( CVV2 => $args{CVV2} )->type( $types{CVV2} ) );
#Assemble Payment Details #Assemble Payment Details
my @paydetail = ( SOAP::Data->name(OrderTotal => $args{OrderTotal}) my @paydetail = (
->attr({currencyID=>$args{currencyID}})->type($types{currencyID}), SOAP::Data->name( OrderTotal => $args{OrderTotal} )
SOAP::Data->name(ItemTotal => $args{ItemTotal}) ->attr( { currencyID => $args{currencyID} } )
->attr({currencyID => $args{currencyID}})->type($types{currencyID}), ->type( $types{currencyID} ),
SOAP::Data->name(TaxTotal => $args{TaxTotal}) SOAP::Data->name( ItemTotal => $args{ItemTotal} )
->attr({currencyID => $args{currencyID}})->type($types{currencyID}), ->attr( { currencyID => $args{currencyID} } )
SOAP::Data->name(ShippingTotal => $args{ShippingTotal}) ->type( $types{currencyID} ),
->attr({currencyID => $args{currencyID}})->type($types{currencyID}), SOAP::Data->name( TaxTotal => $args{TaxTotal} )
SOAP::Data->name(ShipToAddress => \SOAP::Data->value( @shipaddr)), ->attr( { currencyID => $args{currencyID} } )
SOAP::Data->name(InvoiceID => $args{InvoiceID})->type($types{InvoiceID}), ->type( $types{currencyID} ),
SOAP::Data->name(ButtonSource => $args{ButtonSource})->type($types{ButtonSource}) SOAP::Data->name( ShippingTotal => $args{ShippingTotal} )
); ->attr( { currencyID => $args{currencyID} } )
->type( $types{currencyID} ),
SOAP::Data->name( ShipToAddress => \SOAP::Data->value( @shipaddr ) ),
SOAP::Data->name( InvoiceID => $args{InvoiceID} )
->type( $types{InvoiceID} ),
SOAP::Data->name( ButtonSource => $args{ButtonSource} )
->type( $types{ButtonSource} )
);
my @payreqdetail = ( SOAP::Data->name(PaymentAction => $args{PaymentAction})->type(''), my @payreqdetail = (
SOAP::Data->name(PaymentDetails =>\SOAP::Data->value( @paydetail )), SOAP::Data->name( PaymentAction => $args{PaymentAction} )->type( '' ),
SOAP::Data->name(CreditCard => \SOAP::Data->value( @ccard)), SOAP::Data->name(
SOAP::Data->name(IPAddress => $args{IPAddress})->type($types{IPAddress}), PaymentDetails => \SOAP::Data->value( @paydetail )
SOAP::Data->name(MerchantSessionId => $args{MerchantSessionId})->type($types{MerchantSessionId}), ),
); SOAP::Data->name( CreditCard => \SOAP::Data->value( @ccard ) ),
SOAP::Data->name( IPAddress => $args{IPAddress} )
->type( $types{IPAddress} ),
SOAP::Data->name( MerchantSessionId => $args{MerchantSessionId} )
->type( $types{MerchantSessionId} ),
);
#Assemble request #Assemble request
my @reqval = ( SOAP::Data->value($self->version_req), my @reqval = (
SOAP::Data->name( DoDirectPaymentRequestDetails => \SOAP::Data->value( @payreqdetail ))->attr({xmlns=>"urn:ebay:apis:eBLBaseComponents"}), SOAP::Data->value( $self->version_req ),
); SOAP::Data->name(
my $request = (SOAP::Data->name(DoDirectPaymentRequest => \SOAP::Data->value(@reqval)), ); DoDirectPaymentRequestDetails =>
my $som = $self->doCall( DoDirectPaymentReq => $request ) or return; \SOAP::Data->value( @payreqdetail )
my $path = '/Envelope/Body/DoDirectPaymentResponse'; )->attr( { xmlns => "urn:ebay:apis:eBLBaseComponents" } ),
);
my $request = (
SOAP::Data->name(
DoDirectPaymentRequest => \SOAP::Data->value( @reqval )
),
);
my $som = $self->doCall( DoDirectPaymentReq => $request ) or return;
my $path = '/Envelope/Body/DoDirectPaymentResponse';
my %response = (); my %response = ();
unless( $self->getBasic($som, $path, \%response) ) { unless ( $self->getBasic( $som, $path, \%response ) ) {
$self->getErrors($som, $path, \%response); $self->getErrors( $som, $path, \%response );
return %response; return %response;
} }
$self->getFields( $som, $path, \%response, { TransactionID => 'TransactionID', $self->getFields(
Amount => 'Amount', $som, $path,
AVSCode => 'AVSCode', \%response,
CVV2Code => 'CVV2Code', { TransactionID => 'TransactionID',
Timestamp => 'Timestamp', Amount => 'Amount',
} AVSCode => 'AVSCode',
); CVV2Code => 'CVV2Code',
Timestamp => 'Timestamp',
}
);
return %response; return %response;
} }

View file

@ -8,7 +8,8 @@ use SOAP::Lite 0.67;
use Business::PayPal::API (); use Business::PayPal::API ();
our @ISA = qw(Business::PayPal::API); our @ISA = qw(Business::PayPal::API);
our @EXPORT_OK = qw( SetExpressCheckout GetExpressCheckoutDetails DoExpressCheckoutPayment ); our @EXPORT_OK
= qw( SetExpressCheckout GetExpressCheckoutDetails DoExpressCheckoutPayment );
## if you specify an InvoiceID, PayPal seems to remember it and not ## if you specify an InvoiceID, PayPal seems to remember it and not
## allow you to bill twice with it. ## allow you to bill twice with it.
@ -16,33 +17,37 @@ sub SetExpressCheckout {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my %types = ( Token => 'ebl:ExpressCheckoutTokenType', my %types = (
OrderTotal => 'cc:BasicAmountType', Token => 'ebl:ExpressCheckoutTokenType',
currencyID => '', OrderTotal => 'cc:BasicAmountType',
MaxAmount => 'cc:BasicAmountType', currencyID => '',
OrderDescription => 'xs:string', MaxAmount => 'cc:BasicAmountType',
Custom => 'xs:string', OrderDescription => 'xs:string',
InvoiceID => 'xs:string', Custom => 'xs:string',
ReturnURL => 'xs:string', InvoiceID => 'xs:string',
CancelURL => 'xs:string', ReturnURL => 'xs:string',
Address => 'ebl:AddressType', CancelURL => 'xs:string',
ReqConfirmShipping => 'xs:string', Address => 'ebl:AddressType',
NoShipping => 'xs:string', ReqConfirmShipping => 'xs:string',
AddressOverride => 'xs:string', NoShipping => 'xs:string',
LocaleCode => 'xs:string', AddressOverride => 'xs:string',
PageStyle => 'xs:string', LocaleCode => 'xs:string',
'cpp-header-image' => 'xs:string', PageStyle => 'xs:string',
'cpp-header-border-color' => 'xs:string', 'cpp-header-image' => 'xs:string',
'cpp-header-back-color' => 'xs:string', 'cpp-header-border-color' => 'xs:string',
'cpp-payflow-color' => 'xs:string', 'cpp-header-back-color' => 'xs:string',
PaymentAction => '', 'cpp-payflow-color' => 'xs:string',
BuyerEmail => 'ebl:EmailAddressType' ); PaymentAction => '',
BuyerEmail => 'ebl:EmailAddressType'
);
## billing agreement details type ## billing agreement details type
my %badtypes = ( BillingType => '', #'ns:BillingCodeType', my %badtypes = (
BillingAgreementDescription => 'xs:string', BillingType => '', #'ns:BillingCodeType',
PaymentType => '', #'ns:MerchantPullPaymentCodeType', BillingAgreementDescription => 'xs:string',
BillingAgreementCustom => 'xs:string', ); PaymentType => '', #'ns:MerchantPullPaymentCodeType',
BillingAgreementCustom => 'xs:string',
);
## set some defaults ## set some defaults
$args{PaymentAction} ||= 'Sale'; $args{PaymentAction} ||= 'Sale';
@ -50,110 +55,124 @@ sub SetExpressCheckout {
my $currencyID = delete $args{currencyID}; my $currencyID = delete $args{currencyID};
## SetExpressCheckoutRequestDetails ## SetExpressCheckoutRequestDetails
my @secrd = my @secrd = (
( SOAP::Data->name( OrderTotal => delete $args{OrderTotal} )->type( $types{OrderTotal} ) SOAP::Data->name( OrderTotal => delete $args{OrderTotal} )
->attr( {currencyID => $currencyID, xmlns => $self->C_xmlns_ebay}), ->type( $types{OrderTotal} )->attr(
SOAP::Data->name( ReturnURL => delete $args{ReturnURL} )->type( $types{ReturnURL} ), { currencyID => $currencyID, xmlns => $self->C_xmlns_ebay }
SOAP::Data->name( CancelURL => delete $args{CancelURL} )->type( $types{CancelURL} ), ),
); SOAP::Data->name( ReturnURL => delete $args{ReturnURL} )
->type( $types{ReturnURL} ),
SOAP::Data->name( CancelURL => delete $args{CancelURL} )
->type( $types{CancelURL} ),
);
## add all the other fields ## add all the other fields
for my $field ( keys %types ) { for my $field ( keys %types ) {
next unless defined $args{$field}; next unless defined $args{$field};
if( $field eq 'MaxAmount' ) { if ( $field eq 'MaxAmount' ) {
push @secrd, SOAP::Data->name( $field => $args{$field} )->type( $types{$field} ) push @secrd,
->attr( {currencyID => $currencyID, xmlns => $self->C_xmlns_ebay} ); SOAP::Data->name( $field => $args{$field} )
->type( $types{$field} )
->attr(
{ currencyID => $currencyID, xmlns => $self->C_xmlns_ebay } );
} }
else { else {
push @secrd, SOAP::Data->name( $field => $args{$field} )->type( $types{$field} ); push @secrd,
SOAP::Data->name( $field => $args{$field} )
->type( $types{$field} );
} }
} }
my @btypes = (); my @btypes = ();
for my $field ( keys %badtypes ) { for my $field ( keys %badtypes ) {
next unless $args{$field}; next unless $args{$field};
push @btypes, SOAP::Data->name( $field => $args{$field} )->type( $badtypes{$field} ); push @btypes,
SOAP::Data->name( $field => $args{$field} )
->type( $badtypes{$field} );
} }
push @secrd, SOAP::Data->name( BillingAgreementDetails => \SOAP::Data->value(@btypes) ) push @secrd,
if $args{'BillingType'}; SOAP::Data->name(
BillingAgreementDetails => \SOAP::Data->value( @btypes ) )
my $request = SOAP::Data if $args{'BillingType'};
->name( SetExpressCheckoutRequest => \SOAP::Data->value
( $self->version_req,
SOAP::Data->name( SetExpressCheckoutRequestDetails => \SOAP::Data->value(@secrd) )
->attr( {xmlns => $self->C_xmlns_ebay} ),
)
)->type( 'ns:SetExpressCheckoutRequestType' );
my $request = SOAP::Data->name(
SetExpressCheckoutRequest => \SOAP::Data->value(
$self->version_req,
SOAP::Data->name(
SetExpressCheckoutRequestDetails =>
\SOAP::Data->value( @secrd )
)->attr( { xmlns => $self->C_xmlns_ebay } ),
)
)->type( 'ns:SetExpressCheckoutRequestType' );
my $som = $self->doCall( SetExpressCheckoutReq => $request ) my $som = $self->doCall( SetExpressCheckoutReq => $request )
or return; or return;
my $path = '/Envelope/Body/SetExpressCheckoutResponse'; my $path = '/Envelope/Body/SetExpressCheckoutResponse';
my %response = (); my %response = ();
unless( $self->getBasic($som, $path, \%response) ) { unless ( $self->getBasic( $som, $path, \%response ) ) {
$self->getErrors($som, $path, \%response); $self->getErrors( $som, $path, \%response );
return %response; return %response;
} }
$self->getFields($som, $path, \%response, { Token => 'Token' }); $self->getFields( $som, $path, \%response, { Token => 'Token' } );
return %response; return %response;
} }
sub GetExpressCheckoutDetails { sub GetExpressCheckoutDetails {
my $self = shift; my $self = shift;
my $token = shift; my $token = shift;
my $request = SOAP::Data my $request = SOAP::Data->name(
->name( GetExpressCheckoutDetailsRequest => \SOAP::Data->value GetExpressCheckoutDetailsRequest => \SOAP::Data->value(
( $self->version_req, $self->version_req,
SOAP::Data->name( Token => $token ) SOAP::Data->name( Token => $token )->type( 'xs:string' )
->type('xs:string')->attr( {xmlns => $self->C_xmlns_ebay} ), ->attr( { xmlns => $self->C_xmlns_ebay } ),
) )
)->type( 'ns:GetExpressCheckoutRequestType' ); )->type( 'ns:GetExpressCheckoutRequestType' );
my $som = $self->doCall( GetExpressCheckoutDetailsReq => $request ) my $som = $self->doCall( GetExpressCheckoutDetailsReq => $request )
or return; or return;
my $path = '/Envelope/Body/GetExpressCheckoutDetailsResponse'; my $path = '/Envelope/Body/GetExpressCheckoutDetailsResponse';
my %details = (); my %details = ();
unless( $self->getBasic($som, $path, \%details) ) { unless ( $self->getBasic( $som, $path, \%details ) ) {
$self->getErrors($som, $path, \%details); $self->getErrors( $som, $path, \%details );
return %details; return %details;
} }
$self->getFields($som, $self->getFields(
"$path/GetExpressCheckoutDetailsResponseDetails", $som,
\%details, "$path/GetExpressCheckoutDetailsResponseDetails",
{ Token => 'Token', \%details,
Custom => 'Custom', { Token => 'Token',
InvoiceID => 'InvoiceID', Custom => 'Custom',
ContactPhone => 'ContactPhone', InvoiceID => 'InvoiceID',
Payer => 'PayerInfo/Payer', ContactPhone => 'ContactPhone',
PayerID => 'PayerInfo/PayerID', Payer => 'PayerInfo/Payer',
PayerStatus => 'PayerInfo/PayerStatus', PayerID => 'PayerInfo/PayerID',
Salutation => 'PayerInfo/PayerName/Saluation', PayerStatus => 'PayerInfo/PayerStatus',
FirstName => 'PayerInfo/PayerName/FirstName', Salutation => 'PayerInfo/PayerName/Saluation',
MiddleName => 'PayerInfo/PayerName/MiddleName', FirstName => 'PayerInfo/PayerName/FirstName',
LastName => 'PayerInfo/PayerName/LastName', MiddleName => 'PayerInfo/PayerName/MiddleName',
NameSuffix => 'PayerInfo/PayerName/Suffix', LastName => 'PayerInfo/PayerName/LastName',
PayerBusiness => 'PayerInfo/PayerBusiness', NameSuffix => 'PayerInfo/PayerName/Suffix',
AddressStatus => 'PayerInfo/Address/AddressStatus', PayerBusiness => 'PayerInfo/PayerBusiness',
Name => 'PayerInfo/Address/Name', AddressStatus => 'PayerInfo/Address/AddressStatus',
Street1 => 'PayerInfo/Address/Street1', Name => 'PayerInfo/Address/Name',
Street2 => 'PayerInfo/Address/Street2', Street1 => 'PayerInfo/Address/Street1',
CityName => 'PayerInfo/Address/CityName', Street2 => 'PayerInfo/Address/Street2',
StateOrProvince => 'PayerInfo/Address/StateOrProvince', CityName => 'PayerInfo/Address/CityName',
PostalCode => 'PayerInfo/Address/PostalCode', StateOrProvince => 'PayerInfo/Address/StateOrProvince',
Country => 'PayerInfo/Address/Country', PostalCode => 'PayerInfo/Address/PostalCode',
PayerCountry => 'PayerInfo/PayerCountry', Country => 'PayerInfo/Address/Country',
} ); PayerCountry => 'PayerInfo/PayerCountry',
}
);
return %details; return %details;
} }
@ -162,64 +181,71 @@ sub DoExpressCheckoutPayment {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my %types = ( Token => 'xs:string', my %types = (
PaymentAction => '', ## NOTA BENE! Token => 'xs:string',
PayerID => 'ebl:UserIDType', PaymentAction => '', ## NOTA BENE!
currencyID => '', PayerID => 'ebl:UserIDType',
ReturnFMFDetails => 'xs:boolean', currencyID => '',
); ReturnFMFDetails => 'xs:boolean',
);
## PaymentDetails ## PaymentDetails
my %pd_types = ( OrderTotal => 'ebl:BasicAmountType', my %pd_types = (
OrderDescription => 'xs:string', OrderTotal => 'ebl:BasicAmountType',
ItemTotal => 'ebl:BasicAmountType', OrderDescription => 'xs:string',
ShippingTotal => 'ebl:BasicAmountType', ItemTotal => 'ebl:BasicAmountType',
HandlingTotal => 'ebl:BasicAmountType', ShippingTotal => 'ebl:BasicAmountType',
TaxTotal => 'ebl:BasicAmountType', HandlingTotal => 'ebl:BasicAmountType',
Custom => 'xs:string', TaxTotal => 'ebl:BasicAmountType',
InvoiceID => 'xs:string', Custom => 'xs:string',
ButtonSource => 'xs:string', InvoiceID => 'xs:string',
NotifyURL => 'xs:string', ButtonSource => 'xs:string',
); NotifyURL => 'xs:string',
);
## ShipToAddress ## ShipToAddress
my %st_types = ( ST_Name => 'xs:string', my %st_types = (
ST_Street1 => 'xs:string', ST_Name => 'xs:string',
ST_Street2 => 'xs:string', ST_Street1 => 'xs:string',
ST_CityName => 'xs:string', ST_Street2 => 'xs:string',
ST_StateOrProvince => 'xs:string', ST_CityName => 'xs:string',
ST_Country => 'xs:string', ST_StateOrProvince => 'xs:string',
ST_PostalCode => 'xs:string', ST_Country => 'xs:string',
); ST_PostalCode => 'xs:string',
);
##PaymentDetailsItem ##PaymentDetailsItem
my %pdi_types = ( PDI_Name => 'xs:string', my %pdi_types = (
PDI_Amount => 'ebl:BasicAmountType', PDI_Name => 'xs:string',
PDI_Number => 'xs:string', PDI_Amount => 'ebl:BasicAmountType',
PDI_Quantity => 'xs:string', PDI_Number => 'xs:string',
PDI_Tax => 'ebl:BasicAmountType', PDI_Quantity => 'xs:string',
); PDI_Tax => 'ebl:BasicAmountType',
);
$args{PaymentAction} ||= 'Sale'; $args{PaymentAction} ||= 'Sale';
$args{currencyID} ||= 'USD'; $args{currencyID} ||= 'USD';
my @payment_details = ( ); my @payment_details = ();
## push OrderTotal here and delete it (i.e., and all others that have special attrs) ## push OrderTotal here and delete it (i.e., and all others that have special attrs)
push @payment_details, SOAP::Data->name( OrderTotal => $args{OrderTotal} ) push @payment_details,
->type( $pd_types{OrderTotal} ) SOAP::Data->name( OrderTotal => $args{OrderTotal} )
->attr( { currencyID => $args{currencyID}, ->type( $pd_types{OrderTotal} )->attr(
xmlns => $self->C_xmlns_ebay } ); { currencyID => $args{currencyID},
xmlns => $self->C_xmlns_ebay
}
);
## don't process it again ## don't process it again
delete $pd_types{OrderTotal}; delete $pd_types{OrderTotal};
for my $field ( keys %pd_types ) { for my $field ( keys %pd_types ) {
if( $args{$field} ) { if ( $args{$field} ) {
push @payment_details, push @payment_details,
SOAP::Data->name( $field => $args{$field} ) SOAP::Data->name( $field => $args{$field} )
->type( $pd_types{$field} ); ->type( $pd_types{$field} );
} }
} }
## ##
@ -227,20 +253,19 @@ sub DoExpressCheckoutPayment {
## ##
my @ship_types = (); my @ship_types = ();
for my $field ( keys %st_types ) { for my $field ( keys %st_types ) {
if( $args{$field} ) { if ( $args{$field} ) {
(my $name = $field) =~ s/^ST_//; ( my $name = $field ) =~ s/^ST_//;
push @ship_types, push @ship_types,
SOAP::Data->name( $name => $args{$field} ) SOAP::Data->name( $name => $args{$field} )
->type( $st_types{$field} ); ->type( $st_types{$field} );
} }
} }
if( scalar @ship_types ) { if ( scalar @ship_types ) {
push @payment_details, push @payment_details,
SOAP::Data->name( ShipToAddress => \SOAP::Data->value SOAP::Data->name( ShipToAddress =>
( @ship_types )->type('ebl:AddressType') \SOAP::Data->value( @ship_types )->type( 'ebl:AddressType' )
->attr( {xmlns => $self->C_xmlns_ebay} ), ->attr( { xmlns => $self->C_xmlns_ebay } ), );
);
} }
## ##
@ -248,84 +273,93 @@ sub DoExpressCheckoutPayment {
## ##
my @payment_details_item = (); my @payment_details_item = ();
for my $field ( keys %pdi_types ) { for my $field ( keys %pdi_types ) {
if( $args{$field} ) { if ( $args{$field} ) {
(my $name = $field) =~ s/^PDI_//; ( my $name = $field ) =~ s/^PDI_//;
push @payment_details_item, push @payment_details_item,
SOAP::Data->name( $name => $args{$field} ) SOAP::Data->name( $name => $args{$field} )
->type( $pdi_types{$field} ); ->type( $pdi_types{$field} );
} }
} }
if( scalar @payment_details_item ) { if ( scalar @payment_details_item ) {
push @payment_details, push @payment_details,
SOAP::Data->name( PaymentDetailsItem => \SOAP::Data->value SOAP::Data->name(
( @payment_details_item )->type('ebl:PaymentDetailsItemType') PaymentDetailsItem => \SOAP::Data->value( @payment_details_item )
->attr( {xmlns => $self->C_xmlns_ebay} ), ->type( 'ebl:PaymentDetailsItemType' )
); ->attr( { xmlns => $self->C_xmlns_ebay } ), );
} }
## ##
## ExpressCheckoutPaymentDetails ## ExpressCheckoutPaymentDetails
## ##
my @express_details = ( my @express_details = (
SOAP::Data->name( Token => $args{Token} ) SOAP::Data->name( Token => $args{Token} )->type( $types{Token} )
->type($types{Token})->attr( {xmlns => $self->C_xmlns_ebay} ), ->attr( { xmlns => $self->C_xmlns_ebay } ),
SOAP::Data->name( PaymentAction => $args{PaymentAction} ) SOAP::Data->name( PaymentAction => $args{PaymentAction} )
->type($types{PaymentAction})->attr( {xmlns => $self->C_xmlns_ebay} ), ->type( $types{PaymentAction} )
SOAP::Data->name( PayerID => $args{PayerID} ) ->attr( { xmlns => $self->C_xmlns_ebay } ),
->type($types{PayerID})->attr( {xmlns => $self->C_xmlns_ebay} ), SOAP::Data->name( PayerID => $args{PayerID} )
SOAP::Data->name( PaymentDetails => \SOAP::Data->value ->type( $types{PayerID} )
( @payment_details )->type('ebl:PaymentDetailsType') ->attr( { xmlns => $self->C_xmlns_ebay } ),
->attr( {xmlns => $self->C_xmlns_ebay} ), SOAP::Data->name(
), PaymentDetails => \SOAP::Data->value( @payment_details )
SOAP::Data->name( ReturnFMFDetails => $args{ReturnFMFDetails} ) ->type( 'ebl:PaymentDetailsType' )
->type($types{ReturnFMFDetails})->attr( {xmlns => $self->C_xmlns_ebay} ), ); ->attr( { xmlns => $self->C_xmlns_ebay } ),
),
SOAP::Data->name( ReturnFMFDetails => $args{ReturnFMFDetails} )
->type( $types{ReturnFMFDetails} )
->attr( { xmlns => $self->C_xmlns_ebay } ),
);
## ##
## the main request object ## the main request object
## ##
my $request = SOAP::Data my $request = SOAP::Data->name(
->name( DoExpressCheckoutPaymentRequest => \SOAP::Data->value DoExpressCheckoutPaymentRequest => \SOAP::Data->value(
( $self->version_req, $self->version_req,
SOAP::Data->name( DoExpressCheckoutPaymentRequestDetails => \SOAP::Data->value SOAP::Data->name(
( @express_details )->type( 'ns:DoExpressCheckoutPaymentRequestDetailsType' ) DoExpressCheckoutPaymentRequestDetails =>
)->attr( {xmlns => $self->C_xmlns_ebay} ), \SOAP::Data->value( @express_details )
) ->type( 'ns:DoExpressCheckoutPaymentRequestDetailsType' )
); )->attr( { xmlns => $self->C_xmlns_ebay } ),
)
);
my $som = $self->doCall( DoExpressCheckoutPaymentReq => $request ) my $som = $self->doCall( DoExpressCheckoutPaymentReq => $request )
or return; or return;
my $path = '/Envelope/Body/DoExpressCheckoutPaymentResponse'; my $path = '/Envelope/Body/DoExpressCheckoutPaymentResponse';
my %response = (); my %response = ();
unless( $self->getBasic($som, $path, \%response) ) { unless ( $self->getBasic( $som, $path, \%response ) ) {
$self->getErrors($som, $path, \%response); $self->getErrors( $som, $path, \%response );
return %response; return %response;
} }
$self->getFields( $som, $self->getFields(
"$path/DoExpressCheckoutPaymentResponseDetails", $som,
\%response, "$path/DoExpressCheckoutPaymentResponseDetails",
{ Token => 'Token', \%response,
BillingAgreementID => 'BillingAgreementID', { Token => 'Token',
TransactionID => 'PaymentInfo/TransactionID', BillingAgreementID => 'BillingAgreementID',
TransactionType => 'PaymentInfo/TransactionType', TransactionID => 'PaymentInfo/TransactionID',
PaymentType => 'PaymentInfo/PaymentType', TransactionType => 'PaymentInfo/TransactionType',
PaymentDate => 'PaymentInfo/PaymentDate', PaymentType => 'PaymentInfo/PaymentType',
GrossAmount => 'PaymentInfo/GrossAmount', PaymentDate => 'PaymentInfo/PaymentDate',
FeeAmount => 'PaymentInfo/FeeAmount', GrossAmount => 'PaymentInfo/GrossAmount',
SettleAmount => 'PaymentInfo/SettleAmount', FeeAmount => 'PaymentInfo/FeeAmount',
TaxAmount => 'PaymentInfo/TaxAmount', SettleAmount => 'PaymentInfo/SettleAmount',
ExchangeRate => 'PaymentInfo/ExchangeRate', TaxAmount => 'PaymentInfo/TaxAmount',
PaymentStatus => 'PaymentInfo/PaymentStatus', ExchangeRate => 'PaymentInfo/ExchangeRate',
PendingReason => 'PaymentInfo/PendingReason', PaymentStatus => 'PaymentInfo/PaymentStatus',
AcceptFilters => 'FMFDetails/AcceptFilters', PendingReason => 'PaymentInfo/PendingReason',
DenyFilters => 'FMFDetails/DenyFilters', AcceptFilters => 'FMFDetails/AcceptFilters',
PendingFilters => 'FMFDetails/PendingFilters', DenyFilters => 'FMFDetails/DenyFilters',
ReportsFilters => 'FMFDetails/ReportsFilters', PendingFilters => 'FMFDetails/PendingFilters',
ProtectionEligibility => 'PaymentInfo/ProtectionEligibility', ReportsFilters => 'FMFDetails/ReportsFilters',
} ); ProtectionEligibility => 'PaymentInfo/ProtectionEligibility',
}
);
return %response; return %response;
} }

View file

@ -7,8 +7,8 @@ use warnings;
use SOAP::Lite 0.67; use SOAP::Lite 0.67;
use Business::PayPal::API (); use Business::PayPal::API ();
our @ISA = qw(Business::PayPal::API); our @ISA = qw(Business::PayPal::API);
our @EXPORT_OK = qw(GetBalance); ## fake exporter our @EXPORT_OK = qw(GetBalance); ## fake exporter
sub GetBalance { sub GetBalance {
my $self = shift; my $self = shift;

View file

@ -7,122 +7,131 @@ use warnings;
use SOAP::Lite 0.67; use SOAP::Lite 0.67;
use Business::PayPal::API (); use Business::PayPal::API ();
our @ISA = qw(Business::PayPal::API); our @ISA = qw(Business::PayPal::API);
our @EXPORT_OK = qw(GetTransactionDetails); ## fake exporter our @EXPORT_OK = qw(GetTransactionDetails); ## fake exporter
sub GetTransactionDetails { sub GetTransactionDetails {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my @trans = my @trans = (
( $self->version_req,
$self->version_req, SOAP::Data->name( TransactionID => $args{TransactionID} )
SOAP::Data->name( TransactionID => $args{TransactionID} )->type( 'xs:string' ), ->type( 'xs:string' ),
); );
my $request = SOAP::Data->name my $request
( GetTransactionDetailsRequest => \SOAP::Data->value( @trans ) ) = SOAP::Data->name(
->type("ns:GetTransactionDetailsRequestType"); GetTransactionDetailsRequest => \SOAP::Data->value( @trans ) )
->type( "ns:GetTransactionDetailsRequestType" );
my $som = $self->doCall( GetTransactionDetailsReq => $request ) my $som = $self->doCall( GetTransactionDetailsReq => $request )
or return; or return;
my $path = '/Envelope/Body/GetTransactionDetailsResponse'; my $path = '/Envelope/Body/GetTransactionDetailsResponse';
my %response = (); my %response = ();
unless( $self->getBasic($som, $path, \%response) ) { unless ( $self->getBasic( $som, $path, \%response ) ) {
$self->getErrors($som, $path, \%response); $self->getErrors( $som, $path, \%response );
return %response; return %response;
} }
$path .= '/PaymentTransactionDetails'; $path .= '/PaymentTransactionDetails';
$self->getFields($som, $path, \%response, $self->getFields(
{ Business => '/ReceiverInfo/Business', $som, $path,
Receiver => '/ReceiverInfo/Receiver', \%response,
ReceiverID => '/ReceiverInfo/ReceiverID', { Business => '/ReceiverInfo/Business',
Receiver => '/ReceiverInfo/Receiver',
ReceiverID => '/ReceiverInfo/ReceiverID',
Payer => '/PayerInfo/Payer', Payer => '/PayerInfo/Payer',
PayerID => '/PayerInfo/PayerID', PayerID => '/PayerInfo/PayerID',
PayerStatus => '/PayerInfo/PayerStatus', PayerStatus => '/PayerInfo/PayerStatus',
Salutation => '/PayerInfo/PayerName/Salutation', Salutation => '/PayerInfo/PayerName/Salutation',
FirstName => '/PayerInfo/PayerName/FirstName', FirstName => '/PayerInfo/PayerName/FirstName',
MiddleName => '/PayerInfo/PayerName/MiddleName', MiddleName => '/PayerInfo/PayerName/MiddleName',
LastName => '/PayerInfo/PayerName/LastName', LastName => '/PayerInfo/PayerName/LastName',
PayerCountry => '/PayerInfo/PayerCountry', PayerCountry => '/PayerInfo/PayerCountry',
PayerBusiness => '/PayerInfo/PayerBusiness', PayerBusiness => '/PayerInfo/PayerBusiness',
AddressOwner => '/PayerInfo/Address/AddressOwner', AddressOwner => '/PayerInfo/Address/AddressOwner',
AddressStatus => '/PayerInfo/Address/AddressStatus', AddressStatus => '/PayerInfo/Address/AddressStatus',
ADD_Name => '/PayerInfo/Address/Name', ADD_Name => '/PayerInfo/Address/Name',
Street1 => '/PayerInfo/Address/Street1', Street1 => '/PayerInfo/Address/Street1',
Street2 => '/PayerInfo/Address/Street2', Street2 => '/PayerInfo/Address/Street2',
CityName => '/PayerInfo/Address/CityName', CityName => '/PayerInfo/Address/CityName',
StateOrProvince => '/PayerInfo/Address/StateOrProvince', StateOrProvince => '/PayerInfo/Address/StateOrProvince',
Country => '/PayerInfo/Address/Country', Country => '/PayerInfo/Address/Country',
CountryName => '/PayerInfo/Address/CountryName', CountryName => '/PayerInfo/Address/CountryName',
Phone => '/PayerInfo/Address/Phone', Phone => '/PayerInfo/Address/Phone',
PostalCode => '/PayerInfo/Address/PostalCode', PostalCode => '/PayerInfo/Address/PostalCode',
TransactionID => '/PaymentInfo/TransactionID', TransactionID => '/PaymentInfo/TransactionID',
ParentTransactionID => '/PaymentInfo/ParentTransactionID', ParentTransactionID => '/PaymentInfo/ParentTransactionID',
ReceiptID => '/PaymentInfo/ReceiptID', ReceiptID => '/PaymentInfo/ReceiptID',
TransactionType => '/PaymentInfo/TransactionType', TransactionType => '/PaymentInfo/TransactionType',
PaymentType => '/PaymentInfo/PaymentType', PaymentType => '/PaymentInfo/PaymentType',
PaymentDate => '/PaymentInfo/PaymentDate', PaymentDate => '/PaymentInfo/PaymentDate',
GrossAmount => '/PaymentInfo/GrossAmount', GrossAmount => '/PaymentInfo/GrossAmount',
FeeAmount => '/PaymentInfo/FeeAmount', FeeAmount => '/PaymentInfo/FeeAmount',
SettleAmount => '/PaymentInfo/SettleAmount', SettleAmount => '/PaymentInfo/SettleAmount',
TaxAmount => '/PaymentInfo/TaxAmount', TaxAmount => '/PaymentInfo/TaxAmount',
ExchangeRate => '/PaymentInfo/ExchangeRate', ExchangeRate => '/PaymentInfo/ExchangeRate',
PaymentStatus => '/PaymentInfo/PaymentStatus', PaymentStatus => '/PaymentInfo/PaymentStatus',
PendingReason => '/PaymentInfo/PendingReason', PendingReason => '/PaymentInfo/PendingReason',
ReasonCode => '/PaymentInfo/ReasonCode', ReasonCode => '/PaymentInfo/ReasonCode',
ProtectionEligibility => '/PaymentInfo/ProtectionEligibility', ProtectionEligibility => '/PaymentInfo/ProtectionEligibility',
InvoiceID => '/PaymentItemInfo/InvoiceID', InvoiceID => '/PaymentItemInfo/InvoiceID',
Custom => '/PaymentItemInfo/Custom', Custom => '/PaymentItemInfo/Custom',
Memo => '/PaymentItemInfo/Memo', Memo => '/PaymentItemInfo/Memo',
SalesTax => '/PaymentItemInfo/SalesTax', SalesTax => '/PaymentItemInfo/SalesTax',
PII_SalesTax => '/PaymentItemInfo/PaymentItem/SalesTax', PII_SalesTax => '/PaymentItemInfo/PaymentItem/SalesTax',
PII_Name => '/PaymentItemInfo/PaymentItem/Name', PII_Name => '/PaymentItemInfo/PaymentItem/Name',
PII_Number => '/PaymentItemInfo/PaymentItem/Number', PII_Number => '/PaymentItemInfo/PaymentItem/Number',
PII_Quantity => '/PaymentItemInfo/PaymentItem/Quantity', PII_Quantity => '/PaymentItemInfo/PaymentItem/Quantity',
PII_Amount => '/PaymentItemInfo/PaymentItem/Amount', PII_Amount => '/PaymentItemInfo/PaymentItem/Amount',
PII_Options => '/PaymentItemInfo/PaymentItem/Options', PII_Options => '/PaymentItemInfo/PaymentItem/Options',
PII_SubscriptionID => '/PaymentItemInfo/Subscription/SubscriptionID', PII_SubscriptionID =>
PII_SubscriptionDate => '/PaymentItemInfo/Subscription/SubscriptionDate', '/PaymentItemInfo/Subscription/SubscriptionID',
PII_EffectiveDate => '/PaymentItemInfo/Subscription/EffectiveDate', PII_SubscriptionDate =>
PII_RetryTime => '/PaymentItemInfo/Subscription/RetryTime', '/PaymentItemInfo/Subscription/SubscriptionDate',
PII_Username => '/PaymentItemInfo/Subscription/Username', PII_EffectiveDate =>
PII_Password => '/PaymentItemInfo/Subscription/Password', '/PaymentItemInfo/Subscription/EffectiveDate',
PII_Recurrences => '/PaymentItemInfo/Subscription/Recurrences', PII_RetryTime => '/PaymentItemInfo/Subscription/RetryTime',
PII_reattempt => '/PaymentItemInfo/Subscription/reattempt', PII_Username => '/PaymentItemInfo/Subscription/Username',
PII_recurring => '/PaymentItemInfo/Subscription/recurring', PII_Password => '/PaymentItemInfo/Subscription/Password',
PII_Amount => '/PaymentItemInfo/Subscription/Amount', PII_Recurrences => '/PaymentItemInfo/Subscription/Recurrences',
PII_period => '/PaymentItemInfo/Subscription/period', PII_reattempt => '/PaymentItemInfo/Subscription/reattempt',
PII_recurring => '/PaymentItemInfo/Subscription/recurring',
PII_Amount => '/PaymentItemInfo/Subscription/Amount',
PII_period => '/PaymentItemInfo/Subscription/period',
PII_BuyerID => '/PaymentItemInfo/Auction/BuyerID', PII_BuyerID => '/PaymentItemInfo/Auction/BuyerID',
PII_ClosingDate => '/PaymentItemInfo/Auction/ClosingDate', PII_ClosingDate => '/PaymentItemInfo/Auction/ClosingDate',
PII_multiItem => '/PaymentItemInfo/Auction/multiItem', PII_multiItem => '/PaymentItemInfo/Auction/multiItem',
} }
); );
## multiple payment items ## multiple payment items
my $paymentitems = $self->getFieldsList( $som, $path . '/PaymentItemInfo/PaymentItem', my $paymentitems = $self->getFieldsList(
{ SalesTax => 'SalesTax', $som,
Name => 'Name', $path . '/PaymentItemInfo/PaymentItem',
Number => 'Number', { SalesTax => 'SalesTax',
Quantity => 'Quantity', Name => 'Name',
Amount => 'Amount', Number => 'Number',
Options => 'Options', Quantity => 'Quantity',
} ); Amount => 'Amount',
Options => 'Options',
}
);
if( scalar(@$paymentitems) > 0 ) { if ( scalar( @$paymentitems ) > 0 ) {
$response{PaymentItems} = $paymentitems; $response{PaymentItems} = $paymentitems;
} }

View file

@ -7,7 +7,7 @@ use warnings;
use SOAP::Lite 0.67; use SOAP::Lite 0.67;
use Business::PayPal::API (); use Business::PayPal::API ();
our @ISA = qw(Business::PayPal::API); our @ISA = qw(Business::PayPal::API);
our @EXPORT_OK = qw( MassPay ); our @EXPORT_OK = qw( MassPay );
sub MassPay { sub MassPay {
@ -20,20 +20,26 @@ sub MassPay {
$args{MassPayItems} ||= []; $args{MassPayItems} ||= [];
$args{Version} ||= "1.0"; $args{Version} ||= "1.0";
my %types = ( EmailSubject => 'xs:string', my %types = (
Version => 'xsd:string', EmailSubject => 'xs:string',
# ReceiverType => 'ebl:ReceiverInfoCodeType', ## EmailAddress | UserID Version => 'xsd:string',
);
my %attr = ( Version => { xmlns => $self->C_xmlns_ebay }, # ReceiverType => 'ebl:ReceiverInfoCodeType', ## EmailAddress | UserID
Amount => { currencyID => $args{currencyID} }, ); );
my %attr = (
Version => { xmlns => $self->C_xmlns_ebay },
Amount => { currencyID => $args{currencyID} },
);
## mass pay item ## mass pay item
my %mpi_type = ( ReceiverEmail => 'ebl:EmailAddressType', my %mpi_type = (
ReceiverID => 'xs:string', ReceiverEmail => 'ebl:EmailAddressType',
Amount => 'ebl:BasicAmountType', ReceiverID => 'xs:string',
UniqueId => 'xs:string', Amount => 'ebl:BasicAmountType',
Note => 'xs:string', ); UniqueId => 'xs:string',
Note => 'xs:string',
);
my @recipients = @{ $args{MassPayItems} }; my @recipients = @{ $args{MassPayItems} };
@ -41,15 +47,19 @@ sub MassPay {
for my $type ( sort keys %types ) { for my $type ( sort keys %types ) {
next unless $args{$type}; next unless $args{$type};
if( $attr{$type} ) { if ( $attr{$type} ) {
push @masspay, SOAP::Data->name( $type => $args{$type} )->type($types{$type})->attr( { %{ $attr{$type} } } ); push @masspay,
SOAP::Data->name( $type => $args{$type} )
->type( $types{$type} )->attr( { %{ $attr{$type} } } );
} }
else { else {
push @masspay, SOAP::Data->name( $type => $args{$type} )->type($types{$type}); push @masspay,
SOAP::Data->name( $type => $args{$type} )
->type( $types{$type} );
} }
} }
if( $args{ReceiverType} eq 'UserID' ) { if ( $args{ReceiverType} eq 'UserID' ) {
delete $mpi_type{ReceiverEmail}; delete $mpi_type{ReceiverEmail};
} }
@ -61,30 +71,36 @@ sub MassPay {
my @rcpt = (); my @rcpt = ();
for my $type ( keys %mpi_type ) { for my $type ( keys %mpi_type ) {
next unless $mpi_type{$type}; next unless $mpi_type{$type};
if( $attr{$type} ) { if ( $attr{$type} ) {
push @rcpt, SOAP::Data->name( $type => $rcpt->{$type} )->type($mpi_type{$type})->attr( { %{ $attr{$type} } } ); push @rcpt,
SOAP::Data->name( $type => $rcpt->{$type} )
->type( $mpi_type{$type} )->attr( { %{ $attr{$type} } } );
} }
else { else {
push @rcpt, SOAP::Data->name( $type => $rcpt->{$type} )->type($mpi_type{$type}); push @rcpt,
SOAP::Data->name( $type => $rcpt->{$type} )
->type( $mpi_type{$type} );
} }
} }
push @masspay, SOAP::Data->name( MassPayItem => \SOAP::Data->value( @rcpt ) )->type("ns:MassPayRequestItemType"); push @masspay,
SOAP::Data->name( MassPayItem => \SOAP::Data->value( @rcpt ) )
->type( "ns:MassPayRequestItemType" );
} }
my $request = SOAP::Data->name my $request
( MassPayRequest => \SOAP::Data->value( @masspay ) ) = SOAP::Data->name( MassPayRequest => \SOAP::Data->value( @masspay ) )
->type("ns:MassPayRequestType"); ->type( "ns:MassPayRequestType" );
my $som = $self->doCall( MassPayReq => $request ) my $som = $self->doCall( MassPayReq => $request )
or return; or return;
my $path = '/Envelope/Body/MassPayResponse'; my $path = '/Envelope/Body/MassPayResponse';
my %response = (); my %response = ();
unless( $self->getBasic($som, $path, \%response) ) { unless ( $self->getBasic( $som, $path, \%response ) ) {
$self->getErrors($som, $path, \%response); $self->getErrors( $som, $path, \%response );
return %response; return %response;
} }

View file

@ -7,49 +7,53 @@ use warnings;
use SOAP::Lite 0.67; use SOAP::Lite 0.67;
use Business::PayPal::API (); use Business::PayPal::API ();
our @ISA = qw(Business::PayPal::API); our @ISA = qw(Business::PayPal::API);
our @EXPORT_OK = qw(DoReauthorizationRequest); our @EXPORT_OK = qw(DoReauthorizationRequest);
sub DoReauthorizationRequest { sub DoReauthorizationRequest {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my %types = ( AuthorizationID => 'xs:string', my %types = (
Amount => 'ebl:BasicAmountType',); AuthorizationID => 'xs:string',
Amount => 'ebl:BasicAmountType',
);
$args{currencyID} ||= 'USD'; $args{currencyID} ||= 'USD';
my @ref_trans = my @ref_trans = (
($self->version_req, $self->version_req,
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )->type($types{AuthorizationID}),); SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )
->type( $types{AuthorizationID} ),
);
push @ref_trans, push @ref_trans,
SOAP::Data->name( Amount => $args{Amount} ) SOAP::Data->name( Amount => $args{Amount} )->type( $types{Amount} )
->type( $types{Amount} ) ->attr( { currencyID => $args{currencyID} } );
->attr( { currencyID => $args{currencyID} } );
my $request
= SOAP::Data->name(
my $request = SOAP::Data->name DoReauthorizationRequest => \SOAP::Data->value( @ref_trans ) )
( DoReauthorizationRequest => \SOAP::Data->value( @ref_trans ) ) ->type( "ns:ReauthorizationRequestType" );
->type("ns:ReauthorizationRequestType");
my $som = $self->doCall( DoReauthorizationReq => $request ) my $som = $self->doCall( DoReauthorizationReq => $request )
or return; or return;
my $path = '/Envelope/Body/DoReauthorizationResponse'; my $path = '/Envelope/Body/DoReauthorizationResponse';
my %response = (); my %response = ();
unless( $self->getBasic($som, $path, \%response) ) { unless ( $self->getBasic( $som, $path, \%response ) ) {
$self->getErrors($som, $path, \%response); $self->getErrors( $som, $path, \%response );
return %response; return %response;
} }
$self->getFields($som, $path, \%response, $self->getFields(
{ AuthorizationID => 'AuthorizationID', $som, $path,
Amount => 'Amount', } \%response,
); { AuthorizationID => 'AuthorizationID',
Amount => 'Amount',
}
);
return %response; return %response;
} }

View file

@ -7,11 +7,11 @@ use warnings;
use SOAP::Lite 0.67; use SOAP::Lite 0.67;
use Business::PayPal::API (); use Business::PayPal::API ();
our @ISA = qw(Business::PayPal::API); our @ISA = qw(Business::PayPal::API);
our @EXPORT_OK = qw( SetCustomerBillingAgreement our @EXPORT_OK = qw( SetCustomerBillingAgreement
GetBillingAgreementCustomerDetails GetBillingAgreementCustomerDetails
CreateRecurringPaymentsProfile CreateRecurringPaymentsProfile
DoReferenceTransaction); DoReferenceTransaction);
our $API_VERSION = '50.0'; our $API_VERSION = '50.0';
@ -20,61 +20,73 @@ sub SetCustomerBillingAgreement {
my %args = @_; my %args = @_;
## billing agreement details type ## billing agreement details type
my %badtypes = ( BillingType => '', # 'ns:BillingCodeType', my %badtypes = (
BillingAgreementDescription => 'xs:string', BillingType => '', # 'ns:BillingCodeType',
PaymentType => '', # 'ns:MerchantPullPaymentCodeType', BillingAgreementDescription => 'xs:string',
BillingAgreementCustom => 'xs:string', ); PaymentType => '', # 'ns:MerchantPullPaymentCodeType',
BillingAgreementCustom => 'xs:string',
);
my %types = ( BillingAgreementDetails => 'ns:BillingAgreementDetailsType', my %types = (
ReturnURL => 'xs:string', BillingAgreementDetails => 'ns:BillingAgreementDetailsType',
CancelURL => 'xs:string', ReturnURL => 'xs:string',
LocaleCode => 'xs:string', CancelURL => 'xs:string',
PageStyle => 'xs:string', LocaleCode => 'xs:string',
'cpp-header-image' => 'xs:string', PageStyle => 'xs:string',
'cpp-header-border-color' => 'xs:string', 'cpp-header-image' => 'xs:string',
'cpp-header-back-color' => 'xs:string', 'cpp-header-border-color' => 'xs:string',
'cpp-payflow-color' => 'xs:string', 'cpp-header-back-color' => 'xs:string',
PaymentAction => '', 'cpp-payflow-color' => 'xs:string',
BuyerEmail => 'ns:EmailAddressType', ); PaymentAction => '',
BuyerEmail => 'ns:EmailAddressType',
);
## set defaults ## set defaults
$args{BillingType} ||= 'RecurringPayments'; $args{BillingType} ||= 'RecurringPayments';
$args{PaymentType} ||= 'InstantOnly'; $args{PaymentType} ||= 'InstantOnly';
$args{currencyID} ||= 'USD'; $args{currencyID} ||= 'USD';
my @btypes = (); my @btypes = ();
for my $field ( keys %badtypes ) { for my $field ( keys %badtypes ) {
next unless $args{$field}; next unless $args{$field};
push @btypes, SOAP::Data->name( $field => $args{$field} )->type( $badtypes{$field} ); push @btypes,
SOAP::Data->name( $field => $args{$field} )
->type( $badtypes{$field} );
} }
my @scba = (); my @scba = ();
for my $field ( keys %types ) { for my $field ( keys %types ) {
next unless $args{$field}; next unless $args{$field};
push @scba, SOAP::Data->name( $field => $args{$field} )->type( $types{$field} ); push @scba,
SOAP::Data->name( $field => $args{$field} )
->type( $types{$field} );
} }
push @scba, SOAP::Data->name( BillingAgreementDetails => \SOAP::Data->value(@btypes) ); push @scba,
SOAP::Data->name(
BillingAgreementDetails => \SOAP::Data->value( @btypes ) );
my $request = SOAP::Data my $request = SOAP::Data->name(
->name( SetCustomerBillingAgreementRequest => \SOAP::Data->value SetCustomerBillingAgreementRequest => \SOAP::Data->value(
( $self->version_req, #$API_VERSION, $self->version_req, #$API_VERSION,
SOAP::Data->name( SetCustomerBillingAgreementRequestDetails => \SOAP::Data->value(@scba) SOAP::Data->name(
)->attr( {xmlns => $self->C_xmlns_ebay} ), SetCustomerBillingAgreementRequestDetails =>
) \SOAP::Data->value( @scba )
)->type( 'ns:SetCustomerBillingAgreementRequestDetailsType' ); )->attr( { xmlns => $self->C_xmlns_ebay } ),
)
)->type( 'ns:SetCustomerBillingAgreementRequestDetailsType' );
my $som = $self->doCall( SetCustomerBillingAgreementReq => $request ) my $som = $self->doCall( SetCustomerBillingAgreementReq => $request )
or return; or return;
my $path = '/Envelope/Body/SetCustomerBillingAgreementResponse'; my $path = '/Envelope/Body/SetCustomerBillingAgreementResponse';
my %response = (); my %response = ();
unless( $self->getBasic($som, $path, \%response) ) { unless ( $self->getBasic( $som, $path, \%response ) ) {
$self->getErrors($som, $path, \%response); $self->getErrors( $som, $path, \%response );
return %response; return %response;
} }
$self->getFields($som, $path, \%response, { Token => 'Token' }); $self->getFields( $som, $path, \%response, { Token => 'Token' } );
return %response; return %response;
} }
@ -83,50 +95,53 @@ sub GetBillingAgreementCustomerDetails {
my $self = shift; my $self = shift;
my $token = shift; my $token = shift;
my $request = SOAP::Data my $request = SOAP::Data->name(
->name( GetBillingAgreementCustomerDetailsRequest => \SOAP::Data->value GetBillingAgreementCustomerDetailsRequest => \SOAP::Data->value(
( $self->version_req, $self->version_req,
SOAP::Data->name( Token => $token ) SOAP::Data->name( Token => $token )->type( 'xs:string' )
->type('xs:string')->attr( {xmlns => $self->C_xmlns_ebay} ), ->attr( { xmlns => $self->C_xmlns_ebay } ),
) )
)->type( 'ns:GetBillingAgreementCustomerDetailsResponseType' ); )->type( 'ns:GetBillingAgreementCustomerDetailsResponseType' );
my $som = $self->doCall( GetBillingAgreementCustomerDetailsReq => $request ) my $som
or return; = $self->doCall( GetBillingAgreementCustomerDetailsReq => $request )
or return;
my $path = '/Envelope/Body/GetBillingAgreementCustomerDetailsResponse'; my $path = '/Envelope/Body/GetBillingAgreementCustomerDetailsResponse';
my %details = (); my %details = ();
unless( $self->getBasic($som, $path, \%details) ) { unless ( $self->getBasic( $som, $path, \%details ) ) {
$self->getErrors($som, $path, \%details); $self->getErrors( $som, $path, \%details );
return %details; return %details;
} }
$self->getFields($som, $self->getFields(
"$path/GetBillingAgreementCustomerDetailsResponseDetails", $som,
\%details, "$path/GetBillingAgreementCustomerDetailsResponseDetails",
{ Token => 'Token', \%details,
{ Token => 'Token',
Payer => 'PayerInfo/Payer', Payer => 'PayerInfo/Payer',
PayerID => 'PayerInfo/PayerID', PayerID => 'PayerInfo/PayerID',
PayerStatus => 'PayerInfo/PayerStatus', ## 'unverified' PayerStatus => 'PayerInfo/PayerStatus', ## 'unverified'
PayerBusiness => 'PayerInfo/PayerBusiness', PayerBusiness => 'PayerInfo/PayerBusiness',
Name => 'PayerInfo/Address/Name', Name => 'PayerInfo/Address/Name',
AddressOwner => 'PayerInfo/Address/AddressOwner', ## 'PayPal' AddressOwner => 'PayerInfo/Address/AddressOwner', ## 'PayPal'
AddressStatus => 'PayerInfo/Address/AddressStatus', ## 'none' AddressStatus => 'PayerInfo/Address/AddressStatus', ## 'none'
Street1 => 'PayerInfo/Address/Street1', Street1 => 'PayerInfo/Address/Street1',
Street2 => 'PayerInfo/Address/Street2', Street2 => 'PayerInfo/Address/Street2',
StateOrProvince => 'PayerInfo/Address/StateOrProvince', StateOrProvince => 'PayerInfo/Address/StateOrProvince',
PostalCode => 'PayerInfo/Address/PostalCode', PostalCode => 'PayerInfo/Address/PostalCode',
CountryName => 'PayerInfo/Address/CountryName', CountryName => 'PayerInfo/Address/CountryName',
Salutation => 'PayerInfo/PayerName/Salutation', Salutation => 'PayerInfo/PayerName/Salutation',
FirstName => 'PayerInfo/PayerName/FirstName', FirstName => 'PayerInfo/PayerName/FirstName',
MiddleName => 'PayerInfo/PayerName/MiddleName', MiddleName => 'PayerInfo/PayerName/MiddleName',
LastName => 'PayerInfo/PayerName/LastName', LastName => 'PayerInfo/PayerName/LastName',
Suffix => 'PayerInfo/PayerName/Suffix', Suffix => 'PayerInfo/PayerName/Suffix',
} ); }
);
return %details; return %details;
} }
@ -136,172 +151,226 @@ sub CreateRecurringPaymentsProfile {
my %args = @_; my %args = @_;
## RecurringPaymentProfileDetails ## RecurringPaymentProfileDetails
my %profiledetailstype = ( SubscriberName => 'xs:string', my %profiledetailstype = (
SubscriberShipperAddress => 'ns:AddressType', SubscriberName => 'xs:string',
BillingStartDate => 'xs:dateTime', ## MM-DD-YY SubscriberShipperAddress => 'ns:AddressType',
ProfileReference => 'xs:string', ); BillingStartDate => 'xs:dateTime', ## MM-DD-YY
ProfileReference => 'xs:string',
);
## ScheduleDetailsType ## ScheduleDetailsType
my %schedtype = ( Description => 'xs:string', my %schedtype = (
ActivationDetails => 'ns:ActivationDetailsType', Description => 'xs:string',
TrialPeriod => 'ns:BillingPeriodDetailsType', ActivationDetails => 'ns:ActivationDetailsType',
PaymentPeriod => 'ns:BillingPeriodDetailsType', TrialPeriod => 'ns:BillingPeriodDetailsType',
MaxFailedPayments => 'xs:int', PaymentPeriod => 'ns:BillingPeriodDetailsType',
AutoBillOutstandingAmount => 'ns:AutoBillType', ); ## NoAutoBill or AddToNextBilling MaxFailedPayments => 'xs:int',
AutoBillOutstandingAmount => 'ns:AutoBillType',
); ## NoAutoBill or AddToNextBilling
## activation details ## activation details
my %activationdetailstype = ( InitialAmount => 'cc:BasicAmountType', my %activationdetailstype = (
FailedInitialAmountAction => 'ns:FailedPaymentAction', ); ## ContinueOnFailure or CancelOnFailure InitialAmount => 'cc:BasicAmountType',
FailedInitialAmountAction => 'ns:FailedPaymentAction',
); ## ContinueOnFailure or CancelOnFailure
## BillingPeriodDetailsType ## BillingPeriodDetailsType
my %trialbilltype = ( TrialBillingPeriod => 'xs:string', ##'ns:BillingPeriodType', my %trialbilltype = (
TrialBillingFrequency => 'xs:int', TrialBillingPeriod => 'xs:string', ##'ns:BillingPeriodType',
TrialTotalBillingCycles => 'xs:int', TrialBillingFrequency => 'xs:int',
TrialAmount => 'cc:AmountType', TrialTotalBillingCycles => 'xs:int',
TrialShippingAmount => 'cc:AmountType', TrialAmount => 'cc:AmountType',
TrialTaxAmount => 'cc:AmountType', ); TrialShippingAmount => 'cc:AmountType',
TrialTaxAmount => 'cc:AmountType',
);
my %paymentbilltype = ( PaymentBillingPeriod => 'xs:string', ##'ns:BillingPeriodType', my %paymentbilltype = (
PaymentBillingFrequency => 'xs:int', PaymentBillingPeriod => 'xs:string', ##'ns:BillingPeriodType',
PaymentTotalBillingCycles => 'xs:int', PaymentBillingFrequency => 'xs:int',
PaymentAmount => 'cc:AmountType', PaymentTotalBillingCycles => 'xs:int',
PaymentShippingAmount => 'cc:AmountType', PaymentAmount => 'cc:AmountType',
PaymentTaxAmount => 'cc:AmountType', ); PaymentShippingAmount => 'cc:AmountType',
PaymentTaxAmount => 'cc:AmountType',
);
## AddressType ## AddressType
my %payaddrtype = ( CCPayerName => 'xs:string', my %payaddrtype = (
CCPayerStreet1 => 'xs:string', CCPayerName => 'xs:string',
CCPayerStreet2 => 'xs:string', CCPayerStreet1 => 'xs:string',
CCPayerCityName => 'xs:string', CCPayerStreet2 => 'xs:string',
CCPayerStateOrProvince => 'xs:string', CCPayerCityName => 'xs:string',
CCPayerCountry => 'xs:string', ## ebl:CountryCodeType CCPayerStateOrProvince => 'xs:string',
CCPayerPostalCode => 'xs:string', CCPayerCountry => 'xs:string', ## ebl:CountryCodeType
CCPayerPhone => 'xs:string', ); CCPayerPostalCode => 'xs:string',
CCPayerPhone => 'xs:string',
);
my %shipaddrtype = ( SubscriberShipperName => 'xs:string', my %shipaddrtype = (
SubscriberShipperStreet1 => 'xs:string', SubscriberShipperName => 'xs:string',
SubscriberShipperStreet2 => 'xs:string', SubscriberShipperStreet1 => 'xs:string',
SubscriberShipperCityName => 'xs:string', SubscriberShipperStreet2 => 'xs:string',
SubscriberShipperStateOrProvince => 'xs:string', SubscriberShipperCityName => 'xs:string',
SubscriberShipperCountry => 'xs:string', ## ebl:CountryCodeType SubscriberShipperStateOrProvince => 'xs:string',
SubscriberShipperPostalCode => 'xs:string', SubscriberShipperCountry => 'xs:string', ## ebl:CountryCodeType
SubscriberShipperPhone => 'xs:string', ); SubscriberShipperPostalCode => 'xs:string',
SubscriberShipperPhone => 'xs:string',
);
## credit card payer ## credit card payer
my %payerinfotype = ( CCPayer => 'ns:EmailAddressType', my %payerinfotype = (
CCPayerID => 'ebl:UserIDType', CCPayer => 'ns:EmailAddressType',
CCPayerStatus => 'xs:string', CCPayerID => 'ebl:UserIDType',
CCPayerName => 'xs:string', CCPayerStatus => 'xs:string',
CCPayerCountry => 'xs:string', CCPayerName => 'xs:string',
CCPayerPhone => 'xs:string', CCPayerCountry => 'xs:string',
CCPayerBusiness => 'xs:string', CCPayerPhone => 'xs:string',
CCAddress => 'xs:string', CCPayerBusiness => 'xs:string',
); CCAddress => 'xs:string',
);
## credit card details ## credit card details
my %creditcarddetailstype = ( CardOwner => 'ns:PayerInfoType', my %creditcarddetailstype = (
CreditCardType => 'ebl:CreditCardType', ## Visa, MasterCard, Discover, Amex, Switch, Solo CardOwner => 'ns:PayerInfoType',
CreditCardNumber => 'xs:string', CreditCardType => 'ebl:CreditCardType'
ExpMonth => 'xs:int', , ## Visa, MasterCard, Discover, Amex, Switch, Solo
ExpYear => 'xs:int', CreditCardNumber => 'xs:string',
CVV2 => 'xs:string', ExpMonth => 'xs:int',
StartMonth => 'xs:string', ExpYear => 'xs:int',
StartYear => 'xs:string', CVV2 => 'xs:string',
IssueNumber => 'xs:int', ); StartMonth => 'xs:string',
StartYear => 'xs:string',
IssueNumber => 'xs:int',
);
## this gets pushed onto scheduledetails ## this gets pushed onto scheduledetails
my @activationdetailstype = (); my @activationdetailstype = ();
for my $field ( keys %activationdetailstype ) { for my $field ( keys %activationdetailstype ) {
next unless exists $args{$field}; next unless exists $args{$field};
my $real_field = $field; my $real_field = $field;
push @activationdetailstype, SOAP::Data->name( $real_field => $args{$field} )->type( $activationdetailstype{$field} ); push @activationdetailstype,
SOAP::Data->name( $real_field => $args{$field} )
->type( $activationdetailstype{$field} );
} }
## this gets pushed onto scheduledetails ## this gets pushed onto scheduledetails
my @trialbilltype = (); my @trialbilltype = ();
for my $field ( keys %trialbilltype ) { for my $field ( keys %trialbilltype ) {
next unless exists $args{$field}; next unless exists $args{$field};
(my $real_field = $field) =~ s/^Trial//; ( my $real_field = $field ) =~ s/^Trial//;
push @trialbilltype, SOAP::Data->name( $real_field => $args{$field} )->type( $trialbilltype{$field} ); push @trialbilltype,
SOAP::Data->name( $real_field => $args{$field} )
->type( $trialbilltype{$field} );
} }
## this gets pushed onto scheduledetails ## this gets pushed onto scheduledetails
my @paymentbilltype = (); my @paymentbilltype = ();
for my $field ( keys %paymentbilltype ) { for my $field ( keys %paymentbilltype ) {
next unless exists $args{$field}; next unless exists $args{$field};
(my $real_field = $field) =~ s/^Payment//; ( my $real_field = $field ) =~ s/^Payment//;
push @paymentbilltype, SOAP::Data->name( $real_field => $args{$field} )->type( $paymentbilltype{$field} ); push @paymentbilltype,
SOAP::Data->name( $real_field => $args{$field} )
->type( $paymentbilltype{$field} );
} }
## this gets pushed onto the top ## this gets pushed onto the top
my @sched = (); my @sched = ();
for my $field ( keys %schedtype ) { for my $field ( keys %schedtype ) {
next unless exists $args{$field}; next unless exists $args{$field};
push @sched, SOAP::Data->name( $field => $args{$field} )->type( $schedtype{$field} ); push @sched,
SOAP::Data->name( $field => $args{$field} )
->type( $schedtype{$field} );
} }
push @sched, SOAP::Data->name( TrialPeriod => \SOAP::Data->value(@trialbilltype) ); #->type( 'ns:BillingPeriodDetailsType' ); push @sched,
push @sched, SOAP::Data->name( PaymentPeriod => \SOAP::Data->value(@paymentbilltype) ); #->type( 'ns:BillingPeriodDetailsType' ); SOAP::Data->name(
TrialPeriod => \SOAP::Data->value( @trialbilltype ) )
; #->type( 'ns:BillingPeriodDetailsType' );
push @sched,
SOAP::Data->name(
PaymentPeriod => \SOAP::Data->value( @paymentbilltype ) )
; #->type( 'ns:BillingPeriodDetailsType' );
## this gets pushed into profile details ## this gets pushed into profile details
my @shipaddr = (); my @shipaddr = ();
for my $field ( keys %shipaddrtype ) { for my $field ( keys %shipaddrtype ) {
next unless exists $args{$field}; next unless exists $args{$field};
(my $real_field = $field) =~ s/^SubscriberShipper//; ( my $real_field = $field ) =~ s/^SubscriberShipper//;
push @shipaddr, SOAP::Data->name( $real_field => $args{$field} )->type( $shipaddrtype{$field} ); push @shipaddr,
SOAP::Data->name( $real_field => $args{$field} )
->type( $shipaddrtype{$field} );
} }
## this gets pushed into payerinfo (from creditcarddetails) ## this gets pushed into payerinfo (from creditcarddetails)
my @payeraddr = (); my @payeraddr = ();
for my $field ( keys %payaddrtype ) { for my $field ( keys %payaddrtype ) {
next unless $args{$field}; next unless $args{$field};
(my $real_field = $field) =~ s/^CCPayer//; ( my $real_field = $field ) =~ s/^CCPayer//;
push @payeraddr, SOAP::Data->name( $real_field => $args{$field} )->type( payaddrtype{$field} ); push @payeraddr,
SOAP::Data->name( $real_field => $args{$field} )
->type( payaddrtype {$field} );
} }
## credit card type ## credit card type
my @creditcarddetails = (); my @creditcarddetails = ();
for my $field ( keys %creditcarddetailstype ) { for my $field ( keys %creditcarddetailstype ) {
next unless $args{$field}; next unless $args{$field};
(my $real_field = $field) =~ s/^CC//; ( my $real_field = $field ) =~ s/^CC//;
push @payeraddr, SOAP::Data->name( $real_field => $args{$field} )->type( payaddrtype{$field} ); push @payeraddr,
SOAP::Data->name( $real_field => $args{$field} )
->type( payaddrtype {$field} );
} }
## this gets pushed onto the top ## this gets pushed onto the top
my @profdetail = (); my @profdetail = ();
for my $field ( keys %profiledetailstype ) { for my $field ( keys %profiledetailstype ) {
next unless exists $args{$field}; next unless exists $args{$field};
push @profdetail, SOAP::Data->name( $field => $args{$field} )->type( $profiledetailstype{$field} ); push @profdetail,
SOAP::Data->name( $field => $args{$field} )
->type( $profiledetailstype{$field} );
} }
push @profdetail, SOAP::Data->name( SubscriberShipperAddress => \SOAP::Data->value(@shipaddr) ); push @profdetail,
SOAP::Data->name(
SubscriberShipperAddress => \SOAP::Data->value( @shipaddr ) );
## crappard? ## crappard?
my @crpprd = (); my @crpprd = ();
push @crpprd, SOAP::Data->name( Token => $args{Token} ); push @crpprd, SOAP::Data->name( Token => $args{Token} );
push @crpprd, SOAP::Data->name( CreditCardDetails => \SOAP::Data->value(@creditcarddetails) ); #->type( 'ns:CreditCardDetailsType' ); push @crpprd,
push @crpprd, SOAP::Data->name( RecurringPaymentProfileDetails => \SOAP::Data->value(@profdetail) ); #->type( 'ns:RecurringPaymentProfileDetailsType' ); SOAP::Data->name(
push @crpprd, SOAP::Data->name( ScheduleDetails => \SOAP::Data->value(@sched) ); #->type( 'ns:ScheduleDetailsType' ); CreditCardDetails => \SOAP::Data->value( @creditcarddetails ) )
; #->type( 'ns:CreditCardDetailsType' );
push @crpprd,
SOAP::Data->name(
RecurringPaymentProfileDetails => \SOAP::Data->value( @profdetail ) )
; #->type( 'ns:RecurringPaymentProfileDetailsType' );
push @crpprd,
SOAP::Data->name( ScheduleDetails => \SOAP::Data->value( @sched ) )
; #->type( 'ns:ScheduleDetailsType' );
my $request = SOAP::Data->name my $request = SOAP::Data->name(
( CreateRecurringPaymentsProfileRequest => \SOAP::Data->value CreateRecurringPaymentsProfileRequest => \SOAP::Data->value
# ( $API_VERSION,
( $self->version_req, # ( $API_VERSION,
SOAP::Data->name( CreateRecurringPaymentsProfileRequestDetails => \SOAP::Data->value(@crpprd) (
)->attr( {xmlns => $self->C_xmlns_ebay} ) $self->version_req,
) SOAP::Data->name(
); #->type( 'ns:CreateRecurringPaymentsProfileRequestType' ); CreateRecurringPaymentsProfileRequestDetails =>
\SOAP::Data->value( @crpprd )
)->attr( { xmlns => $self->C_xmlns_ebay } )
)
); #->type( 'ns:CreateRecurringPaymentsProfileRequestType' );
my $som = $self->doCall( CreateRecurringPaymentsProfileReq => $request ) my $som = $self->doCall( CreateRecurringPaymentsProfileReq => $request )
or return; or return;
my $path = '/Envelope/Body/CreateRecurringPaymentsProfileResponse'; my $path = '/Envelope/Body/CreateRecurringPaymentsProfileResponse';
my %response = (); my %response = ();
unless( $self->getBasic($som, $path, \%response) ) { unless ( $self->getBasic( $som, $path, \%response ) ) {
$self->getErrors($som, $path, \%response); $self->getErrors( $som, $path, \%response );
return %response; return %response;
} }
$self->getFields($som, $path, \%response, { Token => 'Token' }); $self->getFields( $som, $path, \%response, { Token => 'Token' } );
return %response; return %response;
} }
@ -310,64 +379,71 @@ sub DoReferenceTransaction {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my %types = ( ReferenceID => 'xs:string', my %types = (
PaymentAction => '', ## NOTA BENE! ReferenceID => 'xs:string',
currencyID => '', PaymentAction => '', ## NOTA BENE!
); currencyID => '',
);
## PaymentDetails ## PaymentDetails
my %pd_types = ( OrderTotal => 'ebl:BasicAmountType', my %pd_types = (
OrderDescription => 'xs:string', OrderTotal => 'ebl:BasicAmountType',
ItemTotal => 'ebl:BasicAmountType', OrderDescription => 'xs:string',
ShippingTotal => 'ebl:BasicAmountType', ItemTotal => 'ebl:BasicAmountType',
HandlingTotal => 'ebl:BasicAmountType', ShippingTotal => 'ebl:BasicAmountType',
TaxTotal => 'ebl:BasicAmountType', HandlingTotal => 'ebl:BasicAmountType',
Custom => 'xs:string', TaxTotal => 'ebl:BasicAmountType',
InvoiceID => 'xs:string', Custom => 'xs:string',
ButtonSource => 'xs:string', InvoiceID => 'xs:string',
NotifyURL => 'xs:string', ButtonSource => 'xs:string',
); NotifyURL => 'xs:string',
);
## ShipToAddress ## ShipToAddress
my %st_types = ( ST_Name => 'xs:string', my %st_types = (
ST_Street1 => 'xs:string', ST_Name => 'xs:string',
ST_Street2 => 'xs:string', ST_Street1 => 'xs:string',
ST_CityName => 'xs:string', ST_Street2 => 'xs:string',
ST_StateOrProvince => 'xs:string', ST_CityName => 'xs:string',
ST_Country => 'xs:string', ST_StateOrProvince => 'xs:string',
ST_PostalCode => 'xs:string', ST_Country => 'xs:string',
ST_Phone => 'xs:string', ST_PostalCode => 'xs:string',
); ST_Phone => 'xs:string',
);
##PaymentDetailsItem ##PaymentDetailsItem
my %pdi_types = ( PDI_Name => 'xs:string', my %pdi_types = (
PDI_Description => 'xs:string', PDI_Name => 'xs:string',
PDI_Amount => 'ebl:BasicAmountType', PDI_Description => 'xs:string',
PDI_Number => 'xs:string', PDI_Amount => 'ebl:BasicAmountType',
PDI_Quantity => 'xs:string', PDI_Number => 'xs:string',
PDI_Tax => 'ebl:BasicAmountType', PDI_Quantity => 'xs:string',
); PDI_Tax => 'ebl:BasicAmountType',
);
$args{PaymentAction} ||= 'Sale'; $args{PaymentAction} ||= 'Sale';
$args{currencyID} ||= 'USD'; $args{currencyID} ||= 'USD';
my @payment_details = ( ); my @payment_details = ();
## push OrderTotal here and delete it (i.e., and all others that have special attrs) ## push OrderTotal here and delete it (i.e., and all others that have special attrs)
push @payment_details, SOAP::Data->name( OrderTotal => $args{OrderTotal} ) push @payment_details,
->type( $pd_types{OrderTotal} ) SOAP::Data->name( OrderTotal => $args{OrderTotal} )
->attr( { currencyID => $args{currencyID}, ->type( $pd_types{OrderTotal} )->attr(
xmlns => $self->C_xmlns_ebay } ); { currencyID => $args{currencyID},
xmlns => $self->C_xmlns_ebay
}
);
## don't process it again ## don't process it again
delete $pd_types{OrderTotal}; delete $pd_types{OrderTotal};
for my $field ( keys %pd_types ) { for my $field ( keys %pd_types ) {
if( $args{$field} ) { if ( $args{$field} ) {
push @payment_details, push @payment_details,
SOAP::Data->name( $field => $args{$field} ) SOAP::Data->name( $field => $args{$field} )
->type( $pd_types{$field} ); ->type( $pd_types{$field} );
} }
} }
## ##
@ -375,20 +451,19 @@ sub DoReferenceTransaction {
## ##
my @ship_types = (); my @ship_types = ();
for my $field ( keys %st_types ) { for my $field ( keys %st_types ) {
if( $args{$field} ) { if ( $args{$field} ) {
(my $name = $field) =~ s/^ST_//; ( my $name = $field ) =~ s/^ST_//;
push @ship_types, push @ship_types,
SOAP::Data->name( $name => $args{$field} ) SOAP::Data->name( $name => $args{$field} )
->type( $st_types{$field} ); ->type( $st_types{$field} );
} }
} }
if( scalar @ship_types ) { if ( scalar @ship_types ) {
push @payment_details, push @payment_details,
SOAP::Data->name( ShipToAddress => \SOAP::Data->value SOAP::Data->name( ShipToAddress =>
( @ship_types )->type('ebl:AddressType') \SOAP::Data->value( @ship_types )->type( 'ebl:AddressType' )
->attr( {xmlns => $self->C_xmlns_ebay} ), ->attr( { xmlns => $self->C_xmlns_ebay } ), );
);
} }
## ##
@ -396,75 +471,83 @@ sub DoReferenceTransaction {
## ##
my @payment_details_item = (); my @payment_details_item = ();
for my $field ( keys %pdi_types ) { for my $field ( keys %pdi_types ) {
if( $args{$field} ) { if ( $args{$field} ) {
(my $name = $field) =~ s/^PDI_//; ( my $name = $field ) =~ s/^PDI_//;
push @payment_details_item, push @payment_details_item,
SOAP::Data->name( $name => $args{$field} ) SOAP::Data->name( $name => $args{$field} )
->type( $pdi_types{$field} ); ->type( $pdi_types{$field} );
} }
} }
if( scalar @payment_details_item ) { if ( scalar @payment_details_item ) {
push @payment_details, push @payment_details,
SOAP::Data->name( PaymentDetailsItem => \SOAP::Data->value SOAP::Data->name(
( @payment_details_item )->type('ebl:PaymentDetailsItemType') PaymentDetailsItem => \SOAP::Data->value( @payment_details_item )
->attr( {xmlns => $self->C_xmlns_ebay} ), ->type( 'ebl:PaymentDetailsItemType' )
); ->attr( { xmlns => $self->C_xmlns_ebay } ), );
} }
## ##
## ReferenceTransactionPaymentDetails ## ReferenceTransactionPaymentDetails
## ##
my @reference_details = ( my @reference_details = (
SOAP::Data->name( ReferenceID => $args{ReferenceID} ) SOAP::Data->name( ReferenceID => $args{ReferenceID} )
->type($types{ReferenceID})->attr( {xmlns => $self->C_xmlns_ebay} ), ->type( $types{ReferenceID} )
SOAP::Data->name( PaymentAction => $args{PaymentAction} ) ->attr( { xmlns => $self->C_xmlns_ebay } ),
->type($types{PaymentAction})->attr( {xmlns => $self->C_xmlns_ebay} ), SOAP::Data->name( PaymentAction => $args{PaymentAction} )
SOAP::Data->name( PaymentDetails => \SOAP::Data->value ->type( $types{PaymentAction} )
( @payment_details )->type('ebl:PaymentDetailsType') ->attr( { xmlns => $self->C_xmlns_ebay } ),
->attr( {xmlns => $self->C_xmlns_ebay} ), SOAP::Data->name(
), ); PaymentDetails => \SOAP::Data->value( @payment_details )
->type( 'ebl:PaymentDetailsType' )
->attr( { xmlns => $self->C_xmlns_ebay } ),
),
);
## ##
## the main request object ## the main request object
## ##
my $request = SOAP::Data my $request = SOAP::Data->name(
->name( DoReferenceTransactionRequest => \SOAP::Data->value DoReferenceTransactionRequest => \SOAP::Data->value(
( $self->version_req, $self->version_req,
SOAP::Data->name( DoReferenceTransactionRequestDetails => \SOAP::Data->value SOAP::Data->name(
( @reference_details )->type( 'ns:DoReferenceTransactionRequestDetailsType' ) DoReferenceTransactionRequestDetails =>
)->attr( {xmlns => $self->C_xmlns_ebay} ), \SOAP::Data->value( @reference_details )
) ->type( 'ns:DoReferenceTransactionRequestDetailsType' )
); )->attr( { xmlns => $self->C_xmlns_ebay } ),
)
);
my $som = $self->doCall( DoReferenceTransactionReq => $request ) my $som = $self->doCall( DoReferenceTransactionReq => $request )
or return; or return;
my $path = '/Envelope/Body/DoReferenceTransactionResponse'; my $path = '/Envelope/Body/DoReferenceTransactionResponse';
my %response = (); my %response = ();
unless( $self->getBasic($som, $path, \%response) ) { unless ( $self->getBasic( $som, $path, \%response ) ) {
$self->getErrors($som, $path, \%response); $self->getErrors( $som, $path, \%response );
return %response; return %response;
} }
$self->getFields( $som, $self->getFields(
"$path/DoReferenceTransactionResponseDetails", $som,
\%response, "$path/DoReferenceTransactionResponseDetails",
{ BillingAgreementID => 'BillingAgreementID', \%response,
TransactionID => 'PaymentInfo/TransactionID', { BillingAgreementID => 'BillingAgreementID',
TransactionType => 'PaymentInfo/TransactionType', TransactionID => 'PaymentInfo/TransactionID',
PaymentType => 'PaymentInfo/PaymentType', TransactionType => 'PaymentInfo/TransactionType',
PaymentDate => 'PaymentInfo/PaymentDate', PaymentType => 'PaymentInfo/PaymentType',
GrossAmount => 'PaymentInfo/GrossAmount', PaymentDate => 'PaymentInfo/PaymentDate',
FeeAmount => 'PaymentInfo/FeeAmount', GrossAmount => 'PaymentInfo/GrossAmount',
SettleAmount => 'PaymentInfo/SettleAmount', FeeAmount => 'PaymentInfo/FeeAmount',
TaxAmount => 'PaymentInfo/TaxAmount', SettleAmount => 'PaymentInfo/SettleAmount',
ExchangeRate => 'PaymentInfo/ExchangeRate', TaxAmount => 'PaymentInfo/TaxAmount',
PaymentStatus => 'PaymentInfo/PaymentStatus', ExchangeRate => 'PaymentInfo/ExchangeRate',
PendingReason => 'PaymentInfo/PendingReason', PaymentStatus => 'PaymentInfo/PaymentStatus',
ReasonCode => 'PaymentInfor/ReasonCode', PendingReason => 'PaymentInfo/PendingReason',
} ); ReasonCode => 'PaymentInfor/ReasonCode',
}
);
return %response; return %response;
} }

View file

@ -7,60 +7,67 @@ use warnings;
use SOAP::Lite 0.67; use SOAP::Lite 0.67;
use Business::PayPal::API (); use Business::PayPal::API ();
our @ISA = qw(Business::PayPal::API); our @ISA = qw(Business::PayPal::API);
our @EXPORT_OK = qw(RefundTransaction); our @EXPORT_OK = qw(RefundTransaction);
sub RefundTransaction { sub RefundTransaction {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my %types = ( TransactionID => 'xs:string', my %types = (
RefundType => '', ## Other | Full | Partial TransactionID => 'xs:string',
Amount => 'ebl:BasicAmountType', RefundType => '', ## Other | Full | Partial
Memo => 'xs:string', ); Amount => 'ebl:BasicAmountType',
Memo => 'xs:string',
);
$args{currencyID} ||= 'USD'; $args{currencyID} ||= 'USD';
$args{RefundType} ||= 'Full'; $args{RefundType} ||= 'Full';
my @ref_trans = my @ref_trans = (
( $self->version_req,
$self->version_req, SOAP::Data->name( TransactionID => $args{TransactionID} )
SOAP::Data->name( TransactionID => $args{TransactionID} )->type($types{TransactionID}), ->type( $types{TransactionID} ),
SOAP::Data->name( RefundType => $args{RefundType} )->type($types{RefundType}), SOAP::Data->name( RefundType => $args{RefundType} )
); ->type( $types{RefundType} ),
);
if( $args{RefundType} ne 'Full' && $args{Amount} ) { if ( $args{RefundType} ne 'Full' && $args{Amount} ) {
push @ref_trans, push @ref_trans,
SOAP::Data->name( Amount => $args{Amount} ) SOAP::Data->name( Amount => $args{Amount} )
->type( $types{Amount} ) ->type( $types{Amount} )
->attr( { currencyID => $args{currencyID} } ) ->attr( { currencyID => $args{currencyID} } );
} }
push @ref_trans, push @ref_trans,
SOAP::Data->name( Memo => $args{Memo} )->type( $types{Memo} ) SOAP::Data->name( Memo => $args{Memo} )->type( $types{Memo} )
if $args{Memo}; if $args{Memo};
my $request = SOAP::Data->name my $request
( RefundTransactionRequest => \SOAP::Data->value( @ref_trans ) ) = SOAP::Data->name(
->type("ns:RefundTransactionRequestType"); RefundTransactionRequest => \SOAP::Data->value( @ref_trans ) )
->type( "ns:RefundTransactionRequestType" );
my $som = $self->doCall( RefundTransactionReq => $request ) my $som = $self->doCall( RefundTransactionReq => $request )
or return; or return;
my $path = '/Envelope/Body/RefundTransactionResponse'; my $path = '/Envelope/Body/RefundTransactionResponse';
my %response = (); my %response = ();
unless( $self->getBasic($som, $path, \%response) ) { unless ( $self->getBasic( $som, $path, \%response ) ) {
$self->getErrors($som, $path, \%response); $self->getErrors( $som, $path, \%response );
return %response; return %response;
} }
$self->getFields($som, $path, \%response, $self->getFields(
{ RefundTransactionID => 'RefundTransactionID', $som, $path,
FeeRefundAmount => 'FeeRefundAmount', \%response,
NetRefundAmount => 'NetRefundAmount', { RefundTransactionID => 'RefundTransactionID',
GrossRefundAmount => 'GrossRefundAmount', } FeeRefundAmount => 'FeeRefundAmount',
); NetRefundAmount => 'NetRefundAmount',
GrossRefundAmount => 'GrossRefundAmount',
}
);
return %response; return %response;
} }

View file

@ -7,66 +7,72 @@ use warnings;
use SOAP::Lite 0.67; use SOAP::Lite 0.67;
use Business::PayPal::API (); use Business::PayPal::API ();
our @ISA = qw(Business::PayPal::API); our @ISA = qw(Business::PayPal::API);
our @EXPORT_OK = qw( TransactionSearch ); our @EXPORT_OK = qw( TransactionSearch );
sub TransactionSearch { sub TransactionSearch {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my %types = ( StartDate => 'xs:dateTime', my %types = (
EndDate => 'xs:dateTime', StartDate => 'xs:dateTime',
Payer => 'ebl:EmailAddressType', EndDate => 'xs:dateTime',
Receiver => 'ebl:EmailAddressType', Payer => 'ebl:EmailAddressType',
ReceiptID => 'xs:string', Receiver => 'ebl:EmailAddressType',
TransactionID => 'xs:string', ReceiptID => 'xs:string',
InvoiceID => 'xs:string', TransactionID => 'xs:string',
PayerName => 'xs:string', InvoiceID => 'xs:string',
AuctionItemNumer => 'xs:string', PayerName => 'xs:string',
TransactionClass => '', AuctionItemNumer => 'xs:string',
Amount => 'ebl:BasicAmountType', TransactionClass => '',
CurrencyCode => 'xs:token', Amount => 'ebl:BasicAmountType',
Status => '', CurrencyCode => 'xs:token',
); Status => '',
);
my @trans = my @trans = (
( $self->version_req,
$self->version_req, SOAP::Data->name( StartDate => $args{StartDate} )
SOAP::Data->name( StartDate => $args{StartDate} )->type( delete $types{StartDate} ) ->type( delete $types{StartDate} )
); );
for my $type ( keys %types ) { for my $type ( keys %types ) {
next unless $args{$type}; next unless $args{$type};
push @trans, SOAP::Data->name( $type => $args{$type} )->type($types{$type}); push @trans,
SOAP::Data->name( $type => $args{$type} )->type( $types{$type} );
} }
my $request = SOAP::Data->name my $request
( TransactionSearchRequest => \SOAP::Data->value( @trans ) ) = SOAP::Data->name(
->type("ns:TransactionSearchRequestType"); TransactionSearchRequest => \SOAP::Data->value( @trans ) )
->type( "ns:TransactionSearchRequestType" );
my $som = $self->doCall( TransactionSearchReq => $request ) my $som = $self->doCall( TransactionSearchReq => $request )
or return; or return;
my $path = '/Envelope/Body/TransactionSearchResponse'; my $path = '/Envelope/Body/TransactionSearchResponse';
my %response = (); my %response = ();
unless( $self->getBasic($som, $path, \%response) ) { unless ( $self->getBasic( $som, $path, \%response ) ) {
$self->getErrors($som, $path, \%response); $self->getErrors( $som, $path, \%response );
return %response; return %response;
} }
return $self->getFieldsList( $som, $path . '/PaymentTransactions', return $self->getFieldsList(
{ Timestamp => 'Timestamp', $som,
Timezone => 'Timezone', $path . '/PaymentTransactions',
Type => 'Type', { Timestamp => 'Timestamp',
Payer => 'Payer', Timezone => 'Timezone',
PayerDisplayName => 'PayerDisplayName', Type => 'Type',
TransactionID => 'TransactionID', Payer => 'Payer',
Status => 'Status', PayerDisplayName => 'PayerDisplayName',
GrossAmount => 'GrossAmount', TransactionID => 'TransactionID',
FeeAmount => 'FeeAmount', Status => 'Status',
NetAmount => 'NetAmount', GrossAmount => 'GrossAmount',
} ); FeeAmount => 'FeeAmount',
NetAmount => 'NetAmount',
}
);
} }
1; 1;

View file

@ -7,46 +7,47 @@ use warnings;
use SOAP::Lite 0.67; use SOAP::Lite 0.67;
use Business::PayPal::API (); use Business::PayPal::API ();
our @ISA = qw(Business::PayPal::API); our @ISA = qw(Business::PayPal::API);
our @EXPORT_OK = qw(DoVoidRequest); our @EXPORT_OK = qw(DoVoidRequest);
sub DoVoidRequest { sub DoVoidRequest {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my %types = ( AuthorizationID => 'xs:string', my %types = (
Note => 'xs:string', ); AuthorizationID => 'xs:string',
Note => 'xs:string',
);
my @ref_trans = (
$self->version_req,
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )
->type( $types{AuthorizationID} ),
);
my @ref_trans = if ( $args{Note} ) {
( push @ref_trans,
$self->version_req, SOAP::Data->name( Note => $args{Note} )->type( $types{Note} )
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )->type($types{AuthorizationID}), if $args{Note};
);
if ($args{Note}) {
push @ref_trans,
SOAP::Data->name( Note => $args{Note} )->type( $types{Note} )
if $args{Note};
} }
my $request = SOAP::Data->name my $request
( DoVoidRequest => \SOAP::Data->value( @ref_trans ) ) = SOAP::Data->name(
->type("ns:VoidRequestType"); DoVoidRequest => \SOAP::Data->value( @ref_trans ) )
->type( "ns:VoidRequestType" );
my $som = $self->doCall( DoVoidReq => $request ) my $som = $self->doCall( DoVoidReq => $request )
or return; or return;
my $path = '/Envelope/Body/DoVoidResponse'; my $path = '/Envelope/Body/DoVoidResponse';
my %response = (); my %response = ();
unless( $self->getBasic($som, $path, \%response) ) { unless ( $self->getBasic( $som, $path, \%response ) ) {
$self->getErrors($som, $path, \%response); $self->getErrors( $som, $path, \%response );
return %response; return %response;
} }
$self->getFields($som, $path, \%response, $self->getFields( $som, $path, \%response,
{ AuthorizationID => 'AuthorizationID' } { AuthorizationID => 'AuthorizationID' } );
);
return %response; return %response;
} }

View file

@ -1,3 +1,4 @@
=pod =pod
The tester must supply their own PayPal sandbox seller authentication The tester must supply their own PayPal sandbox seller authentication
@ -13,33 +14,34 @@ variable:
=cut =cut
sub do_args { sub do_args {
unless( $ENV{WPP_TEST} && -f $ENV{WPP_TEST} ) { unless ( $ENV{WPP_TEST} && -f $ENV{WPP_TEST} ) {
die "See the TESTING section in `perldoc Business::PayPal::API documentation`\n"; die
"See the TESTING section in `perldoc Business::PayPal::API documentation`\n";
exit; exit;
} }
my %args = (); my %args = ();
open FILE, "<", $ENV{WPP_TEST} open FILE, "<", $ENV{WPP_TEST}
or die "Could not open $ENV{WPP_TEST}: $!\n"; or die "Could not open $ENV{WPP_TEST}: $!\n";
my @variables = qw( Username Password Signature Subject timeout my @variables = qw( Username Password Signature Subject timeout
CertFile KeyFile PKCS12File PKCS12Password CertFile KeyFile PKCS12File PKCS12Password
BuyerEmail BuyerEmail
); );
my %patterns = (); my %patterns = ();
@patterns{map { qr/^$_\b/i } @variables} = @variables; @patterns{ map {qr/^$_\b/i} @variables } = @variables;
while( <FILE> ) { while ( <FILE> ) {
chomp; chomp;
MATCH: for my $pat (keys %patterns) { MATCH: for my $pat ( keys %patterns ) {
next unless $_ =~ $pat; next unless $_ =~ $pat;
(my $value = $_) =~ s/$pat\s*=\s*(.+)/$1/; ( my $value = $_ ) =~ s/$pat\s*=\s*(.+)/$1/;
$args{ $patterns{$pat} } = $value; $args{ $patterns{$pat} } = $value;
delete $patterns{$pat}; delete $patterns{$pat};
last MATCH; last MATCH;
} }
} }
close FILE; close FILE;

View file

@ -1,5 +1,5 @@
use Test::More tests => 1; use Test::More tests => 1;
BEGIN { use_ok('Business::PayPal::API') }; BEGIN { use_ok( 'Business::PayPal::API' ) }
######################### #########################

View file

@ -3,156 +3,174 @@ use strict;
use warnings; use warnings;
use Test::More; use Test::More;
if( ! $ENV{WPP_TEST} || ! -f $ENV{WPP_TEST} ) { if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests'; plan skip_all =>
'No WPP_TEST env var set. Please see README to run tests';
} }
else { else {
plan tests => '7'; plan tests => '7';
} }
use Business::PayPal::API qw( DirectPayments CaptureRequest ReauthorizationRequest VoidRequest RefundTransaction ); use Business::PayPal::API
qw( DirectPayments CaptureRequest ReauthorizationRequest VoidRequest RefundTransaction );
my @methlist = qw( DirectPayments CaptureRequest ReauthorizationRequest VoidRequest RefundTransaction); my @methlist
use_ok('Business::PayPal::API', @methlist); = qw( DirectPayments CaptureRequest ReauthorizationRequest VoidRequest RefundTransaction);
use_ok( 'Business::PayPal::API', @methlist );
require 't/API.pl'; require 't/API.pl';
my %args = do_args(); my %args = do_args();
my ($transale,$tranvoid,$tranbasic,$tranrefund); my ( $transale, $tranvoid, $tranbasic, $tranrefund );
my ($ppsale,$ppvoid,$ppbasic,$pprefund,$pprefund1,$ppcap,$ppcap1); my ( $ppsale, $ppvoid, $ppbasic, $pprefund, $pprefund1, $ppcap, $ppcap1 );
my (%respsale,%resprefund,%resprefund1,%respbasic,%respcap,%respcap1,%respvoid); my (%respsale, %resprefund, %resprefund1, %respbasic,
%respcap, %respcap1, %respvoid
);
#Test Full Refund on Sale #Test Full Refund on Sale
#$Business::PayPal::API::Debug=1; #$Business::PayPal::API::Debug=1;
$ppsale = new Business::PayPal::API(%args); $ppsale = new Business::PayPal::API( %args );
%respsale = $ppsale->DoDirectPaymentRequest ( %respsale = $ppsale->DoDirectPaymentRequest(
PaymentAction => 'Sale', PaymentAction => 'Sale',
OrderTotal => 11.87, OrderTotal => 11.87,
TaxTotal => 0.0, TaxTotal => 0.0,
ItemTotal => 0.0, ItemTotal => 0.0,
CreditCardType => 'Visa', CreditCardType => 'Visa',
CreditCardNumber => '4561435600988217', CreditCardNumber => '4561435600988217',
ExpMonth => '01', ExpMonth => '01',
ExpYear => +(localtime)[5]+1901, ExpYear => +( localtime )[5] + 1901,
CVV2 => '123', CVV2 => '123',
FirstName => 'JP', FirstName => 'JP',
LastName => 'Morgan', LastName => 'Morgan',
Street1 => '1st Street LaCausa', Street1 => '1st Street LaCausa',
Street2 => '', Street2 => '',
CityName => 'La', CityName => 'La',
StateOrProvince => 'CA', StateOrProvince => 'CA',
PostalCode => '90210', PostalCode => '90210',
Country => 'US', Country => 'US',
Payer => 'mall@example.org', Payer => 'mall@example.org',
CurrencyID => 'USD', CurrencyID => 'USD',
IPAddress => '10.0.0.1', IPAddress => '10.0.0.1',
MerchantSessionID => '10113301', MerchantSessionID => '10113301',
); );
#$Business::PayPal::API::Debug=0; #$Business::PayPal::API::Debug=0;
if(like( $respsale{'Ack'}, qr/Success/, 'Direct Payment Sale')) { if ( like( $respsale{'Ack'}, qr/Success/, 'Direct Payment Sale' ) ) {
$transale = $respsale{'TransactionID'}; $transale = $respsale{'TransactionID'};
#$Business::PayPal::API::Debug=1;
$pprefund = new Business::PayPal::API(%args); #$Business::PayPal::API::Debug=1;
%resprefund = $pprefund->RefundTransaction ( $pprefund = new Business::PayPal::API( %args );
TransactionID => $transale, %resprefund = $pprefund->RefundTransaction(
RefundType => 'Full', TransactionID => $transale,
Memo => 'Full direct sale refund', RefundType => 'Full',
); Memo => 'Full direct sale refund',
#$Business::PayPal::API::Debug=0; );
like( $resprefund{'Ack'}, qr/Success/, 'Full Refund For Sale');
} #$Business::PayPal::API::Debug=0;
like( $resprefund{'Ack'}, qr/Success/, 'Full Refund For Sale' );
}
#Basic Authorization and Capture #Basic Authorization and Capture
%args=do_args(); %args = do_args();
#$Business::PayPal::API::Debug=0;
$ppbasic = new Business::PayPal::API(%args);
%respbasic = $ppbasic->DoDirectPaymentRequest (
PaymentAction => 'Authorization',
OrderTotal => 13.87,
TaxTotal => 0.0,
ItemTotal => 0.0,
CreditCardType => 'Visa',
CreditCardNumber => '4561435600988217',
ExpMonth => '01',
ExpYear => +(localtime)[5]+1901,
CVV2 => '123',
FirstName => 'JP',
LastName => 'Morgan',
Street1 => '1st Street LaCausa',
Street2 => '',
CityName => 'La',
StateOrProvince => 'CA',
PostalCode => '90210',
Country => 'US',
Payer => 'mall@example.org',
CurrencyID => 'USD',
IPAddress => '10.0.0.1',
MerchantSessionID => '10113301',
);
#$Business::PayPal::API::Debug=0; #$Business::PayPal::API::Debug=0;
if( like( $respbasic{'Ack'}, qr/Success/, 'Direct Payment Basic Authorization') ) { $ppbasic = new Business::PayPal::API( %args );
%respbasic = $ppbasic->DoDirectPaymentRequest(
PaymentAction => 'Authorization',
OrderTotal => 13.87,
TaxTotal => 0.0,
ItemTotal => 0.0,
CreditCardType => 'Visa',
CreditCardNumber => '4561435600988217',
ExpMonth => '01',
ExpYear => +( localtime )[5] + 1901,
CVV2 => '123',
FirstName => 'JP',
LastName => 'Morgan',
Street1 => '1st Street LaCausa',
Street2 => '',
CityName => 'La',
StateOrProvince => 'CA',
PostalCode => '90210',
Country => 'US',
Payer => 'mall@example.org',
CurrencyID => 'USD',
IPAddress => '10.0.0.1',
MerchantSessionID => '10113301',
);
#$Business::PayPal::API::Debug=0;
if (like(
$respbasic{'Ack'}, qr/Success/,
'Direct Payment Basic Authorization'
)
)
{
$tranbasic = $respbasic{'TransactionID'}; $tranbasic = $respbasic{'TransactionID'};
#Test Partial Capture #Test Partial Capture
#$Business::PayPal::API::Debug=1; #$Business::PayPal::API::Debug=1;
$ppcap = new Business::PayPal::API(%args); $ppcap = new Business::PayPal::API( %args );
%respcap = $ppcap->DoCaptureRequest(
AuthorizationID => $tranbasic,
CompleteType => 'NotComplete',
Amount => '3.00',
Note => 'Partial Capture',
);
%respcap = $ppcap->DoCaptureRequest (
AuthorizationID => $tranbasic,
CompleteType => 'NotComplete',
Amount => '3.00',
Note => 'Partial Capture',
);
#$Business::PayPal::API::Debug=0; #$Business::PayPal::API::Debug=0;
like( $respcap{'Ack'}, qr/Success/, 'Partial Capture'); like( $respcap{'Ack'}, qr/Success/, 'Partial Capture' );
#Test Full Capture #Test Full Capture
#$Business::PayPal::API::Debug=1; #$Business::PayPal::API::Debug=1;
$ppcap1 = new Business::PayPal::API(%args); $ppcap1 = new Business::PayPal::API( %args );
%respcap1 = $ppcap1->DoCaptureRequest ( %respcap1 = $ppcap1->DoCaptureRequest(
AuthorizationID => $tranbasic, AuthorizationID => $tranbasic,
CompleteType => 'Complete', CompleteType => 'Complete',
Amount => '6.00', Amount => '6.00',
); );
#$Business::PayPal::API::Debug=0; #$Business::PayPal::API::Debug=0;
like( $respcap1{'Ack'}, qr/Success/, 'Full Capture'); like( $respcap1{'Ack'}, qr/Success/, 'Full Capture' );
} }
else { skip( "direct payment auth failed", 2 ) } else { skip( "direct payment auth failed", 2 ) }
#Test Void #Test Void
$ppbasic = new Business::PayPal::API(%args); $ppbasic = new Business::PayPal::API( %args );
%respbasic = $ppbasic->DoDirectPaymentRequest ( %respbasic = $ppbasic->DoDirectPaymentRequest(
PaymentAction => 'Authorization', PaymentAction => 'Authorization',
OrderTotal => 17.37, OrderTotal => 17.37,
TaxTotal => 0.0, TaxTotal => 0.0,
ItemTotal => 0.0, ItemTotal => 0.0,
CreditCardType => 'Visa', CreditCardType => 'Visa',
CreditCardNumber => '4561435600988217', CreditCardNumber => '4561435600988217',
ExpMonth => '01', ExpMonth => '01',
ExpYear => +(localtime)[5]+1901, ExpYear => +( localtime )[5] + 1901,
CVV2 => '123', CVV2 => '123',
FirstName => 'JP', FirstName => 'JP',
LastName => 'Morgan', LastName => 'Morgan',
Street1 => '1st Street LaCausa', Street1 => '1st Street LaCausa',
Street2 => '', Street2 => '',
CityName => 'La', CityName => 'La',
StateOrProvince => 'CA', StateOrProvince => 'CA',
PostalCode => '90210', PostalCode => '90210',
Country => 'US', Country => 'US',
Payer => 'mall@example.org', Payer => 'mall@example.org',
CurrencyID => 'USD', CurrencyID => 'USD',
IPAddress => '10.0.0.1', IPAddress => '10.0.0.1',
MerchantSessionID => '10113301', MerchantSessionID => '10113301',
); );
#$Business::PayPal::API::Debug=1; #$Business::PayPal::API::Debug=1;
$ppvoid = new Business::PayPal::API(%args); $ppvoid = new Business::PayPal::API( %args );
%respvoid = $ppvoid->DoVoidRequest ( AuthorizationID => $respbasic{TransactionID}, %respvoid = $ppvoid->DoVoidRequest(
Note => 'Authorization Void', ); AuthorizationID => $respbasic{TransactionID},
Note => 'Authorization Void',
);
#$Business::PayPal::API::Debug=0; #$Business::PayPal::API::Debug=0;
like( $respvoid{'Ack'}, qr/Success/, 'Authorization Voided'); like( $respvoid{'Ack'}, qr/Success/, 'Authorization Voided' );

View file

@ -1,6 +1,7 @@
use Test::More; use Test::More;
if( ! $ENV{WPP_TEST} || ! -f $ENV{WPP_TEST} ) { if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests'; plan skip_all =>
'No WPP_TEST env var set. Please see README to run tests';
} }
else { else {
plan tests => 6; plan tests => 6;
@ -22,24 +23,27 @@ my $pp = new Business::PayPal::API::ExpressCheckout( %args );
## set checkout info ## set checkout info
## ##
#$Business::PayPal::API::Debug = 1; #$Business::PayPal::API::Debug = 1;
my %response = $pp->SetExpressCheckout my %response = $pp->SetExpressCheckout(
( OrderTotal => '55.43', OrderTotal => '55.43',
ReturnURL => 'http://www.google.com/', ReturnURL => 'http://www.google.com/',
CancelURL => 'http://www.google.com/', CancelURL => 'http://www.google.com/',
Custom => "This field is custom. Isn't that great?", Custom => "This field is custom. Isn't that great?",
PaymentAction => 'Sale', PaymentAction => 'Sale',
BuyerEmail => $args{BuyerEmail}, ## from %args BuyerEmail => $args{BuyerEmail}, ## from %args
); );
#$Business::PayPal::API::Debug = 0; #$Business::PayPal::API::Debug = 0;
my $token = $response{Token}; my $token = $response{Token};
ok( $token, "Got token" ); ok( $token, "Got token" );
die "No token from PayPal! Check your authentication information and try again." die
unless $token; "No token from PayPal! Check your authentication information and try again."
unless $token;
my $pp_url = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=$token"; my $pp_url
= "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=$token";
print STDERR <<"_TOKEN_"; print STDERR <<"_TOKEN_";
@ -61,14 +65,15 @@ _TOKEN_
print STDERR "\nType or paste that PayerID here and hit Enter: \n"; print STDERR "\nType or paste that PayerID here and hit Enter: \n";
my $payerid = <STDIN>; chomp $payerid; my $payerid = <STDIN>;
chomp $payerid;
die "Need a PayerID.\n" unless $payerid; die "Need a PayerID.\n" unless $payerid;
## ##
## get checkout details ## get checkout details
## ##
my %details = $pp->GetExpressCheckoutDetails($token); my %details = $pp->GetExpressCheckoutDetails( $token );
is( $details{Token}, $token, "details ok" ); is( $details{Token}, $token, "details ok" );
#use Data::Dumper; #use Data::Dumper;
@ -76,17 +81,18 @@ is( $details{Token}, $token, "details ok" );
$details{PayerID} = $payerid; $details{PayerID} = $payerid;
my %payment = ( Token => $details{Token}, my %payment = (
PaymentAction => 'Sale', Token => $details{Token},
PayerID => $details{PayerID}, PaymentAction => 'Sale',
OrderTotal => '55.43', PayerID => $details{PayerID},
); OrderTotal => '55.43',
);
## ##
## do checkout ## do checkout
## ##
my %payinfo = $pp->DoExpressCheckoutPayment(%payment); my %payinfo = $pp->DoExpressCheckoutPayment( %payment );
like( $payinfo{Ack}, qr/Success/ , "successful payment" ); like( $payinfo{Ack}, qr/Success/, "successful payment" );
is( $payinfo{Token}, $token, "payment ok" ); is( $payinfo{Token}, $token, "payment ok" );
is( $payinfo{GrossAmount}, 55.43, "amount correct" ); is( $payinfo{GrossAmount}, 55.43, "amount correct" );

View file

@ -1,6 +1,7 @@
use Test::More; use Test::More;
if( ! $ENV{WPP_TEST} || ! -f $ENV{WPP_TEST} ) { if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests'; plan skip_all =>
'No WPP_TEST env var set. Please see README to run tests';
} }
else { else {
plan tests => 8; plan tests => 8;
@ -22,24 +23,27 @@ my $pp = new Business::PayPal::API::ExpressCheckout( %args );
## set checkout info ## set checkout info
## ##
#$Business::PayPal::API::Debug = 1; #$Business::PayPal::API::Debug = 1;
my %response = $pp->SetExpressCheckout my %response = $pp->SetExpressCheckout(
( OrderTotal => '55.43', OrderTotal => '55.43',
ReturnURL => 'http://www.google.com/', ReturnURL => 'http://www.google.com/',
CancelURL => 'http://www.google.com/', CancelURL => 'http://www.google.com/',
Custom => "This field is custom. Isn't that great?", Custom => "This field is custom. Isn't that great?",
PaymentAction => 'Order', PaymentAction => 'Order',
BuyerEmail => $args{BuyerEmail}, ## from %args BuyerEmail => $args{BuyerEmail}, ## from %args
); );
#$Business::PayPal::API::Debug = 0; #$Business::PayPal::API::Debug = 0;
my $token = $response{Token}; my $token = $response{Token};
ok( $token, "Got token" ); ok( $token, "Got token" );
die "No token from PayPal! Check your authentication information and try again." die
unless $token; "No token from PayPal! Check your authentication information and try again."
unless $token;
my $pp_url = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=$token"; my $pp_url
= "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=$token";
print STDERR <<"_TOKEN_"; print STDERR <<"_TOKEN_";
@ -63,14 +67,15 @@ _TOKEN_
print STDERR "\nType or paste that PayerID here and hit Enter: \n"; print STDERR "\nType or paste that PayerID here and hit Enter: \n";
my $payerid = <STDIN>; chomp $payerid; my $payerid = <STDIN>;
chomp $payerid;
die "Need a PayerID.\n" unless $payerid; die "Need a PayerID.\n" unless $payerid;
## ##
## get checkout details ## get checkout details
## ##
my %details = $pp->GetExpressCheckoutDetails($token); my %details = $pp->GetExpressCheckoutDetails( $token );
is( $details{Token}, $token, "details ok" ); is( $details{Token}, $token, "details ok" );
#use Data::Dumper; #use Data::Dumper;
@ -78,35 +83,42 @@ is( $details{Token}, $token, "details ok" );
$details{PayerID} = $payerid; $details{PayerID} = $payerid;
my %payment = ( Token => $details{Token}, my %payment = (
PaymentAction => 'Order', Token => $details{Token},
PayerID => $details{PayerID}, PaymentAction => 'Order',
OrderTotal => '55.43', PayerID => $details{PayerID},
); OrderTotal => '55.43',
);
## ##
## do checkout ## do checkout
## ##
#$Business::PayPal::API::Debug = 1; #$Business::PayPal::API::Debug = 1;
my %payinfo = $pp->DoExpressCheckoutPayment(%payment); my %payinfo = $pp->DoExpressCheckoutPayment( %payment );
#$Business::PayPal::API::Debug = 0; #$Business::PayPal::API::Debug = 0;
#If Order is successful then authorize it, then void it. #If Order is successful then authorize it, then void it.
if(like( $payinfo{Ack}, qr/Success/ , "successful payment" )) { if ( like( $payinfo{Ack}, qr/Success/, "successful payment" ) ) {
my $transid= $payinfo{TransactionID}; my $transid = $payinfo{TransactionID};
my $amount= '25.43'; my $amount = '25.43';
use_ok('Business::PayPal::API::AuthorizationRequest'); use_ok( 'Business::PayPal::API::AuthorizationRequest' );
%args = do_args(); %args = do_args();
#$Business::PayPal::API::Debug = 1;
$ppauth = new Business::PayPal::API::AuthorizationRequest(%args); #$Business::PayPal::API::Debug = 1;
my %resp = $ppauth->DoAuthorizationRequest( TransactionID => $transid, $ppauth = new Business::PayPal::API::AuthorizationRequest( %args );
Amount => $amount); my %resp = $ppauth->DoAuthorizationRequest(
like( $resp{Ack}, qr/Succes/ , 'Successful order authorization' ); TransactionID => $transid,
Amount => $amount
);
like( $resp{Ack}, qr/Succes/, 'Successful order authorization' );
use_ok( 'Business::PayPal::API::VoidRequest' ); use_ok( 'Business::PayPal::API::VoidRequest' );
%args = do_args(); %args = do_args();
my $ppvoid= new Business::PayPal::API::VoidRequest( %args ); my $ppvoid = new Business::PayPal::API::VoidRequest( %args );
%resp1= $ppvoid->DoVoidRequest( AuthorizationID => $transid, %resp1 = $ppvoid->DoVoidRequest(
Note => 'Voided' ); AuthorizationID => $transid,
Note => 'Voided'
);
like( $resp1{Ack}, qr/Success/, 'Successful order void' ); like( $resp1{Ack}, qr/Success/, 'Successful order void' );
} }

View file

@ -1,6 +1,7 @@
use Test::More; use Test::More;
if( ! $ENV{WPP_TEST} || ! -f $ENV{WPP_TEST} ) { if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests'; plan skip_all =>
'No WPP_TEST env var set. Please see README to run tests';
} }
else { else {
plan tests => 2; plan tests => 2;
@ -34,11 +35,12 @@ _TRANSID_
print STDERR "\nType or paste that Transaction ID here and hit Enter: \n"; print STDERR "\nType or paste that Transaction ID here and hit Enter: \n";
my $transid = <STDIN>; chomp $transid; my $transid = <STDIN>;
chomp $transid;
die "Need a transaction id.\n" unless $transid; die "Need a transaction id.\n" unless $transid;
#$Business::PayPal::API::Debug = 1; #$Business::PayPal::API::Debug = 1;
my %resp = $pp->GetTransactionDetails( TransactionID => $transid ); my %resp = $pp->GetTransactionDetails( TransactionID => $transid );
like( $resp{Ack}, qr/Success/ , "transaction received" ); like( $resp{Ack}, qr/Success/, "transaction received" );

View file

@ -1,6 +1,7 @@
use Test::More; use Test::More;
if( ! $ENV{WPP_TEST} || ! -f $ENV{WPP_TEST} ) { if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests'; plan skip_all =>
'No WPP_TEST env var set. Please see README to run tests';
} }
else { else {
plan tests => 3; plan tests => 3;
@ -16,22 +17,33 @@ my %args = do_args();
my $pp = new Business::PayPal::API::MassPay( %args ); my $pp = new Business::PayPal::API::MassPay( %args );
#$Business::PayPal::API::Debug = 1; #$Business::PayPal::API::Debug = 1;
my %resp = $pp->MassPay( EmailSubject => "This is the subject; nice eh?", my %resp = $pp->MassPay(
MassPayItems => [ { ReceiverEmail => 'joe@test.tld', EmailSubject => "This is the subject; nice eh?",
Amount => '24.00', MassPayItems => [
UniqueID => "123456", { ReceiverEmail => 'joe@test.tld',
Note => "Enjoy the money. Don't spend it all in one place." } ] ); Amount => '24.00',
UniqueID => "123456",
Note => "Enjoy the money. Don't spend it all in one place."
}
]
);
like( $resp{Ack}, qr/Success/ , "successful payment" ); like( $resp{Ack}, qr/Success/, "successful payment" );
%resp = $pp->MassPay( EmailSubject => "This is the subject; nice eh?", %resp = $pp->MassPay(
MassPayItems => [ { ReceiverEmail => 'bob@test.tld', EmailSubject => "This is the subject; nice eh?",
Amount => '25.00', MassPayItems => [
UniqueID => "123457", { ReceiverEmail => 'bob@test.tld',
Note => "Enjoy the money. Don't spend it all in one place." }, Amount => '25.00',
{ ReceiverEmail => 'foo@test.tld', UniqueID => "123457",
Amount => '42.00', Note => "Enjoy the money. Don't spend it all in one place."
UniqueID => "123458", },
Note => "Enjoy the money. Don't spend it all in one place." } ] ); { ReceiverEmail => 'foo@test.tld',
Amount => '42.00',
UniqueID => "123458",
Note => "Enjoy the money. Don't spend it all in one place."
}
]
);
like( $resp{Ack}, qr/Success/ , "successful payments" ); like( $resp{Ack}, qr/Success/, "successful payments" );

View file

@ -1,7 +1,8 @@
# -*- mode: cperl -*- # -*- mode: cperl -*-
use Test::More; use Test::More;
if( ! $ENV{WPP_TEST} || ! -f $ENV{WPP_TEST} ) { if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests'; plan skip_all =>
'No WPP_TEST env var set. Please see README to run tests';
} }
else { else {
plan tests => 3; plan tests => 3;
@ -14,31 +15,32 @@ require 't/API.pl';
my %args = do_args(); my %args = do_args();
my $pp = new Business::PayPal::API::RecurringPayments(%args); my $pp = new Business::PayPal::API::RecurringPayments( %args );
#$Business::PayPal::API::Debug = 1; #$Business::PayPal::API::Debug = 1;
my %response = $pp->SetCustomerBillingAgreement my %response = $pp->SetCustomerBillingAgreement(
( BillingType => 'RecurringPayments',
BillingType => 'RecurringPayments', BillingAgreementDescription => '10.00 per month for 1 year',
BillingAgreementDescription => '10.00 per month for 1 year', ReturnURL => 'http://www.google.com/',
ReturnURL => 'http://www.google.com/', CancelURL => 'http://www.google.com/',
CancelURL => 'http://www.google.com/', BuyerEmail => $args{BuyerEmail},
BuyerEmail => $args{BuyerEmail}, );
);
#$Business::PayPal::API::Debug = 0; #$Business::PayPal::API::Debug = 0;
my $token = $response{Token}; my $token = $response{Token};
ok( $token, "Got token" ); ok( $token, "Got token" );
like( $response{Ack}, qr/Success/ , "SetCustomerBillingAgreement successful" ); like( $response{Ack}, qr/Success/, "SetCustomerBillingAgreement successful" );
exit; exit;
die "No token from PayPal! Check your authentication information and try again." die
unless $token; "No token from PayPal! Check your authentication information and try again."
unless $token;
my $pp_url
my $pp_url = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_customer-billing-agreement&token=$token"; = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_customer-billing-agreement&token=$token";
=pod =pod
@ -68,11 +70,10 @@ die "Need a PayerID.\n" unless $payerid;
=cut =cut
## CreateRecurringPaymentsProfile ## CreateRecurringPaymentsProfile
#$Business::PayPal::API::Debug = 1; #$Business::PayPal::API::Debug = 1;
my %profile = $pp->CreateRecurringPaymentsProfile my %profile = $pp->CreateRecurringPaymentsProfile(
( Token => $token, Token => $token,
## RecurringPaymentProfileDetails ## RecurringPaymentProfileDetails
SubscriberName => 'Joe Schmoe', SubscriberName => 'Joe Schmoe',
@ -91,7 +92,7 @@ my %profile = $pp->CreateRecurringPaymentsProfile
## ScheduleDetails ## ScheduleDetails
Description => '12 Month Hosting Package: We Love You!', Description => '12 Month Hosting Package: We Love You!',
InitialAmount => '12.34', InitialAmount => '12.34',
TrialBillingPeriod => 'Month', TrialBillingPeriod => 'Month',
TrialBillingFrequency => 1, TrialBillingFrequency => 1,
@ -107,17 +108,17 @@ my %profile = $pp->CreateRecurringPaymentsProfile
PaymentShippingAmount => 0.00, PaymentShippingAmount => 0.00,
PaymentTaxAmount => 0.00, PaymentTaxAmount => 0.00,
# MaxFailedPayments => 1, # MaxFailedPayments => 1,
# AutoBillOutstandingAmount => 'AddToNextBilling', # AutoBillOutstandingAmount => 'AddToNextBilling',
); );
#$Business::PayPal::API::Debug = 0; #$Business::PayPal::API::Debug = 0;
## GetBillingAgreementCustomerDetails ## GetBillingAgreementCustomerDetails
#$Business::PayPal::API::Debug = 1; #$Business::PayPal::API::Debug = 1;
my %details = $pp->GetBillingAgreementCustomerDetails($token); my %details = $pp->GetBillingAgreementCustomerDetails( $token );
#$Business::PayPal::API::Debug = 0; #$Business::PayPal::API::Debug = 0;
like( $details{Ack}, qr/Success/ , "details ok" ); like( $details{Ack}, qr/Success/, "details ok" );

View file

@ -1,6 +1,7 @@
use Test::More; use Test::More;
if( ! $ENV{WPP_TEST} || ! -f $ENV{WPP_TEST} ) { if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests'; plan skip_all =>
'No WPP_TEST env var set. Please see README to run tests';
} }
else { else {
plan tests => 2; plan tests => 2;
@ -35,17 +36,20 @@ _TRANSID_
print STDERR "\nType or paste that Transaction ID here and hit Enter: \n"; print STDERR "\nType or paste that Transaction ID here and hit Enter: \n";
my $transid = <STDIN>; chomp $transid; my $transid = <STDIN>;
chomp $transid;
die "Need a transaction id.\n" unless $transid; die "Need a transaction id.\n" unless $transid;
my %resp = $pp->RefundTransaction( TransactionID => $transid, my %resp = $pp->RefundTransaction(
RefundType => 'Full', TransactionID => $transid,
Memo => 'Fancy refund time.' ); RefundType => 'Full',
Memo => 'Fancy refund time.'
);
like( $resp{Ack}, qr/Success/ , "Successful refund." ); like( $resp{Ack}, qr/Success/, "Successful refund." );
if( $resp{Ack} ) { if ( $resp{Ack} ) {
print STDERR <<"_REFUND_"; print STDERR <<"_REFUND_";
You may now login to your Business sandbox account and verify the You may now login to your Business sandbox account and verify the

View file

@ -1,6 +1,7 @@
use Test::More; use Test::More;
if( ! $ENV{WPP_TEST} || ! -f $ENV{WPP_TEST} ) { if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests'; plan skip_all =>
'No WPP_TEST env var set. Please see README to run tests';
} }
else { else {
plan tests => 2; plan tests => 2;
@ -12,7 +13,7 @@ use_ok( 'Business::PayPal::API::TransactionSearch' );
require 't/API.pl'; require 't/API.pl';
my %args = do_args(); my %args = do_args();
my $pp = new Business::PayPal::API::TransactionSearch( %args ); my $pp = new Business::PayPal::API::TransactionSearch( %args );
print STDERR <<"_TRANSID_"; print STDERR <<"_TRANSID_";
@ -36,15 +37,17 @@ _TRANSID_
print STDERR "\nType or paste that Transaction ID here and hit Enter: \n"; print STDERR "\nType or paste that Transaction ID here and hit Enter: \n";
my $transid = <STDIN>; chomp $transid; my $transid = <STDIN>;
chomp $transid;
die "Need a transaction id.\n" unless $transid; die "Need a transaction id.\n" unless $transid;
my $startdate = '1998-01-01T01:45:10.00Z'; my $startdate = '1998-01-01T01:45:10.00Z';
#$Business::PayPal::API::Debug = 1; #$Business::PayPal::API::Debug = 1;
my $resp = $pp->TransactionSearch( StartDate => $startdate, my $resp = $pp->TransactionSearch(
TransactionID => $transid, StartDate => $startdate,
); TransactionID => $transid,
ok( scalar @$resp , "Matching Transactions Found"); );
ok( scalar @$resp, "Matching Transactions Found" );