Tidy everything.
This commit is contained in:
parent
a722bb555c
commit
3878e90817
24 changed files with 1520 additions and 1205 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -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
|
||||||
|
|
|
@ -14,13 +14,13 @@ 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.
|
||||||
|
@ -38,15 +38,18 @@ 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 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +57,7 @@ sub import {
|
||||||
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} ||= '';
|
||||||
|
@ -69,28 +72,36 @@ sub new {
|
||||||
$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}
|
||||||
|
? ( $args{Signature}
|
||||||
? C_api_sandbox_3t
|
? C_api_sandbox_3t
|
||||||
: C_api_sandbox)
|
: C_api_sandbox
|
||||||
: ($args{Signature}
|
)
|
||||||
|
: ( $args{Signature}
|
||||||
? C_api_live_3t
|
? C_api_live_3t
|
||||||
: C_api_live)
|
: 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( '' ),
|
||||||
|
SOAP::Data->name( Signature => $args{Signature} )
|
||||||
|
->type( '' ),
|
||||||
|
SOAP::Data->name( Subject => $args{Subject} )->type( '' ),
|
||||||
),
|
),
|
||||||
)->attr( {xmlns => C_xmlns_ebay} )
|
)->attr( { xmlns => C_xmlns_ebay } )
|
||||||
)
|
)
|
||||||
)->attr( {xmlns => C_xmlns_pp} )->mustUnderstand(1);
|
)->attr( { xmlns => C_xmlns_pp } )->mustUnderstand( 1 );
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
@ -106,56 +117,64 @@ 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}
|
||||||
|
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};
|
$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->faultstring
|
||||||
. ( $som->faultdetail ? " (" . $som->faultdetail . ")" : '' )
|
. ( $som->faultdetail ? " (" . $som->faultdetail . ")" : '' )
|
||||||
. "\n";
|
. "\n";
|
||||||
return;
|
return;
|
||||||
|
@ -174,16 +193,17 @@ sub getFieldsList {
|
||||||
|
|
||||||
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;
|
||||||
|
@ -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 {
|
||||||
|
@ -242,7 +262,7 @@ sub getBasic {
|
||||||
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/;
|
||||||
|
@ -258,9 +278,12 @@ sub getErrors {
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ 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 ();
|
||||||
|
|
||||||
|
@ -15,26 +16,27 @@ 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;
|
||||||
|
@ -42,14 +44,17 @@ sub DoAuthorizationRequest {
|
||||||
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(
|
||||||
|
$som, $path,
|
||||||
|
\%response,
|
||||||
{ TransactionID => 'TransactionID',
|
{ TransactionID => 'TransactionID',
|
||||||
Amount => 'Amount', }
|
Amount => 'Amount',
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return %response;
|
return %response;
|
||||||
|
|
|
@ -5,6 +5,7 @@ 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 ();
|
||||||
|
|
||||||
|
@ -17,6 +18,7 @@ sub DoCaptureRequest {
|
||||||
|
|
||||||
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
|
||||||
|
@ -29,23 +31,25 @@ sub DoCaptureRequest {
|
||||||
$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} )->type($types{AuthorizationID}),
|
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )
|
||||||
SOAP::Data->name( CompleteType => $args{CompleteType} )->type($types{CompleteType}),
|
->type( $types{AuthorizationID} ),
|
||||||
|
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;
|
||||||
|
@ -53,14 +57,15 @@ sub DoCaptureRequest {
|
||||||
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,
|
||||||
|
{ TransactionID => 'TransactionID',
|
||||||
ParentTransactionID => 'ParentTransactionID',
|
ParentTransactionID => 'ParentTransactionID',
|
||||||
ReceiptID => 'ReceiptID',
|
ReceiptID => 'ReceiptID',
|
||||||
TransactionType => 'TransactionType',
|
TransactionType => 'TransactionType',
|
||||||
|
|
|
@ -5,6 +5,7 @@ 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 ();
|
||||||
|
|
||||||
|
@ -15,7 +16,9 @@ sub DoDirectPaymentRequest {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my %args = @_;
|
my %args = @_;
|
||||||
|
|
||||||
my %types =( PaymentAction => '',
|
my %types = (
|
||||||
|
PaymentAction => '',
|
||||||
|
|
||||||
# Payment Detail
|
# Payment Detail
|
||||||
OrderTotal => 'xs:string',
|
OrderTotal => 'xs:string',
|
||||||
ItemTotal => 'xsd:string',
|
ItemTotal => 'xsd:string',
|
||||||
|
@ -23,16 +26,20 @@ sub DoDirectPaymentRequest {
|
||||||
TaxTotal => 'xsd:string',
|
TaxTotal => 'xsd:string',
|
||||||
InvoiceID => 'xsd:string',
|
InvoiceID => 'xsd:string',
|
||||||
ButtonSource => 'xsd:string',
|
ButtonSource => 'xsd:string',
|
||||||
|
|
||||||
# Credit Card
|
# Credit Card
|
||||||
CreditCardType => '',
|
CreditCardType => '',
|
||||||
CreditCardNumber => 'xsd:string',
|
CreditCardNumber => 'xsd:string',
|
||||||
ExpMonth => 'xs:int',
|
ExpMonth => 'xs:int',
|
||||||
ExpYear => 'xs:int',
|
ExpYear => 'xs:int',
|
||||||
|
|
||||||
# CardOwner
|
# CardOwner
|
||||||
Payer => 'ns:EmailAddressType',
|
Payer => 'ns:EmailAddressType',
|
||||||
|
|
||||||
# Payer Name
|
# Payer Name
|
||||||
FirstName => 'xs:string',
|
FirstName => 'xs:string',
|
||||||
LastName => 'xs:string',
|
LastName => 'xs:string',
|
||||||
|
|
||||||
# Payer Address
|
# Payer Address
|
||||||
Street1 => 'xs:string',
|
Street1 => 'xs:string',
|
||||||
Street2 => 'xs:string',
|
Street2 => 'xs:string',
|
||||||
|
@ -40,6 +47,7 @@ sub DoDirectPaymentRequest {
|
||||||
StateOrProvince => 'xs:string',
|
StateOrProvince => 'xs:string',
|
||||||
Country => 'xs:string',
|
Country => 'xs:string',
|
||||||
PostalCode => 'xs:string',
|
PostalCode => 'xs:string',
|
||||||
|
|
||||||
# Shipping Address
|
# Shipping Address
|
||||||
ShipToName => 'xs:string',
|
ShipToName => 'xs:string',
|
||||||
ShipToStreet1 => 'xs:string',
|
ShipToStreet1 => 'xs:string',
|
||||||
|
@ -48,6 +56,7 @@ sub DoDirectPaymentRequest {
|
||||||
ShipToStateOrProvince => 'xs:string',
|
ShipToStateOrProvince => 'xs:string',
|
||||||
ShipToCountry => 'xs:string',
|
ShipToCountry => 'xs:string',
|
||||||
ShipToPostalCode => 'xs:string',
|
ShipToPostalCode => 'xs:string',
|
||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
CVV2 => 'xs:string',
|
CVV2 => 'xs:string',
|
||||||
IPAddress => 'xs:string',
|
IPAddress => 'xs:string',
|
||||||
|
@ -58,80 +67,131 @@ sub DoDirectPaymentRequest {
|
||||||
$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(
|
||||||
|
DoDirectPaymentRequestDetails =>
|
||||||
|
\SOAP::Data->value( @payreqdetail )
|
||||||
|
)->attr( { xmlns => "urn:ebay:apis:eBLBaseComponents" } ),
|
||||||
|
);
|
||||||
|
my $request = (
|
||||||
|
SOAP::Data->name(
|
||||||
|
DoDirectPaymentRequest => \SOAP::Data->value( @reqval )
|
||||||
|
),
|
||||||
);
|
);
|
||||||
my $request = (SOAP::Data->name(DoDirectPaymentRequest => \SOAP::Data->value(@reqval)), );
|
|
||||||
my $som = $self->doCall( DoDirectPaymentReq => $request ) or return;
|
my $som = $self->doCall( DoDirectPaymentReq => $request ) or return;
|
||||||
my $path = '/Envelope/Body/DoDirectPaymentResponse';
|
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(
|
||||||
|
$som, $path,
|
||||||
|
\%response,
|
||||||
|
{ TransactionID => 'TransactionID',
|
||||||
Amount => 'Amount',
|
Amount => 'Amount',
|
||||||
AVSCode => 'AVSCode',
|
AVSCode => 'AVSCode',
|
||||||
CVV2Code => 'CVV2Code',
|
CVV2Code => 'CVV2Code',
|
||||||
|
|
|
@ -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,7 +17,8 @@ sub SetExpressCheckout {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my %args = @_;
|
my %args = @_;
|
||||||
|
|
||||||
my %types = ( Token => 'ebl:ExpressCheckoutTokenType',
|
my %types = (
|
||||||
|
Token => 'ebl:ExpressCheckoutTokenType',
|
||||||
OrderTotal => 'cc:BasicAmountType',
|
OrderTotal => 'cc:BasicAmountType',
|
||||||
currencyID => '',
|
currencyID => '',
|
||||||
MaxAmount => 'cc:BasicAmountType',
|
MaxAmount => 'cc:BasicAmountType',
|
||||||
|
@ -36,13 +38,16 @@ sub SetExpressCheckout {
|
||||||
'cpp-header-back-color' => 'xs:string',
|
'cpp-header-back-color' => 'xs:string',
|
||||||
'cpp-payflow-color' => 'xs:string',
|
'cpp-payflow-color' => 'xs:string',
|
||||||
PaymentAction => '',
|
PaymentAction => '',
|
||||||
BuyerEmail => 'ebl:EmailAddressType' );
|
BuyerEmail => 'ebl:EmailAddressType'
|
||||||
|
);
|
||||||
|
|
||||||
## billing agreement details type
|
## billing agreement details type
|
||||||
my %badtypes = ( BillingType => '', #'ns:BillingCodeType',
|
my %badtypes = (
|
||||||
|
BillingType => '', #'ns:BillingCodeType',
|
||||||
BillingAgreementDescription => 'xs:string',
|
BillingAgreementDescription => 'xs:string',
|
||||||
PaymentType => '', #'ns:MerchantPullPaymentCodeType',
|
PaymentType => '', #'ns:MerchantPullPaymentCodeType',
|
||||||
BillingAgreementCustom => 'xs:string', );
|
BillingAgreementCustom => 'xs:string',
|
||||||
|
);
|
||||||
|
|
||||||
## set some defaults
|
## set some defaults
|
||||||
$args{PaymentAction} ||= 'Sale';
|
$args{PaymentAction} ||= 'Sale';
|
||||||
|
@ -50,69 +55,82 @@ 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,
|
||||||
|
SOAP::Data->name(
|
||||||
|
BillingAgreementDetails => \SOAP::Data->value( @btypes ) )
|
||||||
if $args{'BillingType'};
|
if $args{'BillingType'};
|
||||||
|
|
||||||
my $request = SOAP::Data
|
my $request = SOAP::Data->name(
|
||||||
->name( SetExpressCheckoutRequest => \SOAP::Data->value
|
SetExpressCheckoutRequest => \SOAP::Data->value(
|
||||||
( $self->version_req,
|
$self->version_req,
|
||||||
SOAP::Data->name( SetExpressCheckoutRequestDetails => \SOAP::Data->value(@secrd) )
|
SOAP::Data->name(
|
||||||
->attr( {xmlns => $self->C_xmlns_ebay} ),
|
SetExpressCheckoutRequestDetails =>
|
||||||
|
\SOAP::Data->value( @secrd )
|
||||||
|
)->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||||
)
|
)
|
||||||
)->type( 'ns:SetExpressCheckoutRequestType' );
|
)->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' );
|
||||||
|
|
||||||
|
@ -121,14 +139,14 @@ sub GetExpressCheckoutDetails {
|
||||||
|
|
||||||
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(
|
||||||
|
$som,
|
||||||
"$path/GetExpressCheckoutDetailsResponseDetails",
|
"$path/GetExpressCheckoutDetailsResponseDetails",
|
||||||
\%details,
|
\%details,
|
||||||
{ Token => 'Token',
|
{ Token => 'Token',
|
||||||
|
@ -153,7 +171,8 @@ sub GetExpressCheckoutDetails {
|
||||||
PostalCode => 'PayerInfo/Address/PostalCode',
|
PostalCode => 'PayerInfo/Address/PostalCode',
|
||||||
Country => 'PayerInfo/Address/Country',
|
Country => 'PayerInfo/Address/Country',
|
||||||
PayerCountry => 'PayerInfo/PayerCountry',
|
PayerCountry => 'PayerInfo/PayerCountry',
|
||||||
} );
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return %details;
|
return %details;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +181,8 @@ sub DoExpressCheckoutPayment {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my %args = @_;
|
my %args = @_;
|
||||||
|
|
||||||
my %types = ( Token => 'xs:string',
|
my %types = (
|
||||||
|
Token => 'xs:string',
|
||||||
PaymentAction => '', ## NOTA BENE!
|
PaymentAction => '', ## NOTA BENE!
|
||||||
PayerID => 'ebl:UserIDType',
|
PayerID => 'ebl:UserIDType',
|
||||||
currencyID => '',
|
currencyID => '',
|
||||||
|
@ -170,7 +190,8 @@ sub DoExpressCheckoutPayment {
|
||||||
);
|
);
|
||||||
|
|
||||||
## PaymentDetails
|
## PaymentDetails
|
||||||
my %pd_types = ( OrderTotal => 'ebl:BasicAmountType',
|
my %pd_types = (
|
||||||
|
OrderTotal => 'ebl:BasicAmountType',
|
||||||
OrderDescription => 'xs:string',
|
OrderDescription => 'xs:string',
|
||||||
ItemTotal => 'ebl:BasicAmountType',
|
ItemTotal => 'ebl:BasicAmountType',
|
||||||
ShippingTotal => 'ebl:BasicAmountType',
|
ShippingTotal => 'ebl:BasicAmountType',
|
||||||
|
@ -183,7 +204,8 @@ sub DoExpressCheckoutPayment {
|
||||||
);
|
);
|
||||||
|
|
||||||
## ShipToAddress
|
## ShipToAddress
|
||||||
my %st_types = ( ST_Name => 'xs:string',
|
my %st_types = (
|
||||||
|
ST_Name => 'xs:string',
|
||||||
ST_Street1 => 'xs:string',
|
ST_Street1 => 'xs:string',
|
||||||
ST_Street2 => 'xs:string',
|
ST_Street2 => 'xs:string',
|
||||||
ST_CityName => 'xs:string',
|
ST_CityName => 'xs:string',
|
||||||
|
@ -193,7 +215,8 @@ sub DoExpressCheckoutPayment {
|
||||||
);
|
);
|
||||||
|
|
||||||
##PaymentDetailsItem
|
##PaymentDetailsItem
|
||||||
my %pdi_types = ( PDI_Name => 'xs:string',
|
my %pdi_types = (
|
||||||
|
PDI_Name => 'xs:string',
|
||||||
PDI_Amount => 'ebl:BasicAmountType',
|
PDI_Amount => 'ebl:BasicAmountType',
|
||||||
PDI_Number => 'xs:string',
|
PDI_Number => 'xs:string',
|
||||||
PDI_Quantity => 'xs:string',
|
PDI_Quantity => 'xs:string',
|
||||||
|
@ -203,19 +226,22 @@ sub DoExpressCheckoutPayment {
|
||||||
$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,48 +273,55 @@ 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} )
|
||||||
|
->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||||
SOAP::Data->name( PayerID => $args{PayerID} )
|
SOAP::Data->name( PayerID => $args{PayerID} )
|
||||||
->type($types{PayerID})->attr( {xmlns => $self->C_xmlns_ebay} ),
|
->type( $types{PayerID} )
|
||||||
SOAP::Data->name( PaymentDetails => \SOAP::Data->value
|
->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||||
( @payment_details )->type('ebl:PaymentDetailsType')
|
SOAP::Data->name(
|
||||||
->attr( {xmlns => $self->C_xmlns_ebay} ),
|
PaymentDetails => \SOAP::Data->value( @payment_details )
|
||||||
|
->type( 'ebl:PaymentDetailsType' )
|
||||||
|
->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||||
),
|
),
|
||||||
SOAP::Data->name( ReturnFMFDetails => $args{ReturnFMFDetails} )
|
SOAP::Data->name( ReturnFMFDetails => $args{ReturnFMFDetails} )
|
||||||
->type($types{ReturnFMFDetails})->attr( {xmlns => $self->C_xmlns_ebay} ), );
|
->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 } ),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -299,12 +331,13 @@ sub DoExpressCheckoutPayment {
|
||||||
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(
|
||||||
|
$som,
|
||||||
"$path/DoExpressCheckoutPaymentResponseDetails",
|
"$path/DoExpressCheckoutPaymentResponseDetails",
|
||||||
\%response,
|
\%response,
|
||||||
{ Token => 'Token',
|
{ Token => 'Token',
|
||||||
|
@ -325,7 +358,8 @@ sub DoExpressCheckoutPayment {
|
||||||
PendingFilters => 'FMFDetails/PendingFilters',
|
PendingFilters => 'FMFDetails/PendingFilters',
|
||||||
ReportsFilters => 'FMFDetails/ReportsFilters',
|
ReportsFilters => 'FMFDetails/ReportsFilters',
|
||||||
ProtectionEligibility => 'PaymentInfo/ProtectionEligibility',
|
ProtectionEligibility => 'PaymentInfo/ProtectionEligibility',
|
||||||
} );
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return %response;
|
return %response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,15 +14,16 @@ 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} )->type( 'xs:string' ),
|
SOAP::Data->name( TransactionID => $args{TransactionID} )
|
||||||
|
->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;
|
||||||
|
@ -30,14 +31,16 @@ sub GetTransactionDetails {
|
||||||
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(
|
||||||
|
$som, $path,
|
||||||
|
\%response,
|
||||||
{ Business => '/ReceiverInfo/Business',
|
{ Business => '/ReceiverInfo/Business',
|
||||||
Receiver => '/ReceiverInfo/Receiver',
|
Receiver => '/ReceiverInfo/Receiver',
|
||||||
ReceiverID => '/ReceiverInfo/ReceiverID',
|
ReceiverID => '/ReceiverInfo/ReceiverID',
|
||||||
|
@ -94,9 +97,12 @@ sub GetTransactionDetails {
|
||||||
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 =>
|
||||||
|
'/PaymentItemInfo/Subscription/SubscriptionDate',
|
||||||
|
PII_EffectiveDate =>
|
||||||
|
'/PaymentItemInfo/Subscription/EffectiveDate',
|
||||||
PII_RetryTime => '/PaymentItemInfo/Subscription/RetryTime',
|
PII_RetryTime => '/PaymentItemInfo/Subscription/RetryTime',
|
||||||
PII_Username => '/PaymentItemInfo/Subscription/Username',
|
PII_Username => '/PaymentItemInfo/Subscription/Username',
|
||||||
PII_Password => '/PaymentItemInfo/Subscription/Password',
|
PII_Password => '/PaymentItemInfo/Subscription/Password',
|
||||||
|
@ -113,16 +119,19 @@ sub GetTransactionDetails {
|
||||||
);
|
);
|
||||||
|
|
||||||
## multiple payment items
|
## multiple payment items
|
||||||
my $paymentitems = $self->getFieldsList( $som, $path . '/PaymentItemInfo/PaymentItem',
|
my $paymentitems = $self->getFieldsList(
|
||||||
|
$som,
|
||||||
|
$path . '/PaymentItemInfo/PaymentItem',
|
||||||
{ SalesTax => 'SalesTax',
|
{ SalesTax => 'SalesTax',
|
||||||
Name => 'Name',
|
Name => 'Name',
|
||||||
Number => 'Number',
|
Number => 'Number',
|
||||||
Quantity => 'Quantity',
|
Quantity => 'Quantity',
|
||||||
Amount => 'Amount',
|
Amount => 'Amount',
|
||||||
Options => 'Options',
|
Options => 'Options',
|
||||||
} );
|
}
|
||||||
|
);
|
||||||
|
|
||||||
if( scalar(@$paymentitems) > 0 ) {
|
if ( scalar( @$paymentitems ) > 0 ) {
|
||||||
$response{PaymentItems} = $paymentitems;
|
$response{PaymentItems} = $paymentitems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 = (
|
||||||
|
EmailSubject => 'xs:string',
|
||||||
Version => 'xsd:string',
|
Version => 'xsd:string',
|
||||||
|
|
||||||
# ReceiverType => 'ebl:ReceiverInfoCodeType', ## EmailAddress | UserID
|
# ReceiverType => 'ebl:ReceiverInfoCodeType', ## EmailAddress | UserID
|
||||||
);
|
);
|
||||||
|
|
||||||
my %attr = ( Version => { xmlns => $self->C_xmlns_ebay },
|
my %attr = (
|
||||||
Amount => { currencyID => $args{currencyID} }, );
|
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 = (
|
||||||
|
ReceiverEmail => 'ebl:EmailAddressType',
|
||||||
ReceiverID => 'xs:string',
|
ReceiverID => 'xs:string',
|
||||||
Amount => 'ebl:BasicAmountType',
|
Amount => 'ebl:BasicAmountType',
|
||||||
UniqueId => 'xs:string',
|
UniqueId => 'xs:string',
|
||||||
Note => '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,21 +71,27 @@ 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;
|
||||||
|
@ -83,8 +99,8 @@ sub MassPay {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,26 +14,27 @@ 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;
|
||||||
|
@ -41,14 +42,17 @@ sub DoReauthorizationRequest {
|
||||||
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(
|
||||||
|
$som, $path,
|
||||||
|
\%response,
|
||||||
{ AuthorizationID => 'AuthorizationID',
|
{ AuthorizationID => 'AuthorizationID',
|
||||||
Amount => 'Amount', }
|
Amount => 'Amount',
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return %response;
|
return %response;
|
||||||
|
|
|
@ -20,12 +20,15 @@ sub SetCustomerBillingAgreement {
|
||||||
my %args = @_;
|
my %args = @_;
|
||||||
|
|
||||||
## billing agreement details type
|
## billing agreement details type
|
||||||
my %badtypes = ( BillingType => '', # 'ns:BillingCodeType',
|
my %badtypes = (
|
||||||
|
BillingType => '', # 'ns:BillingCodeType',
|
||||||
BillingAgreementDescription => 'xs:string',
|
BillingAgreementDescription => 'xs:string',
|
||||||
PaymentType => '', # 'ns:MerchantPullPaymentCodeType',
|
PaymentType => '', # 'ns:MerchantPullPaymentCodeType',
|
||||||
BillingAgreementCustom => 'xs:string', );
|
BillingAgreementCustom => 'xs:string',
|
||||||
|
);
|
||||||
|
|
||||||
my %types = ( BillingAgreementDetails => 'ns:BillingAgreementDetailsType',
|
my %types = (
|
||||||
|
BillingAgreementDetails => 'ns:BillingAgreementDetailsType',
|
||||||
ReturnURL => 'xs:string',
|
ReturnURL => 'xs:string',
|
||||||
CancelURL => 'xs:string',
|
CancelURL => 'xs:string',
|
||||||
LocaleCode => 'xs:string',
|
LocaleCode => 'xs:string',
|
||||||
|
@ -35,7 +38,8 @@ sub SetCustomerBillingAgreement {
|
||||||
'cpp-header-back-color' => 'xs:string',
|
'cpp-header-back-color' => 'xs:string',
|
||||||
'cpp-payflow-color' => 'xs:string',
|
'cpp-payflow-color' => 'xs:string',
|
||||||
PaymentAction => '',
|
PaymentAction => '',
|
||||||
BuyerEmail => 'ns:EmailAddressType', );
|
BuyerEmail => 'ns:EmailAddressType',
|
||||||
|
);
|
||||||
|
|
||||||
## set defaults
|
## set defaults
|
||||||
$args{BillingType} ||= 'RecurringPayments';
|
$args{BillingType} ||= 'RecurringPayments';
|
||||||
|
@ -45,21 +49,29 @@ sub SetCustomerBillingAgreement {
|
||||||
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 )
|
||||||
|
)->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||||
)
|
)
|
||||||
)->type( 'ns:SetCustomerBillingAgreementRequestDetailsType' );
|
)->type( 'ns:SetCustomerBillingAgreementRequestDetailsType' );
|
||||||
|
|
||||||
|
@ -69,12 +81,12 @@ sub SetCustomerBillingAgreement {
|
||||||
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,26 +95,28 @@ 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
|
||||||
|
= $self->doCall( GetBillingAgreementCustomerDetailsReq => $request )
|
||||||
or return;
|
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(
|
||||||
|
$som,
|
||||||
"$path/GetBillingAgreementCustomerDetailsResponseDetails",
|
"$path/GetBillingAgreementCustomerDetailsResponseDetails",
|
||||||
\%details,
|
\%details,
|
||||||
{ Token => 'Token',
|
{ Token => 'Token',
|
||||||
|
@ -126,7 +140,8 @@ sub GetBillingAgreementCustomerDetails {
|
||||||
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,59 +151,74 @@ sub CreateRecurringPaymentsProfile {
|
||||||
my %args = @_;
|
my %args = @_;
|
||||||
|
|
||||||
## RecurringPaymentProfileDetails
|
## RecurringPaymentProfileDetails
|
||||||
my %profiledetailstype = ( SubscriberName => 'xs:string',
|
my %profiledetailstype = (
|
||||||
|
SubscriberName => 'xs:string',
|
||||||
SubscriberShipperAddress => 'ns:AddressType',
|
SubscriberShipperAddress => 'ns:AddressType',
|
||||||
BillingStartDate => 'xs:dateTime', ## MM-DD-YY
|
BillingStartDate => 'xs:dateTime', ## MM-DD-YY
|
||||||
ProfileReference => 'xs:string', );
|
ProfileReference => 'xs:string',
|
||||||
|
);
|
||||||
|
|
||||||
## ScheduleDetailsType
|
## ScheduleDetailsType
|
||||||
my %schedtype = ( Description => 'xs:string',
|
my %schedtype = (
|
||||||
|
Description => 'xs:string',
|
||||||
ActivationDetails => 'ns:ActivationDetailsType',
|
ActivationDetails => 'ns:ActivationDetailsType',
|
||||||
TrialPeriod => 'ns:BillingPeriodDetailsType',
|
TrialPeriod => 'ns:BillingPeriodDetailsType',
|
||||||
PaymentPeriod => 'ns:BillingPeriodDetailsType',
|
PaymentPeriod => 'ns:BillingPeriodDetailsType',
|
||||||
MaxFailedPayments => 'xs:int',
|
MaxFailedPayments => 'xs:int',
|
||||||
AutoBillOutstandingAmount => 'ns:AutoBillType', ); ## NoAutoBill or AddToNextBilling
|
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 = (
|
||||||
|
TrialBillingPeriod => 'xs:string', ##'ns:BillingPeriodType',
|
||||||
TrialBillingFrequency => 'xs:int',
|
TrialBillingFrequency => 'xs:int',
|
||||||
TrialTotalBillingCycles => 'xs:int',
|
TrialTotalBillingCycles => 'xs:int',
|
||||||
TrialAmount => 'cc:AmountType',
|
TrialAmount => 'cc:AmountType',
|
||||||
TrialShippingAmount => 'cc:AmountType',
|
TrialShippingAmount => 'cc:AmountType',
|
||||||
TrialTaxAmount => 'cc:AmountType', );
|
TrialTaxAmount => 'cc:AmountType',
|
||||||
|
);
|
||||||
|
|
||||||
my %paymentbilltype = ( PaymentBillingPeriod => 'xs:string', ##'ns:BillingPeriodType',
|
my %paymentbilltype = (
|
||||||
|
PaymentBillingPeriod => 'xs:string', ##'ns:BillingPeriodType',
|
||||||
PaymentBillingFrequency => 'xs:int',
|
PaymentBillingFrequency => 'xs:int',
|
||||||
PaymentTotalBillingCycles => 'xs:int',
|
PaymentTotalBillingCycles => 'xs:int',
|
||||||
PaymentAmount => 'cc:AmountType',
|
PaymentAmount => 'cc:AmountType',
|
||||||
PaymentShippingAmount => 'cc:AmountType',
|
PaymentShippingAmount => 'cc:AmountType',
|
||||||
PaymentTaxAmount => 'cc:AmountType', );
|
PaymentTaxAmount => 'cc:AmountType',
|
||||||
|
);
|
||||||
|
|
||||||
## AddressType
|
## AddressType
|
||||||
my %payaddrtype = ( CCPayerName => 'xs:string',
|
my %payaddrtype = (
|
||||||
|
CCPayerName => 'xs:string',
|
||||||
CCPayerStreet1 => 'xs:string',
|
CCPayerStreet1 => 'xs:string',
|
||||||
CCPayerStreet2 => 'xs:string',
|
CCPayerStreet2 => 'xs:string',
|
||||||
CCPayerCityName => 'xs:string',
|
CCPayerCityName => 'xs:string',
|
||||||
CCPayerStateOrProvince => 'xs:string',
|
CCPayerStateOrProvince => 'xs:string',
|
||||||
CCPayerCountry => 'xs:string', ## ebl:CountryCodeType
|
CCPayerCountry => 'xs:string', ## ebl:CountryCodeType
|
||||||
CCPayerPostalCode => 'xs:string',
|
CCPayerPostalCode => 'xs:string',
|
||||||
CCPayerPhone => 'xs:string', );
|
CCPayerPhone => 'xs:string',
|
||||||
|
);
|
||||||
|
|
||||||
my %shipaddrtype = ( SubscriberShipperName => 'xs:string',
|
my %shipaddrtype = (
|
||||||
|
SubscriberShipperName => 'xs:string',
|
||||||
SubscriberShipperStreet1 => 'xs:string',
|
SubscriberShipperStreet1 => 'xs:string',
|
||||||
SubscriberShipperStreet2 => 'xs:string',
|
SubscriberShipperStreet2 => 'xs:string',
|
||||||
SubscriberShipperCityName => 'xs:string',
|
SubscriberShipperCityName => 'xs:string',
|
||||||
SubscriberShipperStateOrProvince => 'xs:string',
|
SubscriberShipperStateOrProvince => 'xs:string',
|
||||||
SubscriberShipperCountry => 'xs:string', ## ebl:CountryCodeType
|
SubscriberShipperCountry => 'xs:string', ## ebl:CountryCodeType
|
||||||
SubscriberShipperPostalCode => 'xs:string',
|
SubscriberShipperPostalCode => 'xs:string',
|
||||||
SubscriberShipperPhone => 'xs:string', );
|
SubscriberShipperPhone => 'xs:string',
|
||||||
|
);
|
||||||
|
|
||||||
## credit card payer
|
## credit card payer
|
||||||
my %payerinfotype = ( CCPayer => 'ns:EmailAddressType',
|
my %payerinfotype = (
|
||||||
|
CCPayer => 'ns:EmailAddressType',
|
||||||
CCPayerID => 'ebl:UserIDType',
|
CCPayerID => 'ebl:UserIDType',
|
||||||
CCPayerStatus => 'xs:string',
|
CCPayerStatus => 'xs:string',
|
||||||
CCPayerName => 'xs:string',
|
CCPayerName => 'xs:string',
|
||||||
|
@ -199,94 +229,133 @@ sub CreateRecurringPaymentsProfile {
|
||||||
);
|
);
|
||||||
|
|
||||||
## 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',
|
||||||
|
CreditCardType => 'ebl:CreditCardType'
|
||||||
|
, ## Visa, MasterCard, Discover, Amex, Switch, Solo
|
||||||
CreditCardNumber => 'xs:string',
|
CreditCardNumber => 'xs:string',
|
||||||
ExpMonth => 'xs:int',
|
ExpMonth => 'xs:int',
|
||||||
ExpYear => 'xs:int',
|
ExpYear => 'xs:int',
|
||||||
CVV2 => 'xs:string',
|
CVV2 => 'xs:string',
|
||||||
StartMonth => 'xs:string',
|
StartMonth => 'xs:string',
|
||||||
StartYear => 'xs:string',
|
StartYear => 'xs:string',
|
||||||
IssueNumber => 'xs:int', );
|
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(
|
||||||
|
CreateRecurringPaymentsProfileRequestDetails =>
|
||||||
|
\SOAP::Data->value( @crpprd )
|
||||||
|
)->attr( { xmlns => $self->C_xmlns_ebay } )
|
||||||
)
|
)
|
||||||
); #->type( 'ns:CreateRecurringPaymentsProfileRequestType' );
|
); #->type( 'ns:CreateRecurringPaymentsProfileRequestType' );
|
||||||
|
|
||||||
|
@ -296,12 +365,12 @@ sub CreateRecurringPaymentsProfile {
|
||||||
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,13 +379,15 @@ sub DoReferenceTransaction {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my %args = @_;
|
my %args = @_;
|
||||||
|
|
||||||
my %types = ( ReferenceID => 'xs:string',
|
my %types = (
|
||||||
|
ReferenceID => 'xs:string',
|
||||||
PaymentAction => '', ## NOTA BENE!
|
PaymentAction => '', ## NOTA BENE!
|
||||||
currencyID => '',
|
currencyID => '',
|
||||||
);
|
);
|
||||||
|
|
||||||
## PaymentDetails
|
## PaymentDetails
|
||||||
my %pd_types = ( OrderTotal => 'ebl:BasicAmountType',
|
my %pd_types = (
|
||||||
|
OrderTotal => 'ebl:BasicAmountType',
|
||||||
OrderDescription => 'xs:string',
|
OrderDescription => 'xs:string',
|
||||||
ItemTotal => 'ebl:BasicAmountType',
|
ItemTotal => 'ebl:BasicAmountType',
|
||||||
ShippingTotal => 'ebl:BasicAmountType',
|
ShippingTotal => 'ebl:BasicAmountType',
|
||||||
|
@ -329,7 +400,8 @@ sub DoReferenceTransaction {
|
||||||
);
|
);
|
||||||
|
|
||||||
## ShipToAddress
|
## ShipToAddress
|
||||||
my %st_types = ( ST_Name => 'xs:string',
|
my %st_types = (
|
||||||
|
ST_Name => 'xs:string',
|
||||||
ST_Street1 => 'xs:string',
|
ST_Street1 => 'xs:string',
|
||||||
ST_Street2 => 'xs:string',
|
ST_Street2 => 'xs:string',
|
||||||
ST_CityName => 'xs:string',
|
ST_CityName => 'xs:string',
|
||||||
|
@ -340,7 +412,8 @@ sub DoReferenceTransaction {
|
||||||
);
|
);
|
||||||
|
|
||||||
##PaymentDetailsItem
|
##PaymentDetailsItem
|
||||||
my %pdi_types = ( PDI_Name => 'xs:string',
|
my %pdi_types = (
|
||||||
|
PDI_Name => 'xs:string',
|
||||||
PDI_Description => 'xs:string',
|
PDI_Description => 'xs:string',
|
||||||
PDI_Amount => 'ebl:BasicAmountType',
|
PDI_Amount => 'ebl:BasicAmountType',
|
||||||
PDI_Number => 'xs:string',
|
PDI_Number => 'xs:string',
|
||||||
|
@ -351,19 +424,22 @@ sub DoReferenceTransaction {
|
||||||
$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,20 +471,20 @@ 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 } ), );
|
||||||
}
|
}
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -417,23 +492,29 @@ sub DoReferenceTransaction {
|
||||||
##
|
##
|
||||||
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} )
|
||||||
|
->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( PaymentDetails => \SOAP::Data->value
|
->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||||
( @payment_details )->type('ebl:PaymentDetailsType')
|
SOAP::Data->name(
|
||||||
->attr( {xmlns => $self->C_xmlns_ebay} ),
|
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 } ),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -443,12 +524,13 @@ sub DoReferenceTransaction {
|
||||||
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(
|
||||||
|
$som,
|
||||||
"$path/DoReferenceTransactionResponseDetails",
|
"$path/DoReferenceTransactionResponseDetails",
|
||||||
\%response,
|
\%response,
|
||||||
{ BillingAgreementID => 'BillingAgreementID',
|
{ BillingAgreementID => 'BillingAgreementID',
|
||||||
|
@ -464,7 +546,8 @@ sub DoReferenceTransaction {
|
||||||
PaymentStatus => 'PaymentInfo/PaymentStatus',
|
PaymentStatus => 'PaymentInfo/PaymentStatus',
|
||||||
PendingReason => 'PaymentInfo/PendingReason',
|
PendingReason => 'PaymentInfo/PendingReason',
|
||||||
ReasonCode => 'PaymentInfor/ReasonCode',
|
ReasonCode => 'PaymentInfor/ReasonCode',
|
||||||
} );
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return %response;
|
return %response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,35 +14,39 @@ sub RefundTransaction {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my %args = @_;
|
my %args = @_;
|
||||||
|
|
||||||
my %types = ( TransactionID => 'xs:string',
|
my %types = (
|
||||||
|
TransactionID => 'xs:string',
|
||||||
RefundType => '', ## Other | Full | Partial
|
RefundType => '', ## Other | Full | Partial
|
||||||
Amount => 'ebl:BasicAmountType',
|
Amount => 'ebl:BasicAmountType',
|
||||||
Memo => 'xs:string', );
|
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} )->type($types{TransactionID}),
|
SOAP::Data->name( TransactionID => $args{TransactionID} )
|
||||||
SOAP::Data->name( RefundType => $args{RefundType} )->type($types{RefundType}),
|
->type( $types{TransactionID} ),
|
||||||
|
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;
|
||||||
|
@ -50,16 +54,19 @@ sub RefundTransaction {
|
||||||
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(
|
||||||
|
$som, $path,
|
||||||
|
\%response,
|
||||||
{ RefundTransactionID => 'RefundTransactionID',
|
{ RefundTransactionID => 'RefundTransactionID',
|
||||||
FeeRefundAmount => 'FeeRefundAmount',
|
FeeRefundAmount => 'FeeRefundAmount',
|
||||||
NetRefundAmount => 'NetRefundAmount',
|
NetRefundAmount => 'NetRefundAmount',
|
||||||
GrossRefundAmount => 'GrossRefundAmount', }
|
GrossRefundAmount => 'GrossRefundAmount',
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return %response;
|
return %response;
|
||||||
|
|
|
@ -14,7 +14,8 @@ sub TransactionSearch {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my %args = @_;
|
my %args = @_;
|
||||||
|
|
||||||
my %types = ( StartDate => 'xs:dateTime',
|
my %types = (
|
||||||
|
StartDate => 'xs:dateTime',
|
||||||
EndDate => 'xs:dateTime',
|
EndDate => 'xs:dateTime',
|
||||||
Payer => 'ebl:EmailAddressType',
|
Payer => 'ebl:EmailAddressType',
|
||||||
Receiver => 'ebl:EmailAddressType',
|
Receiver => 'ebl:EmailAddressType',
|
||||||
|
@ -29,20 +30,22 @@ sub TransactionSearch {
|
||||||
Status => '',
|
Status => '',
|
||||||
);
|
);
|
||||||
|
|
||||||
my @trans =
|
my @trans = (
|
||||||
(
|
|
||||||
$self->version_req,
|
$self->version_req,
|
||||||
SOAP::Data->name( StartDate => $args{StartDate} )->type( delete $types{StartDate} )
|
SOAP::Data->name( StartDate => $args{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;
|
||||||
|
@ -50,12 +53,14 @@ sub TransactionSearch {
|
||||||
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(
|
||||||
|
$som,
|
||||||
|
$path . '/PaymentTransactions',
|
||||||
{ Timestamp => 'Timestamp',
|
{ Timestamp => 'Timestamp',
|
||||||
Timezone => 'Timezone',
|
Timezone => 'Timezone',
|
||||||
Type => 'Type',
|
Type => 'Type',
|
||||||
|
@ -66,7 +71,8 @@ sub TransactionSearch {
|
||||||
GrossAmount => 'GrossAmount',
|
GrossAmount => 'GrossAmount',
|
||||||
FeeAmount => 'FeeAmount',
|
FeeAmount => 'FeeAmount',
|
||||||
NetAmount => 'NetAmount',
|
NetAmount => 'NetAmount',
|
||||||
} );
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -14,24 +14,26 @@ 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}),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($args{Note}) {
|
my @ref_trans = (
|
||||||
|
$self->version_req,
|
||||||
|
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )
|
||||||
|
->type( $types{AuthorizationID} ),
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( $args{Note} ) {
|
||||||
push @ref_trans,
|
push @ref_trans,
|
||||||
SOAP::Data->name( Note => $args{Note} )->type( $types{Note} )
|
SOAP::Data->name( Note => $args{Note} )->type( $types{Note} )
|
||||||
if $args{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;
|
||||||
|
@ -39,14 +41,13 @@ sub DoVoidRequest {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
14
t/API.pl
14
t/API.pl
|
@ -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,8 +14,9 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,14 +30,14 @@ sub do_args {
|
||||||
);
|
);
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -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' ) }
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
|
|
||||||
|
|
|
@ -3,31 +3,36 @@ 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,
|
||||||
|
@ -35,7 +40,7 @@ $ppsale = new Business::PayPal::API(%args);
|
||||||
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',
|
||||||
|
@ -49,27 +54,31 @@ $ppsale = new Business::PayPal::API(%args);
|
||||||
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 );
|
||||||
|
%resprefund = $pprefund->RefundTransaction(
|
||||||
TransactionID => $transale,
|
TransactionID => $transale,
|
||||||
RefundType => 'Full',
|
RefundType => 'Full',
|
||||||
Memo => 'Full direct sale refund',
|
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;
|
#$Business::PayPal::API::Debug=0;
|
||||||
$ppbasic = new Business::PayPal::API(%args);
|
$ppbasic = new Business::PayPal::API( %args );
|
||||||
%respbasic = $ppbasic->DoDirectPaymentRequest (
|
%respbasic = $ppbasic->DoDirectPaymentRequest(
|
||||||
PaymentAction => 'Authorization',
|
PaymentAction => 'Authorization',
|
||||||
OrderTotal => 13.87,
|
OrderTotal => 13.87,
|
||||||
TaxTotal => 0.0,
|
TaxTotal => 0.0,
|
||||||
|
@ -77,7 +86,7 @@ $ppbasic = new Business::PayPal::API(%args);
|
||||||
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',
|
||||||
|
@ -91,42 +100,48 @@ $ppbasic = new Business::PayPal::API(%args);
|
||||||
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( $respbasic{'Ack'}, qr/Success/, 'Direct Payment Basic Authorization') ) {
|
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 (
|
%respcap = $ppcap->DoCaptureRequest(
|
||||||
AuthorizationID => $tranbasic,
|
AuthorizationID => $tranbasic,
|
||||||
CompleteType => 'NotComplete',
|
CompleteType => 'NotComplete',
|
||||||
Amount => '3.00',
|
Amount => '3.00',
|
||||||
Note => 'Partial Capture',
|
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,
|
||||||
|
@ -134,7 +149,7 @@ $ppbasic = new Business::PayPal::API(%args);
|
||||||
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',
|
||||||
|
@ -148,11 +163,14 @@ $ppbasic = new Business::PayPal::API(%args);
|
||||||
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' );
|
||||||
|
|
|
@ -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
|
||||||
|
"No token from PayPal! Check your authentication information and try again."
|
||||||
unless $token;
|
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 = (
|
||||||
|
Token => $details{Token},
|
||||||
PaymentAction => 'Sale',
|
PaymentAction => 'Sale',
|
||||||
PayerID => $details{PayerID},
|
PayerID => $details{PayerID},
|
||||||
OrderTotal => '55.43',
|
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" );
|
||||||
|
|
|
@ -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
|
||||||
|
"No token from PayPal! Check your authentication information and try again."
|
||||||
unless $token;
|
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 = (
|
||||||
|
Token => $details{Token},
|
||||||
PaymentAction => 'Order',
|
PaymentAction => 'Order',
|
||||||
PayerID => $details{PayerID},
|
PayerID => $details{PayerID},
|
||||||
OrderTotal => '55.43',
|
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' );
|
||||||
}
|
}
|
||||||
|
|
|
@ -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" );
|
||||||
|
|
34
t/MassPay.t
34
t/MassPay.t
|
@ -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?",
|
||||||
|
MassPayItems => [
|
||||||
|
{ ReceiverEmail => 'joe@test.tld',
|
||||||
Amount => '24.00',
|
Amount => '24.00',
|
||||||
UniqueID => "123456",
|
UniqueID => "123456",
|
||||||
Note => "Enjoy the money. Don't spend it all in one place." } ] );
|
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?",
|
||||||
|
MassPayItems => [
|
||||||
|
{ ReceiverEmail => 'bob@test.tld',
|
||||||
Amount => '25.00',
|
Amount => '25.00',
|
||||||
UniqueID => "123457",
|
UniqueID => "123457",
|
||||||
Note => "Enjoy the money. Don't spend it all in one place." },
|
Note => "Enjoy the money. Don't spend it all in one place."
|
||||||
|
},
|
||||||
{ ReceiverEmail => 'foo@test.tld',
|
{ ReceiverEmail => 'foo@test.tld',
|
||||||
Amount => '42.00',
|
Amount => '42.00',
|
||||||
UniqueID => "123458",
|
UniqueID => "123458",
|
||||||
Note => "Enjoy the money. Don't spend it all in one place." } ] );
|
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" );
|
||||||
|
|
|
@ -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
|
||||||
|
"No token from PayPal! Check your authentication information and try again."
|
||||||
unless $token;
|
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',
|
||||||
|
@ -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" );
|
||||||
|
|
||||||
|
|
|
@ -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(
|
||||||
|
TransactionID => $transid,
|
||||||
RefundType => 'Full',
|
RefundType => 'Full',
|
||||||
Memo => 'Fancy refund time.' );
|
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
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -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(
|
||||||
|
StartDate => $startdate,
|
||||||
TransactionID => $transid,
|
TransactionID => $transid,
|
||||||
);
|
);
|
||||||
ok( scalar @$resp , "Matching Transactions Found");
|
ok( scalar @$resp, "Matching Transactions Found" );
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue