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-*
|
||||
auth.txt
|
||||
blib
|
||||
perltidy.LOG
|
||||
pm_to_blib
|
||||
|
|
|
@ -4,7 +4,7 @@ use 5.008001;
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
use SOAP::Lite 0.67; # +trace => 'all';
|
||||
use SOAP::Lite 0.67; # +trace => 'all';
|
||||
use Carp qw(carp);
|
||||
|
||||
our $Debug = 0;
|
||||
|
@ -14,23 +14,23 @@ our $Debug = 0;
|
|||
## NOTE: type definitions, at which point this module will become much
|
||||
## NOTE: smaller (or non-existent).
|
||||
|
||||
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_live () { 'https://api.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_ebay () { 'urn:ebay:apis:eBLBaseComponents' }
|
||||
sub C_version () { '61.0' } ## 3.0 adds RecurringPayments
|
||||
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_live () {'https://api.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_ebay () {'urn:ebay:apis:eBLBaseComponents'}
|
||||
sub C_version () {'61.0'} ## 3.0 adds RecurringPayments
|
||||
|
||||
## this is an inside-out object. Make sure you 'delete' additional
|
||||
## members in DESTROY() as you add them.
|
||||
my %Soap;
|
||||
my %Header;
|
||||
|
||||
my %H_PKCS12File; ## path to certificate file (pkc12)
|
||||
my %H_PKCS12Password; ## password for certificate file (pkc12)
|
||||
my %H_CertFile; ## PEM certificate
|
||||
my %H_KeyFile; ## PEM private key
|
||||
my %H_PKCS12File; ## path to certificate file (pkc12)
|
||||
my %H_PKCS12Password; ## password for certificate file (pkc12)
|
||||
my %H_CertFile; ## PEM certificate
|
||||
my %H_KeyFile; ## PEM private key
|
||||
|
||||
sub import {
|
||||
my $self = shift;
|
||||
|
@ -38,23 +38,26 @@ sub import {
|
|||
|
||||
for my $module ( @modules ) {
|
||||
eval( "use Business::PayPal::API::$module;" );
|
||||
if( $@ ) {
|
||||
if ( $@ ) {
|
||||
warn $@;
|
||||
next;
|
||||
}
|
||||
|
||||
## import 'exported' subroutines into our namespace
|
||||
no strict 'refs';
|
||||
for my $sub ( @{"Business::PayPal::API::" . $module . "::EXPORT_OK"} ) {
|
||||
*{"Business::PayPal::API::" . $sub} = *{"Business::PayPal::API::" . $module . "::" . $sub};
|
||||
for my $sub (
|
||||
@{ "Business::PayPal::API::" . $module . "::EXPORT_OK" } )
|
||||
{
|
||||
*{ "Business::PayPal::API::" . $sub }
|
||||
= *{ "Business::PayPal::API::" . $module . "::" . $sub };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my %args = @_;
|
||||
my $self = bless \(my $fake), $class;
|
||||
my %args = @_;
|
||||
my $self = bless \( my $fake ), $class;
|
||||
|
||||
## if you add new args, be sure to update the test file's @variables array
|
||||
$args{Username} ||= '';
|
||||
|
@ -62,35 +65,43 @@ sub new {
|
|||
$args{Signature} ||= '';
|
||||
$args{Subject} ||= '';
|
||||
$args{sandbox} = 1 unless exists $args{sandbox};
|
||||
$args{timeout} ||= 0;
|
||||
$args{timeout} ||= 0;
|
||||
|
||||
$H_PKCS12File{$self} = $args{PKCS12File} || '';
|
||||
$H_PKCS12Password{$self} = $args{PKCS12Password} || '';
|
||||
$H_CertFile{$self} = $args{CertFile} || '';
|
||||
$H_KeyFile{$self} = $args{KeyFile} || '';
|
||||
|
||||
my $proxy = ($args{sandbox}
|
||||
? ($args{Signature}
|
||||
? C_api_sandbox_3t
|
||||
: C_api_sandbox)
|
||||
: ($args{Signature}
|
||||
? C_api_live_3t
|
||||
: C_api_live)
|
||||
);
|
||||
my $proxy = (
|
||||
$args{sandbox}
|
||||
? ( $args{Signature}
|
||||
? C_api_sandbox_3t
|
||||
: C_api_sandbox
|
||||
)
|
||||
: ( $args{Signature}
|
||||
? C_api_live_3t
|
||||
: C_api_live
|
||||
)
|
||||
);
|
||||
|
||||
$Soap{$self} = SOAP::Lite->proxy( $proxy, timeout => $args{timeout} )->uri( C_xmlns_pp );
|
||||
$Soap{$self} = SOAP::Lite->proxy( $proxy, timeout => $args{timeout} )
|
||||
->uri( C_xmlns_pp );
|
||||
|
||||
$Header{$self} = SOAP::Header
|
||||
->name( RequesterCredentials => \SOAP::Header->value
|
||||
( SOAP::Data->name( Credentials => \SOAP::Data->value
|
||||
( SOAP::Data->name( Username => $args{Username} )->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_pp} )->mustUnderstand(1);
|
||||
$Header{$self} = SOAP::Header->name(
|
||||
RequesterCredentials => \SOAP::Header->value(
|
||||
SOAP::Data->name(
|
||||
Credentials => \SOAP::Data->value(
|
||||
SOAP::Data->name( Username => $args{Username} )
|
||||
->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_pp } )->mustUnderstand( 1 );
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
@ -106,57 +117,65 @@ sub DESTROY {
|
|||
delete $H_CertFile{$self};
|
||||
delete $H_KeyFile{$self};
|
||||
|
||||
my $super = $self->can("SUPER::DESTROY");
|
||||
my $super = $self->can( "SUPER::DESTROY" );
|
||||
goto &$super if $super;
|
||||
}
|
||||
|
||||
sub version_req {
|
||||
return SOAP::Data->name( Version => C_version )
|
||||
->type('xs:string')->attr( {xmlns => C_xmlns_ebay} );
|
||||
return SOAP::Data->name( Version => C_version )->type( 'xs:string' )
|
||||
->attr( { xmlns => C_xmlns_ebay } );
|
||||
}
|
||||
|
||||
sub doCall {
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
my $method_name = shift;
|
||||
my $request = shift;
|
||||
my $method = SOAP::Data->name( $method_name )->attr( {xmlns => C_xmlns_pp} );
|
||||
my $request = shift;
|
||||
my $method
|
||||
= SOAP::Data->name( $method_name )->attr( { xmlns => C_xmlns_pp } );
|
||||
|
||||
my $som;
|
||||
{
|
||||
$H_PKCS12File{$self} and local $ENV{HTTPS_PKCS12_FILE} = $H_PKCS12File{$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_PKCS12File{$self}
|
||||
and local $ENV{HTTPS_PKCS12_FILE} = $H_PKCS12File{$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};
|
||||
|
||||
if( $Debug ) {
|
||||
print STDERR SOAP::Serializer->envelope(method => $method,
|
||||
$Header{$self}, $request), "\n";
|
||||
}
|
||||
if ( $Debug ) {
|
||||
print STDERR SOAP::Serializer->envelope(
|
||||
method => $method,
|
||||
$Header{$self}, $request
|
||||
),
|
||||
"\n";
|
||||
}
|
||||
|
||||
# $Soap{$self}->readable( $Debug );
|
||||
# $Soap{$self}->outputxml( $Debug );
|
||||
# $Soap{$self}->readable( $Debug );
|
||||
# $Soap{$self}->outputxml( $Debug );
|
||||
|
||||
no warnings 'redefine';
|
||||
local *SOAP::Deserializer::typecast = sub {shift; return shift};
|
||||
no warnings 'redefine';
|
||||
local *SOAP::Deserializer::typecast = sub { shift; return shift };
|
||||
eval {
|
||||
$som = $Soap{$self}->call( $Header{$self}, $method => $request );
|
||||
$som = $Soap{$self}->call( $Header{$self}, $method => $request );
|
||||
};
|
||||
|
||||
if( $@ ) {
|
||||
carp $@;
|
||||
return;
|
||||
if ( $@ ) {
|
||||
carp $@;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if( $Debug ) {
|
||||
if ( $Debug ) {
|
||||
## FIXME: would be nicer to dump a SOM to XML, but how to do that?
|
||||
require Data::Dumper;
|
||||
print STDERR Data::Dumper::Dumper($som->envelope);
|
||||
print STDERR Data::Dumper::Dumper( $som->envelope );
|
||||
}
|
||||
|
||||
if( ref($som) && $som->fault ) {
|
||||
carp "Fault: " . $som->faultstring
|
||||
. ( $som->faultdetail ? " (" . $som->faultdetail . ")" : '' )
|
||||
if ( ref( $som ) && $som->fault ) {
|
||||
carp "Fault: "
|
||||
. $som->faultstring
|
||||
. ( $som->faultdetail ? " (" . $som->faultdetail . ")" : '' )
|
||||
. "\n";
|
||||
return;
|
||||
}
|
||||
|
@ -165,27 +184,28 @@ sub doCall {
|
|||
}
|
||||
|
||||
sub getFieldsList {
|
||||
my $self = shift;
|
||||
my $som = shift;
|
||||
my $path = shift;
|
||||
my $self = shift;
|
||||
my $som = shift;
|
||||
my $path = shift;
|
||||
my $fields = shift;
|
||||
|
||||
return unless $som;
|
||||
|
||||
my %trans_id = ();
|
||||
my @records = ();
|
||||
for my $rec ( $som->valueof($path) ) {
|
||||
my @records = ();
|
||||
for my $rec ( $som->valueof( $path ) ) {
|
||||
my %response = ();
|
||||
@response{keys %$fields} = @{$rec}{keys %$fields};
|
||||
@response{ keys %$fields } = @{$rec}{ keys %$fields };
|
||||
|
||||
## avoid duplicates
|
||||
if( defined $response{TransactionID}) {
|
||||
if( $trans_id{$response{TransactionID}}) {
|
||||
next;
|
||||
} else {
|
||||
$trans_id{$response{TransactionID}} = 1;
|
||||
}
|
||||
}
|
||||
if ( defined $response{TransactionID} ) {
|
||||
if ( $trans_id{ $response{TransactionID} } ) {
|
||||
next;
|
||||
}
|
||||
else {
|
||||
$trans_id{ $response{TransactionID} } = 1;
|
||||
}
|
||||
}
|
||||
push @records, \%response;
|
||||
}
|
||||
|
||||
|
@ -193,11 +213,11 @@ sub getFieldsList {
|
|||
}
|
||||
|
||||
sub getFields {
|
||||
my $self = shift;
|
||||
my $som = shift;
|
||||
my $path = shift;
|
||||
my $self = shift;
|
||||
my $som = shift;
|
||||
my $path = shift;
|
||||
my $response = shift;
|
||||
my $fields = shift;
|
||||
my $fields = shift;
|
||||
|
||||
return unless $som;
|
||||
|
||||
|
@ -221,10 +241,10 @@ sub getFields {
|
|||
## it.
|
||||
|
||||
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;
|
||||
|
||||
if( scalar(@vals) == 1 ) {
|
||||
if ( scalar( @vals ) == 1 ) {
|
||||
$response->{$field} = $vals[0];
|
||||
}
|
||||
else {
|
||||
|
@ -234,33 +254,36 @@ sub getFields {
|
|||
}
|
||||
|
||||
sub getBasic {
|
||||
my $self = shift;
|
||||
my $som = shift;
|
||||
my $path = shift;
|
||||
my $self = shift;
|
||||
my $som = shift;
|
||||
my $path = shift;
|
||||
my $details = shift;
|
||||
|
||||
return unless $som;
|
||||
|
||||
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/;
|
||||
}
|
||||
|
||||
sub getErrors {
|
||||
my $self = shift;
|
||||
my $som = shift;
|
||||
my $path = shift;
|
||||
my $self = shift;
|
||||
my $som = shift;
|
||||
my $path = shift;
|
||||
my $details = shift;
|
||||
|
||||
return unless $som;
|
||||
|
||||
my @errors = ();
|
||||
|
||||
for my $enode ( $som->valueof("$path/Errors") ) {
|
||||
push @errors, { LongMessage => $enode->{LongMessage},
|
||||
ErrorCode => $enode->{ErrorCode}, };
|
||||
for my $enode ( $som->valueof( "$path/Errors" ) ) {
|
||||
push @errors,
|
||||
{
|
||||
LongMessage => $enode->{LongMessage},
|
||||
ErrorCode => $enode->{ErrorCode},
|
||||
};
|
||||
}
|
||||
$details->{Errors} = \@errors;
|
||||
|
||||
|
|
|
@ -5,52 +5,57 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
use SOAP::Lite 0.67;
|
||||
|
||||
#use SOAP::Lite +trace => 'debug';
|
||||
use Business::PayPal::API ();
|
||||
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @EXPORT_OK = qw(DoAuthorizationRequest);
|
||||
|
||||
sub DoAuthorizationRequest {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my %types = ( TransactionID => 'xs:string',
|
||||
Amount => 'ebl:BasicAmountType',);
|
||||
|
||||
my %types = (
|
||||
TransactionID => 'xs:string',
|
||||
Amount => 'ebl:BasicAmountType',
|
||||
);
|
||||
|
||||
$args{currencyID} ||= 'USD';
|
||||
|
||||
my @ref_trans =
|
||||
($self->version_req,
|
||||
SOAP::Data->name( TransactionID => $args{TransactionID} )->type($types{TransactionID}),);
|
||||
my @ref_trans = (
|
||||
$self->version_req,
|
||||
SOAP::Data->name( TransactionID => $args{TransactionID} )
|
||||
->type( $types{TransactionID} ),
|
||||
);
|
||||
|
||||
push @ref_trans,
|
||||
SOAP::Data->name( Amount => $args{Amount} )
|
||||
->type( $types{Amount} )
|
||||
->attr( { currencyID => $args{currencyID} } );
|
||||
SOAP::Data->name( Amount => $args{Amount} )->type( $types{Amount} )
|
||||
->attr( { currencyID => $args{currencyID} } );
|
||||
|
||||
|
||||
|
||||
my $request = SOAP::Data->name
|
||||
( DoAuthorizationRequest => \SOAP::Data->value( @ref_trans ) )
|
||||
->type("ns:AuthorizationRequestType");
|
||||
my $request
|
||||
= SOAP::Data->name(
|
||||
DoAuthorizationRequest => \SOAP::Data->value( @ref_trans ) )
|
||||
->type( "ns:AuthorizationRequestType" );
|
||||
|
||||
my $som = $self->doCall( DoAuthorizationReq => $request )
|
||||
or return;
|
||||
or return;
|
||||
|
||||
my $path = '/Envelope/Body/DoAuthorizationResponse';
|
||||
|
||||
my %response = ();
|
||||
unless( $self->getBasic($som, $path, \%response) ) {
|
||||
$self->getErrors($som, $path, \%response);
|
||||
unless ( $self->getBasic( $som, $path, \%response ) ) {
|
||||
$self->getErrors( $som, $path, \%response );
|
||||
return %response;
|
||||
}
|
||||
|
||||
$self->getFields($som, $path, \%response,
|
||||
{ TransactionID => 'TransactionID',
|
||||
Amount => 'Amount', }
|
||||
);
|
||||
$self->getFields(
|
||||
$som, $path,
|
||||
\%response,
|
||||
{ TransactionID => 'TransactionID',
|
||||
Amount => 'Amount',
|
||||
}
|
||||
);
|
||||
|
||||
return %response;
|
||||
}
|
||||
|
|
|
@ -5,10 +5,11 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
use SOAP::Lite 0.67;
|
||||
|
||||
#use SOAP::Lite +trace => 'debug';
|
||||
use Business::PayPal::API ();
|
||||
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @EXPORT_OK = qw(DoCaptureRequest);
|
||||
|
||||
sub DoCaptureRequest {
|
||||
|
@ -16,66 +17,70 @@ sub DoCaptureRequest {
|
|||
my %args = @_;
|
||||
|
||||
my %types = (
|
||||
AuthorizationID => 'xs:string',
|
||||
AuthorizationID => 'xs:string',
|
||||
|
||||
#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
|
||||
#with the exception that testing for "Success" fails, one must test for not
|
||||
#being a "Failure"... there may be a life lesson here.
|
||||
CompleteType => '',
|
||||
Amount => 'ebl:BasicAmountType',
|
||||
Note => 'xs:string',
|
||||
);
|
||||
CompleteType => '',
|
||||
Amount => 'ebl:BasicAmountType',
|
||||
Note => 'xs:string',
|
||||
);
|
||||
|
||||
$args{currencyID} ||= 'USD';
|
||||
$args{currencyID} ||= 'USD';
|
||||
$args{CompleteType} ||= 'Complete';
|
||||
|
||||
my @ref_trans =
|
||||
(
|
||||
$self->version_req,
|
||||
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )->type($types{AuthorizationID}),
|
||||
SOAP::Data->name( CompleteType => $args{CompleteType} )->type($types{CompleteType}),
|
||||
);
|
||||
my @ref_trans = (
|
||||
$self->version_req,
|
||||
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )
|
||||
->type( $types{AuthorizationID} ),
|
||||
SOAP::Data->name( CompleteType => $args{CompleteType} )
|
||||
->type( $types{CompleteType} ),
|
||||
);
|
||||
|
||||
if( $args{Amount} ) {
|
||||
push @ref_trans,
|
||||
SOAP::Data->name( Amount => $args{Amount} )
|
||||
->type( $types{Amount} )
|
||||
->attr( { currencyID => $args{currencyID} } )
|
||||
if ( $args{Amount} ) {
|
||||
push @ref_trans,
|
||||
SOAP::Data->name( Amount => $args{Amount} )
|
||||
->type( $types{Amount} )
|
||||
->attr( { currencyID => $args{currencyID} } );
|
||||
}
|
||||
|
||||
my $request = SOAP::Data->name
|
||||
( DoCaptureRequest => \SOAP::Data->value( @ref_trans ) )
|
||||
->type("ns:DoCaptureRequestType");
|
||||
my $request
|
||||
= SOAP::Data->name(
|
||||
DoCaptureRequest => \SOAP::Data->value( @ref_trans ) )
|
||||
->type( "ns:DoCaptureRequestType" );
|
||||
|
||||
my $som = $self->doCall( DoCaptureReq => $request )
|
||||
or return;
|
||||
or return;
|
||||
|
||||
my $path = '/Envelope/Body/DoCaptureResponse';
|
||||
|
||||
my %response = ();
|
||||
unless( $self->getBasic($som, $path, \%response) ) {
|
||||
$self->getErrors($som, $path, \%response);
|
||||
unless ( $self->getBasic( $som, $path, \%response ) ) {
|
||||
$self->getErrors( $som, $path, \%response );
|
||||
return %response;
|
||||
}
|
||||
$path .= '/DoCaptureResponseDetails/PaymentInfo';
|
||||
$self->getFields($som, $path, \%response,
|
||||
{
|
||||
TransactionID => 'TransactionID',
|
||||
ParentTransactionID => 'ParentTransactionID',
|
||||
ReceiptID => 'ReceiptID',
|
||||
TransactionType => 'TransactionType',
|
||||
PaymentType => 'PaymentType',
|
||||
PaymentDate => 'PaymentDate',
|
||||
GrossAmount => 'GrossAmount',
|
||||
FeeAmount => 'FeeAmount',
|
||||
SettleAmount => 'SettleAmount',
|
||||
TaxAmount => 'TaxAmount',
|
||||
ExchangeRate => 'ExchangeRate',
|
||||
PaymentStatus => 'PaymentStatus',
|
||||
PendingReason => 'PendingReason',
|
||||
ReasonCode => 'ReasonCode',
|
||||
}
|
||||
);
|
||||
$self->getFields(
|
||||
$som, $path,
|
||||
\%response,
|
||||
{ TransactionID => 'TransactionID',
|
||||
ParentTransactionID => 'ParentTransactionID',
|
||||
ReceiptID => 'ReceiptID',
|
||||
TransactionType => 'TransactionType',
|
||||
PaymentType => 'PaymentType',
|
||||
PaymentDate => 'PaymentDate',
|
||||
GrossAmount => 'GrossAmount',
|
||||
FeeAmount => 'FeeAmount',
|
||||
SettleAmount => 'SettleAmount',
|
||||
TaxAmount => 'TaxAmount',
|
||||
ExchangeRate => 'ExchangeRate',
|
||||
PaymentStatus => 'PaymentStatus',
|
||||
PendingReason => 'PendingReason',
|
||||
ReasonCode => 'ReasonCode',
|
||||
}
|
||||
);
|
||||
|
||||
return %response;
|
||||
}
|
||||
|
|
|
@ -5,139 +5,199 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
use SOAP::Lite;
|
||||
|
||||
#use SOAP::Lite +trace => 'debug';
|
||||
use Business::PayPal::API ();
|
||||
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @EXPORT_OK = qw(DoDirectPaymentRequest);
|
||||
|
||||
sub DoDirectPaymentRequest {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my %types =( PaymentAction => '',
|
||||
# Payment Detail
|
||||
OrderTotal => 'xs:string',
|
||||
ItemTotal => 'xsd:string',
|
||||
ShippingTotal => 'xsd:string',
|
||||
TaxTotal => 'xsd:string',
|
||||
InvoiceID => 'xsd:string',
|
||||
ButtonSource => 'xsd:string',
|
||||
# Credit Card
|
||||
CreditCardType => '',
|
||||
CreditCardNumber => 'xsd:string',
|
||||
ExpMonth => 'xs:int',
|
||||
ExpYear => 'xs:int',
|
||||
# CardOwner
|
||||
Payer => 'ns:EmailAddressType',
|
||||
# Payer Name
|
||||
FirstName => 'xs:string',
|
||||
LastName => 'xs:string',
|
||||
# Payer Address
|
||||
Street1 => 'xs:string',
|
||||
Street2 => 'xs:string',
|
||||
CityName => 'xs:string',
|
||||
StateOrProvince => 'xs:string',
|
||||
Country => 'xs:string',
|
||||
PostalCode => 'xs:string',
|
||||
# Shipping Address
|
||||
ShipToName => 'xs:string',
|
||||
ShipToStreet1 => 'xs:string',
|
||||
ShipToStreet2 => 'xs:string',
|
||||
ShipToCityName => 'xs:string',
|
||||
ShipToStateOrProvince => 'xs:string',
|
||||
ShipToCountry => 'xs:string',
|
||||
ShipToPostalCode => 'xs:string',
|
||||
# Misc
|
||||
CVV2 => 'xs:string',
|
||||
IPAddress => 'xs:string',
|
||||
MerchantSessionId => 'xs:string',
|
||||
);
|
||||
my %types = (
|
||||
PaymentAction => '',
|
||||
|
||||
$args{currencyID} ||= 'USD';
|
||||
# Payment Detail
|
||||
OrderTotal => 'xs:string',
|
||||
ItemTotal => 'xsd:string',
|
||||
ShippingTotal => 'xsd:string',
|
||||
TaxTotal => 'xsd:string',
|
||||
InvoiceID => 'xsd:string',
|
||||
ButtonSource => 'xsd:string',
|
||||
|
||||
# Credit Card
|
||||
CreditCardType => '',
|
||||
CreditCardNumber => 'xsd:string',
|
||||
ExpMonth => 'xs:int',
|
||||
ExpYear => 'xs:int',
|
||||
|
||||
# CardOwner
|
||||
Payer => 'ns:EmailAddressType',
|
||||
|
||||
# Payer Name
|
||||
FirstName => 'xs:string',
|
||||
LastName => 'xs:string',
|
||||
|
||||
# Payer Address
|
||||
Street1 => 'xs:string',
|
||||
Street2 => 'xs:string',
|
||||
CityName => 'xs:string',
|
||||
StateOrProvince => 'xs:string',
|
||||
Country => 'xs:string',
|
||||
PostalCode => 'xs:string',
|
||||
|
||||
# Shipping Address
|
||||
ShipToName => 'xs:string',
|
||||
ShipToStreet1 => 'xs:string',
|
||||
ShipToStreet2 => 'xs:string',
|
||||
ShipToCityName => 'xs:string',
|
||||
ShipToStateOrProvince => 'xs:string',
|
||||
ShipToCountry => 'xs:string',
|
||||
ShipToPostalCode => 'xs:string',
|
||||
|
||||
# Misc
|
||||
CVV2 => 'xs:string',
|
||||
IPAddress => 'xs:string',
|
||||
MerchantSessionId => 'xs:string',
|
||||
);
|
||||
|
||||
$args{currencyID} ||= 'USD';
|
||||
$args{PaymentAction} ||= 'Sale';
|
||||
|
||||
#Assemble Credit Card Information
|
||||
my @payername = ( SOAP::Data->name(FirstName => $args{FirstName}),
|
||||
SOAP::Data->name(LastName => $args{LastName}),
|
||||
);
|
||||
my @payername = (
|
||||
SOAP::Data->name( FirstName => $args{FirstName} ),
|
||||
SOAP::Data->name( LastName => $args{LastName} ),
|
||||
);
|
||||
|
||||
my @payeraddr = ( SOAP::Data->name(Street1 => $args{Street1} )->type($types{Street1}),
|
||||
SOAP::Data->name(Street2 => $args{Street2} )->type($types{Street2}),
|
||||
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 @payeraddr = (
|
||||
SOAP::Data->name( Street1 => $args{Street1} )
|
||||
->type( $types{Street1} ),
|
||||
SOAP::Data->name( Street2 => $args{Street2} )
|
||||
->type( $types{Street2} ),
|
||||
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}),
|
||||
SOAP::Data->name(Street1 => $args{ShipToStreet1} )->type($types{ShipToStreet1}),
|
||||
SOAP::Data->name(Street2 => $args{ShipToStreet2} )->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 @shipaddr = (
|
||||
SOAP::Data->name( Name => $args{ShipToName} )
|
||||
->type( $types{ShipToName} ),
|
||||
SOAP::Data->name( Street1 => $args{ShipToStreet1} )
|
||||
->type( $types{ShipToStreet1} ),
|
||||
SOAP::Data->name( Street2 => $args{ShipToStreet2} )
|
||||
->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}),
|
||||
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 @ccard = (
|
||||
SOAP::Data->name( CreditCardType => $args{CreditCardType} )
|
||||
->type( $types{CreditCardType} ),
|
||||
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
|
||||
(CardOwner => \SOAP::Data->value
|
||||
( SOAP::Data->name(Payer => $args{Payer})->type($types{Payer}),
|
||||
SOAP::Data->name(PayerName => \SOAP::Data->value ( @payername )),
|
||||
SOAP::Data->name(Address => \SOAP::Data->value( @payeraddr )),
|
||||
)
|
||||
)
|
||||
);
|
||||
my @ccowner = (
|
||||
SOAP::Data->name(
|
||||
CardOwner => \SOAP::Data->value(
|
||||
SOAP::Data->name( Payer => $args{Payer} )
|
||||
->type( $types{Payer} ),
|
||||
SOAP::Data->name(
|
||||
PayerName => \SOAP::Data->value( @payername )
|
||||
),
|
||||
SOAP::Data->name(
|
||||
Address => \SOAP::Data->value( @payeraddr )
|
||||
),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
push( @ccard, @ccowner);
|
||||
push( @ccard, SOAP::Data->name(CVV2 => $args{CVV2})->type($types{CVV2}));
|
||||
push( @ccard, @ccowner );
|
||||
push( @ccard,
|
||||
SOAP::Data->name( CVV2 => $args{CVV2} )->type( $types{CVV2} ) );
|
||||
|
||||
#Assemble Payment Details
|
||||
my @paydetail = ( SOAP::Data->name(OrderTotal => $args{OrderTotal})
|
||||
->attr({currencyID=>$args{currencyID}})->type($types{currencyID}),
|
||||
SOAP::Data->name(ItemTotal => $args{ItemTotal})
|
||||
->attr({currencyID => $args{currencyID}})->type($types{currencyID}),
|
||||
SOAP::Data->name(TaxTotal => $args{TaxTotal})
|
||||
->attr({currencyID => $args{currencyID}})->type($types{currencyID}),
|
||||
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 @paydetail = (
|
||||
SOAP::Data->name( OrderTotal => $args{OrderTotal} )
|
||||
->attr( { currencyID => $args{currencyID} } )
|
||||
->type( $types{currencyID} ),
|
||||
SOAP::Data->name( ItemTotal => $args{ItemTotal} )
|
||||
->attr( { currencyID => $args{currencyID} } )
|
||||
->type( $types{currencyID} ),
|
||||
SOAP::Data->name( TaxTotal => $args{TaxTotal} )
|
||||
->attr( { currencyID => $args{currencyID} } )
|
||||
->type( $types{currencyID} ),
|
||||
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(''),
|
||||
SOAP::Data->name(PaymentDetails =>\SOAP::Data->value( @paydetail )),
|
||||
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}),
|
||||
);
|
||||
my @payreqdetail = (
|
||||
SOAP::Data->name( PaymentAction => $args{PaymentAction} )->type( '' ),
|
||||
SOAP::Data->name(
|
||||
PaymentDetails => \SOAP::Data->value( @paydetail )
|
||||
),
|
||||
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
|
||||
my @reqval = ( 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 $som = $self->doCall( DoDirectPaymentReq => $request ) or return;
|
||||
my $path = '/Envelope/Body/DoDirectPaymentResponse';
|
||||
my @reqval = (
|
||||
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 $som = $self->doCall( DoDirectPaymentReq => $request ) or return;
|
||||
my $path = '/Envelope/Body/DoDirectPaymentResponse';
|
||||
my %response = ();
|
||||
unless( $self->getBasic($som, $path, \%response) ) {
|
||||
$self->getErrors($som, $path, \%response);
|
||||
unless ( $self->getBasic( $som, $path, \%response ) ) {
|
||||
$self->getErrors( $som, $path, \%response );
|
||||
return %response;
|
||||
}
|
||||
|
||||
$self->getFields( $som, $path, \%response, { TransactionID => 'TransactionID',
|
||||
Amount => 'Amount',
|
||||
AVSCode => 'AVSCode',
|
||||
CVV2Code => 'CVV2Code',
|
||||
Timestamp => 'Timestamp',
|
||||
}
|
||||
);
|
||||
$self->getFields(
|
||||
$som, $path,
|
||||
\%response,
|
||||
{ TransactionID => 'TransactionID',
|
||||
Amount => 'Amount',
|
||||
AVSCode => 'AVSCode',
|
||||
CVV2Code => 'CVV2Code',
|
||||
Timestamp => 'Timestamp',
|
||||
}
|
||||
);
|
||||
|
||||
return %response;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ use SOAP::Lite 0.67;
|
|||
use 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
|
||||
## allow you to bill twice with it.
|
||||
|
@ -16,33 +17,37 @@ sub SetExpressCheckout {
|
|||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my %types = ( Token => 'ebl:ExpressCheckoutTokenType',
|
||||
OrderTotal => 'cc:BasicAmountType',
|
||||
currencyID => '',
|
||||
MaxAmount => 'cc:BasicAmountType',
|
||||
OrderDescription => 'xs:string',
|
||||
Custom => 'xs:string',
|
||||
InvoiceID => 'xs:string',
|
||||
ReturnURL => 'xs:string',
|
||||
CancelURL => 'xs:string',
|
||||
Address => 'ebl:AddressType',
|
||||
ReqConfirmShipping => 'xs:string',
|
||||
NoShipping => 'xs:string',
|
||||
AddressOverride => 'xs:string',
|
||||
LocaleCode => 'xs:string',
|
||||
PageStyle => 'xs:string',
|
||||
'cpp-header-image' => 'xs:string',
|
||||
'cpp-header-border-color' => 'xs:string',
|
||||
'cpp-header-back-color' => 'xs:string',
|
||||
'cpp-payflow-color' => 'xs:string',
|
||||
PaymentAction => '',
|
||||
BuyerEmail => 'ebl:EmailAddressType' );
|
||||
my %types = (
|
||||
Token => 'ebl:ExpressCheckoutTokenType',
|
||||
OrderTotal => 'cc:BasicAmountType',
|
||||
currencyID => '',
|
||||
MaxAmount => 'cc:BasicAmountType',
|
||||
OrderDescription => 'xs:string',
|
||||
Custom => 'xs:string',
|
||||
InvoiceID => 'xs:string',
|
||||
ReturnURL => 'xs:string',
|
||||
CancelURL => 'xs:string',
|
||||
Address => 'ebl:AddressType',
|
||||
ReqConfirmShipping => 'xs:string',
|
||||
NoShipping => 'xs:string',
|
||||
AddressOverride => 'xs:string',
|
||||
LocaleCode => 'xs:string',
|
||||
PageStyle => 'xs:string',
|
||||
'cpp-header-image' => 'xs:string',
|
||||
'cpp-header-border-color' => 'xs:string',
|
||||
'cpp-header-back-color' => 'xs:string',
|
||||
'cpp-payflow-color' => 'xs:string',
|
||||
PaymentAction => '',
|
||||
BuyerEmail => 'ebl:EmailAddressType'
|
||||
);
|
||||
|
||||
## billing agreement details type
|
||||
my %badtypes = ( BillingType => '', #'ns:BillingCodeType',
|
||||
BillingAgreementDescription => 'xs:string',
|
||||
PaymentType => '', #'ns:MerchantPullPaymentCodeType',
|
||||
BillingAgreementCustom => 'xs:string', );
|
||||
my %badtypes = (
|
||||
BillingType => '', #'ns:BillingCodeType',
|
||||
BillingAgreementDescription => 'xs:string',
|
||||
PaymentType => '', #'ns:MerchantPullPaymentCodeType',
|
||||
BillingAgreementCustom => 'xs:string',
|
||||
);
|
||||
|
||||
## set some defaults
|
||||
$args{PaymentAction} ||= 'Sale';
|
||||
|
@ -50,110 +55,124 @@ sub SetExpressCheckout {
|
|||
my $currencyID = delete $args{currencyID};
|
||||
|
||||
## SetExpressCheckoutRequestDetails
|
||||
my @secrd =
|
||||
( SOAP::Data->name( OrderTotal => delete $args{OrderTotal} )->type( $types{OrderTotal} )
|
||||
->attr( {currencyID => $currencyID, xmlns => $self->C_xmlns_ebay}),
|
||||
SOAP::Data->name( ReturnURL => delete $args{ReturnURL} )->type( $types{ReturnURL} ),
|
||||
SOAP::Data->name( CancelURL => delete $args{CancelURL} )->type( $types{CancelURL} ),
|
||||
);
|
||||
my @secrd = (
|
||||
SOAP::Data->name( OrderTotal => delete $args{OrderTotal} )
|
||||
->type( $types{OrderTotal} )->attr(
|
||||
{ currencyID => $currencyID, xmlns => $self->C_xmlns_ebay }
|
||||
),
|
||||
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
|
||||
for my $field ( keys %types ) {
|
||||
next unless defined $args{$field};
|
||||
next unless defined $args{$field};
|
||||
|
||||
if( $field eq 'MaxAmount' ) {
|
||||
push @secrd, SOAP::Data->name( $field => $args{$field} )->type( $types{$field} )
|
||||
->attr( {currencyID => $currencyID, xmlns => $self->C_xmlns_ebay} );
|
||||
if ( $field eq 'MaxAmount' ) {
|
||||
push @secrd,
|
||||
SOAP::Data->name( $field => $args{$field} )
|
||||
->type( $types{$field} )
|
||||
->attr(
|
||||
{ currencyID => $currencyID, xmlns => $self->C_xmlns_ebay } );
|
||||
}
|
||||
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 = ();
|
||||
for my $field ( keys %badtypes ) {
|
||||
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) )
|
||||
if $args{'BillingType'};
|
||||
|
||||
my $request = SOAP::Data
|
||||
->name( SetExpressCheckoutRequest => \SOAP::Data->value
|
||||
( $self->version_req,
|
||||
SOAP::Data->name( SetExpressCheckoutRequestDetails => \SOAP::Data->value(@secrd) )
|
||||
->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
)
|
||||
)->type( 'ns:SetExpressCheckoutRequestType' );
|
||||
push @secrd,
|
||||
SOAP::Data->name(
|
||||
BillingAgreementDetails => \SOAP::Data->value( @btypes ) )
|
||||
if $args{'BillingType'};
|
||||
|
||||
my $request = SOAP::Data->name(
|
||||
SetExpressCheckoutRequest => \SOAP::Data->value(
|
||||
$self->version_req,
|
||||
SOAP::Data->name(
|
||||
SetExpressCheckoutRequestDetails =>
|
||||
\SOAP::Data->value( @secrd )
|
||||
)->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||
)
|
||||
)->type( 'ns:SetExpressCheckoutRequestType' );
|
||||
|
||||
my $som = $self->doCall( SetExpressCheckoutReq => $request )
|
||||
or return;
|
||||
or return;
|
||||
|
||||
my $path = '/Envelope/Body/SetExpressCheckoutResponse';
|
||||
|
||||
my %response = ();
|
||||
unless( $self->getBasic($som, $path, \%response) ) {
|
||||
$self->getErrors($som, $path, \%response);
|
||||
unless ( $self->getBasic( $som, $path, \%response ) ) {
|
||||
$self->getErrors( $som, $path, \%response );
|
||||
return %response;
|
||||
}
|
||||
|
||||
$self->getFields($som, $path, \%response, { Token => 'Token' });
|
||||
$self->getFields( $som, $path, \%response, { Token => 'Token' } );
|
||||
|
||||
return %response;
|
||||
}
|
||||
|
||||
|
||||
sub GetExpressCheckoutDetails {
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
my $token = shift;
|
||||
|
||||
my $request = SOAP::Data
|
||||
->name( GetExpressCheckoutDetailsRequest => \SOAP::Data->value
|
||||
( $self->version_req,
|
||||
SOAP::Data->name( Token => $token )
|
||||
->type('xs:string')->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
)
|
||||
)->type( 'ns:GetExpressCheckoutRequestType' );
|
||||
my $request = SOAP::Data->name(
|
||||
GetExpressCheckoutDetailsRequest => \SOAP::Data->value(
|
||||
$self->version_req,
|
||||
SOAP::Data->name( Token => $token )->type( 'xs:string' )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||
)
|
||||
)->type( 'ns:GetExpressCheckoutRequestType' );
|
||||
|
||||
my $som = $self->doCall( GetExpressCheckoutDetailsReq => $request )
|
||||
or return;
|
||||
or return;
|
||||
|
||||
my $path = '/Envelope/Body/GetExpressCheckoutDetailsResponse';
|
||||
|
||||
|
||||
my %details = ();
|
||||
unless( $self->getBasic($som, $path, \%details) ) {
|
||||
$self->getErrors($som, $path, \%details);
|
||||
unless ( $self->getBasic( $som, $path, \%details ) ) {
|
||||
$self->getErrors( $som, $path, \%details );
|
||||
return %details;
|
||||
}
|
||||
|
||||
$self->getFields($som,
|
||||
"$path/GetExpressCheckoutDetailsResponseDetails",
|
||||
\%details,
|
||||
{ Token => 'Token',
|
||||
Custom => 'Custom',
|
||||
InvoiceID => 'InvoiceID',
|
||||
ContactPhone => 'ContactPhone',
|
||||
Payer => 'PayerInfo/Payer',
|
||||
PayerID => 'PayerInfo/PayerID',
|
||||
PayerStatus => 'PayerInfo/PayerStatus',
|
||||
Salutation => 'PayerInfo/PayerName/Saluation',
|
||||
FirstName => 'PayerInfo/PayerName/FirstName',
|
||||
MiddleName => 'PayerInfo/PayerName/MiddleName',
|
||||
LastName => 'PayerInfo/PayerName/LastName',
|
||||
NameSuffix => 'PayerInfo/PayerName/Suffix',
|
||||
PayerBusiness => 'PayerInfo/PayerBusiness',
|
||||
AddressStatus => 'PayerInfo/Address/AddressStatus',
|
||||
Name => 'PayerInfo/Address/Name',
|
||||
Street1 => 'PayerInfo/Address/Street1',
|
||||
Street2 => 'PayerInfo/Address/Street2',
|
||||
CityName => 'PayerInfo/Address/CityName',
|
||||
StateOrProvince => 'PayerInfo/Address/StateOrProvince',
|
||||
PostalCode => 'PayerInfo/Address/PostalCode',
|
||||
Country => 'PayerInfo/Address/Country',
|
||||
PayerCountry => 'PayerInfo/PayerCountry',
|
||||
} );
|
||||
$self->getFields(
|
||||
$som,
|
||||
"$path/GetExpressCheckoutDetailsResponseDetails",
|
||||
\%details,
|
||||
{ Token => 'Token',
|
||||
Custom => 'Custom',
|
||||
InvoiceID => 'InvoiceID',
|
||||
ContactPhone => 'ContactPhone',
|
||||
Payer => 'PayerInfo/Payer',
|
||||
PayerID => 'PayerInfo/PayerID',
|
||||
PayerStatus => 'PayerInfo/PayerStatus',
|
||||
Salutation => 'PayerInfo/PayerName/Saluation',
|
||||
FirstName => 'PayerInfo/PayerName/FirstName',
|
||||
MiddleName => 'PayerInfo/PayerName/MiddleName',
|
||||
LastName => 'PayerInfo/PayerName/LastName',
|
||||
NameSuffix => 'PayerInfo/PayerName/Suffix',
|
||||
PayerBusiness => 'PayerInfo/PayerBusiness',
|
||||
AddressStatus => 'PayerInfo/Address/AddressStatus',
|
||||
Name => 'PayerInfo/Address/Name',
|
||||
Street1 => 'PayerInfo/Address/Street1',
|
||||
Street2 => 'PayerInfo/Address/Street2',
|
||||
CityName => 'PayerInfo/Address/CityName',
|
||||
StateOrProvince => 'PayerInfo/Address/StateOrProvince',
|
||||
PostalCode => 'PayerInfo/Address/PostalCode',
|
||||
Country => 'PayerInfo/Address/Country',
|
||||
PayerCountry => 'PayerInfo/PayerCountry',
|
||||
}
|
||||
);
|
||||
|
||||
return %details;
|
||||
}
|
||||
|
@ -162,64 +181,71 @@ sub DoExpressCheckoutPayment {
|
|||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my %types = ( Token => 'xs:string',
|
||||
PaymentAction => '', ## NOTA BENE!
|
||||
PayerID => 'ebl:UserIDType',
|
||||
currencyID => '',
|
||||
ReturnFMFDetails => 'xs:boolean',
|
||||
);
|
||||
my %types = (
|
||||
Token => 'xs:string',
|
||||
PaymentAction => '', ## NOTA BENE!
|
||||
PayerID => 'ebl:UserIDType',
|
||||
currencyID => '',
|
||||
ReturnFMFDetails => 'xs:boolean',
|
||||
);
|
||||
|
||||
## PaymentDetails
|
||||
my %pd_types = ( OrderTotal => 'ebl:BasicAmountType',
|
||||
OrderDescription => 'xs:string',
|
||||
ItemTotal => 'ebl:BasicAmountType',
|
||||
ShippingTotal => 'ebl:BasicAmountType',
|
||||
HandlingTotal => 'ebl:BasicAmountType',
|
||||
TaxTotal => 'ebl:BasicAmountType',
|
||||
Custom => 'xs:string',
|
||||
InvoiceID => 'xs:string',
|
||||
ButtonSource => 'xs:string',
|
||||
NotifyURL => 'xs:string',
|
||||
);
|
||||
my %pd_types = (
|
||||
OrderTotal => 'ebl:BasicAmountType',
|
||||
OrderDescription => 'xs:string',
|
||||
ItemTotal => 'ebl:BasicAmountType',
|
||||
ShippingTotal => 'ebl:BasicAmountType',
|
||||
HandlingTotal => 'ebl:BasicAmountType',
|
||||
TaxTotal => 'ebl:BasicAmountType',
|
||||
Custom => 'xs:string',
|
||||
InvoiceID => 'xs:string',
|
||||
ButtonSource => 'xs:string',
|
||||
NotifyURL => 'xs:string',
|
||||
);
|
||||
|
||||
## ShipToAddress
|
||||
my %st_types = ( ST_Name => 'xs:string',
|
||||
ST_Street1 => 'xs:string',
|
||||
ST_Street2 => 'xs:string',
|
||||
ST_CityName => 'xs:string',
|
||||
ST_StateOrProvince => 'xs:string',
|
||||
ST_Country => 'xs:string',
|
||||
ST_PostalCode => 'xs:string',
|
||||
);
|
||||
my %st_types = (
|
||||
ST_Name => 'xs:string',
|
||||
ST_Street1 => 'xs:string',
|
||||
ST_Street2 => 'xs:string',
|
||||
ST_CityName => 'xs:string',
|
||||
ST_StateOrProvince => 'xs:string',
|
||||
ST_Country => 'xs:string',
|
||||
ST_PostalCode => 'xs:string',
|
||||
);
|
||||
|
||||
##PaymentDetailsItem
|
||||
my %pdi_types = ( PDI_Name => 'xs:string',
|
||||
PDI_Amount => 'ebl:BasicAmountType',
|
||||
PDI_Number => 'xs:string',
|
||||
PDI_Quantity => 'xs:string',
|
||||
PDI_Tax => 'ebl:BasicAmountType',
|
||||
);
|
||||
my %pdi_types = (
|
||||
PDI_Name => 'xs:string',
|
||||
PDI_Amount => 'ebl:BasicAmountType',
|
||||
PDI_Number => 'xs:string',
|
||||
PDI_Quantity => 'xs:string',
|
||||
PDI_Tax => 'ebl:BasicAmountType',
|
||||
);
|
||||
|
||||
$args{PaymentAction} ||= 'Sale';
|
||||
$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 @payment_details, SOAP::Data->name( OrderTotal => $args{OrderTotal} )
|
||||
->type( $pd_types{OrderTotal} )
|
||||
->attr( { currencyID => $args{currencyID},
|
||||
xmlns => $self->C_xmlns_ebay } );
|
||||
push @payment_details,
|
||||
SOAP::Data->name( OrderTotal => $args{OrderTotal} )
|
||||
->type( $pd_types{OrderTotal} )->attr(
|
||||
{ currencyID => $args{currencyID},
|
||||
xmlns => $self->C_xmlns_ebay
|
||||
}
|
||||
);
|
||||
|
||||
## don't process it again
|
||||
delete $pd_types{OrderTotal};
|
||||
|
||||
for my $field ( keys %pd_types ) {
|
||||
if( $args{$field} ) {
|
||||
push @payment_details,
|
||||
SOAP::Data->name( $field => $args{$field} )
|
||||
->type( $pd_types{$field} );
|
||||
}
|
||||
if ( $args{$field} ) {
|
||||
push @payment_details,
|
||||
SOAP::Data->name( $field => $args{$field} )
|
||||
->type( $pd_types{$field} );
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
|
@ -227,20 +253,19 @@ sub DoExpressCheckoutPayment {
|
|||
##
|
||||
my @ship_types = ();
|
||||
for my $field ( keys %st_types ) {
|
||||
if( $args{$field} ) {
|
||||
(my $name = $field) =~ s/^ST_//;
|
||||
push @ship_types,
|
||||
SOAP::Data->name( $name => $args{$field} )
|
||||
->type( $st_types{$field} );
|
||||
}
|
||||
if ( $args{$field} ) {
|
||||
( my $name = $field ) =~ s/^ST_//;
|
||||
push @ship_types,
|
||||
SOAP::Data->name( $name => $args{$field} )
|
||||
->type( $st_types{$field} );
|
||||
}
|
||||
}
|
||||
|
||||
if( scalar @ship_types ) {
|
||||
push @payment_details,
|
||||
SOAP::Data->name( ShipToAddress => \SOAP::Data->value
|
||||
( @ship_types )->type('ebl:AddressType')
|
||||
->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
);
|
||||
if ( scalar @ship_types ) {
|
||||
push @payment_details,
|
||||
SOAP::Data->name( ShipToAddress =>
|
||||
\SOAP::Data->value( @ship_types )->type( 'ebl:AddressType' )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ), );
|
||||
}
|
||||
|
||||
##
|
||||
|
@ -248,84 +273,93 @@ sub DoExpressCheckoutPayment {
|
|||
##
|
||||
my @payment_details_item = ();
|
||||
for my $field ( keys %pdi_types ) {
|
||||
if( $args{$field} ) {
|
||||
(my $name = $field) =~ s/^PDI_//;
|
||||
push @payment_details_item,
|
||||
SOAP::Data->name( $name => $args{$field} )
|
||||
->type( $pdi_types{$field} );
|
||||
}
|
||||
if ( $args{$field} ) {
|
||||
( my $name = $field ) =~ s/^PDI_//;
|
||||
push @payment_details_item,
|
||||
SOAP::Data->name( $name => $args{$field} )
|
||||
->type( $pdi_types{$field} );
|
||||
}
|
||||
}
|
||||
|
||||
if( scalar @payment_details_item ) {
|
||||
push @payment_details,
|
||||
SOAP::Data->name( PaymentDetailsItem => \SOAP::Data->value
|
||||
( @payment_details_item )->type('ebl:PaymentDetailsItemType')
|
||||
->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
);
|
||||
if ( scalar @payment_details_item ) {
|
||||
push @payment_details,
|
||||
SOAP::Data->name(
|
||||
PaymentDetailsItem => \SOAP::Data->value( @payment_details_item )
|
||||
->type( 'ebl:PaymentDetailsItemType' )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ), );
|
||||
}
|
||||
|
||||
##
|
||||
## ExpressCheckoutPaymentDetails
|
||||
##
|
||||
my @express_details = (
|
||||
SOAP::Data->name( Token => $args{Token} )
|
||||
->type($types{Token})->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
SOAP::Data->name( PaymentAction => $args{PaymentAction} )
|
||||
->type($types{PaymentAction})->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
SOAP::Data->name( PayerID => $args{PayerID} )
|
||||
->type($types{PayerID})->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
SOAP::Data->name( PaymentDetails => \SOAP::Data->value
|
||||
( @payment_details )->type('ebl:PaymentDetailsType')
|
||||
->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
),
|
||||
SOAP::Data->name( ReturnFMFDetails => $args{ReturnFMFDetails} )
|
||||
->type($types{ReturnFMFDetails})->attr( {xmlns => $self->C_xmlns_ebay} ), );
|
||||
SOAP::Data->name( Token => $args{Token} )->type( $types{Token} )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||
SOAP::Data->name( PaymentAction => $args{PaymentAction} )
|
||||
->type( $types{PaymentAction} )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||
SOAP::Data->name( PayerID => $args{PayerID} )
|
||||
->type( $types{PayerID} )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||
SOAP::Data->name(
|
||||
PaymentDetails => \SOAP::Data->value( @payment_details )
|
||||
->type( 'ebl:PaymentDetailsType' )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||
),
|
||||
SOAP::Data->name( ReturnFMFDetails => $args{ReturnFMFDetails} )
|
||||
->type( $types{ReturnFMFDetails} )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||
);
|
||||
|
||||
##
|
||||
## the main request object
|
||||
##
|
||||
my $request = SOAP::Data
|
||||
->name( DoExpressCheckoutPaymentRequest => \SOAP::Data->value
|
||||
( $self->version_req,
|
||||
SOAP::Data->name( DoExpressCheckoutPaymentRequestDetails => \SOAP::Data->value
|
||||
( @express_details )->type( 'ns:DoExpressCheckoutPaymentRequestDetailsType' )
|
||||
)->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
)
|
||||
);
|
||||
my $request = SOAP::Data->name(
|
||||
DoExpressCheckoutPaymentRequest => \SOAP::Data->value(
|
||||
$self->version_req,
|
||||
SOAP::Data->name(
|
||||
DoExpressCheckoutPaymentRequestDetails =>
|
||||
\SOAP::Data->value( @express_details )
|
||||
->type( 'ns:DoExpressCheckoutPaymentRequestDetailsType' )
|
||||
)->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||
)
|
||||
);
|
||||
|
||||
my $som = $self->doCall( DoExpressCheckoutPaymentReq => $request )
|
||||
or return;
|
||||
or return;
|
||||
|
||||
my $path = '/Envelope/Body/DoExpressCheckoutPaymentResponse';
|
||||
|
||||
my %response = ();
|
||||
unless( $self->getBasic($som, $path, \%response) ) {
|
||||
$self->getErrors($som, $path, \%response);
|
||||
unless ( $self->getBasic( $som, $path, \%response ) ) {
|
||||
$self->getErrors( $som, $path, \%response );
|
||||
return %response;
|
||||
}
|
||||
|
||||
$self->getFields( $som,
|
||||
"$path/DoExpressCheckoutPaymentResponseDetails",
|
||||
\%response,
|
||||
{ Token => 'Token',
|
||||
BillingAgreementID => 'BillingAgreementID',
|
||||
TransactionID => 'PaymentInfo/TransactionID',
|
||||
TransactionType => 'PaymentInfo/TransactionType',
|
||||
PaymentType => 'PaymentInfo/PaymentType',
|
||||
PaymentDate => 'PaymentInfo/PaymentDate',
|
||||
GrossAmount => 'PaymentInfo/GrossAmount',
|
||||
FeeAmount => 'PaymentInfo/FeeAmount',
|
||||
SettleAmount => 'PaymentInfo/SettleAmount',
|
||||
TaxAmount => 'PaymentInfo/TaxAmount',
|
||||
ExchangeRate => 'PaymentInfo/ExchangeRate',
|
||||
PaymentStatus => 'PaymentInfo/PaymentStatus',
|
||||
PendingReason => 'PaymentInfo/PendingReason',
|
||||
AcceptFilters => 'FMFDetails/AcceptFilters',
|
||||
DenyFilters => 'FMFDetails/DenyFilters',
|
||||
PendingFilters => 'FMFDetails/PendingFilters',
|
||||
ReportsFilters => 'FMFDetails/ReportsFilters',
|
||||
ProtectionEligibility => 'PaymentInfo/ProtectionEligibility',
|
||||
} );
|
||||
$self->getFields(
|
||||
$som,
|
||||
"$path/DoExpressCheckoutPaymentResponseDetails",
|
||||
\%response,
|
||||
{ Token => 'Token',
|
||||
BillingAgreementID => 'BillingAgreementID',
|
||||
TransactionID => 'PaymentInfo/TransactionID',
|
||||
TransactionType => 'PaymentInfo/TransactionType',
|
||||
PaymentType => 'PaymentInfo/PaymentType',
|
||||
PaymentDate => 'PaymentInfo/PaymentDate',
|
||||
GrossAmount => 'PaymentInfo/GrossAmount',
|
||||
FeeAmount => 'PaymentInfo/FeeAmount',
|
||||
SettleAmount => 'PaymentInfo/SettleAmount',
|
||||
TaxAmount => 'PaymentInfo/TaxAmount',
|
||||
ExchangeRate => 'PaymentInfo/ExchangeRate',
|
||||
PaymentStatus => 'PaymentInfo/PaymentStatus',
|
||||
PendingReason => 'PaymentInfo/PendingReason',
|
||||
AcceptFilters => 'FMFDetails/AcceptFilters',
|
||||
DenyFilters => 'FMFDetails/DenyFilters',
|
||||
PendingFilters => 'FMFDetails/PendingFilters',
|
||||
ReportsFilters => 'FMFDetails/ReportsFilters',
|
||||
ProtectionEligibility => 'PaymentInfo/ProtectionEligibility',
|
||||
}
|
||||
);
|
||||
|
||||
return %response;
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ use warnings;
|
|||
use SOAP::Lite 0.67;
|
||||
use Business::PayPal::API ();
|
||||
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @EXPORT_OK = qw(GetBalance); ## fake exporter
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @EXPORT_OK = qw(GetBalance); ## fake exporter
|
||||
|
||||
sub GetBalance {
|
||||
my $self = shift;
|
||||
|
|
|
@ -7,122 +7,131 @@ use warnings;
|
|||
use SOAP::Lite 0.67;
|
||||
use Business::PayPal::API ();
|
||||
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @EXPORT_OK = qw(GetTransactionDetails); ## fake exporter
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @EXPORT_OK = qw(GetTransactionDetails); ## fake exporter
|
||||
|
||||
sub GetTransactionDetails {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my @trans =
|
||||
(
|
||||
$self->version_req,
|
||||
SOAP::Data->name( TransactionID => $args{TransactionID} )->type( 'xs:string' ),
|
||||
);
|
||||
my @trans = (
|
||||
$self->version_req,
|
||||
SOAP::Data->name( TransactionID => $args{TransactionID} )
|
||||
->type( 'xs:string' ),
|
||||
);
|
||||
|
||||
my $request = SOAP::Data->name
|
||||
( GetTransactionDetailsRequest => \SOAP::Data->value( @trans ) )
|
||||
->type("ns:GetTransactionDetailsRequestType");
|
||||
my $request
|
||||
= SOAP::Data->name(
|
||||
GetTransactionDetailsRequest => \SOAP::Data->value( @trans ) )
|
||||
->type( "ns:GetTransactionDetailsRequestType" );
|
||||
|
||||
my $som = $self->doCall( GetTransactionDetailsReq => $request )
|
||||
or return;
|
||||
or return;
|
||||
|
||||
my $path = '/Envelope/Body/GetTransactionDetailsResponse';
|
||||
|
||||
my %response = ();
|
||||
unless( $self->getBasic($som, $path, \%response) ) {
|
||||
$self->getErrors($som, $path, \%response);
|
||||
unless ( $self->getBasic( $som, $path, \%response ) ) {
|
||||
$self->getErrors( $som, $path, \%response );
|
||||
return %response;
|
||||
}
|
||||
|
||||
$path .= '/PaymentTransactionDetails';
|
||||
|
||||
$self->getFields($som, $path, \%response,
|
||||
{ Business => '/ReceiverInfo/Business',
|
||||
Receiver => '/ReceiverInfo/Receiver',
|
||||
ReceiverID => '/ReceiverInfo/ReceiverID',
|
||||
$self->getFields(
|
||||
$som, $path,
|
||||
\%response,
|
||||
{ Business => '/ReceiverInfo/Business',
|
||||
Receiver => '/ReceiverInfo/Receiver',
|
||||
ReceiverID => '/ReceiverInfo/ReceiverID',
|
||||
|
||||
Payer => '/PayerInfo/Payer',
|
||||
PayerID => '/PayerInfo/PayerID',
|
||||
PayerStatus => '/PayerInfo/PayerStatus',
|
||||
Payer => '/PayerInfo/Payer',
|
||||
PayerID => '/PayerInfo/PayerID',
|
||||
PayerStatus => '/PayerInfo/PayerStatus',
|
||||
|
||||
Salutation => '/PayerInfo/PayerName/Salutation',
|
||||
FirstName => '/PayerInfo/PayerName/FirstName',
|
||||
MiddleName => '/PayerInfo/PayerName/MiddleName',
|
||||
LastName => '/PayerInfo/PayerName/LastName',
|
||||
Salutation => '/PayerInfo/PayerName/Salutation',
|
||||
FirstName => '/PayerInfo/PayerName/FirstName',
|
||||
MiddleName => '/PayerInfo/PayerName/MiddleName',
|
||||
LastName => '/PayerInfo/PayerName/LastName',
|
||||
|
||||
PayerCountry => '/PayerInfo/PayerCountry',
|
||||
PayerBusiness => '/PayerInfo/PayerBusiness',
|
||||
PayerCountry => '/PayerInfo/PayerCountry',
|
||||
PayerBusiness => '/PayerInfo/PayerBusiness',
|
||||
|
||||
AddressOwner => '/PayerInfo/Address/AddressOwner',
|
||||
AddressStatus => '/PayerInfo/Address/AddressStatus',
|
||||
ADD_Name => '/PayerInfo/Address/Name',
|
||||
Street1 => '/PayerInfo/Address/Street1',
|
||||
Street2 => '/PayerInfo/Address/Street2',
|
||||
CityName => '/PayerInfo/Address/CityName',
|
||||
StateOrProvince => '/PayerInfo/Address/StateOrProvince',
|
||||
Country => '/PayerInfo/Address/Country',
|
||||
CountryName => '/PayerInfo/Address/CountryName',
|
||||
Phone => '/PayerInfo/Address/Phone',
|
||||
PostalCode => '/PayerInfo/Address/PostalCode',
|
||||
AddressOwner => '/PayerInfo/Address/AddressOwner',
|
||||
AddressStatus => '/PayerInfo/Address/AddressStatus',
|
||||
ADD_Name => '/PayerInfo/Address/Name',
|
||||
Street1 => '/PayerInfo/Address/Street1',
|
||||
Street2 => '/PayerInfo/Address/Street2',
|
||||
CityName => '/PayerInfo/Address/CityName',
|
||||
StateOrProvince => '/PayerInfo/Address/StateOrProvince',
|
||||
Country => '/PayerInfo/Address/Country',
|
||||
CountryName => '/PayerInfo/Address/CountryName',
|
||||
Phone => '/PayerInfo/Address/Phone',
|
||||
PostalCode => '/PayerInfo/Address/PostalCode',
|
||||
|
||||
TransactionID => '/PaymentInfo/TransactionID',
|
||||
ParentTransactionID => '/PaymentInfo/ParentTransactionID',
|
||||
ReceiptID => '/PaymentInfo/ReceiptID',
|
||||
TransactionType => '/PaymentInfo/TransactionType',
|
||||
PaymentType => '/PaymentInfo/PaymentType',
|
||||
PaymentDate => '/PaymentInfo/PaymentDate',
|
||||
GrossAmount => '/PaymentInfo/GrossAmount',
|
||||
FeeAmount => '/PaymentInfo/FeeAmount',
|
||||
SettleAmount => '/PaymentInfo/SettleAmount',
|
||||
TaxAmount => '/PaymentInfo/TaxAmount',
|
||||
ExchangeRate => '/PaymentInfo/ExchangeRate',
|
||||
PaymentStatus => '/PaymentInfo/PaymentStatus',
|
||||
PendingReason => '/PaymentInfo/PendingReason',
|
||||
ReasonCode => '/PaymentInfo/ReasonCode',
|
||||
ProtectionEligibility => '/PaymentInfo/ProtectionEligibility',
|
||||
TransactionID => '/PaymentInfo/TransactionID',
|
||||
ParentTransactionID => '/PaymentInfo/ParentTransactionID',
|
||||
ReceiptID => '/PaymentInfo/ReceiptID',
|
||||
TransactionType => '/PaymentInfo/TransactionType',
|
||||
PaymentType => '/PaymentInfo/PaymentType',
|
||||
PaymentDate => '/PaymentInfo/PaymentDate',
|
||||
GrossAmount => '/PaymentInfo/GrossAmount',
|
||||
FeeAmount => '/PaymentInfo/FeeAmount',
|
||||
SettleAmount => '/PaymentInfo/SettleAmount',
|
||||
TaxAmount => '/PaymentInfo/TaxAmount',
|
||||
ExchangeRate => '/PaymentInfo/ExchangeRate',
|
||||
PaymentStatus => '/PaymentInfo/PaymentStatus',
|
||||
PendingReason => '/PaymentInfo/PendingReason',
|
||||
ReasonCode => '/PaymentInfo/ReasonCode',
|
||||
ProtectionEligibility => '/PaymentInfo/ProtectionEligibility',
|
||||
|
||||
InvoiceID => '/PaymentItemInfo/InvoiceID',
|
||||
Custom => '/PaymentItemInfo/Custom',
|
||||
Memo => '/PaymentItemInfo/Memo',
|
||||
SalesTax => '/PaymentItemInfo/SalesTax',
|
||||
InvoiceID => '/PaymentItemInfo/InvoiceID',
|
||||
Custom => '/PaymentItemInfo/Custom',
|
||||
Memo => '/PaymentItemInfo/Memo',
|
||||
SalesTax => '/PaymentItemInfo/SalesTax',
|
||||
|
||||
PII_SalesTax => '/PaymentItemInfo/PaymentItem/SalesTax',
|
||||
PII_Name => '/PaymentItemInfo/PaymentItem/Name',
|
||||
PII_Number => '/PaymentItemInfo/PaymentItem/Number',
|
||||
PII_Quantity => '/PaymentItemInfo/PaymentItem/Quantity',
|
||||
PII_Amount => '/PaymentItemInfo/PaymentItem/Amount',
|
||||
PII_Options => '/PaymentItemInfo/PaymentItem/Options',
|
||||
PII_SalesTax => '/PaymentItemInfo/PaymentItem/SalesTax',
|
||||
PII_Name => '/PaymentItemInfo/PaymentItem/Name',
|
||||
PII_Number => '/PaymentItemInfo/PaymentItem/Number',
|
||||
PII_Quantity => '/PaymentItemInfo/PaymentItem/Quantity',
|
||||
PII_Amount => '/PaymentItemInfo/PaymentItem/Amount',
|
||||
PII_Options => '/PaymentItemInfo/PaymentItem/Options',
|
||||
|
||||
PII_SubscriptionID => '/PaymentItemInfo/Subscription/SubscriptionID',
|
||||
PII_SubscriptionDate => '/PaymentItemInfo/Subscription/SubscriptionDate',
|
||||
PII_EffectiveDate => '/PaymentItemInfo/Subscription/EffectiveDate',
|
||||
PII_RetryTime => '/PaymentItemInfo/Subscription/RetryTime',
|
||||
PII_Username => '/PaymentItemInfo/Subscription/Username',
|
||||
PII_Password => '/PaymentItemInfo/Subscription/Password',
|
||||
PII_Recurrences => '/PaymentItemInfo/Subscription/Recurrences',
|
||||
PII_reattempt => '/PaymentItemInfo/Subscription/reattempt',
|
||||
PII_recurring => '/PaymentItemInfo/Subscription/recurring',
|
||||
PII_Amount => '/PaymentItemInfo/Subscription/Amount',
|
||||
PII_period => '/PaymentItemInfo/Subscription/period',
|
||||
PII_SubscriptionID =>
|
||||
'/PaymentItemInfo/Subscription/SubscriptionID',
|
||||
PII_SubscriptionDate =>
|
||||
'/PaymentItemInfo/Subscription/SubscriptionDate',
|
||||
PII_EffectiveDate =>
|
||||
'/PaymentItemInfo/Subscription/EffectiveDate',
|
||||
PII_RetryTime => '/PaymentItemInfo/Subscription/RetryTime',
|
||||
PII_Username => '/PaymentItemInfo/Subscription/Username',
|
||||
PII_Password => '/PaymentItemInfo/Subscription/Password',
|
||||
PII_Recurrences => '/PaymentItemInfo/Subscription/Recurrences',
|
||||
PII_reattempt => '/PaymentItemInfo/Subscription/reattempt',
|
||||
PII_recurring => '/PaymentItemInfo/Subscription/recurring',
|
||||
PII_Amount => '/PaymentItemInfo/Subscription/Amount',
|
||||
PII_period => '/PaymentItemInfo/Subscription/period',
|
||||
|
||||
PII_BuyerID => '/PaymentItemInfo/Auction/BuyerID',
|
||||
PII_ClosingDate => '/PaymentItemInfo/Auction/ClosingDate',
|
||||
PII_multiItem => '/PaymentItemInfo/Auction/multiItem',
|
||||
}
|
||||
);
|
||||
PII_BuyerID => '/PaymentItemInfo/Auction/BuyerID',
|
||||
PII_ClosingDate => '/PaymentItemInfo/Auction/ClosingDate',
|
||||
PII_multiItem => '/PaymentItemInfo/Auction/multiItem',
|
||||
}
|
||||
);
|
||||
|
||||
## multiple payment items
|
||||
my $paymentitems = $self->getFieldsList( $som, $path . '/PaymentItemInfo/PaymentItem',
|
||||
{ SalesTax => 'SalesTax',
|
||||
Name => 'Name',
|
||||
Number => 'Number',
|
||||
Quantity => 'Quantity',
|
||||
Amount => 'Amount',
|
||||
Options => 'Options',
|
||||
} );
|
||||
my $paymentitems = $self->getFieldsList(
|
||||
$som,
|
||||
$path . '/PaymentItemInfo/PaymentItem',
|
||||
{ SalesTax => 'SalesTax',
|
||||
Name => 'Name',
|
||||
Number => 'Number',
|
||||
Quantity => 'Quantity',
|
||||
Amount => 'Amount',
|
||||
Options => 'Options',
|
||||
}
|
||||
);
|
||||
|
||||
if( scalar(@$paymentitems) > 0 ) {
|
||||
if ( scalar( @$paymentitems ) > 0 ) {
|
||||
$response{PaymentItems} = $paymentitems;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use warnings;
|
|||
use SOAP::Lite 0.67;
|
||||
use Business::PayPal::API ();
|
||||
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @EXPORT_OK = qw( MassPay );
|
||||
|
||||
sub MassPay {
|
||||
|
@ -20,20 +20,26 @@ sub MassPay {
|
|||
$args{MassPayItems} ||= [];
|
||||
$args{Version} ||= "1.0";
|
||||
|
||||
my %types = ( EmailSubject => 'xs:string',
|
||||
Version => 'xsd:string',
|
||||
# ReceiverType => 'ebl:ReceiverInfoCodeType', ## EmailAddress | UserID
|
||||
);
|
||||
my %types = (
|
||||
EmailSubject => 'xs:string',
|
||||
Version => 'xsd:string',
|
||||
|
||||
my %attr = ( Version => { xmlns => $self->C_xmlns_ebay },
|
||||
Amount => { currencyID => $args{currencyID} }, );
|
||||
# ReceiverType => 'ebl:ReceiverInfoCodeType', ## EmailAddress | UserID
|
||||
);
|
||||
|
||||
my %attr = (
|
||||
Version => { xmlns => $self->C_xmlns_ebay },
|
||||
Amount => { currencyID => $args{currencyID} },
|
||||
);
|
||||
|
||||
## mass pay item
|
||||
my %mpi_type = ( ReceiverEmail => 'ebl:EmailAddressType',
|
||||
ReceiverID => 'xs:string',
|
||||
Amount => 'ebl:BasicAmountType',
|
||||
UniqueId => 'xs:string',
|
||||
Note => 'xs:string', );
|
||||
my %mpi_type = (
|
||||
ReceiverEmail => 'ebl:EmailAddressType',
|
||||
ReceiverID => 'xs:string',
|
||||
Amount => 'ebl:BasicAmountType',
|
||||
UniqueId => 'xs:string',
|
||||
Note => 'xs:string',
|
||||
);
|
||||
|
||||
my @recipients = @{ $args{MassPayItems} };
|
||||
|
||||
|
@ -41,15 +47,19 @@ sub MassPay {
|
|||
|
||||
for my $type ( sort keys %types ) {
|
||||
next unless $args{$type};
|
||||
if( $attr{$type} ) {
|
||||
push @masspay, SOAP::Data->name( $type => $args{$type} )->type($types{$type})->attr( { %{ $attr{$type} } } );
|
||||
if ( $attr{$type} ) {
|
||||
push @masspay,
|
||||
SOAP::Data->name( $type => $args{$type} )
|
||||
->type( $types{$type} )->attr( { %{ $attr{$type} } } );
|
||||
}
|
||||
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};
|
||||
}
|
||||
|
||||
|
@ -61,30 +71,36 @@ sub MassPay {
|
|||
my @rcpt = ();
|
||||
for my $type ( keys %mpi_type ) {
|
||||
next unless $mpi_type{$type};
|
||||
if( $attr{$type} ) {
|
||||
push @rcpt, SOAP::Data->name( $type => $rcpt->{$type} )->type($mpi_type{$type})->attr( { %{ $attr{$type} } } );
|
||||
if ( $attr{$type} ) {
|
||||
push @rcpt,
|
||||
SOAP::Data->name( $type => $rcpt->{$type} )
|
||||
->type( $mpi_type{$type} )->attr( { %{ $attr{$type} } } );
|
||||
}
|
||||
|
||||
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
|
||||
( MassPayRequest => \SOAP::Data->value( @masspay ) )
|
||||
->type("ns:MassPayRequestType");
|
||||
my $request
|
||||
= SOAP::Data->name( MassPayRequest => \SOAP::Data->value( @masspay ) )
|
||||
->type( "ns:MassPayRequestType" );
|
||||
|
||||
my $som = $self->doCall( MassPayReq => $request )
|
||||
or return;
|
||||
or return;
|
||||
|
||||
my $path = '/Envelope/Body/MassPayResponse';
|
||||
|
||||
my %response = ();
|
||||
unless( $self->getBasic($som, $path, \%response) ) {
|
||||
$self->getErrors($som, $path, \%response);
|
||||
unless ( $self->getBasic( $som, $path, \%response ) ) {
|
||||
$self->getErrors( $som, $path, \%response );
|
||||
return %response;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,49 +7,53 @@ use warnings;
|
|||
use SOAP::Lite 0.67;
|
||||
use Business::PayPal::API ();
|
||||
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @EXPORT_OK = qw(DoReauthorizationRequest);
|
||||
|
||||
sub DoReauthorizationRequest {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my %types = ( AuthorizationID => 'xs:string',
|
||||
Amount => 'ebl:BasicAmountType',);
|
||||
|
||||
my %types = (
|
||||
AuthorizationID => 'xs:string',
|
||||
Amount => 'ebl:BasicAmountType',
|
||||
);
|
||||
|
||||
$args{currencyID} ||= 'USD';
|
||||
|
||||
my @ref_trans =
|
||||
($self->version_req,
|
||||
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )->type($types{AuthorizationID}),);
|
||||
my @ref_trans = (
|
||||
$self->version_req,
|
||||
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )
|
||||
->type( $types{AuthorizationID} ),
|
||||
);
|
||||
|
||||
push @ref_trans,
|
||||
SOAP::Data->name( Amount => $args{Amount} )
|
||||
->type( $types{Amount} )
|
||||
->attr( { currencyID => $args{currencyID} } );
|
||||
SOAP::Data->name( Amount => $args{Amount} )->type( $types{Amount} )
|
||||
->attr( { currencyID => $args{currencyID} } );
|
||||
|
||||
|
||||
|
||||
my $request = SOAP::Data->name
|
||||
( DoReauthorizationRequest => \SOAP::Data->value( @ref_trans ) )
|
||||
->type("ns:ReauthorizationRequestType");
|
||||
my $request
|
||||
= SOAP::Data->name(
|
||||
DoReauthorizationRequest => \SOAP::Data->value( @ref_trans ) )
|
||||
->type( "ns:ReauthorizationRequestType" );
|
||||
|
||||
my $som = $self->doCall( DoReauthorizationReq => $request )
|
||||
or return;
|
||||
or return;
|
||||
|
||||
my $path = '/Envelope/Body/DoReauthorizationResponse';
|
||||
|
||||
my %response = ();
|
||||
unless( $self->getBasic($som, $path, \%response) ) {
|
||||
$self->getErrors($som, $path, \%response);
|
||||
unless ( $self->getBasic( $som, $path, \%response ) ) {
|
||||
$self->getErrors( $som, $path, \%response );
|
||||
return %response;
|
||||
}
|
||||
|
||||
$self->getFields($som, $path, \%response,
|
||||
{ AuthorizationID => 'AuthorizationID',
|
||||
Amount => 'Amount', }
|
||||
);
|
||||
$self->getFields(
|
||||
$som, $path,
|
||||
\%response,
|
||||
{ AuthorizationID => 'AuthorizationID',
|
||||
Amount => 'Amount',
|
||||
}
|
||||
);
|
||||
|
||||
return %response;
|
||||
}
|
||||
|
|
|
@ -7,11 +7,11 @@ use warnings;
|
|||
use SOAP::Lite 0.67;
|
||||
use Business::PayPal::API ();
|
||||
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @EXPORT_OK = qw( SetCustomerBillingAgreement
|
||||
GetBillingAgreementCustomerDetails
|
||||
CreateRecurringPaymentsProfile
|
||||
DoReferenceTransaction);
|
||||
GetBillingAgreementCustomerDetails
|
||||
CreateRecurringPaymentsProfile
|
||||
DoReferenceTransaction);
|
||||
|
||||
our $API_VERSION = '50.0';
|
||||
|
||||
|
@ -20,61 +20,73 @@ sub SetCustomerBillingAgreement {
|
|||
my %args = @_;
|
||||
|
||||
## billing agreement details type
|
||||
my %badtypes = ( BillingType => '', # 'ns:BillingCodeType',
|
||||
BillingAgreementDescription => 'xs:string',
|
||||
PaymentType => '', # 'ns:MerchantPullPaymentCodeType',
|
||||
BillingAgreementCustom => 'xs:string', );
|
||||
my %badtypes = (
|
||||
BillingType => '', # 'ns:BillingCodeType',
|
||||
BillingAgreementDescription => 'xs:string',
|
||||
PaymentType => '', # 'ns:MerchantPullPaymentCodeType',
|
||||
BillingAgreementCustom => 'xs:string',
|
||||
);
|
||||
|
||||
my %types = ( BillingAgreementDetails => 'ns:BillingAgreementDetailsType',
|
||||
ReturnURL => 'xs:string',
|
||||
CancelURL => 'xs:string',
|
||||
LocaleCode => 'xs:string',
|
||||
PageStyle => 'xs:string',
|
||||
'cpp-header-image' => 'xs:string',
|
||||
'cpp-header-border-color' => 'xs:string',
|
||||
'cpp-header-back-color' => 'xs:string',
|
||||
'cpp-payflow-color' => 'xs:string',
|
||||
PaymentAction => '',
|
||||
BuyerEmail => 'ns:EmailAddressType', );
|
||||
my %types = (
|
||||
BillingAgreementDetails => 'ns:BillingAgreementDetailsType',
|
||||
ReturnURL => 'xs:string',
|
||||
CancelURL => 'xs:string',
|
||||
LocaleCode => 'xs:string',
|
||||
PageStyle => 'xs:string',
|
||||
'cpp-header-image' => 'xs:string',
|
||||
'cpp-header-border-color' => 'xs:string',
|
||||
'cpp-header-back-color' => 'xs:string',
|
||||
'cpp-payflow-color' => 'xs:string',
|
||||
PaymentAction => '',
|
||||
BuyerEmail => 'ns:EmailAddressType',
|
||||
);
|
||||
|
||||
## set defaults
|
||||
$args{BillingType} ||= 'RecurringPayments';
|
||||
$args{PaymentType} ||= 'InstantOnly';
|
||||
$args{currencyID} ||= 'USD';
|
||||
$args{BillingType} ||= 'RecurringPayments';
|
||||
$args{PaymentType} ||= 'InstantOnly';
|
||||
$args{currencyID} ||= 'USD';
|
||||
|
||||
my @btypes = ();
|
||||
for my $field ( keys %badtypes ) {
|
||||
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 = ();
|
||||
for my $field ( keys %types ) {
|
||||
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
|
||||
->name( SetCustomerBillingAgreementRequest => \SOAP::Data->value
|
||||
( $self->version_req, #$API_VERSION,
|
||||
SOAP::Data->name( SetCustomerBillingAgreementRequestDetails => \SOAP::Data->value(@scba)
|
||||
)->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
)
|
||||
)->type( 'ns:SetCustomerBillingAgreementRequestDetailsType' );
|
||||
my $request = SOAP::Data->name(
|
||||
SetCustomerBillingAgreementRequest => \SOAP::Data->value(
|
||||
$self->version_req, #$API_VERSION,
|
||||
SOAP::Data->name(
|
||||
SetCustomerBillingAgreementRequestDetails =>
|
||||
\SOAP::Data->value( @scba )
|
||||
)->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||
)
|
||||
)->type( 'ns:SetCustomerBillingAgreementRequestDetailsType' );
|
||||
|
||||
my $som = $self->doCall( SetCustomerBillingAgreementReq => $request )
|
||||
or return;
|
||||
or return;
|
||||
|
||||
my $path = '/Envelope/Body/SetCustomerBillingAgreementResponse';
|
||||
|
||||
my %response = ();
|
||||
unless( $self->getBasic($som, $path, \%response) ) {
|
||||
$self->getErrors($som, $path, \%response);
|
||||
unless ( $self->getBasic( $som, $path, \%response ) ) {
|
||||
$self->getErrors( $som, $path, \%response );
|
||||
return %response;
|
||||
}
|
||||
|
||||
$self->getFields($som, $path, \%response, { Token => 'Token' });
|
||||
$self->getFields( $som, $path, \%response, { Token => 'Token' } );
|
||||
|
||||
return %response;
|
||||
}
|
||||
|
@ -83,50 +95,53 @@ sub GetBillingAgreementCustomerDetails {
|
|||
my $self = shift;
|
||||
my $token = shift;
|
||||
|
||||
my $request = SOAP::Data
|
||||
->name( GetBillingAgreementCustomerDetailsRequest => \SOAP::Data->value
|
||||
( $self->version_req,
|
||||
SOAP::Data->name( Token => $token )
|
||||
->type('xs:string')->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
)
|
||||
)->type( 'ns:GetBillingAgreementCustomerDetailsResponseType' );
|
||||
my $request = SOAP::Data->name(
|
||||
GetBillingAgreementCustomerDetailsRequest => \SOAP::Data->value(
|
||||
$self->version_req,
|
||||
SOAP::Data->name( Token => $token )->type( 'xs:string' )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||
)
|
||||
)->type( 'ns:GetBillingAgreementCustomerDetailsResponseType' );
|
||||
|
||||
my $som = $self->doCall( GetBillingAgreementCustomerDetailsReq => $request )
|
||||
or return;
|
||||
my $som
|
||||
= $self->doCall( GetBillingAgreementCustomerDetailsReq => $request )
|
||||
or return;
|
||||
|
||||
my $path = '/Envelope/Body/GetBillingAgreementCustomerDetailsResponse';
|
||||
|
||||
my %details = ();
|
||||
unless( $self->getBasic($som, $path, \%details) ) {
|
||||
$self->getErrors($som, $path, \%details);
|
||||
unless ( $self->getBasic( $som, $path, \%details ) ) {
|
||||
$self->getErrors( $som, $path, \%details );
|
||||
return %details;
|
||||
}
|
||||
|
||||
$self->getFields($som,
|
||||
"$path/GetBillingAgreementCustomerDetailsResponseDetails",
|
||||
\%details,
|
||||
{ Token => 'Token',
|
||||
$self->getFields(
|
||||
$som,
|
||||
"$path/GetBillingAgreementCustomerDetailsResponseDetails",
|
||||
\%details,
|
||||
{ Token => 'Token',
|
||||
|
||||
Payer => 'PayerInfo/Payer',
|
||||
PayerID => 'PayerInfo/PayerID',
|
||||
PayerStatus => 'PayerInfo/PayerStatus', ## 'unverified'
|
||||
PayerBusiness => 'PayerInfo/PayerBusiness',
|
||||
Payer => 'PayerInfo/Payer',
|
||||
PayerID => 'PayerInfo/PayerID',
|
||||
PayerStatus => 'PayerInfo/PayerStatus', ## 'unverified'
|
||||
PayerBusiness => 'PayerInfo/PayerBusiness',
|
||||
|
||||
Name => 'PayerInfo/Address/Name',
|
||||
AddressOwner => 'PayerInfo/Address/AddressOwner', ## 'PayPal'
|
||||
AddressStatus => 'PayerInfo/Address/AddressStatus', ## 'none'
|
||||
Street1 => 'PayerInfo/Address/Street1',
|
||||
Street2 => 'PayerInfo/Address/Street2',
|
||||
StateOrProvince => 'PayerInfo/Address/StateOrProvince',
|
||||
PostalCode => 'PayerInfo/Address/PostalCode',
|
||||
CountryName => 'PayerInfo/Address/CountryName',
|
||||
Name => 'PayerInfo/Address/Name',
|
||||
AddressOwner => 'PayerInfo/Address/AddressOwner', ## 'PayPal'
|
||||
AddressStatus => 'PayerInfo/Address/AddressStatus', ## 'none'
|
||||
Street1 => 'PayerInfo/Address/Street1',
|
||||
Street2 => 'PayerInfo/Address/Street2',
|
||||
StateOrProvince => 'PayerInfo/Address/StateOrProvince',
|
||||
PostalCode => 'PayerInfo/Address/PostalCode',
|
||||
CountryName => 'PayerInfo/Address/CountryName',
|
||||
|
||||
Salutation => 'PayerInfo/PayerName/Salutation',
|
||||
FirstName => 'PayerInfo/PayerName/FirstName',
|
||||
MiddleName => 'PayerInfo/PayerName/MiddleName',
|
||||
LastName => 'PayerInfo/PayerName/LastName',
|
||||
Suffix => 'PayerInfo/PayerName/Suffix',
|
||||
} );
|
||||
Salutation => 'PayerInfo/PayerName/Salutation',
|
||||
FirstName => 'PayerInfo/PayerName/FirstName',
|
||||
MiddleName => 'PayerInfo/PayerName/MiddleName',
|
||||
LastName => 'PayerInfo/PayerName/LastName',
|
||||
Suffix => 'PayerInfo/PayerName/Suffix',
|
||||
}
|
||||
);
|
||||
|
||||
return %details;
|
||||
}
|
||||
|
@ -136,172 +151,226 @@ sub CreateRecurringPaymentsProfile {
|
|||
my %args = @_;
|
||||
|
||||
## RecurringPaymentProfileDetails
|
||||
my %profiledetailstype = ( SubscriberName => 'xs:string',
|
||||
SubscriberShipperAddress => 'ns:AddressType',
|
||||
BillingStartDate => 'xs:dateTime', ## MM-DD-YY
|
||||
ProfileReference => 'xs:string', );
|
||||
my %profiledetailstype = (
|
||||
SubscriberName => 'xs:string',
|
||||
SubscriberShipperAddress => 'ns:AddressType',
|
||||
BillingStartDate => 'xs:dateTime', ## MM-DD-YY
|
||||
ProfileReference => 'xs:string',
|
||||
);
|
||||
|
||||
## ScheduleDetailsType
|
||||
my %schedtype = ( Description => 'xs:string',
|
||||
ActivationDetails => 'ns:ActivationDetailsType',
|
||||
TrialPeriod => 'ns:BillingPeriodDetailsType',
|
||||
PaymentPeriod => 'ns:BillingPeriodDetailsType',
|
||||
MaxFailedPayments => 'xs:int',
|
||||
AutoBillOutstandingAmount => 'ns:AutoBillType', ); ## NoAutoBill or AddToNextBilling
|
||||
my %schedtype = (
|
||||
Description => 'xs:string',
|
||||
ActivationDetails => 'ns:ActivationDetailsType',
|
||||
TrialPeriod => 'ns:BillingPeriodDetailsType',
|
||||
PaymentPeriod => 'ns:BillingPeriodDetailsType',
|
||||
MaxFailedPayments => 'xs:int',
|
||||
AutoBillOutstandingAmount => 'ns:AutoBillType',
|
||||
); ## NoAutoBill or AddToNextBilling
|
||||
|
||||
## activation details
|
||||
my %activationdetailstype = ( InitialAmount => 'cc:BasicAmountType',
|
||||
FailedInitialAmountAction => 'ns:FailedPaymentAction', ); ## ContinueOnFailure or CancelOnFailure
|
||||
my %activationdetailstype = (
|
||||
InitialAmount => 'cc:BasicAmountType',
|
||||
FailedInitialAmountAction => 'ns:FailedPaymentAction',
|
||||
); ## ContinueOnFailure or CancelOnFailure
|
||||
|
||||
## BillingPeriodDetailsType
|
||||
my %trialbilltype = ( TrialBillingPeriod => 'xs:string', ##'ns:BillingPeriodType',
|
||||
TrialBillingFrequency => 'xs:int',
|
||||
TrialTotalBillingCycles => 'xs:int',
|
||||
TrialAmount => 'cc:AmountType',
|
||||
TrialShippingAmount => 'cc:AmountType',
|
||||
TrialTaxAmount => 'cc:AmountType', );
|
||||
my %trialbilltype = (
|
||||
TrialBillingPeriod => 'xs:string', ##'ns:BillingPeriodType',
|
||||
TrialBillingFrequency => 'xs:int',
|
||||
TrialTotalBillingCycles => 'xs:int',
|
||||
TrialAmount => 'cc:AmountType',
|
||||
TrialShippingAmount => 'cc:AmountType',
|
||||
TrialTaxAmount => 'cc:AmountType',
|
||||
);
|
||||
|
||||
my %paymentbilltype = ( PaymentBillingPeriod => 'xs:string', ##'ns:BillingPeriodType',
|
||||
PaymentBillingFrequency => 'xs:int',
|
||||
PaymentTotalBillingCycles => 'xs:int',
|
||||
PaymentAmount => 'cc:AmountType',
|
||||
PaymentShippingAmount => 'cc:AmountType',
|
||||
PaymentTaxAmount => 'cc:AmountType', );
|
||||
my %paymentbilltype = (
|
||||
PaymentBillingPeriod => 'xs:string', ##'ns:BillingPeriodType',
|
||||
PaymentBillingFrequency => 'xs:int',
|
||||
PaymentTotalBillingCycles => 'xs:int',
|
||||
PaymentAmount => 'cc:AmountType',
|
||||
PaymentShippingAmount => 'cc:AmountType',
|
||||
PaymentTaxAmount => 'cc:AmountType',
|
||||
);
|
||||
|
||||
## AddressType
|
||||
my %payaddrtype = ( CCPayerName => 'xs:string',
|
||||
CCPayerStreet1 => 'xs:string',
|
||||
CCPayerStreet2 => 'xs:string',
|
||||
CCPayerCityName => 'xs:string',
|
||||
CCPayerStateOrProvince => 'xs:string',
|
||||
CCPayerCountry => 'xs:string', ## ebl:CountryCodeType
|
||||
CCPayerPostalCode => 'xs:string',
|
||||
CCPayerPhone => 'xs:string', );
|
||||
my %payaddrtype = (
|
||||
CCPayerName => 'xs:string',
|
||||
CCPayerStreet1 => 'xs:string',
|
||||
CCPayerStreet2 => 'xs:string',
|
||||
CCPayerCityName => 'xs:string',
|
||||
CCPayerStateOrProvince => 'xs:string',
|
||||
CCPayerCountry => 'xs:string', ## ebl:CountryCodeType
|
||||
CCPayerPostalCode => 'xs:string',
|
||||
CCPayerPhone => 'xs:string',
|
||||
);
|
||||
|
||||
my %shipaddrtype = ( SubscriberShipperName => 'xs:string',
|
||||
SubscriberShipperStreet1 => 'xs:string',
|
||||
SubscriberShipperStreet2 => 'xs:string',
|
||||
SubscriberShipperCityName => 'xs:string',
|
||||
SubscriberShipperStateOrProvince => 'xs:string',
|
||||
SubscriberShipperCountry => 'xs:string', ## ebl:CountryCodeType
|
||||
SubscriberShipperPostalCode => 'xs:string',
|
||||
SubscriberShipperPhone => 'xs:string', );
|
||||
my %shipaddrtype = (
|
||||
SubscriberShipperName => 'xs:string',
|
||||
SubscriberShipperStreet1 => 'xs:string',
|
||||
SubscriberShipperStreet2 => 'xs:string',
|
||||
SubscriberShipperCityName => 'xs:string',
|
||||
SubscriberShipperStateOrProvince => 'xs:string',
|
||||
SubscriberShipperCountry => 'xs:string', ## ebl:CountryCodeType
|
||||
SubscriberShipperPostalCode => 'xs:string',
|
||||
SubscriberShipperPhone => 'xs:string',
|
||||
);
|
||||
|
||||
## credit card payer
|
||||
my %payerinfotype = ( CCPayer => 'ns:EmailAddressType',
|
||||
CCPayerID => 'ebl:UserIDType',
|
||||
CCPayerStatus => 'xs:string',
|
||||
CCPayerName => 'xs:string',
|
||||
CCPayerCountry => 'xs:string',
|
||||
CCPayerPhone => 'xs:string',
|
||||
CCPayerBusiness => 'xs:string',
|
||||
CCAddress => 'xs:string',
|
||||
);
|
||||
my %payerinfotype = (
|
||||
CCPayer => 'ns:EmailAddressType',
|
||||
CCPayerID => 'ebl:UserIDType',
|
||||
CCPayerStatus => 'xs:string',
|
||||
CCPayerName => 'xs:string',
|
||||
CCPayerCountry => 'xs:string',
|
||||
CCPayerPhone => 'xs:string',
|
||||
CCPayerBusiness => 'xs:string',
|
||||
CCAddress => 'xs:string',
|
||||
);
|
||||
|
||||
## credit card details
|
||||
my %creditcarddetailstype = ( CardOwner => 'ns:PayerInfoType',
|
||||
CreditCardType => 'ebl:CreditCardType', ## Visa, MasterCard, Discover, Amex, Switch, Solo
|
||||
CreditCardNumber => 'xs:string',
|
||||
ExpMonth => 'xs:int',
|
||||
ExpYear => 'xs:int',
|
||||
CVV2 => 'xs:string',
|
||||
StartMonth => 'xs:string',
|
||||
StartYear => 'xs:string',
|
||||
IssueNumber => 'xs:int', );
|
||||
my %creditcarddetailstype = (
|
||||
CardOwner => 'ns:PayerInfoType',
|
||||
CreditCardType => 'ebl:CreditCardType'
|
||||
, ## Visa, MasterCard, Discover, Amex, Switch, Solo
|
||||
CreditCardNumber => 'xs:string',
|
||||
ExpMonth => 'xs:int',
|
||||
ExpYear => 'xs:int',
|
||||
CVV2 => 'xs:string',
|
||||
StartMonth => 'xs:string',
|
||||
StartYear => 'xs:string',
|
||||
IssueNumber => 'xs:int',
|
||||
);
|
||||
|
||||
## this gets pushed onto scheduledetails
|
||||
my @activationdetailstype = ();
|
||||
for my $field ( keys %activationdetailstype ) {
|
||||
next unless exists $args{$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
|
||||
my @trialbilltype = ();
|
||||
for my $field ( keys %trialbilltype ) {
|
||||
next unless exists $args{$field};
|
||||
(my $real_field = $field) =~ s/^Trial//;
|
||||
push @trialbilltype, SOAP::Data->name( $real_field => $args{$field} )->type( $trialbilltype{$field} );
|
||||
( my $real_field = $field ) =~ s/^Trial//;
|
||||
push @trialbilltype,
|
||||
SOAP::Data->name( $real_field => $args{$field} )
|
||||
->type( $trialbilltype{$field} );
|
||||
}
|
||||
|
||||
## this gets pushed onto scheduledetails
|
||||
my @paymentbilltype = ();
|
||||
for my $field ( keys %paymentbilltype ) {
|
||||
next unless exists $args{$field};
|
||||
(my $real_field = $field) =~ s/^Payment//;
|
||||
push @paymentbilltype, SOAP::Data->name( $real_field => $args{$field} )->type( $paymentbilltype{$field} );
|
||||
( my $real_field = $field ) =~ s/^Payment//;
|
||||
push @paymentbilltype,
|
||||
SOAP::Data->name( $real_field => $args{$field} )
|
||||
->type( $paymentbilltype{$field} );
|
||||
}
|
||||
|
||||
## this gets pushed onto the top
|
||||
my @sched = ();
|
||||
for my $field ( keys %schedtype ) {
|
||||
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, SOAP::Data->name( PaymentPeriod => \SOAP::Data->value(@paymentbilltype) ); #->type( 'ns:BillingPeriodDetailsType' );
|
||||
push @sched,
|
||||
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
|
||||
my @shipaddr = ();
|
||||
for my $field ( keys %shipaddrtype ) {
|
||||
next unless exists $args{$field};
|
||||
(my $real_field = $field) =~ s/^SubscriberShipper//;
|
||||
push @shipaddr, SOAP::Data->name( $real_field => $args{$field} )->type( $shipaddrtype{$field} );
|
||||
( my $real_field = $field ) =~ s/^SubscriberShipper//;
|
||||
push @shipaddr,
|
||||
SOAP::Data->name( $real_field => $args{$field} )
|
||||
->type( $shipaddrtype{$field} );
|
||||
}
|
||||
|
||||
## this gets pushed into payerinfo (from creditcarddetails)
|
||||
my @payeraddr = ();
|
||||
for my $field ( keys %payaddrtype ) {
|
||||
next unless $args{$field};
|
||||
(my $real_field = $field) =~ s/^CCPayer//;
|
||||
push @payeraddr, SOAP::Data->name( $real_field => $args{$field} )->type( payaddrtype{$field} );
|
||||
( my $real_field = $field ) =~ s/^CCPayer//;
|
||||
push @payeraddr,
|
||||
SOAP::Data->name( $real_field => $args{$field} )
|
||||
->type( payaddrtype {$field} );
|
||||
}
|
||||
|
||||
## credit card type
|
||||
my @creditcarddetails = ();
|
||||
for my $field ( keys %creditcarddetailstype ) {
|
||||
next unless $args{$field};
|
||||
(my $real_field = $field) =~ s/^CC//;
|
||||
push @payeraddr, SOAP::Data->name( $real_field => $args{$field} )->type( payaddrtype{$field} );
|
||||
( my $real_field = $field ) =~ s/^CC//;
|
||||
push @payeraddr,
|
||||
SOAP::Data->name( $real_field => $args{$field} )
|
||||
->type( payaddrtype {$field} );
|
||||
}
|
||||
|
||||
## this gets pushed onto the top
|
||||
my @profdetail = ();
|
||||
for my $field ( keys %profiledetailstype ) {
|
||||
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?
|
||||
my @crpprd = ();
|
||||
push @crpprd, SOAP::Data->name( Token => $args{Token} );
|
||||
push @crpprd, SOAP::Data->name( 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' );
|
||||
push @crpprd,
|
||||
SOAP::Data->name(
|
||||
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
|
||||
( CreateRecurringPaymentsProfileRequest => \SOAP::Data->value
|
||||
# ( $API_VERSION,
|
||||
( $self->version_req,
|
||||
SOAP::Data->name( CreateRecurringPaymentsProfileRequestDetails => \SOAP::Data->value(@crpprd)
|
||||
)->attr( {xmlns => $self->C_xmlns_ebay} )
|
||||
)
|
||||
); #->type( 'ns:CreateRecurringPaymentsProfileRequestType' );
|
||||
my $request = SOAP::Data->name(
|
||||
CreateRecurringPaymentsProfileRequest => \SOAP::Data->value
|
||||
|
||||
# ( $API_VERSION,
|
||||
(
|
||||
$self->version_req,
|
||||
SOAP::Data->name(
|
||||
CreateRecurringPaymentsProfileRequestDetails =>
|
||||
\SOAP::Data->value( @crpprd )
|
||||
)->attr( { xmlns => $self->C_xmlns_ebay } )
|
||||
)
|
||||
); #->type( 'ns:CreateRecurringPaymentsProfileRequestType' );
|
||||
|
||||
my $som = $self->doCall( CreateRecurringPaymentsProfileReq => $request )
|
||||
or return;
|
||||
or return;
|
||||
|
||||
my $path = '/Envelope/Body/CreateRecurringPaymentsProfileResponse';
|
||||
|
||||
my %response = ();
|
||||
unless( $self->getBasic($som, $path, \%response) ) {
|
||||
$self->getErrors($som, $path, \%response);
|
||||
unless ( $self->getBasic( $som, $path, \%response ) ) {
|
||||
$self->getErrors( $som, $path, \%response );
|
||||
return %response;
|
||||
}
|
||||
|
||||
$self->getFields($som, $path, \%response, { Token => 'Token' });
|
||||
$self->getFields( $som, $path, \%response, { Token => 'Token' } );
|
||||
|
||||
return %response;
|
||||
}
|
||||
|
@ -310,64 +379,71 @@ sub DoReferenceTransaction {
|
|||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my %types = ( ReferenceID => 'xs:string',
|
||||
PaymentAction => '', ## NOTA BENE!
|
||||
currencyID => '',
|
||||
);
|
||||
my %types = (
|
||||
ReferenceID => 'xs:string',
|
||||
PaymentAction => '', ## NOTA BENE!
|
||||
currencyID => '',
|
||||
);
|
||||
|
||||
## PaymentDetails
|
||||
my %pd_types = ( OrderTotal => 'ebl:BasicAmountType',
|
||||
OrderDescription => 'xs:string',
|
||||
ItemTotal => 'ebl:BasicAmountType',
|
||||
ShippingTotal => 'ebl:BasicAmountType',
|
||||
HandlingTotal => 'ebl:BasicAmountType',
|
||||
TaxTotal => 'ebl:BasicAmountType',
|
||||
Custom => 'xs:string',
|
||||
InvoiceID => 'xs:string',
|
||||
ButtonSource => 'xs:string',
|
||||
NotifyURL => 'xs:string',
|
||||
);
|
||||
my %pd_types = (
|
||||
OrderTotal => 'ebl:BasicAmountType',
|
||||
OrderDescription => 'xs:string',
|
||||
ItemTotal => 'ebl:BasicAmountType',
|
||||
ShippingTotal => 'ebl:BasicAmountType',
|
||||
HandlingTotal => 'ebl:BasicAmountType',
|
||||
TaxTotal => 'ebl:BasicAmountType',
|
||||
Custom => 'xs:string',
|
||||
InvoiceID => 'xs:string',
|
||||
ButtonSource => 'xs:string',
|
||||
NotifyURL => 'xs:string',
|
||||
);
|
||||
|
||||
## ShipToAddress
|
||||
my %st_types = ( ST_Name => 'xs:string',
|
||||
ST_Street1 => 'xs:string',
|
||||
ST_Street2 => 'xs:string',
|
||||
ST_CityName => 'xs:string',
|
||||
ST_StateOrProvince => 'xs:string',
|
||||
ST_Country => 'xs:string',
|
||||
ST_PostalCode => 'xs:string',
|
||||
ST_Phone => 'xs:string',
|
||||
);
|
||||
my %st_types = (
|
||||
ST_Name => 'xs:string',
|
||||
ST_Street1 => 'xs:string',
|
||||
ST_Street2 => 'xs:string',
|
||||
ST_CityName => 'xs:string',
|
||||
ST_StateOrProvince => 'xs:string',
|
||||
ST_Country => 'xs:string',
|
||||
ST_PostalCode => 'xs:string',
|
||||
ST_Phone => 'xs:string',
|
||||
);
|
||||
|
||||
##PaymentDetailsItem
|
||||
my %pdi_types = ( PDI_Name => 'xs:string',
|
||||
PDI_Description => 'xs:string',
|
||||
PDI_Amount => 'ebl:BasicAmountType',
|
||||
PDI_Number => 'xs:string',
|
||||
PDI_Quantity => 'xs:string',
|
||||
PDI_Tax => 'ebl:BasicAmountType',
|
||||
);
|
||||
my %pdi_types = (
|
||||
PDI_Name => 'xs:string',
|
||||
PDI_Description => 'xs:string',
|
||||
PDI_Amount => 'ebl:BasicAmountType',
|
||||
PDI_Number => 'xs:string',
|
||||
PDI_Quantity => 'xs:string',
|
||||
PDI_Tax => 'ebl:BasicAmountType',
|
||||
);
|
||||
|
||||
$args{PaymentAction} ||= 'Sale';
|
||||
$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 @payment_details, SOAP::Data->name( OrderTotal => $args{OrderTotal} )
|
||||
->type( $pd_types{OrderTotal} )
|
||||
->attr( { currencyID => $args{currencyID},
|
||||
xmlns => $self->C_xmlns_ebay } );
|
||||
push @payment_details,
|
||||
SOAP::Data->name( OrderTotal => $args{OrderTotal} )
|
||||
->type( $pd_types{OrderTotal} )->attr(
|
||||
{ currencyID => $args{currencyID},
|
||||
xmlns => $self->C_xmlns_ebay
|
||||
}
|
||||
);
|
||||
|
||||
## don't process it again
|
||||
delete $pd_types{OrderTotal};
|
||||
|
||||
for my $field ( keys %pd_types ) {
|
||||
if( $args{$field} ) {
|
||||
push @payment_details,
|
||||
SOAP::Data->name( $field => $args{$field} )
|
||||
->type( $pd_types{$field} );
|
||||
}
|
||||
if ( $args{$field} ) {
|
||||
push @payment_details,
|
||||
SOAP::Data->name( $field => $args{$field} )
|
||||
->type( $pd_types{$field} );
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
|
@ -375,20 +451,19 @@ sub DoReferenceTransaction {
|
|||
##
|
||||
my @ship_types = ();
|
||||
for my $field ( keys %st_types ) {
|
||||
if( $args{$field} ) {
|
||||
(my $name = $field) =~ s/^ST_//;
|
||||
push @ship_types,
|
||||
SOAP::Data->name( $name => $args{$field} )
|
||||
->type( $st_types{$field} );
|
||||
}
|
||||
if ( $args{$field} ) {
|
||||
( my $name = $field ) =~ s/^ST_//;
|
||||
push @ship_types,
|
||||
SOAP::Data->name( $name => $args{$field} )
|
||||
->type( $st_types{$field} );
|
||||
}
|
||||
}
|
||||
|
||||
if( scalar @ship_types ) {
|
||||
push @payment_details,
|
||||
SOAP::Data->name( ShipToAddress => \SOAP::Data->value
|
||||
( @ship_types )->type('ebl:AddressType')
|
||||
->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
);
|
||||
if ( scalar @ship_types ) {
|
||||
push @payment_details,
|
||||
SOAP::Data->name( ShipToAddress =>
|
||||
\SOAP::Data->value( @ship_types )->type( 'ebl:AddressType' )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ), );
|
||||
}
|
||||
|
||||
##
|
||||
|
@ -396,75 +471,83 @@ sub DoReferenceTransaction {
|
|||
##
|
||||
my @payment_details_item = ();
|
||||
for my $field ( keys %pdi_types ) {
|
||||
if( $args{$field} ) {
|
||||
(my $name = $field) =~ s/^PDI_//;
|
||||
push @payment_details_item,
|
||||
SOAP::Data->name( $name => $args{$field} )
|
||||
->type( $pdi_types{$field} );
|
||||
}
|
||||
if ( $args{$field} ) {
|
||||
( my $name = $field ) =~ s/^PDI_//;
|
||||
push @payment_details_item,
|
||||
SOAP::Data->name( $name => $args{$field} )
|
||||
->type( $pdi_types{$field} );
|
||||
}
|
||||
}
|
||||
|
||||
if( scalar @payment_details_item ) {
|
||||
push @payment_details,
|
||||
SOAP::Data->name( PaymentDetailsItem => \SOAP::Data->value
|
||||
( @payment_details_item )->type('ebl:PaymentDetailsItemType')
|
||||
->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
);
|
||||
if ( scalar @payment_details_item ) {
|
||||
push @payment_details,
|
||||
SOAP::Data->name(
|
||||
PaymentDetailsItem => \SOAP::Data->value( @payment_details_item )
|
||||
->type( 'ebl:PaymentDetailsItemType' )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ), );
|
||||
}
|
||||
|
||||
##
|
||||
## ReferenceTransactionPaymentDetails
|
||||
##
|
||||
my @reference_details = (
|
||||
SOAP::Data->name( ReferenceID => $args{ReferenceID} )
|
||||
->type($types{ReferenceID})->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
SOAP::Data->name( PaymentAction => $args{PaymentAction} )
|
||||
->type($types{PaymentAction})->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
SOAP::Data->name( PaymentDetails => \SOAP::Data->value
|
||||
( @payment_details )->type('ebl:PaymentDetailsType')
|
||||
->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
), );
|
||||
SOAP::Data->name( ReferenceID => $args{ReferenceID} )
|
||||
->type( $types{ReferenceID} )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||
SOAP::Data->name( PaymentAction => $args{PaymentAction} )
|
||||
->type( $types{PaymentAction} )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||
SOAP::Data->name(
|
||||
PaymentDetails => \SOAP::Data->value( @payment_details )
|
||||
->type( 'ebl:PaymentDetailsType' )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||
),
|
||||
);
|
||||
|
||||
##
|
||||
## the main request object
|
||||
##
|
||||
my $request = SOAP::Data
|
||||
->name( DoReferenceTransactionRequest => \SOAP::Data->value
|
||||
( $self->version_req,
|
||||
SOAP::Data->name( DoReferenceTransactionRequestDetails => \SOAP::Data->value
|
||||
( @reference_details )->type( 'ns:DoReferenceTransactionRequestDetailsType' )
|
||||
)->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
)
|
||||
);
|
||||
my $request = SOAP::Data->name(
|
||||
DoReferenceTransactionRequest => \SOAP::Data->value(
|
||||
$self->version_req,
|
||||
SOAP::Data->name(
|
||||
DoReferenceTransactionRequestDetails =>
|
||||
\SOAP::Data->value( @reference_details )
|
||||
->type( 'ns:DoReferenceTransactionRequestDetailsType' )
|
||||
)->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||
)
|
||||
);
|
||||
|
||||
my $som = $self->doCall( DoReferenceTransactionReq => $request )
|
||||
or return;
|
||||
or return;
|
||||
|
||||
my $path = '/Envelope/Body/DoReferenceTransactionResponse';
|
||||
|
||||
my %response = ();
|
||||
unless( $self->getBasic($som, $path, \%response) ) {
|
||||
$self->getErrors($som, $path, \%response);
|
||||
unless ( $self->getBasic( $som, $path, \%response ) ) {
|
||||
$self->getErrors( $som, $path, \%response );
|
||||
return %response;
|
||||
}
|
||||
|
||||
$self->getFields( $som,
|
||||
"$path/DoReferenceTransactionResponseDetails",
|
||||
\%response,
|
||||
{ BillingAgreementID => 'BillingAgreementID',
|
||||
TransactionID => 'PaymentInfo/TransactionID',
|
||||
TransactionType => 'PaymentInfo/TransactionType',
|
||||
PaymentType => 'PaymentInfo/PaymentType',
|
||||
PaymentDate => 'PaymentInfo/PaymentDate',
|
||||
GrossAmount => 'PaymentInfo/GrossAmount',
|
||||
FeeAmount => 'PaymentInfo/FeeAmount',
|
||||
SettleAmount => 'PaymentInfo/SettleAmount',
|
||||
TaxAmount => 'PaymentInfo/TaxAmount',
|
||||
ExchangeRate => 'PaymentInfo/ExchangeRate',
|
||||
PaymentStatus => 'PaymentInfo/PaymentStatus',
|
||||
PendingReason => 'PaymentInfo/PendingReason',
|
||||
ReasonCode => 'PaymentInfor/ReasonCode',
|
||||
} );
|
||||
$self->getFields(
|
||||
$som,
|
||||
"$path/DoReferenceTransactionResponseDetails",
|
||||
\%response,
|
||||
{ BillingAgreementID => 'BillingAgreementID',
|
||||
TransactionID => 'PaymentInfo/TransactionID',
|
||||
TransactionType => 'PaymentInfo/TransactionType',
|
||||
PaymentType => 'PaymentInfo/PaymentType',
|
||||
PaymentDate => 'PaymentInfo/PaymentDate',
|
||||
GrossAmount => 'PaymentInfo/GrossAmount',
|
||||
FeeAmount => 'PaymentInfo/FeeAmount',
|
||||
SettleAmount => 'PaymentInfo/SettleAmount',
|
||||
TaxAmount => 'PaymentInfo/TaxAmount',
|
||||
ExchangeRate => 'PaymentInfo/ExchangeRate',
|
||||
PaymentStatus => 'PaymentInfo/PaymentStatus',
|
||||
PendingReason => 'PaymentInfo/PendingReason',
|
||||
ReasonCode => 'PaymentInfor/ReasonCode',
|
||||
}
|
||||
);
|
||||
|
||||
return %response;
|
||||
}
|
||||
|
|
|
@ -7,60 +7,67 @@ use warnings;
|
|||
use SOAP::Lite 0.67;
|
||||
use Business::PayPal::API ();
|
||||
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @EXPORT_OK = qw(RefundTransaction);
|
||||
|
||||
sub RefundTransaction {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my %types = ( TransactionID => 'xs:string',
|
||||
RefundType => '', ## Other | Full | Partial
|
||||
Amount => 'ebl:BasicAmountType',
|
||||
Memo => 'xs:string', );
|
||||
my %types = (
|
||||
TransactionID => 'xs:string',
|
||||
RefundType => '', ## Other | Full | Partial
|
||||
Amount => 'ebl:BasicAmountType',
|
||||
Memo => 'xs:string',
|
||||
);
|
||||
|
||||
$args{currencyID} ||= 'USD';
|
||||
$args{RefundType} ||= 'Full';
|
||||
|
||||
my @ref_trans =
|
||||
(
|
||||
$self->version_req,
|
||||
SOAP::Data->name( TransactionID => $args{TransactionID} )->type($types{TransactionID}),
|
||||
SOAP::Data->name( RefundType => $args{RefundType} )->type($types{RefundType}),
|
||||
);
|
||||
my @ref_trans = (
|
||||
$self->version_req,
|
||||
SOAP::Data->name( TransactionID => $args{TransactionID} )
|
||||
->type( $types{TransactionID} ),
|
||||
SOAP::Data->name( RefundType => $args{RefundType} )
|
||||
->type( $types{RefundType} ),
|
||||
);
|
||||
|
||||
if( $args{RefundType} ne 'Full' && $args{Amount} ) {
|
||||
push @ref_trans,
|
||||
SOAP::Data->name( Amount => $args{Amount} )
|
||||
->type( $types{Amount} )
|
||||
->attr( { currencyID => $args{currencyID} } )
|
||||
if ( $args{RefundType} ne 'Full' && $args{Amount} ) {
|
||||
push @ref_trans,
|
||||
SOAP::Data->name( Amount => $args{Amount} )
|
||||
->type( $types{Amount} )
|
||||
->attr( { currencyID => $args{currencyID} } );
|
||||
}
|
||||
|
||||
push @ref_trans,
|
||||
SOAP::Data->name( Memo => $args{Memo} )->type( $types{Memo} )
|
||||
if $args{Memo};
|
||||
SOAP::Data->name( Memo => $args{Memo} )->type( $types{Memo} )
|
||||
if $args{Memo};
|
||||
|
||||
my $request = SOAP::Data->name
|
||||
( RefundTransactionRequest => \SOAP::Data->value( @ref_trans ) )
|
||||
->type("ns:RefundTransactionRequestType");
|
||||
my $request
|
||||
= SOAP::Data->name(
|
||||
RefundTransactionRequest => \SOAP::Data->value( @ref_trans ) )
|
||||
->type( "ns:RefundTransactionRequestType" );
|
||||
|
||||
my $som = $self->doCall( RefundTransactionReq => $request )
|
||||
or return;
|
||||
or return;
|
||||
|
||||
my $path = '/Envelope/Body/RefundTransactionResponse';
|
||||
|
||||
my %response = ();
|
||||
unless( $self->getBasic($som, $path, \%response) ) {
|
||||
$self->getErrors($som, $path, \%response);
|
||||
unless ( $self->getBasic( $som, $path, \%response ) ) {
|
||||
$self->getErrors( $som, $path, \%response );
|
||||
return %response;
|
||||
}
|
||||
|
||||
$self->getFields($som, $path, \%response,
|
||||
{ RefundTransactionID => 'RefundTransactionID',
|
||||
FeeRefundAmount => 'FeeRefundAmount',
|
||||
NetRefundAmount => 'NetRefundAmount',
|
||||
GrossRefundAmount => 'GrossRefundAmount', }
|
||||
);
|
||||
$self->getFields(
|
||||
$som, $path,
|
||||
\%response,
|
||||
{ RefundTransactionID => 'RefundTransactionID',
|
||||
FeeRefundAmount => 'FeeRefundAmount',
|
||||
NetRefundAmount => 'NetRefundAmount',
|
||||
GrossRefundAmount => 'GrossRefundAmount',
|
||||
}
|
||||
);
|
||||
|
||||
return %response;
|
||||
}
|
||||
|
|
|
@ -7,66 +7,72 @@ use warnings;
|
|||
use SOAP::Lite 0.67;
|
||||
use Business::PayPal::API ();
|
||||
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @EXPORT_OK = qw( TransactionSearch );
|
||||
|
||||
sub TransactionSearch {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my %types = ( StartDate => 'xs:dateTime',
|
||||
EndDate => 'xs:dateTime',
|
||||
Payer => 'ebl:EmailAddressType',
|
||||
Receiver => 'ebl:EmailAddressType',
|
||||
ReceiptID => 'xs:string',
|
||||
TransactionID => 'xs:string',
|
||||
InvoiceID => 'xs:string',
|
||||
PayerName => 'xs:string',
|
||||
AuctionItemNumer => 'xs:string',
|
||||
TransactionClass => '',
|
||||
Amount => 'ebl:BasicAmountType',
|
||||
CurrencyCode => 'xs:token',
|
||||
Status => '',
|
||||
);
|
||||
my %types = (
|
||||
StartDate => 'xs:dateTime',
|
||||
EndDate => 'xs:dateTime',
|
||||
Payer => 'ebl:EmailAddressType',
|
||||
Receiver => 'ebl:EmailAddressType',
|
||||
ReceiptID => 'xs:string',
|
||||
TransactionID => 'xs:string',
|
||||
InvoiceID => 'xs:string',
|
||||
PayerName => 'xs:string',
|
||||
AuctionItemNumer => 'xs:string',
|
||||
TransactionClass => '',
|
||||
Amount => 'ebl:BasicAmountType',
|
||||
CurrencyCode => 'xs:token',
|
||||
Status => '',
|
||||
);
|
||||
|
||||
my @trans =
|
||||
(
|
||||
$self->version_req,
|
||||
SOAP::Data->name( StartDate => $args{StartDate} )->type( delete $types{StartDate} )
|
||||
);
|
||||
my @trans = (
|
||||
$self->version_req,
|
||||
SOAP::Data->name( StartDate => $args{StartDate} )
|
||||
->type( delete $types{StartDate} )
|
||||
);
|
||||
|
||||
for my $type ( keys %types ) {
|
||||
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
|
||||
( TransactionSearchRequest => \SOAP::Data->value( @trans ) )
|
||||
->type("ns:TransactionSearchRequestType");
|
||||
my $request
|
||||
= SOAP::Data->name(
|
||||
TransactionSearchRequest => \SOAP::Data->value( @trans ) )
|
||||
->type( "ns:TransactionSearchRequestType" );
|
||||
|
||||
my $som = $self->doCall( TransactionSearchReq => $request )
|
||||
or return;
|
||||
or return;
|
||||
|
||||
my $path = '/Envelope/Body/TransactionSearchResponse';
|
||||
|
||||
my %response = ();
|
||||
unless( $self->getBasic($som, $path, \%response) ) {
|
||||
$self->getErrors($som, $path, \%response);
|
||||
unless ( $self->getBasic( $som, $path, \%response ) ) {
|
||||
$self->getErrors( $som, $path, \%response );
|
||||
return %response;
|
||||
}
|
||||
|
||||
return $self->getFieldsList( $som, $path . '/PaymentTransactions',
|
||||
{ Timestamp => 'Timestamp',
|
||||
Timezone => 'Timezone',
|
||||
Type => 'Type',
|
||||
Payer => 'Payer',
|
||||
PayerDisplayName => 'PayerDisplayName',
|
||||
TransactionID => 'TransactionID',
|
||||
Status => 'Status',
|
||||
GrossAmount => 'GrossAmount',
|
||||
FeeAmount => 'FeeAmount',
|
||||
NetAmount => 'NetAmount',
|
||||
} );
|
||||
return $self->getFieldsList(
|
||||
$som,
|
||||
$path . '/PaymentTransactions',
|
||||
{ Timestamp => 'Timestamp',
|
||||
Timezone => 'Timezone',
|
||||
Type => 'Type',
|
||||
Payer => 'Payer',
|
||||
PayerDisplayName => 'PayerDisplayName',
|
||||
TransactionID => 'TransactionID',
|
||||
Status => 'Status',
|
||||
GrossAmount => 'GrossAmount',
|
||||
FeeAmount => 'FeeAmount',
|
||||
NetAmount => 'NetAmount',
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -7,46 +7,47 @@ use warnings;
|
|||
use SOAP::Lite 0.67;
|
||||
use Business::PayPal::API ();
|
||||
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @ISA = qw(Business::PayPal::API);
|
||||
our @EXPORT_OK = qw(DoVoidRequest);
|
||||
|
||||
sub DoVoidRequest {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my %types = ( AuthorizationID => 'xs:string',
|
||||
Note => 'xs:string', );
|
||||
my %types = (
|
||||
AuthorizationID => 'xs:string',
|
||||
Note => 'xs:string',
|
||||
);
|
||||
|
||||
my @ref_trans = (
|
||||
$self->version_req,
|
||||
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )
|
||||
->type( $types{AuthorizationID} ),
|
||||
);
|
||||
|
||||
my @ref_trans =
|
||||
(
|
||||
$self->version_req,
|
||||
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )->type($types{AuthorizationID}),
|
||||
);
|
||||
|
||||
if ($args{Note}) {
|
||||
push @ref_trans,
|
||||
SOAP::Data->name( Note => $args{Note} )->type( $types{Note} )
|
||||
if $args{Note};
|
||||
if ( $args{Note} ) {
|
||||
push @ref_trans,
|
||||
SOAP::Data->name( Note => $args{Note} )->type( $types{Note} )
|
||||
if $args{Note};
|
||||
}
|
||||
my $request = SOAP::Data->name
|
||||
( DoVoidRequest => \SOAP::Data->value( @ref_trans ) )
|
||||
->type("ns:VoidRequestType");
|
||||
my $request
|
||||
= SOAP::Data->name(
|
||||
DoVoidRequest => \SOAP::Data->value( @ref_trans ) )
|
||||
->type( "ns:VoidRequestType" );
|
||||
|
||||
my $som = $self->doCall( DoVoidReq => $request )
|
||||
or return;
|
||||
or return;
|
||||
|
||||
my $path = '/Envelope/Body/DoVoidResponse';
|
||||
|
||||
my %response = ();
|
||||
unless( $self->getBasic($som, $path, \%response) ) {
|
||||
$self->getErrors($som, $path, \%response);
|
||||
unless ( $self->getBasic( $som, $path, \%response ) ) {
|
||||
$self->getErrors( $som, $path, \%response );
|
||||
return %response;
|
||||
}
|
||||
|
||||
$self->getFields($som, $path, \%response,
|
||||
{ AuthorizationID => 'AuthorizationID' }
|
||||
);
|
||||
$self->getFields( $som, $path, \%response,
|
||||
{ AuthorizationID => 'AuthorizationID' } );
|
||||
|
||||
return %response;
|
||||
}
|
||||
|
|
32
t/API.pl
32
t/API.pl
|
@ -1,3 +1,4 @@
|
|||
|
||||
=pod
|
||||
|
||||
The tester must supply their own PayPal sandbox seller authentication
|
||||
|
@ -13,33 +14,34 @@ variable:
|
|||
=cut
|
||||
|
||||
sub do_args {
|
||||
unless( $ENV{WPP_TEST} && -f $ENV{WPP_TEST} ) {
|
||||
die "See the TESTING section in `perldoc Business::PayPal::API documentation`\n";
|
||||
unless ( $ENV{WPP_TEST} && -f $ENV{WPP_TEST} ) {
|
||||
die
|
||||
"See the TESTING section in `perldoc Business::PayPal::API documentation`\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
my %args = ();
|
||||
open FILE, "<", $ENV{WPP_TEST}
|
||||
or die "Could not open $ENV{WPP_TEST}: $!\n";
|
||||
or die "Could not open $ENV{WPP_TEST}: $!\n";
|
||||
|
||||
my @variables = qw( Username Password Signature Subject timeout
|
||||
CertFile KeyFile PKCS12File PKCS12Password
|
||||
BuyerEmail
|
||||
);
|
||||
CertFile KeyFile PKCS12File PKCS12Password
|
||||
BuyerEmail
|
||||
);
|
||||
|
||||
my %patterns = ();
|
||||
@patterns{map { qr/^$_\b/i } @variables} = @variables;
|
||||
@patterns{ map {qr/^$_\b/i} @variables } = @variables;
|
||||
|
||||
while( <FILE> ) {
|
||||
while ( <FILE> ) {
|
||||
chomp;
|
||||
|
||||
MATCH: for my $pat (keys %patterns) {
|
||||
next unless $_ =~ $pat;
|
||||
(my $value = $_) =~ s/$pat\s*=\s*(.+)/$1/;
|
||||
$args{ $patterns{$pat} } = $value;
|
||||
delete $patterns{$pat};
|
||||
last MATCH;
|
||||
}
|
||||
MATCH: for my $pat ( keys %patterns ) {
|
||||
next unless $_ =~ $pat;
|
||||
( my $value = $_ ) =~ s/$pat\s*=\s*(.+)/$1/;
|
||||
$args{ $patterns{$pat} } = $value;
|
||||
delete $patterns{$pat};
|
||||
last MATCH;
|
||||
}
|
||||
}
|
||||
|
||||
close FILE;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use Test::More tests => 1;
|
||||
BEGIN { use_ok('Business::PayPal::API') };
|
||||
BEGIN { use_ok( 'Business::PayPal::API' ) }
|
||||
|
||||
#########################
|
||||
|
||||
|
|
|
@ -3,156 +3,174 @@ use strict;
|
|||
use warnings;
|
||||
use Test::More;
|
||||
|
||||
if( ! $ENV{WPP_TEST} || ! -f $ENV{WPP_TEST} ) {
|
||||
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests';
|
||||
if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
|
||||
plan skip_all =>
|
||||
'No WPP_TEST env var set. Please see README to run tests';
|
||||
}
|
||||
else {
|
||||
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);
|
||||
use_ok('Business::PayPal::API', @methlist);
|
||||
my @methlist
|
||||
= qw( DirectPayments CaptureRequest ReauthorizationRequest VoidRequest RefundTransaction);
|
||||
use_ok( 'Business::PayPal::API', @methlist );
|
||||
|
||||
require 't/API.pl';
|
||||
|
||||
my %args = do_args();
|
||||
|
||||
my ($transale,$tranvoid,$tranbasic,$tranrefund);
|
||||
my ($ppsale,$ppvoid,$ppbasic,$pprefund,$pprefund1,$ppcap,$ppcap1);
|
||||
my (%respsale,%resprefund,%resprefund1,%respbasic,%respcap,%respcap1,%respvoid);
|
||||
my ( $transale, $tranvoid, $tranbasic, $tranrefund );
|
||||
my ( $ppsale, $ppvoid, $ppbasic, $pprefund, $pprefund1, $ppcap, $ppcap1 );
|
||||
my (%respsale, %resprefund, %resprefund1, %respbasic,
|
||||
%respcap, %respcap1, %respvoid
|
||||
);
|
||||
|
||||
#Test Full Refund on Sale
|
||||
|
||||
#$Business::PayPal::API::Debug=1;
|
||||
$ppsale = new Business::PayPal::API(%args);
|
||||
%respsale = $ppsale->DoDirectPaymentRequest (
|
||||
PaymentAction => 'Sale',
|
||||
OrderTotal => 11.87,
|
||||
TaxTotal => 0.0,
|
||||
ItemTotal => 0.0,
|
||||
CreditCardType => 'Visa',
|
||||
CreditCardNumber => '4561435600988217',
|
||||
ExpMonth => '01',
|
||||
ExpYear => +(localtime)[5]+1901,
|
||||
CVV2 => '123',
|
||||
FirstName => 'JP',
|
||||
LastName => 'Morgan',
|
||||
Street1 => '1st Street LaCausa',
|
||||
Street2 => '',
|
||||
CityName => 'La',
|
||||
StateOrProvince => 'CA',
|
||||
PostalCode => '90210',
|
||||
Country => 'US',
|
||||
Payer => 'mall@example.org',
|
||||
CurrencyID => 'USD',
|
||||
IPAddress => '10.0.0.1',
|
||||
MerchantSessionID => '10113301',
|
||||
);
|
||||
$ppsale = new Business::PayPal::API( %args );
|
||||
%respsale = $ppsale->DoDirectPaymentRequest(
|
||||
PaymentAction => 'Sale',
|
||||
OrderTotal => 11.87,
|
||||
TaxTotal => 0.0,
|
||||
ItemTotal => 0.0,
|
||||
CreditCardType => 'Visa',
|
||||
CreditCardNumber => '4561435600988217',
|
||||
ExpMonth => '01',
|
||||
ExpYear => +( localtime )[5] + 1901,
|
||||
CVV2 => '123',
|
||||
FirstName => 'JP',
|
||||
LastName => 'Morgan',
|
||||
Street1 => '1st Street LaCausa',
|
||||
Street2 => '',
|
||||
CityName => 'La',
|
||||
StateOrProvince => 'CA',
|
||||
PostalCode => '90210',
|
||||
Country => 'US',
|
||||
Payer => 'mall@example.org',
|
||||
CurrencyID => 'USD',
|
||||
IPAddress => '10.0.0.1',
|
||||
MerchantSessionID => '10113301',
|
||||
);
|
||||
|
||||
#$Business::PayPal::API::Debug=0;
|
||||
if(like( $respsale{'Ack'}, qr/Success/, 'Direct Payment Sale')) {
|
||||
$transale = $respsale{'TransactionID'};
|
||||
#$Business::PayPal::API::Debug=1;
|
||||
$pprefund = new Business::PayPal::API(%args);
|
||||
%resprefund = $pprefund->RefundTransaction (
|
||||
TransactionID => $transale,
|
||||
RefundType => 'Full',
|
||||
Memo => 'Full direct sale refund',
|
||||
);
|
||||
#$Business::PayPal::API::Debug=0;
|
||||
like( $resprefund{'Ack'}, qr/Success/, 'Full Refund For Sale');
|
||||
}
|
||||
if ( like( $respsale{'Ack'}, qr/Success/, 'Direct Payment Sale' ) ) {
|
||||
$transale = $respsale{'TransactionID'};
|
||||
|
||||
#$Business::PayPal::API::Debug=1;
|
||||
$pprefund = new Business::PayPal::API( %args );
|
||||
%resprefund = $pprefund->RefundTransaction(
|
||||
TransactionID => $transale,
|
||||
RefundType => 'Full',
|
||||
Memo => 'Full direct sale refund',
|
||||
);
|
||||
|
||||
#$Business::PayPal::API::Debug=0;
|
||||
like( $resprefund{'Ack'}, qr/Success/, 'Full Refund For Sale' );
|
||||
}
|
||||
|
||||
#Basic Authorization and Capture
|
||||
|
||||
%args=do_args();
|
||||
#$Business::PayPal::API::Debug=0;
|
||||
$ppbasic = new Business::PayPal::API(%args);
|
||||
%respbasic = $ppbasic->DoDirectPaymentRequest (
|
||||
PaymentAction => 'Authorization',
|
||||
OrderTotal => 13.87,
|
||||
TaxTotal => 0.0,
|
||||
ItemTotal => 0.0,
|
||||
CreditCardType => 'Visa',
|
||||
CreditCardNumber => '4561435600988217',
|
||||
ExpMonth => '01',
|
||||
ExpYear => +(localtime)[5]+1901,
|
||||
CVV2 => '123',
|
||||
FirstName => 'JP',
|
||||
LastName => 'Morgan',
|
||||
Street1 => '1st Street LaCausa',
|
||||
Street2 => '',
|
||||
CityName => 'La',
|
||||
StateOrProvince => 'CA',
|
||||
PostalCode => '90210',
|
||||
Country => 'US',
|
||||
Payer => 'mall@example.org',
|
||||
CurrencyID => 'USD',
|
||||
IPAddress => '10.0.0.1',
|
||||
MerchantSessionID => '10113301',
|
||||
);
|
||||
%args = do_args();
|
||||
|
||||
#$Business::PayPal::API::Debug=0;
|
||||
if( like( $respbasic{'Ack'}, qr/Success/, 'Direct Payment Basic Authorization') ) {
|
||||
$ppbasic = new Business::PayPal::API( %args );
|
||||
%respbasic = $ppbasic->DoDirectPaymentRequest(
|
||||
PaymentAction => 'Authorization',
|
||||
OrderTotal => 13.87,
|
||||
TaxTotal => 0.0,
|
||||
ItemTotal => 0.0,
|
||||
CreditCardType => 'Visa',
|
||||
CreditCardNumber => '4561435600988217',
|
||||
ExpMonth => '01',
|
||||
ExpYear => +( localtime )[5] + 1901,
|
||||
CVV2 => '123',
|
||||
FirstName => 'JP',
|
||||
LastName => 'Morgan',
|
||||
Street1 => '1st Street LaCausa',
|
||||
Street2 => '',
|
||||
CityName => 'La',
|
||||
StateOrProvince => 'CA',
|
||||
PostalCode => '90210',
|
||||
Country => 'US',
|
||||
Payer => 'mall@example.org',
|
||||
CurrencyID => 'USD',
|
||||
IPAddress => '10.0.0.1',
|
||||
MerchantSessionID => '10113301',
|
||||
);
|
||||
|
||||
#$Business::PayPal::API::Debug=0;
|
||||
if (like(
|
||||
$respbasic{'Ack'}, qr/Success/,
|
||||
'Direct Payment Basic Authorization'
|
||||
)
|
||||
)
|
||||
{
|
||||
$tranbasic = $respbasic{'TransactionID'};
|
||||
|
||||
#Test Partial Capture
|
||||
#$Business::PayPal::API::Debug=1;
|
||||
$ppcap = new Business::PayPal::API(%args);
|
||||
$ppcap = new Business::PayPal::API( %args );
|
||||
|
||||
%respcap = $ppcap->DoCaptureRequest(
|
||||
AuthorizationID => $tranbasic,
|
||||
CompleteType => 'NotComplete',
|
||||
Amount => '3.00',
|
||||
Note => 'Partial Capture',
|
||||
);
|
||||
|
||||
%respcap = $ppcap->DoCaptureRequest (
|
||||
AuthorizationID => $tranbasic,
|
||||
CompleteType => 'NotComplete',
|
||||
Amount => '3.00',
|
||||
Note => 'Partial Capture',
|
||||
);
|
||||
#$Business::PayPal::API::Debug=0;
|
||||
like( $respcap{'Ack'}, qr/Success/, 'Partial Capture');
|
||||
like( $respcap{'Ack'}, qr/Success/, 'Partial Capture' );
|
||||
|
||||
#Test Full Capture
|
||||
#$Business::PayPal::API::Debug=1;
|
||||
$ppcap1 = new Business::PayPal::API(%args);
|
||||
%respcap1 = $ppcap1->DoCaptureRequest (
|
||||
AuthorizationID => $tranbasic,
|
||||
CompleteType => 'Complete',
|
||||
Amount => '6.00',
|
||||
);
|
||||
$ppcap1 = new Business::PayPal::API( %args );
|
||||
%respcap1 = $ppcap1->DoCaptureRequest(
|
||||
AuthorizationID => $tranbasic,
|
||||
CompleteType => 'Complete',
|
||||
Amount => '6.00',
|
||||
);
|
||||
|
||||
#$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 ) }
|
||||
|
||||
|
||||
#Test Void
|
||||
$ppbasic = new Business::PayPal::API(%args);
|
||||
%respbasic = $ppbasic->DoDirectPaymentRequest (
|
||||
PaymentAction => 'Authorization',
|
||||
OrderTotal => 17.37,
|
||||
TaxTotal => 0.0,
|
||||
ItemTotal => 0.0,
|
||||
CreditCardType => 'Visa',
|
||||
CreditCardNumber => '4561435600988217',
|
||||
ExpMonth => '01',
|
||||
ExpYear => +(localtime)[5]+1901,
|
||||
CVV2 => '123',
|
||||
FirstName => 'JP',
|
||||
LastName => 'Morgan',
|
||||
Street1 => '1st Street LaCausa',
|
||||
Street2 => '',
|
||||
CityName => 'La',
|
||||
StateOrProvince => 'CA',
|
||||
PostalCode => '90210',
|
||||
Country => 'US',
|
||||
Payer => 'mall@example.org',
|
||||
CurrencyID => 'USD',
|
||||
IPAddress => '10.0.0.1',
|
||||
MerchantSessionID => '10113301',
|
||||
);
|
||||
$ppbasic = new Business::PayPal::API( %args );
|
||||
%respbasic = $ppbasic->DoDirectPaymentRequest(
|
||||
PaymentAction => 'Authorization',
|
||||
OrderTotal => 17.37,
|
||||
TaxTotal => 0.0,
|
||||
ItemTotal => 0.0,
|
||||
CreditCardType => 'Visa',
|
||||
CreditCardNumber => '4561435600988217',
|
||||
ExpMonth => '01',
|
||||
ExpYear => +( localtime )[5] + 1901,
|
||||
CVV2 => '123',
|
||||
FirstName => 'JP',
|
||||
LastName => 'Morgan',
|
||||
Street1 => '1st Street LaCausa',
|
||||
Street2 => '',
|
||||
CityName => 'La',
|
||||
StateOrProvince => 'CA',
|
||||
PostalCode => '90210',
|
||||
Country => 'US',
|
||||
Payer => 'mall@example.org',
|
||||
CurrencyID => 'USD',
|
||||
IPAddress => '10.0.0.1',
|
||||
MerchantSessionID => '10113301',
|
||||
);
|
||||
|
||||
#$Business::PayPal::API::Debug=1;
|
||||
$ppvoid = new Business::PayPal::API(%args);
|
||||
%respvoid = $ppvoid->DoVoidRequest ( AuthorizationID => $respbasic{TransactionID},
|
||||
Note => 'Authorization Void', );
|
||||
$ppvoid = new Business::PayPal::API( %args );
|
||||
%respvoid = $ppvoid->DoVoidRequest(
|
||||
AuthorizationID => $respbasic{TransactionID},
|
||||
Note => 'Authorization Void',
|
||||
);
|
||||
|
||||
#$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;
|
||||
if( ! $ENV{WPP_TEST} || ! -f $ENV{WPP_TEST} ) {
|
||||
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests';
|
||||
if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
|
||||
plan skip_all =>
|
||||
'No WPP_TEST env var set. Please see README to run tests';
|
||||
}
|
||||
else {
|
||||
plan tests => 6;
|
||||
|
@ -22,24 +23,27 @@ my $pp = new Business::PayPal::API::ExpressCheckout( %args );
|
|||
## set checkout info
|
||||
##
|
||||
#$Business::PayPal::API::Debug = 1;
|
||||
my %response = $pp->SetExpressCheckout
|
||||
( OrderTotal => '55.43',
|
||||
ReturnURL => 'http://www.google.com/',
|
||||
CancelURL => 'http://www.google.com/',
|
||||
Custom => "This field is custom. Isn't that great?",
|
||||
my %response = $pp->SetExpressCheckout(
|
||||
OrderTotal => '55.43',
|
||||
ReturnURL => 'http://www.google.com/',
|
||||
CancelURL => 'http://www.google.com/',
|
||||
Custom => "This field is custom. Isn't that great?",
|
||||
PaymentAction => 'Sale',
|
||||
BuyerEmail => $args{BuyerEmail}, ## from %args
|
||||
);
|
||||
BuyerEmail => $args{BuyerEmail}, ## from %args
|
||||
);
|
||||
|
||||
#$Business::PayPal::API::Debug = 0;
|
||||
|
||||
my $token = $response{Token};
|
||||
|
||||
ok( $token, "Got token" );
|
||||
|
||||
die "No token from PayPal! Check your authentication information and try again."
|
||||
unless $token;
|
||||
die
|
||||
"No token from PayPal! Check your authentication information and try again."
|
||||
unless $token;
|
||||
|
||||
my $pp_url = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=$token";
|
||||
my $pp_url
|
||||
= "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=$token";
|
||||
|
||||
print STDERR <<"_TOKEN_";
|
||||
|
||||
|
@ -61,14 +65,15 @@ _TOKEN_
|
|||
|
||||
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;
|
||||
|
||||
##
|
||||
## get checkout details
|
||||
##
|
||||
my %details = $pp->GetExpressCheckoutDetails($token);
|
||||
my %details = $pp->GetExpressCheckoutDetails( $token );
|
||||
is( $details{Token}, $token, "details ok" );
|
||||
|
||||
#use Data::Dumper;
|
||||
|
@ -76,17 +81,18 @@ is( $details{Token}, $token, "details ok" );
|
|||
|
||||
$details{PayerID} = $payerid;
|
||||
|
||||
my %payment = ( Token => $details{Token},
|
||||
PaymentAction => 'Sale',
|
||||
PayerID => $details{PayerID},
|
||||
OrderTotal => '55.43',
|
||||
);
|
||||
my %payment = (
|
||||
Token => $details{Token},
|
||||
PaymentAction => 'Sale',
|
||||
PayerID => $details{PayerID},
|
||||
OrderTotal => '55.43',
|
||||
);
|
||||
|
||||
##
|
||||
## do checkout
|
||||
##
|
||||
my %payinfo = $pp->DoExpressCheckoutPayment(%payment);
|
||||
my %payinfo = $pp->DoExpressCheckoutPayment( %payment );
|
||||
|
||||
like( $payinfo{Ack}, qr/Success/ , "successful payment" );
|
||||
is( $payinfo{Token}, $token, "payment ok" );
|
||||
is( $payinfo{GrossAmount}, 55.43, "amount correct" );
|
||||
like( $payinfo{Ack}, qr/Success/, "successful payment" );
|
||||
is( $payinfo{Token}, $token, "payment ok" );
|
||||
is( $payinfo{GrossAmount}, 55.43, "amount correct" );
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use Test::More;
|
||||
if( ! $ENV{WPP_TEST} || ! -f $ENV{WPP_TEST} ) {
|
||||
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests';
|
||||
if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
|
||||
plan skip_all =>
|
||||
'No WPP_TEST env var set. Please see README to run tests';
|
||||
}
|
||||
else {
|
||||
plan tests => 8;
|
||||
|
@ -22,24 +23,27 @@ my $pp = new Business::PayPal::API::ExpressCheckout( %args );
|
|||
## set checkout info
|
||||
##
|
||||
#$Business::PayPal::API::Debug = 1;
|
||||
my %response = $pp->SetExpressCheckout
|
||||
( OrderTotal => '55.43',
|
||||
ReturnURL => 'http://www.google.com/',
|
||||
CancelURL => 'http://www.google.com/',
|
||||
Custom => "This field is custom. Isn't that great?",
|
||||
my %response = $pp->SetExpressCheckout(
|
||||
OrderTotal => '55.43',
|
||||
ReturnURL => 'http://www.google.com/',
|
||||
CancelURL => 'http://www.google.com/',
|
||||
Custom => "This field is custom. Isn't that great?",
|
||||
PaymentAction => 'Order',
|
||||
BuyerEmail => $args{BuyerEmail}, ## from %args
|
||||
);
|
||||
BuyerEmail => $args{BuyerEmail}, ## from %args
|
||||
);
|
||||
|
||||
#$Business::PayPal::API::Debug = 0;
|
||||
|
||||
my $token = $response{Token};
|
||||
|
||||
ok( $token, "Got token" );
|
||||
|
||||
die "No token from PayPal! Check your authentication information and try again."
|
||||
unless $token;
|
||||
die
|
||||
"No token from PayPal! Check your authentication information and try again."
|
||||
unless $token;
|
||||
|
||||
my $pp_url = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=$token";
|
||||
my $pp_url
|
||||
= "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=$token";
|
||||
|
||||
print STDERR <<"_TOKEN_";
|
||||
|
||||
|
@ -63,14 +67,15 @@ _TOKEN_
|
|||
|
||||
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;
|
||||
|
||||
##
|
||||
## get checkout details
|
||||
##
|
||||
my %details = $pp->GetExpressCheckoutDetails($token);
|
||||
my %details = $pp->GetExpressCheckoutDetails( $token );
|
||||
is( $details{Token}, $token, "details ok" );
|
||||
|
||||
#use Data::Dumper;
|
||||
|
@ -78,35 +83,42 @@ is( $details{Token}, $token, "details ok" );
|
|||
|
||||
$details{PayerID} = $payerid;
|
||||
|
||||
my %payment = ( Token => $details{Token},
|
||||
PaymentAction => 'Order',
|
||||
PayerID => $details{PayerID},
|
||||
OrderTotal => '55.43',
|
||||
);
|
||||
my %payment = (
|
||||
Token => $details{Token},
|
||||
PaymentAction => 'Order',
|
||||
PayerID => $details{PayerID},
|
||||
OrderTotal => '55.43',
|
||||
);
|
||||
|
||||
##
|
||||
## do checkout
|
||||
##
|
||||
#$Business::PayPal::API::Debug = 1;
|
||||
my %payinfo = $pp->DoExpressCheckoutPayment(%payment);
|
||||
my %payinfo = $pp->DoExpressCheckoutPayment( %payment );
|
||||
|
||||
#$Business::PayPal::API::Debug = 0;
|
||||
#If Order is successful then authorize it, then void it.
|
||||
|
||||
if(like( $payinfo{Ack}, qr/Success/ , "successful payment" )) {
|
||||
my $transid= $payinfo{TransactionID};
|
||||
my $amount= '25.43';
|
||||
use_ok('Business::PayPal::API::AuthorizationRequest');
|
||||
if ( like( $payinfo{Ack}, qr/Success/, "successful payment" ) ) {
|
||||
my $transid = $payinfo{TransactionID};
|
||||
my $amount = '25.43';
|
||||
use_ok( 'Business::PayPal::API::AuthorizationRequest' );
|
||||
%args = do_args();
|
||||
#$Business::PayPal::API::Debug = 1;
|
||||
$ppauth = new Business::PayPal::API::AuthorizationRequest(%args);
|
||||
my %resp = $ppauth->DoAuthorizationRequest( TransactionID => $transid,
|
||||
Amount => $amount);
|
||||
like( $resp{Ack}, qr/Succes/ , 'Successful order authorization' );
|
||||
|
||||
#$Business::PayPal::API::Debug = 1;
|
||||
$ppauth = new Business::PayPal::API::AuthorizationRequest( %args );
|
||||
my %resp = $ppauth->DoAuthorizationRequest(
|
||||
TransactionID => $transid,
|
||||
Amount => $amount
|
||||
);
|
||||
like( $resp{Ack}, qr/Succes/, 'Successful order authorization' );
|
||||
use_ok( 'Business::PayPal::API::VoidRequest' );
|
||||
%args = do_args();
|
||||
my $ppvoid= new Business::PayPal::API::VoidRequest( %args );
|
||||
%resp1= $ppvoid->DoVoidRequest( AuthorizationID => $transid,
|
||||
Note => 'Voided' );
|
||||
my $ppvoid = new Business::PayPal::API::VoidRequest( %args );
|
||||
%resp1 = $ppvoid->DoVoidRequest(
|
||||
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;
|
||||
if( ! $ENV{WPP_TEST} || ! -f $ENV{WPP_TEST} ) {
|
||||
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests';
|
||||
if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
|
||||
plan skip_all =>
|
||||
'No WPP_TEST env var set. Please see README to run tests';
|
||||
}
|
||||
else {
|
||||
plan tests => 2;
|
||||
|
@ -34,11 +35,12 @@ _TRANSID_
|
|||
|
||||
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;
|
||||
|
||||
#$Business::PayPal::API::Debug = 1;
|
||||
my %resp = $pp->GetTransactionDetails( TransactionID => $transid );
|
||||
|
||||
like( $resp{Ack}, qr/Success/ , "transaction received" );
|
||||
like( $resp{Ack}, qr/Success/, "transaction received" );
|
||||
|
|
48
t/MassPay.t
48
t/MassPay.t
|
@ -1,6 +1,7 @@
|
|||
use Test::More;
|
||||
if( ! $ENV{WPP_TEST} || ! -f $ENV{WPP_TEST} ) {
|
||||
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests';
|
||||
if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
|
||||
plan skip_all =>
|
||||
'No WPP_TEST env var set. Please see README to run tests';
|
||||
}
|
||||
else {
|
||||
plan tests => 3;
|
||||
|
@ -16,22 +17,33 @@ my %args = do_args();
|
|||
my $pp = new Business::PayPal::API::MassPay( %args );
|
||||
|
||||
#$Business::PayPal::API::Debug = 1;
|
||||
my %resp = $pp->MassPay( EmailSubject => "This is the subject; nice eh?",
|
||||
MassPayItems => [ { ReceiverEmail => 'joe@test.tld',
|
||||
Amount => '24.00',
|
||||
UniqueID => "123456",
|
||||
Note => "Enjoy the money. Don't spend it all in one place." } ] );
|
||||
my %resp = $pp->MassPay(
|
||||
EmailSubject => "This is the subject; nice eh?",
|
||||
MassPayItems => [
|
||||
{ ReceiverEmail => 'joe@test.tld',
|
||||
Amount => '24.00',
|
||||
UniqueID => "123456",
|
||||
Note => "Enjoy the money. Don't spend it all in one place."
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
like( $resp{Ack}, qr/Success/ , "successful payment" );
|
||||
like( $resp{Ack}, qr/Success/, "successful payment" );
|
||||
|
||||
%resp = $pp->MassPay( EmailSubject => "This is the subject; nice eh?",
|
||||
MassPayItems => [ { ReceiverEmail => 'bob@test.tld',
|
||||
Amount => '25.00',
|
||||
UniqueID => "123457",
|
||||
Note => "Enjoy the money. Don't spend it all in one place." },
|
||||
{ ReceiverEmail => 'foo@test.tld',
|
||||
Amount => '42.00',
|
||||
UniqueID => "123458",
|
||||
Note => "Enjoy the money. Don't spend it all in one place." } ] );
|
||||
%resp = $pp->MassPay(
|
||||
EmailSubject => "This is the subject; nice eh?",
|
||||
MassPayItems => [
|
||||
{ ReceiverEmail => 'bob@test.tld',
|
||||
Amount => '25.00',
|
||||
UniqueID => "123457",
|
||||
Note => "Enjoy the money. Don't spend it all in one place."
|
||||
},
|
||||
{ ReceiverEmail => 'foo@test.tld',
|
||||
Amount => '42.00',
|
||||
UniqueID => "123458",
|
||||
Note => "Enjoy the money. Don't spend it all in one place."
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
like( $resp{Ack}, qr/Success/ , "successful payments" );
|
||||
like( $resp{Ack}, qr/Success/, "successful payments" );
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
# -*- mode: cperl -*-
|
||||
use Test::More;
|
||||
if( ! $ENV{WPP_TEST} || ! -f $ENV{WPP_TEST} ) {
|
||||
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests';
|
||||
if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
|
||||
plan skip_all =>
|
||||
'No WPP_TEST env var set. Please see README to run tests';
|
||||
}
|
||||
else {
|
||||
plan tests => 3;
|
||||
|
@ -14,31 +15,32 @@ require 't/API.pl';
|
|||
|
||||
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;
|
||||
my %response = $pp->SetCustomerBillingAgreement
|
||||
(
|
||||
BillingType => 'RecurringPayments',
|
||||
BillingAgreementDescription => '10.00 per month for 1 year',
|
||||
ReturnURL => 'http://www.google.com/',
|
||||
CancelURL => 'http://www.google.com/',
|
||||
BuyerEmail => $args{BuyerEmail},
|
||||
);
|
||||
my %response = $pp->SetCustomerBillingAgreement(
|
||||
BillingType => 'RecurringPayments',
|
||||
BillingAgreementDescription => '10.00 per month for 1 year',
|
||||
ReturnURL => 'http://www.google.com/',
|
||||
CancelURL => 'http://www.google.com/',
|
||||
BuyerEmail => $args{BuyerEmail},
|
||||
);
|
||||
|
||||
#$Business::PayPal::API::Debug = 0;
|
||||
|
||||
my $token = $response{Token};
|
||||
|
||||
ok( $token, "Got token" );
|
||||
like( $response{Ack}, qr/Success/ , "SetCustomerBillingAgreement successful" );
|
||||
like( $response{Ack}, qr/Success/, "SetCustomerBillingAgreement successful" );
|
||||
|
||||
exit;
|
||||
|
||||
die "No token from PayPal! Check your authentication information and try again."
|
||||
unless $token;
|
||||
die
|
||||
"No token from PayPal! Check your authentication information and try again."
|
||||
unless $token;
|
||||
|
||||
|
||||
my $pp_url = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_customer-billing-agreement&token=$token";
|
||||
my $pp_url
|
||||
= "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_customer-billing-agreement&token=$token";
|
||||
|
||||
=pod
|
||||
|
||||
|
@ -68,11 +70,10 @@ die "Need a PayerID.\n" unless $payerid;
|
|||
|
||||
=cut
|
||||
|
||||
|
||||
## CreateRecurringPaymentsProfile
|
||||
#$Business::PayPal::API::Debug = 1;
|
||||
my %profile = $pp->CreateRecurringPaymentsProfile
|
||||
( Token => $token,
|
||||
my %profile = $pp->CreateRecurringPaymentsProfile(
|
||||
Token => $token,
|
||||
|
||||
## RecurringPaymentProfileDetails
|
||||
SubscriberName => 'Joe Schmoe',
|
||||
|
@ -91,7 +92,7 @@ my %profile = $pp->CreateRecurringPaymentsProfile
|
|||
## ScheduleDetails
|
||||
Description => '12 Month Hosting Package: We Love You!',
|
||||
|
||||
InitialAmount => '12.34',
|
||||
InitialAmount => '12.34',
|
||||
|
||||
TrialBillingPeriod => 'Month',
|
||||
TrialBillingFrequency => 1,
|
||||
|
@ -107,17 +108,17 @@ my %profile = $pp->CreateRecurringPaymentsProfile
|
|||
PaymentShippingAmount => 0.00,
|
||||
PaymentTaxAmount => 0.00,
|
||||
|
||||
# MaxFailedPayments => 1,
|
||||
# AutoBillOutstandingAmount => 'AddToNextBilling',
|
||||
);
|
||||
# MaxFailedPayments => 1,
|
||||
# AutoBillOutstandingAmount => 'AddToNextBilling',
|
||||
);
|
||||
|
||||
#$Business::PayPal::API::Debug = 0;
|
||||
|
||||
|
||||
## GetBillingAgreementCustomerDetails
|
||||
#$Business::PayPal::API::Debug = 1;
|
||||
my %details = $pp->GetBillingAgreementCustomerDetails($token);
|
||||
my %details = $pp->GetBillingAgreementCustomerDetails( $token );
|
||||
|
||||
#$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;
|
||||
if( ! $ENV{WPP_TEST} || ! -f $ENV{WPP_TEST} ) {
|
||||
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests';
|
||||
if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
|
||||
plan skip_all =>
|
||||
'No WPP_TEST env var set. Please see README to run tests';
|
||||
}
|
||||
else {
|
||||
plan tests => 2;
|
||||
|
@ -35,17 +36,20 @@ _TRANSID_
|
|||
|
||||
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;
|
||||
|
||||
my %resp = $pp->RefundTransaction( TransactionID => $transid,
|
||||
RefundType => 'Full',
|
||||
Memo => 'Fancy refund time.' );
|
||||
my %resp = $pp->RefundTransaction(
|
||||
TransactionID => $transid,
|
||||
RefundType => 'Full',
|
||||
Memo => 'Fancy refund time.'
|
||||
);
|
||||
|
||||
like( $resp{Ack}, qr/Success/ , "Successful refund." );
|
||||
like( $resp{Ack}, qr/Success/, "Successful refund." );
|
||||
|
||||
if( $resp{Ack} ) {
|
||||
if ( $resp{Ack} ) {
|
||||
print STDERR <<"_REFUND_";
|
||||
|
||||
You may now login to your Business sandbox account and verify the
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use Test::More;
|
||||
if( ! $ENV{WPP_TEST} || ! -f $ENV{WPP_TEST} ) {
|
||||
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests';
|
||||
if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
|
||||
plan skip_all =>
|
||||
'No WPP_TEST env var set. Please see README to run tests';
|
||||
}
|
||||
else {
|
||||
plan tests => 2;
|
||||
|
@ -12,7 +13,7 @@ use_ok( 'Business::PayPal::API::TransactionSearch' );
|
|||
require 't/API.pl';
|
||||
|
||||
my %args = do_args();
|
||||
my $pp = new Business::PayPal::API::TransactionSearch( %args );
|
||||
my $pp = new Business::PayPal::API::TransactionSearch( %args );
|
||||
|
||||
print STDERR <<"_TRANSID_";
|
||||
|
||||
|
@ -36,15 +37,17 @@ _TRANSID_
|
|||
|
||||
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;
|
||||
|
||||
my $startdate = '1998-01-01T01:45:10.00Z';
|
||||
|
||||
#$Business::PayPal::API::Debug = 1;
|
||||
my $resp = $pp->TransactionSearch( StartDate => $startdate,
|
||||
TransactionID => $transid,
|
||||
);
|
||||
ok( scalar @$resp , "Matching Transactions Found");
|
||||
my $resp = $pp->TransactionSearch(
|
||||
StartDate => $startdate,
|
||||
TransactionID => $transid,
|
||||
);
|
||||
ok( scalar @$resp, "Matching Transactions Found" );
|
||||
|
||||
|
|
Loading…
Reference in a new issue