Tidy everything.

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

2
.gitignore vendored
View file

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

View file

@ -45,8 +45,11 @@ sub import {
## import 'exported' subroutines into our namespace ## import 'exported' subroutines into our namespace
no strict 'refs'; no strict 'refs';
for my $sub ( @{"Business::PayPal::API::" . $module . "::EXPORT_OK"} ) { for my $sub (
*{"Business::PayPal::API::" . $sub} = *{"Business::PayPal::API::" . $module . "::" . $sub}; @{ "Business::PayPal::API::" . $module . "::EXPORT_OK" } )
{
*{ "Business::PayPal::API::" . $sub }
= *{ "Business::PayPal::API::" . $module . "::" . $sub };
} }
} }
} }
@ -69,23 +72,31 @@ sub new {
$H_CertFile{$self} = $args{CertFile} || ''; $H_CertFile{$self} = $args{CertFile} || '';
$H_KeyFile{$self} = $args{KeyFile} || ''; $H_KeyFile{$self} = $args{KeyFile} || '';
my $proxy = ($args{sandbox} my $proxy = (
$args{sandbox}
? ( $args{Signature} ? ( $args{Signature}
? C_api_sandbox_3t ? C_api_sandbox_3t
: C_api_sandbox) : C_api_sandbox
)
: ( $args{Signature} : ( $args{Signature}
? C_api_live_3t ? C_api_live_3t
: C_api_live) : C_api_live
)
); );
$Soap{$self} = SOAP::Lite->proxy( $proxy, timeout => $args{timeout} )->uri( C_xmlns_pp ); $Soap{$self} = SOAP::Lite->proxy( $proxy, timeout => $args{timeout} )
->uri( C_xmlns_pp );
$Header{$self} = SOAP::Header $Header{$self} = SOAP::Header->name(
->name( RequesterCredentials => \SOAP::Header->value RequesterCredentials => \SOAP::Header->value(
( SOAP::Data->name( Credentials => \SOAP::Data->value SOAP::Data->name(
( SOAP::Data->name( Username => $args{Username} )->type(''), Credentials => \SOAP::Data->value(
SOAP::Data->name( Password => $args{Password} )->type(''), SOAP::Data->name( Username => $args{Username} )
SOAP::Data->name( Signature => $args{Signature} )->type(''), ->type( '' ),
SOAP::Data->name( Password => $args{Password} )
->type( '' ),
SOAP::Data->name( Signature => $args{Signature} )
->type( '' ),
SOAP::Data->name( Subject => $args{Subject} )->type( '' ), SOAP::Data->name( Subject => $args{Subject} )->type( '' ),
), ),
)->attr( { xmlns => C_xmlns_ebay } ) )->attr( { xmlns => C_xmlns_ebay } )
@ -111,26 +122,33 @@ sub DESTROY {
} }
sub version_req { sub version_req {
return SOAP::Data->name( Version => C_version ) return SOAP::Data->name( Version => C_version )->type( 'xs:string' )
->type('xs:string')->attr( {xmlns => C_xmlns_ebay} ); ->attr( { xmlns => C_xmlns_ebay } );
} }
sub doCall { sub doCall {
my $self = shift; my $self = shift;
my $method_name = shift; my $method_name = shift;
my $request = shift; my $request = shift;
my $method = SOAP::Data->name( $method_name )->attr( {xmlns => C_xmlns_pp} ); my $method
= SOAP::Data->name( $method_name )->attr( { xmlns => C_xmlns_pp } );
my $som; my $som;
{ {
$H_PKCS12File{$self} and local $ENV{HTTPS_PKCS12_FILE} = $H_PKCS12File{$self}; $H_PKCS12File{$self}
$H_PKCS12Password{$self} and local $ENV{HTTPS_PKCS12_PASSWORD} = $H_PKCS12Password{$self}; and local $ENV{HTTPS_PKCS12_FILE} = $H_PKCS12File{$self};
$H_CertFile{$self} and local $ENV{HTTPS_CERT_FILE} = $H_CertFile{$self}; $H_PKCS12Password{$self}
and local $ENV{HTTPS_PKCS12_PASSWORD} = $H_PKCS12Password{$self};
$H_CertFile{$self}
and local $ENV{HTTPS_CERT_FILE} = $H_CertFile{$self};
$H_KeyFile{$self} and local $ENV{HTTPS_KEY_FILE} = $H_KeyFile{$self}; $H_KeyFile{$self} and local $ENV{HTTPS_KEY_FILE} = $H_KeyFile{$self};
if ( $Debug ) { if ( $Debug ) {
print STDERR SOAP::Serializer->envelope(method => $method, print STDERR SOAP::Serializer->envelope(
$Header{$self}, $request), "\n"; method => $method,
$Header{$self}, $request
),
"\n";
} }
# $Soap{$self}->readable( $Debug ); # $Soap{$self}->readable( $Debug );
@ -155,7 +173,8 @@ sub doCall {
} }
if ( ref( $som ) && $som->fault ) { if ( ref( $som ) && $som->fault ) {
carp "Fault: " . $som->faultstring carp "Fault: "
. $som->faultstring
. ( $som->faultdetail ? " (" . $som->faultdetail . ")" : '' ) . ( $som->faultdetail ? " (" . $som->faultdetail . ")" : '' )
. "\n"; . "\n";
return; return;
@ -182,7 +201,8 @@ sub getFieldsList {
if ( defined $response{TransactionID} ) { if ( defined $response{TransactionID} ) {
if ( $trans_id{ $response{TransactionID} } ) { if ( $trans_id{ $response{TransactionID} } ) {
next; next;
} else { }
else {
$trans_id{ $response{TransactionID} } = 1; $trans_id{ $response{TransactionID} } = 1;
} }
} }
@ -259,8 +279,11 @@ sub getErrors {
my @errors = (); my @errors = ();
for my $enode ( $som->valueof( "$path/Errors" ) ) { for my $enode ( $som->valueof( "$path/Errors" ) ) {
push @errors, { LongMessage => $enode->{LongMessage}, push @errors,
ErrorCode => $enode->{ErrorCode}, }; {
LongMessage => $enode->{LongMessage},
ErrorCode => $enode->{ErrorCode},
};
} }
$details->{Errors} = \@errors; $details->{Errors} = \@errors;

View file

@ -5,6 +5,7 @@ use strict;
use warnings; use warnings;
use SOAP::Lite 0.67; use SOAP::Lite 0.67;
#use SOAP::Lite +trace => 'debug'; #use SOAP::Lite +trace => 'debug';
use Business::PayPal::API (); use Business::PayPal::API ();
@ -15,25 +16,26 @@ sub DoAuthorizationRequest {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my %types = ( TransactionID => 'xs:string', my %types = (
Amount => 'ebl:BasicAmountType',); TransactionID => 'xs:string',
Amount => 'ebl:BasicAmountType',
);
$args{currencyID} ||= 'USD'; $args{currencyID} ||= 'USD';
my @ref_trans = my @ref_trans = (
($self->version_req, $self->version_req,
SOAP::Data->name( TransactionID => $args{TransactionID} )->type($types{TransactionID}),); SOAP::Data->name( TransactionID => $args{TransactionID} )
->type( $types{TransactionID} ),
);
push @ref_trans, push @ref_trans,
SOAP::Data->name( Amount => $args{Amount} ) SOAP::Data->name( Amount => $args{Amount} )->type( $types{Amount} )
->type( $types{Amount} )
->attr( { currencyID => $args{currencyID} } ); ->attr( { currencyID => $args{currencyID} } );
my $request
= SOAP::Data->name(
my $request = SOAP::Data->name DoAuthorizationRequest => \SOAP::Data->value( @ref_trans ) )
( DoAuthorizationRequest => \SOAP::Data->value( @ref_trans ) )
->type( "ns:AuthorizationRequestType" ); ->type( "ns:AuthorizationRequestType" );
my $som = $self->doCall( DoAuthorizationReq => $request ) my $som = $self->doCall( DoAuthorizationReq => $request )
@ -47,9 +49,12 @@ sub DoAuthorizationRequest {
return %response; return %response;
} }
$self->getFields($som, $path, \%response, $self->getFields(
$som, $path,
\%response,
{ TransactionID => 'TransactionID', { TransactionID => 'TransactionID',
Amount => 'Amount', } Amount => 'Amount',
}
); );
return %response; return %response;

View file

@ -5,6 +5,7 @@ use strict;
use warnings; use warnings;
use SOAP::Lite 0.67; use SOAP::Lite 0.67;
#use SOAP::Lite +trace => 'debug'; #use SOAP::Lite +trace => 'debug';
use Business::PayPal::API (); use Business::PayPal::API ();
@ -17,6 +18,7 @@ sub DoCaptureRequest {
my %types = ( my %types = (
AuthorizationID => 'xs:string', AuthorizationID => 'xs:string',
#The inclusion of the "ebl:CompleteCodeType" here, or any other reasonable type, #The inclusion of the "ebl:CompleteCodeType" here, or any other reasonable type,
#causes and error. Assigning a null string allows the module to work normally #causes and error. Assigning a null string allows the module to work normally
#with the exception that testing for "Success" fails, one must test for not #with the exception that testing for "Success" fails, one must test for not
@ -29,22 +31,24 @@ sub DoCaptureRequest {
$args{currencyID} ||= 'USD'; $args{currencyID} ||= 'USD';
$args{CompleteType} ||= 'Complete'; $args{CompleteType} ||= 'Complete';
my @ref_trans = my @ref_trans = (
(
$self->version_req, $self->version_req,
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )->type($types{AuthorizationID}), SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )
SOAP::Data->name( CompleteType => $args{CompleteType} )->type($types{CompleteType}), ->type( $types{AuthorizationID} ),
SOAP::Data->name( CompleteType => $args{CompleteType} )
->type( $types{CompleteType} ),
); );
if ( $args{Amount} ) { if ( $args{Amount} ) {
push @ref_trans, push @ref_trans,
SOAP::Data->name( Amount => $args{Amount} ) SOAP::Data->name( Amount => $args{Amount} )
->type( $types{Amount} ) ->type( $types{Amount} )
->attr( { currencyID => $args{currencyID} } ) ->attr( { currencyID => $args{currencyID} } );
} }
my $request = SOAP::Data->name my $request
( DoCaptureRequest => \SOAP::Data->value( @ref_trans ) ) = SOAP::Data->name(
DoCaptureRequest => \SOAP::Data->value( @ref_trans ) )
->type( "ns:DoCaptureRequestType" ); ->type( "ns:DoCaptureRequestType" );
my $som = $self->doCall( DoCaptureReq => $request ) my $som = $self->doCall( DoCaptureReq => $request )
@ -58,9 +62,10 @@ sub DoCaptureRequest {
return %response; return %response;
} }
$path .= '/DoCaptureResponseDetails/PaymentInfo'; $path .= '/DoCaptureResponseDetails/PaymentInfo';
$self->getFields($som, $path, \%response, $self->getFields(
{ $som, $path,
TransactionID => 'TransactionID', \%response,
{ TransactionID => 'TransactionID',
ParentTransactionID => 'ParentTransactionID', ParentTransactionID => 'ParentTransactionID',
ReceiptID => 'ReceiptID', ReceiptID => 'ReceiptID',
TransactionType => 'TransactionType', TransactionType => 'TransactionType',

View file

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

View file

@ -8,7 +8,8 @@ use SOAP::Lite 0.67;
use Business::PayPal::API (); use Business::PayPal::API ();
our @ISA = qw(Business::PayPal::API); our @ISA = qw(Business::PayPal::API);
our @EXPORT_OK = qw( SetExpressCheckout GetExpressCheckoutDetails DoExpressCheckoutPayment ); our @EXPORT_OK
= qw( SetExpressCheckout GetExpressCheckoutDetails DoExpressCheckoutPayment );
## if you specify an InvoiceID, PayPal seems to remember it and not ## if you specify an InvoiceID, PayPal seems to remember it and not
## allow you to bill twice with it. ## allow you to bill twice with it.
@ -16,7 +17,8 @@ sub SetExpressCheckout {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my %types = ( Token => 'ebl:ExpressCheckoutTokenType', my %types = (
Token => 'ebl:ExpressCheckoutTokenType',
OrderTotal => 'cc:BasicAmountType', OrderTotal => 'cc:BasicAmountType',
currencyID => '', currencyID => '',
MaxAmount => 'cc:BasicAmountType', MaxAmount => 'cc:BasicAmountType',
@ -36,13 +38,16 @@ sub SetExpressCheckout {
'cpp-header-back-color' => 'xs:string', 'cpp-header-back-color' => 'xs:string',
'cpp-payflow-color' => 'xs:string', 'cpp-payflow-color' => 'xs:string',
PaymentAction => '', PaymentAction => '',
BuyerEmail => 'ebl:EmailAddressType' ); BuyerEmail => 'ebl:EmailAddressType'
);
## billing agreement details type ## billing agreement details type
my %badtypes = ( BillingType => '', #'ns:BillingCodeType', my %badtypes = (
BillingType => '', #'ns:BillingCodeType',
BillingAgreementDescription => 'xs:string', BillingAgreementDescription => 'xs:string',
PaymentType => '', #'ns:MerchantPullPaymentCodeType', PaymentType => '', #'ns:MerchantPullPaymentCodeType',
BillingAgreementCustom => 'xs:string', ); BillingAgreementCustom => 'xs:string',
);
## set some defaults ## set some defaults
$args{PaymentAction} ||= 'Sale'; $args{PaymentAction} ||= 'Sale';
@ -50,11 +55,15 @@ sub SetExpressCheckout {
my $currencyID = delete $args{currencyID}; my $currencyID = delete $args{currencyID};
## SetExpressCheckoutRequestDetails ## SetExpressCheckoutRequestDetails
my @secrd = my @secrd = (
( SOAP::Data->name( OrderTotal => delete $args{OrderTotal} )->type( $types{OrderTotal} ) SOAP::Data->name( OrderTotal => delete $args{OrderTotal} )
->attr( {currencyID => $currencyID, xmlns => $self->C_xmlns_ebay}), ->type( $types{OrderTotal} )->attr(
SOAP::Data->name( ReturnURL => delete $args{ReturnURL} )->type( $types{ReturnURL} ), { currencyID => $currencyID, xmlns => $self->C_xmlns_ebay }
SOAP::Data->name( CancelURL => delete $args{CancelURL} )->type( $types{CancelURL} ), ),
SOAP::Data->name( ReturnURL => delete $args{ReturnURL} )
->type( $types{ReturnURL} ),
SOAP::Data->name( CancelURL => delete $args{CancelURL} )
->type( $types{CancelURL} ),
); );
## add all the other fields ## add all the other fields
@ -62,31 +71,41 @@ sub SetExpressCheckout {
next unless defined $args{$field}; next unless defined $args{$field};
if ( $field eq 'MaxAmount' ) { if ( $field eq 'MaxAmount' ) {
push @secrd, SOAP::Data->name( $field => $args{$field} )->type( $types{$field} ) push @secrd,
->attr( {currencyID => $currencyID, xmlns => $self->C_xmlns_ebay} ); SOAP::Data->name( $field => $args{$field} )
->type( $types{$field} )
->attr(
{ currencyID => $currencyID, xmlns => $self->C_xmlns_ebay } );
} }
else { else {
push @secrd, SOAP::Data->name( $field => $args{$field} )->type( $types{$field} ); push @secrd,
SOAP::Data->name( $field => $args{$field} )
->type( $types{$field} );
} }
} }
my @btypes = (); my @btypes = ();
for my $field ( keys %badtypes ) { for my $field ( keys %badtypes ) {
next unless $args{$field}; next unless $args{$field};
push @btypes, SOAP::Data->name( $field => $args{$field} )->type( $badtypes{$field} ); push @btypes,
SOAP::Data->name( $field => $args{$field} )
->type( $badtypes{$field} );
} }
push @secrd, SOAP::Data->name( BillingAgreementDetails => \SOAP::Data->value(@btypes) ) push @secrd,
SOAP::Data->name(
BillingAgreementDetails => \SOAP::Data->value( @btypes ) )
if $args{'BillingType'}; if $args{'BillingType'};
my $request = SOAP::Data my $request = SOAP::Data->name(
->name( SetExpressCheckoutRequest => \SOAP::Data->value SetExpressCheckoutRequest => \SOAP::Data->value(
( $self->version_req, $self->version_req,
SOAP::Data->name( SetExpressCheckoutRequestDetails => \SOAP::Data->value(@secrd) ) SOAP::Data->name(
->attr( {xmlns => $self->C_xmlns_ebay} ), SetExpressCheckoutRequestDetails =>
\SOAP::Data->value( @secrd )
)->attr( { xmlns => $self->C_xmlns_ebay } ),
) )
)->type( 'ns:SetExpressCheckoutRequestType' ); )->type( 'ns:SetExpressCheckoutRequestType' );
my $som = $self->doCall( SetExpressCheckoutReq => $request ) my $som = $self->doCall( SetExpressCheckoutReq => $request )
or return; or return;
@ -103,16 +122,15 @@ sub SetExpressCheckout {
return %response; return %response;
} }
sub GetExpressCheckoutDetails { sub GetExpressCheckoutDetails {
my $self = shift; my $self = shift;
my $token = shift; my $token = shift;
my $request = SOAP::Data my $request = SOAP::Data->name(
->name( GetExpressCheckoutDetailsRequest => \SOAP::Data->value GetExpressCheckoutDetailsRequest => \SOAP::Data->value(
( $self->version_req, $self->version_req,
SOAP::Data->name( Token => $token ) SOAP::Data->name( Token => $token )->type( 'xs:string' )
->type('xs:string')->attr( {xmlns => $self->C_xmlns_ebay} ), ->attr( { xmlns => $self->C_xmlns_ebay } ),
) )
)->type( 'ns:GetExpressCheckoutRequestType' ); )->type( 'ns:GetExpressCheckoutRequestType' );
@ -121,14 +139,14 @@ sub GetExpressCheckoutDetails {
my $path = '/Envelope/Body/GetExpressCheckoutDetailsResponse'; my $path = '/Envelope/Body/GetExpressCheckoutDetailsResponse';
my %details = (); my %details = ();
unless ( $self->getBasic( $som, $path, \%details ) ) { unless ( $self->getBasic( $som, $path, \%details ) ) {
$self->getErrors( $som, $path, \%details ); $self->getErrors( $som, $path, \%details );
return %details; return %details;
} }
$self->getFields($som, $self->getFields(
$som,
"$path/GetExpressCheckoutDetailsResponseDetails", "$path/GetExpressCheckoutDetailsResponseDetails",
\%details, \%details,
{ Token => 'Token', { Token => 'Token',
@ -153,7 +171,8 @@ sub GetExpressCheckoutDetails {
PostalCode => 'PayerInfo/Address/PostalCode', PostalCode => 'PayerInfo/Address/PostalCode',
Country => 'PayerInfo/Address/Country', Country => 'PayerInfo/Address/Country',
PayerCountry => 'PayerInfo/PayerCountry', PayerCountry => 'PayerInfo/PayerCountry',
} ); }
);
return %details; return %details;
} }
@ -162,7 +181,8 @@ sub DoExpressCheckoutPayment {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my %types = ( Token => 'xs:string', my %types = (
Token => 'xs:string',
PaymentAction => '', ## NOTA BENE! PaymentAction => '', ## NOTA BENE!
PayerID => 'ebl:UserIDType', PayerID => 'ebl:UserIDType',
currencyID => '', currencyID => '',
@ -170,7 +190,8 @@ sub DoExpressCheckoutPayment {
); );
## PaymentDetails ## PaymentDetails
my %pd_types = ( OrderTotal => 'ebl:BasicAmountType', my %pd_types = (
OrderTotal => 'ebl:BasicAmountType',
OrderDescription => 'xs:string', OrderDescription => 'xs:string',
ItemTotal => 'ebl:BasicAmountType', ItemTotal => 'ebl:BasicAmountType',
ShippingTotal => 'ebl:BasicAmountType', ShippingTotal => 'ebl:BasicAmountType',
@ -183,7 +204,8 @@ sub DoExpressCheckoutPayment {
); );
## ShipToAddress ## ShipToAddress
my %st_types = ( ST_Name => 'xs:string', my %st_types = (
ST_Name => 'xs:string',
ST_Street1 => 'xs:string', ST_Street1 => 'xs:string',
ST_Street2 => 'xs:string', ST_Street2 => 'xs:string',
ST_CityName => 'xs:string', ST_CityName => 'xs:string',
@ -193,7 +215,8 @@ sub DoExpressCheckoutPayment {
); );
##PaymentDetailsItem ##PaymentDetailsItem
my %pdi_types = ( PDI_Name => 'xs:string', my %pdi_types = (
PDI_Name => 'xs:string',
PDI_Amount => 'ebl:BasicAmountType', PDI_Amount => 'ebl:BasicAmountType',
PDI_Number => 'xs:string', PDI_Number => 'xs:string',
PDI_Quantity => 'xs:string', PDI_Quantity => 'xs:string',
@ -206,10 +229,13 @@ sub DoExpressCheckoutPayment {
my @payment_details = (); my @payment_details = ();
## push OrderTotal here and delete it (i.e., and all others that have special attrs) ## push OrderTotal here and delete it (i.e., and all others that have special attrs)
push @payment_details, SOAP::Data->name( OrderTotal => $args{OrderTotal} ) push @payment_details,
->type( $pd_types{OrderTotal} ) SOAP::Data->name( OrderTotal => $args{OrderTotal} )
->attr( { currencyID => $args{currencyID}, ->type( $pd_types{OrderTotal} )->attr(
xmlns => $self->C_xmlns_ebay } ); { currencyID => $args{currencyID},
xmlns => $self->C_xmlns_ebay
}
);
## don't process it again ## don't process it again
delete $pd_types{OrderTotal}; delete $pd_types{OrderTotal};
@ -237,10 +263,9 @@ sub DoExpressCheckoutPayment {
if ( scalar @ship_types ) { if ( scalar @ship_types ) {
push @payment_details, push @payment_details,
SOAP::Data->name( ShipToAddress => \SOAP::Data->value SOAP::Data->name( ShipToAddress =>
( @ship_types )->type('ebl:AddressType') \SOAP::Data->value( @ship_types )->type( 'ebl:AddressType' )
->attr( {xmlns => $self->C_xmlns_ebay} ), ->attr( { xmlns => $self->C_xmlns_ebay } ), );
);
} }
## ##
@ -258,37 +283,44 @@ sub DoExpressCheckoutPayment {
if ( scalar @payment_details_item ) { if ( scalar @payment_details_item ) {
push @payment_details, push @payment_details,
SOAP::Data->name( PaymentDetailsItem => \SOAP::Data->value SOAP::Data->name(
( @payment_details_item )->type('ebl:PaymentDetailsItemType') PaymentDetailsItem => \SOAP::Data->value( @payment_details_item )
->attr( {xmlns => $self->C_xmlns_ebay} ), ->type( 'ebl:PaymentDetailsItemType' )
); ->attr( { xmlns => $self->C_xmlns_ebay } ), );
} }
## ##
## ExpressCheckoutPaymentDetails ## ExpressCheckoutPaymentDetails
## ##
my @express_details = ( my @express_details = (
SOAP::Data->name( Token => $args{Token} ) SOAP::Data->name( Token => $args{Token} )->type( $types{Token} )
->type($types{Token})->attr( {xmlns => $self->C_xmlns_ebay} ), ->attr( { xmlns => $self->C_xmlns_ebay } ),
SOAP::Data->name( PaymentAction => $args{PaymentAction} ) SOAP::Data->name( PaymentAction => $args{PaymentAction} )
->type($types{PaymentAction})->attr( {xmlns => $self->C_xmlns_ebay} ), ->type( $types{PaymentAction} )
->attr( { xmlns => $self->C_xmlns_ebay } ),
SOAP::Data->name( PayerID => $args{PayerID} ) SOAP::Data->name( PayerID => $args{PayerID} )
->type($types{PayerID})->attr( {xmlns => $self->C_xmlns_ebay} ), ->type( $types{PayerID} )
SOAP::Data->name( PaymentDetails => \SOAP::Data->value ->attr( { xmlns => $self->C_xmlns_ebay } ),
( @payment_details )->type('ebl:PaymentDetailsType') SOAP::Data->name(
PaymentDetails => \SOAP::Data->value( @payment_details )
->type( 'ebl:PaymentDetailsType' )
->attr( { xmlns => $self->C_xmlns_ebay } ), ->attr( { xmlns => $self->C_xmlns_ebay } ),
), ),
SOAP::Data->name( ReturnFMFDetails => $args{ReturnFMFDetails} ) SOAP::Data->name( ReturnFMFDetails => $args{ReturnFMFDetails} )
->type($types{ReturnFMFDetails})->attr( {xmlns => $self->C_xmlns_ebay} ), ); ->type( $types{ReturnFMFDetails} )
->attr( { xmlns => $self->C_xmlns_ebay } ),
);
## ##
## the main request object ## the main request object
## ##
my $request = SOAP::Data my $request = SOAP::Data->name(
->name( DoExpressCheckoutPaymentRequest => \SOAP::Data->value DoExpressCheckoutPaymentRequest => \SOAP::Data->value(
( $self->version_req, $self->version_req,
SOAP::Data->name( DoExpressCheckoutPaymentRequestDetails => \SOAP::Data->value SOAP::Data->name(
( @express_details )->type( 'ns:DoExpressCheckoutPaymentRequestDetailsType' ) DoExpressCheckoutPaymentRequestDetails =>
\SOAP::Data->value( @express_details )
->type( 'ns:DoExpressCheckoutPaymentRequestDetailsType' )
)->attr( { xmlns => $self->C_xmlns_ebay } ), )->attr( { xmlns => $self->C_xmlns_ebay } ),
) )
); );
@ -304,7 +336,8 @@ sub DoExpressCheckoutPayment {
return %response; return %response;
} }
$self->getFields( $som, $self->getFields(
$som,
"$path/DoExpressCheckoutPaymentResponseDetails", "$path/DoExpressCheckoutPaymentResponseDetails",
\%response, \%response,
{ Token => 'Token', { Token => 'Token',
@ -325,7 +358,8 @@ sub DoExpressCheckoutPayment {
PendingFilters => 'FMFDetails/PendingFilters', PendingFilters => 'FMFDetails/PendingFilters',
ReportsFilters => 'FMFDetails/ReportsFilters', ReportsFilters => 'FMFDetails/ReportsFilters',
ProtectionEligibility => 'PaymentInfo/ProtectionEligibility', ProtectionEligibility => 'PaymentInfo/ProtectionEligibility',
} ); }
);
return %response; return %response;
} }

View file

@ -14,14 +14,15 @@ sub GetTransactionDetails {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my @trans = my @trans = (
(
$self->version_req, $self->version_req,
SOAP::Data->name( TransactionID => $args{TransactionID} )->type( 'xs:string' ), SOAP::Data->name( TransactionID => $args{TransactionID} )
->type( 'xs:string' ),
); );
my $request = SOAP::Data->name my $request
( GetTransactionDetailsRequest => \SOAP::Data->value( @trans ) ) = SOAP::Data->name(
GetTransactionDetailsRequest => \SOAP::Data->value( @trans ) )
->type( "ns:GetTransactionDetailsRequestType" ); ->type( "ns:GetTransactionDetailsRequestType" );
my $som = $self->doCall( GetTransactionDetailsReq => $request ) my $som = $self->doCall( GetTransactionDetailsReq => $request )
@ -37,7 +38,9 @@ sub GetTransactionDetails {
$path .= '/PaymentTransactionDetails'; $path .= '/PaymentTransactionDetails';
$self->getFields($som, $path, \%response, $self->getFields(
$som, $path,
\%response,
{ Business => '/ReceiverInfo/Business', { Business => '/ReceiverInfo/Business',
Receiver => '/ReceiverInfo/Receiver', Receiver => '/ReceiverInfo/Receiver',
ReceiverID => '/ReceiverInfo/ReceiverID', ReceiverID => '/ReceiverInfo/ReceiverID',
@ -94,9 +97,12 @@ sub GetTransactionDetails {
PII_Amount => '/PaymentItemInfo/PaymentItem/Amount', PII_Amount => '/PaymentItemInfo/PaymentItem/Amount',
PII_Options => '/PaymentItemInfo/PaymentItem/Options', PII_Options => '/PaymentItemInfo/PaymentItem/Options',
PII_SubscriptionID => '/PaymentItemInfo/Subscription/SubscriptionID', PII_SubscriptionID =>
PII_SubscriptionDate => '/PaymentItemInfo/Subscription/SubscriptionDate', '/PaymentItemInfo/Subscription/SubscriptionID',
PII_EffectiveDate => '/PaymentItemInfo/Subscription/EffectiveDate', PII_SubscriptionDate =>
'/PaymentItemInfo/Subscription/SubscriptionDate',
PII_EffectiveDate =>
'/PaymentItemInfo/Subscription/EffectiveDate',
PII_RetryTime => '/PaymentItemInfo/Subscription/RetryTime', PII_RetryTime => '/PaymentItemInfo/Subscription/RetryTime',
PII_Username => '/PaymentItemInfo/Subscription/Username', PII_Username => '/PaymentItemInfo/Subscription/Username',
PII_Password => '/PaymentItemInfo/Subscription/Password', PII_Password => '/PaymentItemInfo/Subscription/Password',
@ -113,14 +119,17 @@ sub GetTransactionDetails {
); );
## multiple payment items ## multiple payment items
my $paymentitems = $self->getFieldsList( $som, $path . '/PaymentItemInfo/PaymentItem', my $paymentitems = $self->getFieldsList(
$som,
$path . '/PaymentItemInfo/PaymentItem',
{ SalesTax => 'SalesTax', { SalesTax => 'SalesTax',
Name => 'Name', Name => 'Name',
Number => 'Number', Number => 'Number',
Quantity => 'Quantity', Quantity => 'Quantity',
Amount => 'Amount', Amount => 'Amount',
Options => 'Options', Options => 'Options',
} ); }
);
if ( scalar( @$paymentitems ) > 0 ) { if ( scalar( @$paymentitems ) > 0 ) {
$response{PaymentItems} = $paymentitems; $response{PaymentItems} = $paymentitems;

View file

@ -20,20 +20,26 @@ sub MassPay {
$args{MassPayItems} ||= []; $args{MassPayItems} ||= [];
$args{Version} ||= "1.0"; $args{Version} ||= "1.0";
my %types = ( EmailSubject => 'xs:string', my %types = (
EmailSubject => 'xs:string',
Version => 'xsd:string', Version => 'xsd:string',
# ReceiverType => 'ebl:ReceiverInfoCodeType', ## EmailAddress | UserID # ReceiverType => 'ebl:ReceiverInfoCodeType', ## EmailAddress | UserID
); );
my %attr = ( Version => { xmlns => $self->C_xmlns_ebay }, my %attr = (
Amount => { currencyID => $args{currencyID} }, ); Version => { xmlns => $self->C_xmlns_ebay },
Amount => { currencyID => $args{currencyID} },
);
## mass pay item ## mass pay item
my %mpi_type = ( ReceiverEmail => 'ebl:EmailAddressType', my %mpi_type = (
ReceiverEmail => 'ebl:EmailAddressType',
ReceiverID => 'xs:string', ReceiverID => 'xs:string',
Amount => 'ebl:BasicAmountType', Amount => 'ebl:BasicAmountType',
UniqueId => 'xs:string', UniqueId => 'xs:string',
Note => 'xs:string', ); Note => 'xs:string',
);
my @recipients = @{ $args{MassPayItems} }; my @recipients = @{ $args{MassPayItems} };
@ -42,10 +48,14 @@ sub MassPay {
for my $type ( sort keys %types ) { for my $type ( sort keys %types ) {
next unless $args{$type}; next unless $args{$type};
if ( $attr{$type} ) { if ( $attr{$type} ) {
push @masspay, SOAP::Data->name( $type => $args{$type} )->type($types{$type})->attr( { %{ $attr{$type} } } ); push @masspay,
SOAP::Data->name( $type => $args{$type} )
->type( $types{$type} )->attr( { %{ $attr{$type} } } );
} }
else { else {
push @masspay, SOAP::Data->name( $type => $args{$type} )->type($types{$type}); push @masspay,
SOAP::Data->name( $type => $args{$type} )
->type( $types{$type} );
} }
} }
@ -62,19 +72,25 @@ sub MassPay {
for my $type ( keys %mpi_type ) { for my $type ( keys %mpi_type ) {
next unless $mpi_type{$type}; next unless $mpi_type{$type};
if ( $attr{$type} ) { if ( $attr{$type} ) {
push @rcpt, SOAP::Data->name( $type => $rcpt->{$type} )->type($mpi_type{$type})->attr( { %{ $attr{$type} } } ); push @rcpt,
SOAP::Data->name( $type => $rcpt->{$type} )
->type( $mpi_type{$type} )->attr( { %{ $attr{$type} } } );
} }
else { else {
push @rcpt, SOAP::Data->name( $type => $rcpt->{$type} )->type($mpi_type{$type}); push @rcpt,
SOAP::Data->name( $type => $rcpt->{$type} )
->type( $mpi_type{$type} );
} }
} }
push @masspay, SOAP::Data->name( MassPayItem => \SOAP::Data->value( @rcpt ) )->type("ns:MassPayRequestItemType"); push @masspay,
SOAP::Data->name( MassPayItem => \SOAP::Data->value( @rcpt ) )
->type( "ns:MassPayRequestItemType" );
} }
my $request = SOAP::Data->name my $request
( MassPayRequest => \SOAP::Data->value( @masspay ) ) = SOAP::Data->name( MassPayRequest => \SOAP::Data->value( @masspay ) )
->type( "ns:MassPayRequestType" ); ->type( "ns:MassPayRequestType" );
my $som = $self->doCall( MassPayReq => $request ) my $som = $self->doCall( MassPayReq => $request )

View file

@ -14,25 +14,26 @@ sub DoReauthorizationRequest {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my %types = ( AuthorizationID => 'xs:string', my %types = (
Amount => 'ebl:BasicAmountType',); AuthorizationID => 'xs:string',
Amount => 'ebl:BasicAmountType',
);
$args{currencyID} ||= 'USD'; $args{currencyID} ||= 'USD';
my @ref_trans = my @ref_trans = (
($self->version_req, $self->version_req,
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )->type($types{AuthorizationID}),); SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )
->type( $types{AuthorizationID} ),
);
push @ref_trans, push @ref_trans,
SOAP::Data->name( Amount => $args{Amount} ) SOAP::Data->name( Amount => $args{Amount} )->type( $types{Amount} )
->type( $types{Amount} )
->attr( { currencyID => $args{currencyID} } ); ->attr( { currencyID => $args{currencyID} } );
my $request
= SOAP::Data->name(
my $request = SOAP::Data->name DoReauthorizationRequest => \SOAP::Data->value( @ref_trans ) )
( DoReauthorizationRequest => \SOAP::Data->value( @ref_trans ) )
->type( "ns:ReauthorizationRequestType" ); ->type( "ns:ReauthorizationRequestType" );
my $som = $self->doCall( DoReauthorizationReq => $request ) my $som = $self->doCall( DoReauthorizationReq => $request )
@ -46,9 +47,12 @@ sub DoReauthorizationRequest {
return %response; return %response;
} }
$self->getFields($som, $path, \%response, $self->getFields(
$som, $path,
\%response,
{ AuthorizationID => 'AuthorizationID', { AuthorizationID => 'AuthorizationID',
Amount => 'Amount', } Amount => 'Amount',
}
); );
return %response; return %response;

View file

@ -20,12 +20,15 @@ sub SetCustomerBillingAgreement {
my %args = @_; my %args = @_;
## billing agreement details type ## billing agreement details type
my %badtypes = ( BillingType => '', # 'ns:BillingCodeType', my %badtypes = (
BillingType => '', # 'ns:BillingCodeType',
BillingAgreementDescription => 'xs:string', BillingAgreementDescription => 'xs:string',
PaymentType => '', # 'ns:MerchantPullPaymentCodeType', PaymentType => '', # 'ns:MerchantPullPaymentCodeType',
BillingAgreementCustom => 'xs:string', ); BillingAgreementCustom => 'xs:string',
);
my %types = ( BillingAgreementDetails => 'ns:BillingAgreementDetailsType', my %types = (
BillingAgreementDetails => 'ns:BillingAgreementDetailsType',
ReturnURL => 'xs:string', ReturnURL => 'xs:string',
CancelURL => 'xs:string', CancelURL => 'xs:string',
LocaleCode => 'xs:string', LocaleCode => 'xs:string',
@ -35,7 +38,8 @@ sub SetCustomerBillingAgreement {
'cpp-header-back-color' => 'xs:string', 'cpp-header-back-color' => 'xs:string',
'cpp-payflow-color' => 'xs:string', 'cpp-payflow-color' => 'xs:string',
PaymentAction => '', PaymentAction => '',
BuyerEmail => 'ns:EmailAddressType', ); BuyerEmail => 'ns:EmailAddressType',
);
## set defaults ## set defaults
$args{BillingType} ||= 'RecurringPayments'; $args{BillingType} ||= 'RecurringPayments';
@ -45,20 +49,28 @@ sub SetCustomerBillingAgreement {
my @btypes = (); my @btypes = ();
for my $field ( keys %badtypes ) { for my $field ( keys %badtypes ) {
next unless $args{$field}; next unless $args{$field};
push @btypes, SOAP::Data->name( $field => $args{$field} )->type( $badtypes{$field} ); push @btypes,
SOAP::Data->name( $field => $args{$field} )
->type( $badtypes{$field} );
} }
my @scba = (); my @scba = ();
for my $field ( keys %types ) { for my $field ( keys %types ) {
next unless $args{$field}; next unless $args{$field};
push @scba, SOAP::Data->name( $field => $args{$field} )->type( $types{$field} ); push @scba,
SOAP::Data->name( $field => $args{$field} )
->type( $types{$field} );
} }
push @scba, SOAP::Data->name( BillingAgreementDetails => \SOAP::Data->value(@btypes) ); push @scba,
SOAP::Data->name(
BillingAgreementDetails => \SOAP::Data->value( @btypes ) );
my $request = SOAP::Data my $request = SOAP::Data->name(
->name( SetCustomerBillingAgreementRequest => \SOAP::Data->value SetCustomerBillingAgreementRequest => \SOAP::Data->value(
( $self->version_req, #$API_VERSION, $self->version_req, #$API_VERSION,
SOAP::Data->name( SetCustomerBillingAgreementRequestDetails => \SOAP::Data->value(@scba) SOAP::Data->name(
SetCustomerBillingAgreementRequestDetails =>
\SOAP::Data->value( @scba )
)->attr( { xmlns => $self->C_xmlns_ebay } ), )->attr( { xmlns => $self->C_xmlns_ebay } ),
) )
)->type( 'ns:SetCustomerBillingAgreementRequestDetailsType' ); )->type( 'ns:SetCustomerBillingAgreementRequestDetailsType' );
@ -83,15 +95,16 @@ sub GetBillingAgreementCustomerDetails {
my $self = shift; my $self = shift;
my $token = shift; my $token = shift;
my $request = SOAP::Data my $request = SOAP::Data->name(
->name( GetBillingAgreementCustomerDetailsRequest => \SOAP::Data->value GetBillingAgreementCustomerDetailsRequest => \SOAP::Data->value(
( $self->version_req, $self->version_req,
SOAP::Data->name( Token => $token ) SOAP::Data->name( Token => $token )->type( 'xs:string' )
->type('xs:string')->attr( {xmlns => $self->C_xmlns_ebay} ), ->attr( { xmlns => $self->C_xmlns_ebay } ),
) )
)->type( 'ns:GetBillingAgreementCustomerDetailsResponseType' ); )->type( 'ns:GetBillingAgreementCustomerDetailsResponseType' );
my $som = $self->doCall( GetBillingAgreementCustomerDetailsReq => $request ) my $som
= $self->doCall( GetBillingAgreementCustomerDetailsReq => $request )
or return; or return;
my $path = '/Envelope/Body/GetBillingAgreementCustomerDetailsResponse'; my $path = '/Envelope/Body/GetBillingAgreementCustomerDetailsResponse';
@ -102,7 +115,8 @@ sub GetBillingAgreementCustomerDetails {
return %details; return %details;
} }
$self->getFields($som, $self->getFields(
$som,
"$path/GetBillingAgreementCustomerDetailsResponseDetails", "$path/GetBillingAgreementCustomerDetailsResponseDetails",
\%details, \%details,
{ Token => 'Token', { Token => 'Token',
@ -126,7 +140,8 @@ sub GetBillingAgreementCustomerDetails {
MiddleName => 'PayerInfo/PayerName/MiddleName', MiddleName => 'PayerInfo/PayerName/MiddleName',
LastName => 'PayerInfo/PayerName/LastName', LastName => 'PayerInfo/PayerName/LastName',
Suffix => 'PayerInfo/PayerName/Suffix', Suffix => 'PayerInfo/PayerName/Suffix',
} ); }
);
return %details; return %details;
} }
@ -136,59 +151,74 @@ sub CreateRecurringPaymentsProfile {
my %args = @_; my %args = @_;
## RecurringPaymentProfileDetails ## RecurringPaymentProfileDetails
my %profiledetailstype = ( SubscriberName => 'xs:string', my %profiledetailstype = (
SubscriberName => 'xs:string',
SubscriberShipperAddress => 'ns:AddressType', SubscriberShipperAddress => 'ns:AddressType',
BillingStartDate => 'xs:dateTime', ## MM-DD-YY BillingStartDate => 'xs:dateTime', ## MM-DD-YY
ProfileReference => 'xs:string', ); ProfileReference => 'xs:string',
);
## ScheduleDetailsType ## ScheduleDetailsType
my %schedtype = ( Description => 'xs:string', my %schedtype = (
Description => 'xs:string',
ActivationDetails => 'ns:ActivationDetailsType', ActivationDetails => 'ns:ActivationDetailsType',
TrialPeriod => 'ns:BillingPeriodDetailsType', TrialPeriod => 'ns:BillingPeriodDetailsType',
PaymentPeriod => 'ns:BillingPeriodDetailsType', PaymentPeriod => 'ns:BillingPeriodDetailsType',
MaxFailedPayments => 'xs:int', MaxFailedPayments => 'xs:int',
AutoBillOutstandingAmount => 'ns:AutoBillType', ); ## NoAutoBill or AddToNextBilling AutoBillOutstandingAmount => 'ns:AutoBillType',
); ## NoAutoBill or AddToNextBilling
## activation details ## activation details
my %activationdetailstype = ( InitialAmount => 'cc:BasicAmountType', my %activationdetailstype = (
FailedInitialAmountAction => 'ns:FailedPaymentAction', ); ## ContinueOnFailure or CancelOnFailure InitialAmount => 'cc:BasicAmountType',
FailedInitialAmountAction => 'ns:FailedPaymentAction',
); ## ContinueOnFailure or CancelOnFailure
## BillingPeriodDetailsType ## BillingPeriodDetailsType
my %trialbilltype = ( TrialBillingPeriod => 'xs:string', ##'ns:BillingPeriodType', my %trialbilltype = (
TrialBillingPeriod => 'xs:string', ##'ns:BillingPeriodType',
TrialBillingFrequency => 'xs:int', TrialBillingFrequency => 'xs:int',
TrialTotalBillingCycles => 'xs:int', TrialTotalBillingCycles => 'xs:int',
TrialAmount => 'cc:AmountType', TrialAmount => 'cc:AmountType',
TrialShippingAmount => 'cc:AmountType', TrialShippingAmount => 'cc:AmountType',
TrialTaxAmount => 'cc:AmountType', ); TrialTaxAmount => 'cc:AmountType',
);
my %paymentbilltype = ( PaymentBillingPeriod => 'xs:string', ##'ns:BillingPeriodType', my %paymentbilltype = (
PaymentBillingPeriod => 'xs:string', ##'ns:BillingPeriodType',
PaymentBillingFrequency => 'xs:int', PaymentBillingFrequency => 'xs:int',
PaymentTotalBillingCycles => 'xs:int', PaymentTotalBillingCycles => 'xs:int',
PaymentAmount => 'cc:AmountType', PaymentAmount => 'cc:AmountType',
PaymentShippingAmount => 'cc:AmountType', PaymentShippingAmount => 'cc:AmountType',
PaymentTaxAmount => 'cc:AmountType', ); PaymentTaxAmount => 'cc:AmountType',
);
## AddressType ## AddressType
my %payaddrtype = ( CCPayerName => 'xs:string', my %payaddrtype = (
CCPayerName => 'xs:string',
CCPayerStreet1 => 'xs:string', CCPayerStreet1 => 'xs:string',
CCPayerStreet2 => 'xs:string', CCPayerStreet2 => 'xs:string',
CCPayerCityName => 'xs:string', CCPayerCityName => 'xs:string',
CCPayerStateOrProvince => 'xs:string', CCPayerStateOrProvince => 'xs:string',
CCPayerCountry => 'xs:string', ## ebl:CountryCodeType CCPayerCountry => 'xs:string', ## ebl:CountryCodeType
CCPayerPostalCode => 'xs:string', CCPayerPostalCode => 'xs:string',
CCPayerPhone => 'xs:string', ); CCPayerPhone => 'xs:string',
);
my %shipaddrtype = ( SubscriberShipperName => 'xs:string', my %shipaddrtype = (
SubscriberShipperName => 'xs:string',
SubscriberShipperStreet1 => 'xs:string', SubscriberShipperStreet1 => 'xs:string',
SubscriberShipperStreet2 => 'xs:string', SubscriberShipperStreet2 => 'xs:string',
SubscriberShipperCityName => 'xs:string', SubscriberShipperCityName => 'xs:string',
SubscriberShipperStateOrProvince => 'xs:string', SubscriberShipperStateOrProvince => 'xs:string',
SubscriberShipperCountry => 'xs:string', ## ebl:CountryCodeType SubscriberShipperCountry => 'xs:string', ## ebl:CountryCodeType
SubscriberShipperPostalCode => 'xs:string', SubscriberShipperPostalCode => 'xs:string',
SubscriberShipperPhone => 'xs:string', ); SubscriberShipperPhone => 'xs:string',
);
## credit card payer ## credit card payer
my %payerinfotype = ( CCPayer => 'ns:EmailAddressType', my %payerinfotype = (
CCPayer => 'ns:EmailAddressType',
CCPayerID => 'ebl:UserIDType', CCPayerID => 'ebl:UserIDType',
CCPayerStatus => 'xs:string', CCPayerStatus => 'xs:string',
CCPayerName => 'xs:string', CCPayerName => 'xs:string',
@ -199,22 +229,27 @@ sub CreateRecurringPaymentsProfile {
); );
## credit card details ## credit card details
my %creditcarddetailstype = ( CardOwner => 'ns:PayerInfoType', my %creditcarddetailstype = (
CreditCardType => 'ebl:CreditCardType', ## Visa, MasterCard, Discover, Amex, Switch, Solo CardOwner => 'ns:PayerInfoType',
CreditCardType => 'ebl:CreditCardType'
, ## Visa, MasterCard, Discover, Amex, Switch, Solo
CreditCardNumber => 'xs:string', CreditCardNumber => 'xs:string',
ExpMonth => 'xs:int', ExpMonth => 'xs:int',
ExpYear => 'xs:int', ExpYear => 'xs:int',
CVV2 => 'xs:string', CVV2 => 'xs:string',
StartMonth => 'xs:string', StartMonth => 'xs:string',
StartYear => 'xs:string', StartYear => 'xs:string',
IssueNumber => 'xs:int', ); IssueNumber => 'xs:int',
);
## this gets pushed onto scheduledetails ## this gets pushed onto scheduledetails
my @activationdetailstype = (); my @activationdetailstype = ();
for my $field ( keys %activationdetailstype ) { for my $field ( keys %activationdetailstype ) {
next unless exists $args{$field}; next unless exists $args{$field};
my $real_field = $field; my $real_field = $field;
push @activationdetailstype, SOAP::Data->name( $real_field => $args{$field} )->type( $activationdetailstype{$field} ); push @activationdetailstype,
SOAP::Data->name( $real_field => $args{$field} )
->type( $activationdetailstype{$field} );
} }
## this gets pushed onto scheduledetails ## this gets pushed onto scheduledetails
@ -222,7 +257,9 @@ sub CreateRecurringPaymentsProfile {
for my $field ( keys %trialbilltype ) { for my $field ( keys %trialbilltype ) {
next unless exists $args{$field}; next unless exists $args{$field};
( my $real_field = $field ) =~ s/^Trial//; ( my $real_field = $field ) =~ s/^Trial//;
push @trialbilltype, SOAP::Data->name( $real_field => $args{$field} )->type( $trialbilltype{$field} ); push @trialbilltype,
SOAP::Data->name( $real_field => $args{$field} )
->type( $trialbilltype{$field} );
} }
## this gets pushed onto scheduledetails ## this gets pushed onto scheduledetails
@ -230,24 +267,36 @@ sub CreateRecurringPaymentsProfile {
for my $field ( keys %paymentbilltype ) { for my $field ( keys %paymentbilltype ) {
next unless exists $args{$field}; next unless exists $args{$field};
( my $real_field = $field ) =~ s/^Payment//; ( my $real_field = $field ) =~ s/^Payment//;
push @paymentbilltype, SOAP::Data->name( $real_field => $args{$field} )->type( $paymentbilltype{$field} ); push @paymentbilltype,
SOAP::Data->name( $real_field => $args{$field} )
->type( $paymentbilltype{$field} );
} }
## this gets pushed onto the top ## this gets pushed onto the top
my @sched = (); my @sched = ();
for my $field ( keys %schedtype ) { for my $field ( keys %schedtype ) {
next unless exists $args{$field}; next unless exists $args{$field};
push @sched, SOAP::Data->name( $field => $args{$field} )->type( $schedtype{$field} ); push @sched,
SOAP::Data->name( $field => $args{$field} )
->type( $schedtype{$field} );
} }
push @sched, SOAP::Data->name( TrialPeriod => \SOAP::Data->value(@trialbilltype) ); #->type( 'ns:BillingPeriodDetailsType' ); push @sched,
push @sched, SOAP::Data->name( PaymentPeriod => \SOAP::Data->value(@paymentbilltype) ); #->type( 'ns:BillingPeriodDetailsType' ); SOAP::Data->name(
TrialPeriod => \SOAP::Data->value( @trialbilltype ) )
; #->type( 'ns:BillingPeriodDetailsType' );
push @sched,
SOAP::Data->name(
PaymentPeriod => \SOAP::Data->value( @paymentbilltype ) )
; #->type( 'ns:BillingPeriodDetailsType' );
## this gets pushed into profile details ## this gets pushed into profile details
my @shipaddr = (); my @shipaddr = ();
for my $field ( keys %shipaddrtype ) { for my $field ( keys %shipaddrtype ) {
next unless exists $args{$field}; next unless exists $args{$field};
( my $real_field = $field ) =~ s/^SubscriberShipper//; ( my $real_field = $field ) =~ s/^SubscriberShipper//;
push @shipaddr, SOAP::Data->name( $real_field => $args{$field} )->type( $shipaddrtype{$field} ); push @shipaddr,
SOAP::Data->name( $real_field => $args{$field} )
->type( $shipaddrtype{$field} );
} }
## this gets pushed into payerinfo (from creditcarddetails) ## this gets pushed into payerinfo (from creditcarddetails)
@ -255,7 +304,9 @@ sub CreateRecurringPaymentsProfile {
for my $field ( keys %payaddrtype ) { for my $field ( keys %payaddrtype ) {
next unless $args{$field}; next unless $args{$field};
( my $real_field = $field ) =~ s/^CCPayer//; ( my $real_field = $field ) =~ s/^CCPayer//;
push @payeraddr, SOAP::Data->name( $real_field => $args{$field} )->type( payaddrtype{$field} ); push @payeraddr,
SOAP::Data->name( $real_field => $args{$field} )
->type( payaddrtype {$field} );
} }
## credit card type ## credit card type
@ -263,29 +314,47 @@ sub CreateRecurringPaymentsProfile {
for my $field ( keys %creditcarddetailstype ) { for my $field ( keys %creditcarddetailstype ) {
next unless $args{$field}; next unless $args{$field};
( my $real_field = $field ) =~ s/^CC//; ( my $real_field = $field ) =~ s/^CC//;
push @payeraddr, SOAP::Data->name( $real_field => $args{$field} )->type( payaddrtype{$field} ); push @payeraddr,
SOAP::Data->name( $real_field => $args{$field} )
->type( payaddrtype {$field} );
} }
## this gets pushed onto the top ## this gets pushed onto the top
my @profdetail = (); my @profdetail = ();
for my $field ( keys %profiledetailstype ) { for my $field ( keys %profiledetailstype ) {
next unless exists $args{$field}; next unless exists $args{$field};
push @profdetail, SOAP::Data->name( $field => $args{$field} )->type( $profiledetailstype{$field} ); push @profdetail,
SOAP::Data->name( $field => $args{$field} )
->type( $profiledetailstype{$field} );
} }
push @profdetail, SOAP::Data->name( SubscriberShipperAddress => \SOAP::Data->value(@shipaddr) ); push @profdetail,
SOAP::Data->name(
SubscriberShipperAddress => \SOAP::Data->value( @shipaddr ) );
## crappard? ## crappard?
my @crpprd = (); my @crpprd = ();
push @crpprd, SOAP::Data->name( Token => $args{Token} ); push @crpprd, SOAP::Data->name( Token => $args{Token} );
push @crpprd, SOAP::Data->name( CreditCardDetails => \SOAP::Data->value(@creditcarddetails) ); #->type( 'ns:CreditCardDetailsType' ); push @crpprd,
push @crpprd, SOAP::Data->name( RecurringPaymentProfileDetails => \SOAP::Data->value(@profdetail) ); #->type( 'ns:RecurringPaymentProfileDetailsType' ); SOAP::Data->name(
push @crpprd, SOAP::Data->name( ScheduleDetails => \SOAP::Data->value(@sched) ); #->type( 'ns:ScheduleDetailsType' ); CreditCardDetails => \SOAP::Data->value( @creditcarddetails ) )
; #->type( 'ns:CreditCardDetailsType' );
push @crpprd,
SOAP::Data->name(
RecurringPaymentProfileDetails => \SOAP::Data->value( @profdetail ) )
; #->type( 'ns:RecurringPaymentProfileDetailsType' );
push @crpprd,
SOAP::Data->name( ScheduleDetails => \SOAP::Data->value( @sched ) )
; #->type( 'ns:ScheduleDetailsType' );
my $request = SOAP::Data->name(
CreateRecurringPaymentsProfileRequest => \SOAP::Data->value
my $request = SOAP::Data->name
( CreateRecurringPaymentsProfileRequest => \SOAP::Data->value
# ( $API_VERSION, # ( $API_VERSION,
( $self->version_req, (
SOAP::Data->name( CreateRecurringPaymentsProfileRequestDetails => \SOAP::Data->value(@crpprd) $self->version_req,
SOAP::Data->name(
CreateRecurringPaymentsProfileRequestDetails =>
\SOAP::Data->value( @crpprd )
)->attr( { xmlns => $self->C_xmlns_ebay } ) )->attr( { xmlns => $self->C_xmlns_ebay } )
) )
); #->type( 'ns:CreateRecurringPaymentsProfileRequestType' ); ); #->type( 'ns:CreateRecurringPaymentsProfileRequestType' );
@ -310,13 +379,15 @@ sub DoReferenceTransaction {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my %types = ( ReferenceID => 'xs:string', my %types = (
ReferenceID => 'xs:string',
PaymentAction => '', ## NOTA BENE! PaymentAction => '', ## NOTA BENE!
currencyID => '', currencyID => '',
); );
## PaymentDetails ## PaymentDetails
my %pd_types = ( OrderTotal => 'ebl:BasicAmountType', my %pd_types = (
OrderTotal => 'ebl:BasicAmountType',
OrderDescription => 'xs:string', OrderDescription => 'xs:string',
ItemTotal => 'ebl:BasicAmountType', ItemTotal => 'ebl:BasicAmountType',
ShippingTotal => 'ebl:BasicAmountType', ShippingTotal => 'ebl:BasicAmountType',
@ -329,7 +400,8 @@ sub DoReferenceTransaction {
); );
## ShipToAddress ## ShipToAddress
my %st_types = ( ST_Name => 'xs:string', my %st_types = (
ST_Name => 'xs:string',
ST_Street1 => 'xs:string', ST_Street1 => 'xs:string',
ST_Street2 => 'xs:string', ST_Street2 => 'xs:string',
ST_CityName => 'xs:string', ST_CityName => 'xs:string',
@ -340,7 +412,8 @@ sub DoReferenceTransaction {
); );
##PaymentDetailsItem ##PaymentDetailsItem
my %pdi_types = ( PDI_Name => 'xs:string', my %pdi_types = (
PDI_Name => 'xs:string',
PDI_Description => 'xs:string', PDI_Description => 'xs:string',
PDI_Amount => 'ebl:BasicAmountType', PDI_Amount => 'ebl:BasicAmountType',
PDI_Number => 'xs:string', PDI_Number => 'xs:string',
@ -354,10 +427,13 @@ sub DoReferenceTransaction {
my @payment_details = (); my @payment_details = ();
## push OrderTotal here and delete it (i.e., and all others that have special attrs) ## push OrderTotal here and delete it (i.e., and all others that have special attrs)
push @payment_details, SOAP::Data->name( OrderTotal => $args{OrderTotal} ) push @payment_details,
->type( $pd_types{OrderTotal} ) SOAP::Data->name( OrderTotal => $args{OrderTotal} )
->attr( { currencyID => $args{currencyID}, ->type( $pd_types{OrderTotal} )->attr(
xmlns => $self->C_xmlns_ebay } ); { currencyID => $args{currencyID},
xmlns => $self->C_xmlns_ebay
}
);
## don't process it again ## don't process it again
delete $pd_types{OrderTotal}; delete $pd_types{OrderTotal};
@ -385,10 +461,9 @@ sub DoReferenceTransaction {
if ( scalar @ship_types ) { if ( scalar @ship_types ) {
push @payment_details, push @payment_details,
SOAP::Data->name( ShipToAddress => \SOAP::Data->value SOAP::Data->name( ShipToAddress =>
( @ship_types )->type('ebl:AddressType') \SOAP::Data->value( @ship_types )->type( 'ebl:AddressType' )
->attr( {xmlns => $self->C_xmlns_ebay} ), ->attr( { xmlns => $self->C_xmlns_ebay } ), );
);
} }
## ##
@ -406,10 +481,10 @@ sub DoReferenceTransaction {
if ( scalar @payment_details_item ) { if ( scalar @payment_details_item ) {
push @payment_details, push @payment_details,
SOAP::Data->name( PaymentDetailsItem => \SOAP::Data->value SOAP::Data->name(
( @payment_details_item )->type('ebl:PaymentDetailsItemType') PaymentDetailsItem => \SOAP::Data->value( @payment_details_item )
->attr( {xmlns => $self->C_xmlns_ebay} ), ->type( 'ebl:PaymentDetailsItemType' )
); ->attr( { xmlns => $self->C_xmlns_ebay } ), );
} }
## ##
@ -417,22 +492,28 @@ sub DoReferenceTransaction {
## ##
my @reference_details = ( my @reference_details = (
SOAP::Data->name( ReferenceID => $args{ReferenceID} ) SOAP::Data->name( ReferenceID => $args{ReferenceID} )
->type($types{ReferenceID})->attr( {xmlns => $self->C_xmlns_ebay} ), ->type( $types{ReferenceID} )
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 } ), ->attr( { xmlns => $self->C_xmlns_ebay } ),
), ); SOAP::Data->name( PaymentAction => $args{PaymentAction} )
->type( $types{PaymentAction} )
->attr( { xmlns => $self->C_xmlns_ebay } ),
SOAP::Data->name(
PaymentDetails => \SOAP::Data->value( @payment_details )
->type( 'ebl:PaymentDetailsType' )
->attr( { xmlns => $self->C_xmlns_ebay } ),
),
);
## ##
## the main request object ## the main request object
## ##
my $request = SOAP::Data my $request = SOAP::Data->name(
->name( DoReferenceTransactionRequest => \SOAP::Data->value DoReferenceTransactionRequest => \SOAP::Data->value(
( $self->version_req, $self->version_req,
SOAP::Data->name( DoReferenceTransactionRequestDetails => \SOAP::Data->value SOAP::Data->name(
( @reference_details )->type( 'ns:DoReferenceTransactionRequestDetailsType' ) DoReferenceTransactionRequestDetails =>
\SOAP::Data->value( @reference_details )
->type( 'ns:DoReferenceTransactionRequestDetailsType' )
)->attr( { xmlns => $self->C_xmlns_ebay } ), )->attr( { xmlns => $self->C_xmlns_ebay } ),
) )
); );
@ -448,7 +529,8 @@ sub DoReferenceTransaction {
return %response; return %response;
} }
$self->getFields( $som, $self->getFields(
$som,
"$path/DoReferenceTransactionResponseDetails", "$path/DoReferenceTransactionResponseDetails",
\%response, \%response,
{ BillingAgreementID => 'BillingAgreementID', { BillingAgreementID => 'BillingAgreementID',
@ -464,7 +546,8 @@ sub DoReferenceTransaction {
PaymentStatus => 'PaymentInfo/PaymentStatus', PaymentStatus => 'PaymentInfo/PaymentStatus',
PendingReason => 'PaymentInfo/PendingReason', PendingReason => 'PaymentInfo/PendingReason',
ReasonCode => 'PaymentInfor/ReasonCode', ReasonCode => 'PaymentInfor/ReasonCode',
} ); }
);
return %response; return %response;
} }

View file

@ -14,34 +14,38 @@ sub RefundTransaction {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my %types = ( TransactionID => 'xs:string', my %types = (
TransactionID => 'xs:string',
RefundType => '', ## Other | Full | Partial RefundType => '', ## Other | Full | Partial
Amount => 'ebl:BasicAmountType', Amount => 'ebl:BasicAmountType',
Memo => 'xs:string', ); Memo => 'xs:string',
);
$args{currencyID} ||= 'USD'; $args{currencyID} ||= 'USD';
$args{RefundType} ||= 'Full'; $args{RefundType} ||= 'Full';
my @ref_trans = my @ref_trans = (
(
$self->version_req, $self->version_req,
SOAP::Data->name( TransactionID => $args{TransactionID} )->type($types{TransactionID}), SOAP::Data->name( TransactionID => $args{TransactionID} )
SOAP::Data->name( RefundType => $args{RefundType} )->type($types{RefundType}), ->type( $types{TransactionID} ),
SOAP::Data->name( RefundType => $args{RefundType} )
->type( $types{RefundType} ),
); );
if ( $args{RefundType} ne 'Full' && $args{Amount} ) { if ( $args{RefundType} ne 'Full' && $args{Amount} ) {
push @ref_trans, push @ref_trans,
SOAP::Data->name( Amount => $args{Amount} ) SOAP::Data->name( Amount => $args{Amount} )
->type( $types{Amount} ) ->type( $types{Amount} )
->attr( { currencyID => $args{currencyID} } ) ->attr( { currencyID => $args{currencyID} } );
} }
push @ref_trans, push @ref_trans,
SOAP::Data->name( Memo => $args{Memo} )->type( $types{Memo} ) SOAP::Data->name( Memo => $args{Memo} )->type( $types{Memo} )
if $args{Memo}; if $args{Memo};
my $request = SOAP::Data->name my $request
( RefundTransactionRequest => \SOAP::Data->value( @ref_trans ) ) = SOAP::Data->name(
RefundTransactionRequest => \SOAP::Data->value( @ref_trans ) )
->type( "ns:RefundTransactionRequestType" ); ->type( "ns:RefundTransactionRequestType" );
my $som = $self->doCall( RefundTransactionReq => $request ) my $som = $self->doCall( RefundTransactionReq => $request )
@ -55,11 +59,14 @@ sub RefundTransaction {
return %response; return %response;
} }
$self->getFields($som, $path, \%response, $self->getFields(
$som, $path,
\%response,
{ RefundTransactionID => 'RefundTransactionID', { RefundTransactionID => 'RefundTransactionID',
FeeRefundAmount => 'FeeRefundAmount', FeeRefundAmount => 'FeeRefundAmount',
NetRefundAmount => 'NetRefundAmount', NetRefundAmount => 'NetRefundAmount',
GrossRefundAmount => 'GrossRefundAmount', } GrossRefundAmount => 'GrossRefundAmount',
}
); );
return %response; return %response;

View file

@ -14,7 +14,8 @@ sub TransactionSearch {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my %types = ( StartDate => 'xs:dateTime', my %types = (
StartDate => 'xs:dateTime',
EndDate => 'xs:dateTime', EndDate => 'xs:dateTime',
Payer => 'ebl:EmailAddressType', Payer => 'ebl:EmailAddressType',
Receiver => 'ebl:EmailAddressType', Receiver => 'ebl:EmailAddressType',
@ -29,19 +30,21 @@ sub TransactionSearch {
Status => '', Status => '',
); );
my @trans = my @trans = (
(
$self->version_req, $self->version_req,
SOAP::Data->name( StartDate => $args{StartDate} )->type( delete $types{StartDate} ) SOAP::Data->name( StartDate => $args{StartDate} )
->type( delete $types{StartDate} )
); );
for my $type ( keys %types ) { for my $type ( keys %types ) {
next unless $args{$type}; next unless $args{$type};
push @trans, SOAP::Data->name( $type => $args{$type} )->type($types{$type}); push @trans,
SOAP::Data->name( $type => $args{$type} )->type( $types{$type} );
} }
my $request = SOAP::Data->name my $request
( TransactionSearchRequest => \SOAP::Data->value( @trans ) ) = SOAP::Data->name(
TransactionSearchRequest => \SOAP::Data->value( @trans ) )
->type( "ns:TransactionSearchRequestType" ); ->type( "ns:TransactionSearchRequestType" );
my $som = $self->doCall( TransactionSearchReq => $request ) my $som = $self->doCall( TransactionSearchReq => $request )
@ -55,7 +58,9 @@ sub TransactionSearch {
return %response; return %response;
} }
return $self->getFieldsList( $som, $path . '/PaymentTransactions', return $self->getFieldsList(
$som,
$path . '/PaymentTransactions',
{ Timestamp => 'Timestamp', { Timestamp => 'Timestamp',
Timezone => 'Timezone', Timezone => 'Timezone',
Type => 'Type', Type => 'Type',
@ -66,7 +71,8 @@ sub TransactionSearch {
GrossAmount => 'GrossAmount', GrossAmount => 'GrossAmount',
FeeAmount => 'FeeAmount', FeeAmount => 'FeeAmount',
NetAmount => 'NetAmount', NetAmount => 'NetAmount',
} ); }
);
} }
1; 1;

View file

@ -14,14 +14,15 @@ sub DoVoidRequest {
my $self = shift; my $self = shift;
my %args = @_; my %args = @_;
my %types = ( AuthorizationID => 'xs:string', my %types = (
Note => 'xs:string', ); AuthorizationID => 'xs:string',
Note => 'xs:string',
);
my @ref_trans = (
my @ref_trans =
(
$self->version_req, $self->version_req,
SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )->type($types{AuthorizationID}), SOAP::Data->name( AuthorizationID => $args{AuthorizationID} )
->type( $types{AuthorizationID} ),
); );
if ( $args{Note} ) { if ( $args{Note} ) {
@ -29,8 +30,9 @@ sub DoVoidRequest {
SOAP::Data->name( Note => $args{Note} )->type( $types{Note} ) SOAP::Data->name( Note => $args{Note} )->type( $types{Note} )
if $args{Note}; if $args{Note};
} }
my $request = SOAP::Data->name my $request
( DoVoidRequest => \SOAP::Data->value( @ref_trans ) ) = SOAP::Data->name(
DoVoidRequest => \SOAP::Data->value( @ref_trans ) )
->type( "ns:VoidRequestType" ); ->type( "ns:VoidRequestType" );
my $som = $self->doCall( DoVoidReq => $request ) my $som = $self->doCall( DoVoidReq => $request )
@ -45,8 +47,7 @@ sub DoVoidRequest {
} }
$self->getFields( $som, $path, \%response, $self->getFields( $som, $path, \%response,
{ AuthorizationID => 'AuthorizationID' } { AuthorizationID => 'AuthorizationID' } );
);
return %response; return %response;
} }

View file

@ -1,3 +1,4 @@
=pod =pod
The tester must supply their own PayPal sandbox seller authentication The tester must supply their own PayPal sandbox seller authentication
@ -14,7 +15,8 @@ variable:
sub do_args { sub do_args {
unless ( $ENV{WPP_TEST} && -f $ENV{WPP_TEST} ) { unless ( $ENV{WPP_TEST} && -f $ENV{WPP_TEST} ) {
die "See the TESTING section in `perldoc Business::PayPal::API documentation`\n"; die
"See the TESTING section in `perldoc Business::PayPal::API documentation`\n";
exit; exit;
} }

View file

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

View file

@ -4,15 +4,18 @@ use warnings;
use Test::More; use Test::More;
if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) { if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests'; plan skip_all =>
'No WPP_TEST env var set. Please see README to run tests';
} }
else { else {
plan tests => '7'; plan tests => '7';
} }
use Business::PayPal::API qw( DirectPayments CaptureRequest ReauthorizationRequest VoidRequest RefundTransaction ); use Business::PayPal::API
qw( DirectPayments CaptureRequest ReauthorizationRequest VoidRequest RefundTransaction );
my @methlist = qw( DirectPayments CaptureRequest ReauthorizationRequest VoidRequest RefundTransaction); my @methlist
= qw( DirectPayments CaptureRequest ReauthorizationRequest VoidRequest RefundTransaction);
use_ok( 'Business::PayPal::API', @methlist ); use_ok( 'Business::PayPal::API', @methlist );
require 't/API.pl'; require 't/API.pl';
@ -21,7 +24,9 @@ my %args = do_args();
my ( $transale, $tranvoid, $tranbasic, $tranrefund ); my ( $transale, $tranvoid, $tranbasic, $tranrefund );
my ( $ppsale, $ppvoid, $ppbasic, $pprefund, $pprefund1, $ppcap, $ppcap1 ); my ( $ppsale, $ppvoid, $ppbasic, $pprefund, $pprefund1, $ppcap, $ppcap1 );
my (%respsale,%resprefund,%resprefund1,%respbasic,%respcap,%respcap1,%respvoid); my (%respsale, %resprefund, %resprefund1, %respbasic,
%respcap, %respcap1, %respvoid
);
#Test Full Refund on Sale #Test Full Refund on Sale
@ -50,9 +55,11 @@ $ppsale = new Business::PayPal::API(%args);
IPAddress => '10.0.0.1', IPAddress => '10.0.0.1',
MerchantSessionID => '10113301', MerchantSessionID => '10113301',
); );
#$Business::PayPal::API::Debug=0; #$Business::PayPal::API::Debug=0;
if ( like( $respsale{'Ack'}, qr/Success/, 'Direct Payment Sale' ) ) { if ( like( $respsale{'Ack'}, qr/Success/, 'Direct Payment Sale' ) ) {
$transale = $respsale{'TransactionID'}; $transale = $respsale{'TransactionID'};
#$Business::PayPal::API::Debug=1; #$Business::PayPal::API::Debug=1;
$pprefund = new Business::PayPal::API( %args ); $pprefund = new Business::PayPal::API( %args );
%resprefund = $pprefund->RefundTransaction( %resprefund = $pprefund->RefundTransaction(
@ -60,6 +67,7 @@ if(like( $respsale{'Ack'}, qr/Success/, 'Direct Payment Sale')) {
RefundType => 'Full', RefundType => 'Full',
Memo => 'Full direct sale refund', Memo => 'Full direct sale refund',
); );
#$Business::PayPal::API::Debug=0; #$Business::PayPal::API::Debug=0;
like( $resprefund{'Ack'}, qr/Success/, 'Full Refund For Sale' ); like( $resprefund{'Ack'}, qr/Success/, 'Full Refund For Sale' );
} }
@ -67,6 +75,7 @@ if(like( $respsale{'Ack'}, qr/Success/, 'Direct Payment Sale')) {
#Basic Authorization and Capture #Basic Authorization and Capture
%args = do_args(); %args = do_args();
#$Business::PayPal::API::Debug=0; #$Business::PayPal::API::Debug=0;
$ppbasic = new Business::PayPal::API( %args ); $ppbasic = new Business::PayPal::API( %args );
%respbasic = $ppbasic->DoDirectPaymentRequest( %respbasic = $ppbasic->DoDirectPaymentRequest(
@ -94,7 +103,12 @@ $ppbasic = new Business::PayPal::API(%args);
); );
#$Business::PayPal::API::Debug=0; #$Business::PayPal::API::Debug=0;
if( like( $respbasic{'Ack'}, qr/Success/, 'Direct Payment Basic Authorization') ) { if (like(
$respbasic{'Ack'}, qr/Success/,
'Direct Payment Basic Authorization'
)
)
{
$tranbasic = $respbasic{'TransactionID'}; $tranbasic = $respbasic{'TransactionID'};
#Test Partial Capture #Test Partial Capture
@ -107,6 +121,7 @@ if( like( $respbasic{'Ack'}, qr/Success/, 'Direct Payment Basic Authorization')
Amount => '3.00', Amount => '3.00',
Note => 'Partial Capture', Note => 'Partial Capture',
); );
#$Business::PayPal::API::Debug=0; #$Business::PayPal::API::Debug=0;
like( $respcap{'Ack'}, qr/Success/, 'Partial Capture' ); like( $respcap{'Ack'}, qr/Success/, 'Partial Capture' );
@ -118,12 +133,12 @@ if( like( $respbasic{'Ack'}, qr/Success/, 'Direct Payment Basic Authorization')
CompleteType => 'Complete', CompleteType => 'Complete',
Amount => '6.00', Amount => '6.00',
); );
#$Business::PayPal::API::Debug=0; #$Business::PayPal::API::Debug=0;
like( $respcap1{'Ack'}, qr/Success/, 'Full Capture' ); like( $respcap1{'Ack'}, qr/Success/, 'Full Capture' );
} }
else { skip( "direct payment auth failed", 2 ) } else { skip( "direct payment auth failed", 2 ) }
#Test Void #Test Void
$ppbasic = new Business::PayPal::API( %args ); $ppbasic = new Business::PayPal::API( %args );
%respbasic = $ppbasic->DoDirectPaymentRequest( %respbasic = $ppbasic->DoDirectPaymentRequest(
@ -152,7 +167,10 @@ $ppbasic = new Business::PayPal::API(%args);
#$Business::PayPal::API::Debug=1; #$Business::PayPal::API::Debug=1;
$ppvoid = new Business::PayPal::API( %args ); $ppvoid = new Business::PayPal::API( %args );
%respvoid = $ppvoid->DoVoidRequest ( AuthorizationID => $respbasic{TransactionID}, %respvoid = $ppvoid->DoVoidRequest(
Note => 'Authorization Void', ); AuthorizationID => $respbasic{TransactionID},
Note => 'Authorization Void',
);
#$Business::PayPal::API::Debug=0; #$Business::PayPal::API::Debug=0;
like( $respvoid{'Ack'}, qr/Success/, 'Authorization Voided' ); like( $respvoid{'Ack'}, qr/Success/, 'Authorization Voided' );

View file

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

View file

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

View file

@ -1,6 +1,7 @@
use Test::More; use Test::More;
if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) { if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests'; plan skip_all =>
'No WPP_TEST env var set. Please see README to run tests';
} }
else { else {
plan tests => 2; plan tests => 2;
@ -34,7 +35,8 @@ _TRANSID_
print STDERR "\nType or paste that Transaction ID here and hit Enter: \n"; print STDERR "\nType or paste that Transaction ID here and hit Enter: \n";
my $transid = <STDIN>; chomp $transid; my $transid = <STDIN>;
chomp $transid;
die "Need a transaction id.\n" unless $transid; die "Need a transaction id.\n" unless $transid;

View file

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

View file

@ -1,7 +1,8 @@
# -*- mode: cperl -*- # -*- mode: cperl -*-
use Test::More; use Test::More;
if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) { if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
plan skip_all => 'No WPP_TEST env var set. Please see README to run tests'; plan skip_all =>
'No WPP_TEST env var set. Please see README to run tests';
} }
else { else {
plan tests => 3; plan tests => 3;
@ -17,14 +18,14 @@ my %args = do_args();
my $pp = new Business::PayPal::API::RecurringPayments( %args ); my $pp = new Business::PayPal::API::RecurringPayments( %args );
#$Business::PayPal::API::Debug = 1; #$Business::PayPal::API::Debug = 1;
my %response = $pp->SetCustomerBillingAgreement my %response = $pp->SetCustomerBillingAgreement(
(
BillingType => 'RecurringPayments', BillingType => 'RecurringPayments',
BillingAgreementDescription => '10.00 per month for 1 year', BillingAgreementDescription => '10.00 per month for 1 year',
ReturnURL => 'http://www.google.com/', ReturnURL => 'http://www.google.com/',
CancelURL => 'http://www.google.com/', CancelURL => 'http://www.google.com/',
BuyerEmail => $args{BuyerEmail}, BuyerEmail => $args{BuyerEmail},
); );
#$Business::PayPal::API::Debug = 0; #$Business::PayPal::API::Debug = 0;
my $token = $response{Token}; my $token = $response{Token};
@ -34,11 +35,12 @@ like( $response{Ack}, qr/Success/ , "SetCustomerBillingAgreement successful" );
exit; exit;
die "No token from PayPal! Check your authentication information and try again." die
"No token from PayPal! Check your authentication information and try again."
unless $token; unless $token;
my $pp_url
my $pp_url = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_customer-billing-agreement&token=$token"; = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_customer-billing-agreement&token=$token";
=pod =pod
@ -68,11 +70,10 @@ die "Need a PayerID.\n" unless $payerid;
=cut =cut
## CreateRecurringPaymentsProfile ## CreateRecurringPaymentsProfile
#$Business::PayPal::API::Debug = 1; #$Business::PayPal::API::Debug = 1;
my %profile = $pp->CreateRecurringPaymentsProfile my %profile = $pp->CreateRecurringPaymentsProfile(
( Token => $token, Token => $token,
## RecurringPaymentProfileDetails ## RecurringPaymentProfileDetails
SubscriberName => 'Joe Schmoe', SubscriberName => 'Joe Schmoe',
@ -113,10 +114,10 @@ my %profile = $pp->CreateRecurringPaymentsProfile
#$Business::PayPal::API::Debug = 0; #$Business::PayPal::API::Debug = 0;
## GetBillingAgreementCustomerDetails ## GetBillingAgreementCustomerDetails
#$Business::PayPal::API::Debug = 1; #$Business::PayPal::API::Debug = 1;
my %details = $pp->GetBillingAgreementCustomerDetails( $token ); my %details = $pp->GetBillingAgreementCustomerDetails( $token );
#$Business::PayPal::API::Debug = 0; #$Business::PayPal::API::Debug = 0;
like( $details{Ack}, qr/Success/, "details ok" ); like( $details{Ack}, qr/Success/, "details ok" );

View file

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

View file

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