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
|
||||
|
|
|
@ -14,13 +14,13 @@ 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.
|
||||
|
@ -38,15 +38,18 @@ 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 };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +57,7 @@ sub import {
|
|||
sub new {
|
||||
my $class = shift;
|
||||
my %args = @_;
|
||||
my $self = bless \(my $fake), $class;
|
||||
my $self = bless \( my $fake ), $class;
|
||||
|
||||
## if you add new args, be sure to update the test file's @variables array
|
||||
$args{Username} ||= '';
|
||||
|
@ -69,28 +72,36 @@ sub new {
|
|||
$H_CertFile{$self} = $args{CertFile} || '';
|
||||
$H_KeyFile{$self} = $args{KeyFile} || '';
|
||||
|
||||
my $proxy = ($args{sandbox}
|
||||
? ($args{Signature}
|
||||
my $proxy = (
|
||||
$args{sandbox}
|
||||
? ( $args{Signature}
|
||||
? C_api_sandbox_3t
|
||||
: C_api_sandbox)
|
||||
: ($args{Signature}
|
||||
: C_api_sandbox
|
||||
)
|
||||
: ( $args{Signature}
|
||||
? C_api_live_3t
|
||||
: C_api_live)
|
||||
: C_api_live
|
||||
)
|
||||
);
|
||||
|
||||
$Soap{$self} = SOAP::Lite->proxy( $proxy, timeout => $args{timeout} )->uri( C_xmlns_pp );
|
||||
$Soap{$self} = SOAP::Lite->proxy( $proxy, timeout => $args{timeout} )
|
||||
->uri( C_xmlns_pp );
|
||||
|
||||
$Header{$self} = SOAP::Header
|
||||
->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(''),
|
||||
$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_ebay } )
|
||||
)
|
||||
)->attr( {xmlns => C_xmlns_pp} )->mustUnderstand(1);
|
||||
)->attr( { xmlns => C_xmlns_pp } )->mustUnderstand( 1 );
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
@ -106,56 +117,64 @@ 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 $method_name = shift;
|
||||
my $request = shift;
|
||||
my $method = SOAP::Data->name( $method_name )->attr( {xmlns => C_xmlns_pp} );
|
||||
my $method
|
||||
= SOAP::Data->name( $method_name )->attr( { xmlns => C_xmlns_pp } );
|
||||
|
||||
my $som;
|
||||
{
|
||||
$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_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};
|
||||
local *SOAP::Deserializer::typecast = sub { shift; return shift };
|
||||
eval {
|
||||
$som = $Soap{$self}->call( $Header{$self}, $method => $request );
|
||||
};
|
||||
|
||||
if( $@ ) {
|
||||
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
|
||||
if ( ref( $som ) && $som->fault ) {
|
||||
carp "Fault: "
|
||||
. $som->faultstring
|
||||
. ( $som->faultdetail ? " (" . $som->faultdetail . ")" : '' )
|
||||
. "\n";
|
||||
return;
|
||||
|
@ -174,16 +193,17 @@ sub getFieldsList {
|
|||
|
||||
my %trans_id = ();
|
||||
my @records = ();
|
||||
for my $rec ( $som->valueof($path) ) {
|
||||
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}}) {
|
||||
if ( defined $response{TransactionID} ) {
|
||||
if ( $trans_id{ $response{TransactionID} } ) {
|
||||
next;
|
||||
} else {
|
||||
$trans_id{$response{TransactionID}} = 1;
|
||||
}
|
||||
else {
|
||||
$trans_id{ $response{TransactionID} } = 1;
|
||||
}
|
||||
}
|
||||
push @records, \%response;
|
||||
|
@ -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 {
|
||||
|
@ -242,7 +262,7 @@ sub getBasic {
|
|||
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/;
|
||||
|
@ -258,9 +278,12 @@ sub getErrors {
|
|||
|
||||
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,6 +5,7 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
use SOAP::Lite 0.67;
|
||||
|
||||
#use SOAP::Lite +trace => 'debug';
|
||||
use Business::PayPal::API ();
|
||||
|
||||
|
@ -15,26 +16,27 @@ 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} )
|
||||
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;
|
||||
|
@ -42,14 +44,17 @@ sub DoAuthorizationRequest {
|
|||
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,
|
||||
$self->getFields(
|
||||
$som, $path,
|
||||
\%response,
|
||||
{ TransactionID => 'TransactionID',
|
||||
Amount => 'Amount', }
|
||||
Amount => 'Amount',
|
||||
}
|
||||
);
|
||||
|
||||
return %response;
|
||||
|
|
|
@ -5,6 +5,7 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
use SOAP::Lite 0.67;
|
||||
|
||||
#use SOAP::Lite +trace => 'debug';
|
||||
use Business::PayPal::API ();
|
||||
|
||||
|
@ -17,6 +18,7 @@ sub DoCaptureRequest {
|
|||
|
||||
my %types = (
|
||||
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
|
||||
|
@ -29,23 +31,25 @@ sub DoCaptureRequest {
|
|||
$args{currencyID} ||= 'USD';
|
||||
$args{CompleteType} ||= 'Complete';
|
||||
|
||||
my @ref_trans =
|
||||
(
|
||||
my @ref_trans = (
|
||||
$self->version_req,
|
||||
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )->type($types{AuthorizationID}),
|
||||
SOAP::Data->name( CompleteType => $args{CompleteType} )->type($types{CompleteType}),
|
||||
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )
|
||||
->type( $types{AuthorizationID} ),
|
||||
SOAP::Data->name( CompleteType => $args{CompleteType} )
|
||||
->type( $types{CompleteType} ),
|
||||
);
|
||||
|
||||
if( $args{Amount} ) {
|
||||
if ( $args{Amount} ) {
|
||||
push @ref_trans,
|
||||
SOAP::Data->name( Amount => $args{Amount} )
|
||||
->type( $types{Amount} )
|
||||
->attr( { currencyID => $args{currencyID} } )
|
||||
->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;
|
||||
|
@ -53,14 +57,15 @@ sub DoCaptureRequest {
|
|||
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',
|
||||
$self->getFields(
|
||||
$som, $path,
|
||||
\%response,
|
||||
{ TransactionID => 'TransactionID',
|
||||
ParentTransactionID => 'ParentTransactionID',
|
||||
ReceiptID => 'ReceiptID',
|
||||
TransactionType => 'TransactionType',
|
||||
|
|
|
@ -5,6 +5,7 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
use SOAP::Lite;
|
||||
|
||||
#use SOAP::Lite +trace => 'debug';
|
||||
use Business::PayPal::API ();
|
||||
|
||||
|
@ -15,7 +16,9 @@ sub DoDirectPaymentRequest {
|
|||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my %types =( PaymentAction => '',
|
||||
my %types = (
|
||||
PaymentAction => '',
|
||||
|
||||
# Payment Detail
|
||||
OrderTotal => 'xs:string',
|
||||
ItemTotal => 'xsd:string',
|
||||
|
@ -23,16 +26,20 @@ sub DoDirectPaymentRequest {
|
|||
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',
|
||||
|
@ -40,6 +47,7 @@ sub DoDirectPaymentRequest {
|
|||
StateOrProvince => 'xs:string',
|
||||
Country => 'xs:string',
|
||||
PostalCode => 'xs:string',
|
||||
|
||||
# Shipping Address
|
||||
ShipToName => 'xs:string',
|
||||
ShipToStreet1 => 'xs:string',
|
||||
|
@ -48,6 +56,7 @@ sub DoDirectPaymentRequest {
|
|||
ShipToStateOrProvince => 'xs:string',
|
||||
ShipToCountry => 'xs:string',
|
||||
ShipToPostalCode => 'xs:string',
|
||||
|
||||
# Misc
|
||||
CVV2 => 'xs:string',
|
||||
IPAddress => 'xs:string',
|
||||
|
@ -58,80 +67,131 @@ sub DoDirectPaymentRequest {
|
|||
$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 @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 $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',
|
||||
$self->getFields(
|
||||
$som, $path,
|
||||
\%response,
|
||||
{ TransactionID => 'TransactionID',
|
||||
Amount => 'Amount',
|
||||
AVSCode => 'AVSCode',
|
||||
CVV2Code => 'CVV2Code',
|
||||
|
|
|
@ -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,7 +17,8 @@ sub SetExpressCheckout {
|
|||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my %types = ( Token => 'ebl:ExpressCheckoutTokenType',
|
||||
my %types = (
|
||||
Token => 'ebl:ExpressCheckoutTokenType',
|
||||
OrderTotal => 'cc:BasicAmountType',
|
||||
currencyID => '',
|
||||
MaxAmount => 'cc:BasicAmountType',
|
||||
|
@ -36,13 +38,16 @@ sub SetExpressCheckout {
|
|||
'cpp-header-back-color' => 'xs:string',
|
||||
'cpp-payflow-color' => 'xs:string',
|
||||
PaymentAction => '',
|
||||
BuyerEmail => 'ebl:EmailAddressType' );
|
||||
BuyerEmail => 'ebl:EmailAddressType'
|
||||
);
|
||||
|
||||
## billing agreement details type
|
||||
my %badtypes = ( BillingType => '', #'ns:BillingCodeType',
|
||||
my %badtypes = (
|
||||
BillingType => '', #'ns:BillingCodeType',
|
||||
BillingAgreementDescription => 'xs:string',
|
||||
PaymentType => '', #'ns:MerchantPullPaymentCodeType',
|
||||
BillingAgreementCustom => 'xs:string', );
|
||||
BillingAgreementCustom => 'xs:string',
|
||||
);
|
||||
|
||||
## set some defaults
|
||||
$args{PaymentAction} ||= 'Sale';
|
||||
|
@ -50,69 +55,82 @@ 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};
|
||||
|
||||
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) )
|
||||
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} ),
|
||||
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;
|
||||
|
||||
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 $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} ),
|
||||
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' );
|
||||
|
||||
|
@ -121,14 +139,14 @@ sub GetExpressCheckoutDetails {
|
|||
|
||||
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,
|
||||
$self->getFields(
|
||||
$som,
|
||||
"$path/GetExpressCheckoutDetailsResponseDetails",
|
||||
\%details,
|
||||
{ Token => 'Token',
|
||||
|
@ -153,7 +171,8 @@ sub GetExpressCheckoutDetails {
|
|||
PostalCode => 'PayerInfo/Address/PostalCode',
|
||||
Country => 'PayerInfo/Address/Country',
|
||||
PayerCountry => 'PayerInfo/PayerCountry',
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
||||
return %details;
|
||||
}
|
||||
|
@ -162,7 +181,8 @@ sub DoExpressCheckoutPayment {
|
|||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my %types = ( Token => 'xs:string',
|
||||
my %types = (
|
||||
Token => 'xs:string',
|
||||
PaymentAction => '', ## NOTA BENE!
|
||||
PayerID => 'ebl:UserIDType',
|
||||
currencyID => '',
|
||||
|
@ -170,7 +190,8 @@ sub DoExpressCheckoutPayment {
|
|||
);
|
||||
|
||||
## PaymentDetails
|
||||
my %pd_types = ( OrderTotal => 'ebl:BasicAmountType',
|
||||
my %pd_types = (
|
||||
OrderTotal => 'ebl:BasicAmountType',
|
||||
OrderDescription => 'xs:string',
|
||||
ItemTotal => 'ebl:BasicAmountType',
|
||||
ShippingTotal => 'ebl:BasicAmountType',
|
||||
|
@ -183,7 +204,8 @@ sub DoExpressCheckoutPayment {
|
|||
);
|
||||
|
||||
## ShipToAddress
|
||||
my %st_types = ( ST_Name => 'xs:string',
|
||||
my %st_types = (
|
||||
ST_Name => 'xs:string',
|
||||
ST_Street1 => 'xs:string',
|
||||
ST_Street2 => 'xs:string',
|
||||
ST_CityName => 'xs:string',
|
||||
|
@ -193,7 +215,8 @@ sub DoExpressCheckoutPayment {
|
|||
);
|
||||
|
||||
##PaymentDetailsItem
|
||||
my %pdi_types = ( PDI_Name => 'xs:string',
|
||||
my %pdi_types = (
|
||||
PDI_Name => 'xs:string',
|
||||
PDI_Amount => 'ebl:BasicAmountType',
|
||||
PDI_Number => 'xs:string',
|
||||
PDI_Quantity => 'xs:string',
|
||||
|
@ -203,19 +226,22 @@ sub DoExpressCheckoutPayment {
|
|||
$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} ) {
|
||||
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_//;
|
||||
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 ) {
|
||||
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} ),
|
||||
);
|
||||
SOAP::Data->name( ShipToAddress =>
|
||||
\SOAP::Data->value( @ship_types )->type( 'ebl:AddressType' )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ), );
|
||||
}
|
||||
|
||||
##
|
||||
|
@ -248,48 +273,55 @@ sub DoExpressCheckoutPayment {
|
|||
##
|
||||
my @payment_details_item = ();
|
||||
for my $field ( keys %pdi_types ) {
|
||||
if( $args{$field} ) {
|
||||
(my $name = $field) =~ s/^PDI_//;
|
||||
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 ) {
|
||||
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} ),
|
||||
);
|
||||
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( 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} ),
|
||||
->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} ),
|
||||
->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} ), );
|
||||
->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 } ),
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -299,12 +331,13 @@ sub DoExpressCheckoutPayment {
|
|||
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,
|
||||
$self->getFields(
|
||||
$som,
|
||||
"$path/DoExpressCheckoutPaymentResponseDetails",
|
||||
\%response,
|
||||
{ Token => 'Token',
|
||||
|
@ -325,7 +358,8 @@ sub DoExpressCheckoutPayment {
|
|||
PendingFilters => 'FMFDetails/PendingFilters',
|
||||
ReportsFilters => 'FMFDetails/ReportsFilters',
|
||||
ProtectionEligibility => 'PaymentInfo/ProtectionEligibility',
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
||||
return %response;
|
||||
}
|
||||
|
|
|
@ -14,15 +14,16 @@ sub GetTransactionDetails {
|
|||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my @trans =
|
||||
(
|
||||
my @trans = (
|
||||
$self->version_req,
|
||||
SOAP::Data->name( TransactionID => $args{TransactionID} )->type( 'xs:string' ),
|
||||
SOAP::Data->name( TransactionID => $args{TransactionID} )
|
||||
->type( 'xs:string' ),
|
||||
);
|
||||
|
||||
my $request = SOAP::Data->name
|
||||
( 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;
|
||||
|
@ -30,14 +31,16 @@ sub GetTransactionDetails {
|
|||
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,
|
||||
$self->getFields(
|
||||
$som, $path,
|
||||
\%response,
|
||||
{ Business => '/ReceiverInfo/Business',
|
||||
Receiver => '/ReceiverInfo/Receiver',
|
||||
ReceiverID => '/ReceiverInfo/ReceiverID',
|
||||
|
@ -94,9 +97,12 @@ sub GetTransactionDetails {
|
|||
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_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',
|
||||
|
@ -113,16 +119,19 @@ sub GetTransactionDetails {
|
|||
);
|
||||
|
||||
## multiple payment items
|
||||
my $paymentitems = $self->getFieldsList( $som, $path . '/PaymentItemInfo/PaymentItem',
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,20 +20,26 @@ sub MassPay {
|
|||
$args{MassPayItems} ||= [];
|
||||
$args{Version} ||= "1.0";
|
||||
|
||||
my %types = ( EmailSubject => 'xs:string',
|
||||
my %types = (
|
||||
EmailSubject => 'xs:string',
|
||||
Version => 'xsd:string',
|
||||
|
||||
# ReceiverType => 'ebl:ReceiverInfoCodeType', ## EmailAddress | UserID
|
||||
);
|
||||
|
||||
my %attr = ( Version => { xmlns => $self->C_xmlns_ebay },
|
||||
Amount => { currencyID => $args{currencyID} }, );
|
||||
my %attr = (
|
||||
Version => { xmlns => $self->C_xmlns_ebay },
|
||||
Amount => { currencyID => $args{currencyID} },
|
||||
);
|
||||
|
||||
## mass pay item
|
||||
my %mpi_type = ( ReceiverEmail => 'ebl:EmailAddressType',
|
||||
my %mpi_type = (
|
||||
ReceiverEmail => 'ebl:EmailAddressType',
|
||||
ReceiverID => 'xs:string',
|
||||
Amount => 'ebl:BasicAmountType',
|
||||
UniqueId => 'xs:string',
|
||||
Note => '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,21 +71,27 @@ 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;
|
||||
|
@ -83,8 +99,8 @@ sub MassPay {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,26 +14,27 @@ 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} )
|
||||
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;
|
||||
|
@ -41,14 +42,17 @@ sub DoReauthorizationRequest {
|
|||
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,
|
||||
$self->getFields(
|
||||
$som, $path,
|
||||
\%response,
|
||||
{ AuthorizationID => 'AuthorizationID',
|
||||
Amount => 'Amount', }
|
||||
Amount => 'Amount',
|
||||
}
|
||||
);
|
||||
|
||||
return %response;
|
||||
|
|
|
@ -20,12 +20,15 @@ sub SetCustomerBillingAgreement {
|
|||
my %args = @_;
|
||||
|
||||
## billing agreement details type
|
||||
my %badtypes = ( BillingType => '', # 'ns:BillingCodeType',
|
||||
my %badtypes = (
|
||||
BillingType => '', # 'ns:BillingCodeType',
|
||||
BillingAgreementDescription => 'xs:string',
|
||||
PaymentType => '', # 'ns:MerchantPullPaymentCodeType',
|
||||
BillingAgreementCustom => 'xs:string', );
|
||||
BillingAgreementCustom => 'xs:string',
|
||||
);
|
||||
|
||||
my %types = ( BillingAgreementDetails => 'ns:BillingAgreementDetailsType',
|
||||
my %types = (
|
||||
BillingAgreementDetails => 'ns:BillingAgreementDetailsType',
|
||||
ReturnURL => 'xs:string',
|
||||
CancelURL => 'xs:string',
|
||||
LocaleCode => 'xs:string',
|
||||
|
@ -35,7 +38,8 @@ sub SetCustomerBillingAgreement {
|
|||
'cpp-header-back-color' => 'xs:string',
|
||||
'cpp-payflow-color' => 'xs:string',
|
||||
PaymentAction => '',
|
||||
BuyerEmail => 'ns:EmailAddressType', );
|
||||
BuyerEmail => 'ns:EmailAddressType',
|
||||
);
|
||||
|
||||
## set defaults
|
||||
$args{BillingType} ||= 'RecurringPayments';
|
||||
|
@ -45,21 +49,29 @@ sub SetCustomerBillingAgreement {
|
|||
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} ),
|
||||
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' );
|
||||
|
||||
|
@ -69,12 +81,12 @@ sub SetCustomerBillingAgreement {
|
|||
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,26 +95,28 @@ 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} ),
|
||||
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 )
|
||||
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,
|
||||
$self->getFields(
|
||||
$som,
|
||||
"$path/GetBillingAgreementCustomerDetailsResponseDetails",
|
||||
\%details,
|
||||
{ Token => 'Token',
|
||||
|
@ -126,7 +140,8 @@ sub GetBillingAgreementCustomerDetails {
|
|||
MiddleName => 'PayerInfo/PayerName/MiddleName',
|
||||
LastName => 'PayerInfo/PayerName/LastName',
|
||||
Suffix => 'PayerInfo/PayerName/Suffix',
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
||||
return %details;
|
||||
}
|
||||
|
@ -136,59 +151,74 @@ sub CreateRecurringPaymentsProfile {
|
|||
my %args = @_;
|
||||
|
||||
## RecurringPaymentProfileDetails
|
||||
my %profiledetailstype = ( SubscriberName => 'xs:string',
|
||||
my %profiledetailstype = (
|
||||
SubscriberName => 'xs:string',
|
||||
SubscriberShipperAddress => 'ns:AddressType',
|
||||
BillingStartDate => 'xs:dateTime', ## MM-DD-YY
|
||||
ProfileReference => 'xs:string', );
|
||||
ProfileReference => 'xs:string',
|
||||
);
|
||||
|
||||
## ScheduleDetailsType
|
||||
my %schedtype = ( Description => 'xs:string',
|
||||
my %schedtype = (
|
||||
Description => 'xs:string',
|
||||
ActivationDetails => 'ns:ActivationDetailsType',
|
||||
TrialPeriod => 'ns:BillingPeriodDetailsType',
|
||||
PaymentPeriod => 'ns:BillingPeriodDetailsType',
|
||||
MaxFailedPayments => 'xs:int',
|
||||
AutoBillOutstandingAmount => 'ns:AutoBillType', ); ## NoAutoBill or AddToNextBilling
|
||||
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',
|
||||
my %trialbilltype = (
|
||||
TrialBillingPeriod => 'xs:string', ##'ns:BillingPeriodType',
|
||||
TrialBillingFrequency => 'xs:int',
|
||||
TrialTotalBillingCycles => 'xs:int',
|
||||
TrialAmount => 'cc:AmountType',
|
||||
TrialShippingAmount => 'cc:AmountType',
|
||||
TrialTaxAmount => 'cc:AmountType', );
|
||||
TrialTaxAmount => 'cc:AmountType',
|
||||
);
|
||||
|
||||
my %paymentbilltype = ( PaymentBillingPeriod => 'xs:string', ##'ns:BillingPeriodType',
|
||||
my %paymentbilltype = (
|
||||
PaymentBillingPeriod => 'xs:string', ##'ns:BillingPeriodType',
|
||||
PaymentBillingFrequency => 'xs:int',
|
||||
PaymentTotalBillingCycles => 'xs:int',
|
||||
PaymentAmount => 'cc:AmountType',
|
||||
PaymentShippingAmount => 'cc:AmountType',
|
||||
PaymentTaxAmount => 'cc:AmountType', );
|
||||
PaymentTaxAmount => 'cc:AmountType',
|
||||
);
|
||||
|
||||
## AddressType
|
||||
my %payaddrtype = ( CCPayerName => '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', );
|
||||
CCPayerPhone => 'xs:string',
|
||||
);
|
||||
|
||||
my %shipaddrtype = ( SubscriberShipperName => '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', );
|
||||
SubscriberShipperPhone => 'xs:string',
|
||||
);
|
||||
|
||||
## credit card payer
|
||||
my %payerinfotype = ( CCPayer => 'ns:EmailAddressType',
|
||||
my %payerinfotype = (
|
||||
CCPayer => 'ns:EmailAddressType',
|
||||
CCPayerID => 'ebl:UserIDType',
|
||||
CCPayerStatus => 'xs:string',
|
||||
CCPayerName => 'xs:string',
|
||||
|
@ -199,94 +229,133 @@ sub CreateRecurringPaymentsProfile {
|
|||
);
|
||||
|
||||
## credit card details
|
||||
my %creditcarddetailstype = ( CardOwner => 'ns:PayerInfoType',
|
||||
CreditCardType => 'ebl:CreditCardType', ## Visa, MasterCard, Discover, Amex, Switch, Solo
|
||||
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', );
|
||||
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} )
|
||||
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' );
|
||||
|
||||
|
@ -296,12 +365,12 @@ sub CreateRecurringPaymentsProfile {
|
|||
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,13 +379,15 @@ sub DoReferenceTransaction {
|
|||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my %types = ( ReferenceID => 'xs:string',
|
||||
my %types = (
|
||||
ReferenceID => 'xs:string',
|
||||
PaymentAction => '', ## NOTA BENE!
|
||||
currencyID => '',
|
||||
);
|
||||
|
||||
## PaymentDetails
|
||||
my %pd_types = ( OrderTotal => 'ebl:BasicAmountType',
|
||||
my %pd_types = (
|
||||
OrderTotal => 'ebl:BasicAmountType',
|
||||
OrderDescription => 'xs:string',
|
||||
ItemTotal => 'ebl:BasicAmountType',
|
||||
ShippingTotal => 'ebl:BasicAmountType',
|
||||
|
@ -329,7 +400,8 @@ sub DoReferenceTransaction {
|
|||
);
|
||||
|
||||
## ShipToAddress
|
||||
my %st_types = ( ST_Name => 'xs:string',
|
||||
my %st_types = (
|
||||
ST_Name => 'xs:string',
|
||||
ST_Street1 => 'xs:string',
|
||||
ST_Street2 => 'xs:string',
|
||||
ST_CityName => 'xs:string',
|
||||
|
@ -340,7 +412,8 @@ sub DoReferenceTransaction {
|
|||
);
|
||||
|
||||
##PaymentDetailsItem
|
||||
my %pdi_types = ( PDI_Name => 'xs:string',
|
||||
my %pdi_types = (
|
||||
PDI_Name => 'xs:string',
|
||||
PDI_Description => 'xs:string',
|
||||
PDI_Amount => 'ebl:BasicAmountType',
|
||||
PDI_Number => 'xs:string',
|
||||
|
@ -351,19 +424,22 @@ sub DoReferenceTransaction {
|
|||
$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} ) {
|
||||
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_//;
|
||||
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 ) {
|
||||
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} ),
|
||||
);
|
||||
SOAP::Data->name( ShipToAddress =>
|
||||
\SOAP::Data->value( @ship_types )->type( 'ebl:AddressType' )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ), );
|
||||
}
|
||||
|
||||
##
|
||||
|
@ -396,20 +471,20 @@ sub DoReferenceTransaction {
|
|||
##
|
||||
my @payment_details_item = ();
|
||||
for my $field ( keys %pdi_types ) {
|
||||
if( $args{$field} ) {
|
||||
(my $name = $field) =~ s/^PDI_//;
|
||||
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 ) {
|
||||
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} ),
|
||||
);
|
||||
SOAP::Data->name(
|
||||
PaymentDetailsItem => \SOAP::Data->value( @payment_details_item )
|
||||
->type( 'ebl:PaymentDetailsItemType' )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ), );
|
||||
}
|
||||
|
||||
##
|
||||
|
@ -417,23 +492,29 @@ sub DoReferenceTransaction {
|
|||
##
|
||||
my @reference_details = (
|
||||
SOAP::Data->name( ReferenceID => $args{ReferenceID} )
|
||||
->type($types{ReferenceID})->attr( {xmlns => $self->C_xmlns_ebay} ),
|
||||
->type( $types{ReferenceID} )
|
||||
->attr( { xmlns => $self->C_xmlns_ebay } ),
|
||||
SOAP::Data->name( PaymentAction => $args{PaymentAction} )
|
||||
->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} ),
|
||||
), );
|
||||
->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 } ),
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -443,12 +524,13 @@ sub DoReferenceTransaction {
|
|||
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,
|
||||
$self->getFields(
|
||||
$som,
|
||||
"$path/DoReferenceTransactionResponseDetails",
|
||||
\%response,
|
||||
{ BillingAgreementID => 'BillingAgreementID',
|
||||
|
@ -464,7 +546,8 @@ sub DoReferenceTransaction {
|
|||
PaymentStatus => 'PaymentInfo/PaymentStatus',
|
||||
PendingReason => 'PaymentInfo/PendingReason',
|
||||
ReasonCode => 'PaymentInfor/ReasonCode',
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
||||
return %response;
|
||||
}
|
||||
|
|
|
@ -14,35 +14,39 @@ sub RefundTransaction {
|
|||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my %types = ( TransactionID => 'xs:string',
|
||||
my %types = (
|
||||
TransactionID => 'xs:string',
|
||||
RefundType => '', ## Other | Full | Partial
|
||||
Amount => 'ebl:BasicAmountType',
|
||||
Memo => 'xs:string', );
|
||||
Memo => 'xs:string',
|
||||
);
|
||||
|
||||
$args{currencyID} ||= 'USD';
|
||||
$args{RefundType} ||= 'Full';
|
||||
|
||||
my @ref_trans =
|
||||
(
|
||||
my @ref_trans = (
|
||||
$self->version_req,
|
||||
SOAP::Data->name( TransactionID => $args{TransactionID} )->type($types{TransactionID}),
|
||||
SOAP::Data->name( RefundType => $args{RefundType} )->type($types{RefundType}),
|
||||
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} ) {
|
||||
if ( $args{RefundType} ne 'Full' && $args{Amount} ) {
|
||||
push @ref_trans,
|
||||
SOAP::Data->name( Amount => $args{Amount} )
|
||||
->type( $types{Amount} )
|
||||
->attr( { currencyID => $args{currencyID} } )
|
||||
->attr( { currencyID => $args{currencyID} } );
|
||||
}
|
||||
|
||||
push @ref_trans,
|
||||
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;
|
||||
|
@ -50,16 +54,19 @@ sub RefundTransaction {
|
|||
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,
|
||||
$self->getFields(
|
||||
$som, $path,
|
||||
\%response,
|
||||
{ RefundTransactionID => 'RefundTransactionID',
|
||||
FeeRefundAmount => 'FeeRefundAmount',
|
||||
NetRefundAmount => 'NetRefundAmount',
|
||||
GrossRefundAmount => 'GrossRefundAmount', }
|
||||
GrossRefundAmount => 'GrossRefundAmount',
|
||||
}
|
||||
);
|
||||
|
||||
return %response;
|
||||
|
|
|
@ -14,7 +14,8 @@ sub TransactionSearch {
|
|||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my %types = ( StartDate => 'xs:dateTime',
|
||||
my %types = (
|
||||
StartDate => 'xs:dateTime',
|
||||
EndDate => 'xs:dateTime',
|
||||
Payer => 'ebl:EmailAddressType',
|
||||
Receiver => 'ebl:EmailAddressType',
|
||||
|
@ -29,20 +30,22 @@ sub TransactionSearch {
|
|||
Status => '',
|
||||
);
|
||||
|
||||
my @trans =
|
||||
(
|
||||
my @trans = (
|
||||
$self->version_req,
|
||||
SOAP::Data->name( StartDate => $args{StartDate} )->type( delete $types{StartDate} )
|
||||
SOAP::Data->name( StartDate => $args{StartDate} )
|
||||
->type( delete $types{StartDate} )
|
||||
);
|
||||
|
||||
for my $type ( keys %types ) {
|
||||
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;
|
||||
|
@ -50,12 +53,14 @@ sub TransactionSearch {
|
|||
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',
|
||||
return $self->getFieldsList(
|
||||
$som,
|
||||
$path . '/PaymentTransactions',
|
||||
{ Timestamp => 'Timestamp',
|
||||
Timezone => 'Timezone',
|
||||
Type => 'Type',
|
||||
|
@ -66,7 +71,8 @@ sub TransactionSearch {
|
|||
GrossAmount => 'GrossAmount',
|
||||
FeeAmount => 'FeeAmount',
|
||||
NetAmount => 'NetAmount',
|
||||
} );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -14,24 +14,26 @@ sub DoVoidRequest {
|
|||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
my %types = ( AuthorizationID => 'xs:string',
|
||||
Note => 'xs:string', );
|
||||
|
||||
|
||||
my @ref_trans =
|
||||
(
|
||||
$self->version_req,
|
||||
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )->type($types{AuthorizationID}),
|
||||
my %types = (
|
||||
AuthorizationID => 'xs:string',
|
||||
Note => 'xs:string',
|
||||
);
|
||||
|
||||
if ($args{Note}) {
|
||||
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};
|
||||
}
|
||||
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;
|
||||
|
@ -39,14 +41,13 @@ sub DoVoidRequest {
|
|||
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;
|
||||
}
|
||||
|
|
14
t/API.pl
14
t/API.pl
|
@ -1,3 +1,4 @@
|
|||
|
||||
=pod
|
||||
|
||||
The tester must supply their own PayPal sandbox seller authentication
|
||||
|
@ -13,8 +14,9 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -28,14 +30,14 @@ sub do_args {
|
|||
);
|
||||
|
||||
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) {
|
||||
MATCH: for my $pat ( keys %patterns ) {
|
||||
next unless $_ =~ $pat;
|
||||
(my $value = $_) =~ s/$pat\s*=\s*(.+)/$1/;
|
||||
( my $value = $_ ) =~ s/$pat\s*=\s*(.+)/$1/;
|
||||
$args{ $patterns{$pat} } = $value;
|
||||
delete $patterns{$pat};
|
||||
last MATCH;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use Test::More tests => 1;
|
||||
BEGIN { use_ok('Business::PayPal::API') };
|
||||
BEGIN { use_ok( 'Business::PayPal::API' ) }
|
||||
|
||||
#########################
|
||||
|
||||
|
|
|
@ -3,31 +3,36 @@ use strict;
|
|||
use warnings;
|
||||
use 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 (
|
||||
$ppsale = new Business::PayPal::API( %args );
|
||||
%respsale = $ppsale->DoDirectPaymentRequest(
|
||||
PaymentAction => 'Sale',
|
||||
OrderTotal => 11.87,
|
||||
TaxTotal => 0.0,
|
||||
|
@ -35,7 +40,7 @@ $ppsale = new Business::PayPal::API(%args);
|
|||
CreditCardType => 'Visa',
|
||||
CreditCardNumber => '4561435600988217',
|
||||
ExpMonth => '01',
|
||||
ExpYear => +(localtime)[5]+1901,
|
||||
ExpYear => +( localtime )[5] + 1901,
|
||||
CVV2 => '123',
|
||||
FirstName => 'JP',
|
||||
LastName => 'Morgan',
|
||||
|
@ -49,27 +54,31 @@ $ppsale = new Business::PayPal::API(%args);
|
|||
CurrencyID => 'USD',
|
||||
IPAddress => '10.0.0.1',
|
||||
MerchantSessionID => '10113301',
|
||||
);
|
||||
);
|
||||
|
||||
#$Business::PayPal::API::Debug=0;
|
||||
if(like( $respsale{'Ack'}, qr/Success/, 'Direct Payment Sale')) {
|
||||
if ( like( $respsale{'Ack'}, qr/Success/, 'Direct Payment Sale' ) ) {
|
||||
$transale = $respsale{'TransactionID'};
|
||||
#$Business::PayPal::API::Debug=1;
|
||||
$pprefund = new Business::PayPal::API(%args);
|
||||
%resprefund = $pprefund->RefundTransaction (
|
||||
|
||||
#$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');
|
||||
}
|
||||
|
||||
#$Business::PayPal::API::Debug=0;
|
||||
like( $resprefund{'Ack'}, qr/Success/, 'Full Refund For Sale' );
|
||||
}
|
||||
|
||||
#Basic Authorization and Capture
|
||||
|
||||
%args=do_args();
|
||||
%args = do_args();
|
||||
|
||||
#$Business::PayPal::API::Debug=0;
|
||||
$ppbasic = new Business::PayPal::API(%args);
|
||||
%respbasic = $ppbasic->DoDirectPaymentRequest (
|
||||
$ppbasic = new Business::PayPal::API( %args );
|
||||
%respbasic = $ppbasic->DoDirectPaymentRequest(
|
||||
PaymentAction => 'Authorization',
|
||||
OrderTotal => 13.87,
|
||||
TaxTotal => 0.0,
|
||||
|
@ -77,7 +86,7 @@ $ppbasic = new Business::PayPal::API(%args);
|
|||
CreditCardType => 'Visa',
|
||||
CreditCardNumber => '4561435600988217',
|
||||
ExpMonth => '01',
|
||||
ExpYear => +(localtime)[5]+1901,
|
||||
ExpYear => +( localtime )[5] + 1901,
|
||||
CVV2 => '123',
|
||||
FirstName => 'JP',
|
||||
LastName => 'Morgan',
|
||||
|
@ -91,42 +100,48 @@ $ppbasic = new Business::PayPal::API(%args);
|
|||
CurrencyID => 'USD',
|
||||
IPAddress => '10.0.0.1',
|
||||
MerchantSessionID => '10113301',
|
||||
);
|
||||
);
|
||||
|
||||
#$Business::PayPal::API::Debug=0;
|
||||
if( like( $respbasic{'Ack'}, qr/Success/, 'Direct Payment Basic Authorization') ) {
|
||||
if (like(
|
||||
$respbasic{'Ack'}, qr/Success/,
|
||||
'Direct Payment Basic Authorization'
|
||||
)
|
||||
)
|
||||
{
|
||||
$tranbasic = $respbasic{'TransactionID'};
|
||||
|
||||
#Test Partial Capture
|
||||
#$Business::PayPal::API::Debug=1;
|
||||
$ppcap = new Business::PayPal::API(%args);
|
||||
$ppcap = new Business::PayPal::API( %args );
|
||||
|
||||
%respcap = $ppcap->DoCaptureRequest (
|
||||
%respcap = $ppcap->DoCaptureRequest(
|
||||
AuthorizationID => $tranbasic,
|
||||
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 (
|
||||
$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 (
|
||||
$ppbasic = new Business::PayPal::API( %args );
|
||||
%respbasic = $ppbasic->DoDirectPaymentRequest(
|
||||
PaymentAction => 'Authorization',
|
||||
OrderTotal => 17.37,
|
||||
TaxTotal => 0.0,
|
||||
|
@ -134,7 +149,7 @@ $ppbasic = new Business::PayPal::API(%args);
|
|||
CreditCardType => 'Visa',
|
||||
CreditCardNumber => '4561435600988217',
|
||||
ExpMonth => '01',
|
||||
ExpYear => +(localtime)[5]+1901,
|
||||
ExpYear => +( localtime )[5] + 1901,
|
||||
CVV2 => '123',
|
||||
FirstName => 'JP',
|
||||
LastName => 'Morgan',
|
||||
|
@ -148,11 +163,14 @@ $ppbasic = new Business::PayPal::API(%args);
|
|||
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',
|
||||
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
|
||||
);
|
||||
);
|
||||
|
||||
#$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."
|
||||
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},
|
||||
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" );
|
||||
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',
|
||||
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
|
||||
);
|
||||
);
|
||||
|
||||
#$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."
|
||||
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},
|
||||
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' );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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" );
|
||||
|
|
34
t/MassPay.t
34
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',
|
||||
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." } ] );
|
||||
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',
|
||||
%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." },
|
||||
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." } ] );
|
||||
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
|
||||
(
|
||||
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."
|
||||
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',
|
||||
|
@ -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,
|
||||
my %resp = $pp->RefundTransaction(
|
||||
TransactionID => $transid,
|
||||
RefundType => 'Full',
|
||||
Memo => 'Fancy refund time.' );
|
||||
Memo => 'Fancy refund time.'
|
||||
);
|
||||
|
||||
like( $resp{Ack}, qr/Success/ , "Successful refund." );
|
||||
like( $resp{Ack}, qr/Success/, "Successful refund." );
|
||||
|
||||
if( $resp{Ack} ) {
|
||||
if ( $resp{Ack} ) {
|
||||
print STDERR <<"_REFUND_";
|
||||
|
||||
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;
|
||||
|
@ -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,
|
||||
my $resp = $pp->TransactionSearch(
|
||||
StartDate => $startdate,
|
||||
TransactionID => $transid,
|
||||
);
|
||||
ok( scalar @$resp , "Matching Transactions Found");
|
||||
);
|
||||
ok( scalar @$resp, "Matching Transactions Found" );
|
||||
|
||||
|
|
Loading…
Reference in a new issue