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-*
auth.txt
blib
perltidy.LOG
pm_to_blib

View file

@ -45,8 +45,11 @@ sub import {
## 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 };
}
}
}
@ -69,23 +72,31 @@ sub new {
$H_CertFile{$self} = $args{CertFile} || '';
$H_KeyFile{$self} = $args{KeyFile} || '';
my $proxy = ($args{sandbox}
my $proxy = (
$args{sandbox}
? ( $args{Signature}
? C_api_sandbox_3t
: C_api_sandbox)
: 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(''),
$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 } )
@ -111,26 +122,33 @@ sub DESTROY {
}
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";
print STDERR SOAP::Serializer->envelope(
method => $method,
$Header{$self}, $request
),
"\n";
}
# $Soap{$self}->readable( $Debug );
@ -155,7 +173,8 @@ sub doCall {
}
if ( ref( $som ) && $som->fault ) {
carp "Fault: " . $som->faultstring
carp "Fault: "
. $som->faultstring
. ( $som->faultdetail ? " (" . $som->faultdetail . ")" : '' )
. "\n";
return;
@ -182,7 +201,8 @@ sub getFieldsList {
if ( defined $response{TransactionID} ) {
if ( $trans_id{ $response{TransactionID} } ) {
next;
} else {
}
else {
$trans_id{ $response{TransactionID} } = 1;
}
}
@ -259,8 +279,11 @@ sub getErrors {
my @errors = ();
for my $enode ( $som->valueof( "$path/Errors" ) ) {
push @errors, { LongMessage => $enode->{LongMessage},
ErrorCode => $enode->{ErrorCode}, };
push @errors,
{
LongMessage => $enode->{LongMessage},
ErrorCode => $enode->{ErrorCode},
};
}
$details->{Errors} = \@errors;

View file

@ -5,6 +5,7 @@ use strict;
use warnings;
use SOAP::Lite 0.67;
#use SOAP::Lite +trace => 'debug';
use Business::PayPal::API ();
@ -15,25 +16,26 @@ 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 ) )
my $request
= SOAP::Data->name(
DoAuthorizationRequest => \SOAP::Data->value( @ref_trans ) )
->type( "ns:AuthorizationRequestType" );
my $som = $self->doCall( DoAuthorizationReq => $request )
@ -47,9 +49,12 @@ sub DoAuthorizationRequest {
return %response;
}
$self->getFields($som, $path, \%response,
$self->getFields(
$som, $path,
\%response,
{ TransactionID => 'TransactionID',
Amount => 'Amount', }
Amount => 'Amount',
}
);
return %response;

View file

@ -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,22 +31,24 @@ 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} ) {
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 ) )
my $request
= SOAP::Data->name(
DoCaptureRequest => \SOAP::Data->value( @ref_trans ) )
->type( "ns:DoCaptureRequestType" );
my $som = $self->doCall( DoCaptureReq => $request )
@ -58,9 +62,10 @@ sub DoCaptureRequest {
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',

View file

@ -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,71 +67,119 @@ sub DoDirectPaymentRequest {
$args{PaymentAction} ||= 'Sale';
#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} ),
);
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,
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}),
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}),
->attr( { currencyID => $args{currencyID} } )
->type( $types{currencyID} ),
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} )
->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(InvoiceID => $args{InvoiceID})->type($types{InvoiceID}),
SOAP::Data->name(ButtonSource => $args{ButtonSource})->type($types{ButtonSource})
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 )),
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}),
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 = ();
@ -131,7 +188,10 @@ sub DoDirectPaymentRequest {
return %response;
}
$self->getFields( $som, $path, \%response, { TransactionID => 'TransactionID',
$self->getFields(
$som, $path,
\%response,
{ TransactionID => 'TransactionID',
Amount => 'Amount',
AVSCode => 'AVSCode',
CVV2Code => 'CVV2Code',

View file

@ -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,11 +55,15 @@ 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
@ -62,31 +71,41 @@ sub SetExpressCheckout {
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} );
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;
@ -103,16 +122,15 @@ sub SetExpressCheckout {
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 );
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',
@ -206,10 +229,13 @@ sub DoExpressCheckoutPayment {
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};
@ -237,10 +263,9 @@ sub DoExpressCheckoutPayment {
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 } ), );
}
##
@ -258,37 +283,44 @@ sub DoExpressCheckoutPayment {
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')
->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' )
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 } ),
)
);
@ -304,7 +336,8 @@ sub DoExpressCheckoutPayment {
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;
}

View file

@ -14,14 +14,15 @@ 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 ) )
my $request
= SOAP::Data->name(
GetTransactionDetailsRequest => \SOAP::Data->value( @trans ) )
->type( "ns:GetTransactionDetailsRequestType" );
my $som = $self->doCall( GetTransactionDetailsReq => $request )
@ -37,7 +38,9 @@ sub GetTransactionDetails {
$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,14 +119,17 @@ 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 ) {
$response{PaymentItems} = $paymentitems;

View file

@ -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} };
@ -42,10 +48,14 @@ 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} } } );
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} );
}
}
@ -62,19 +72,25 @@ sub MassPay {
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} } } );
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 ) )
my $request
= SOAP::Data->name( MassPayRequest => \SOAP::Data->value( @masspay ) )
->type( "ns:MassPayRequestType" );
my $som = $self->doCall( MassPayReq => $request )

View file

@ -14,25 +14,26 @@ 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 ) )
my $request
= SOAP::Data->name(
DoReauthorizationRequest => \SOAP::Data->value( @ref_trans ) )
->type( "ns:ReauthorizationRequestType" );
my $som = $self->doCall( DoReauthorizationReq => $request )
@ -46,9 +47,12 @@ sub DoReauthorizationRequest {
return %response;
}
$self->getFields($som, $path, \%response,
$self->getFields(
$som, $path,
\%response,
{ AuthorizationID => 'AuthorizationID',
Amount => 'Amount', }
Amount => 'Amount',
}
);
return %response;

View file

@ -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,20 +49,28 @@ 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)
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' );
@ -83,15 +95,16 @@ 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';
@ -102,7 +115,8 @@ sub GetBillingAgreementCustomerDetails {
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,22 +229,27 @@ 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
@ -222,7 +257,9 @@ sub CreateRecurringPaymentsProfile {
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} );
push @trialbilltype,
SOAP::Data->name( $real_field => $args{$field} )
->type( $trialbilltype{$field} );
}
## this gets pushed onto scheduledetails
@ -230,24 +267,36 @@ sub CreateRecurringPaymentsProfile {
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} );
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} );
push @shipaddr,
SOAP::Data->name( $real_field => $args{$field} )
->type( $shipaddrtype{$field} );
}
## this gets pushed into payerinfo (from creditcarddetails)
@ -255,7 +304,9 @@ sub CreateRecurringPaymentsProfile {
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} );
push @payeraddr,
SOAP::Data->name( $real_field => $args{$field} )
->type( payaddrtype {$field} );
}
## credit card type
@ -263,29 +314,47 @@ sub CreateRecurringPaymentsProfile {
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} );
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
my $request = SOAP::Data->name
( CreateRecurringPaymentsProfileRequest => \SOAP::Data->value
# ( $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 } )
)
); #->type( 'ns:CreateRecurringPaymentsProfileRequestType' );
@ -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',
@ -354,10 +427,13 @@ sub DoReferenceTransaction {
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};
@ -385,10 +461,9 @@ sub DoReferenceTransaction {
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 } ), );
}
##
@ -406,10 +481,10 @@ sub DoReferenceTransaction {
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,22 +492,28 @@ sub DoReferenceTransaction {
##
my @reference_details = (
SOAP::Data->name( ReferenceID => $args{ReferenceID} )
->type($types{ReferenceID})->attr( {xmlns => $self->C_xmlns_ebay} ),
SOAP::Data->name( PaymentAction => $args{PaymentAction} )
->type($types{PaymentAction})->attr( {xmlns => $self->C_xmlns_ebay} ),
SOAP::Data->name( PaymentDetails => \SOAP::Data->value
( @payment_details )->type('ebl:PaymentDetailsType')
->type( $types{ReferenceID} )
->attr( { xmlns => $self->C_xmlns_ebay } ),
), );
SOAP::Data->name( PaymentAction => $args{PaymentAction} )
->type( $types{PaymentAction} )
->attr( { xmlns => $self->C_xmlns_ebay } ),
SOAP::Data->name(
PaymentDetails => \SOAP::Data->value( @payment_details )
->type( 'ebl:PaymentDetailsType' )
->attr( { xmlns => $self->C_xmlns_ebay } ),
),
);
##
## the main request object
##
my $request = SOAP::Data
->name( DoReferenceTransactionRequest => \SOAP::Data->value
( $self->version_req,
SOAP::Data->name( DoReferenceTransactionRequestDetails => \SOAP::Data->value
( @reference_details )->type( 'ns:DoReferenceTransactionRequestDetailsType' )
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 } ),
)
);
@ -448,7 +529,8 @@ sub DoReferenceTransaction {
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;
}

View file

@ -14,34 +14,38 @@ 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} ) {
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 ) )
my $request
= SOAP::Data->name(
RefundTransactionRequest => \SOAP::Data->value( @ref_trans ) )
->type( "ns:RefundTransactionRequestType" );
my $som = $self->doCall( RefundTransactionReq => $request )
@ -55,11 +59,14 @@ sub RefundTransaction {
return %response;
}
$self->getFields($som, $path, \%response,
$self->getFields(
$som, $path,
\%response,
{ RefundTransactionID => 'RefundTransactionID',
FeeRefundAmount => 'FeeRefundAmount',
NetRefundAmount => 'NetRefundAmount',
GrossRefundAmount => 'GrossRefundAmount', }
GrossRefundAmount => 'GrossRefundAmount',
}
);
return %response;

View file

@ -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,19 +30,21 @@ 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 ) )
my $request
= SOAP::Data->name(
TransactionSearchRequest => \SOAP::Data->value( @trans ) )
->type( "ns:TransactionSearchRequestType" );
my $som = $self->doCall( TransactionSearchReq => $request )
@ -55,7 +58,9 @@ sub TransactionSearch {
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;

View file

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

View file

@ -1,3 +1,4 @@
=pod
The tester must supply their own PayPal sandbox seller authentication
@ -14,7 +15,8 @@ variable:
sub do_args {
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;
}

View file

@ -1,5 +1,5 @@
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;
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 {
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 );
require 't/API.pl';
@ -21,7 +24,9 @@ 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 (%respsale, %resprefund, %resprefund1, %respbasic,
%respcap, %respcap1, %respvoid
);
#Test Full Refund on Sale
@ -50,9 +55,11 @@ $ppsale = new Business::PayPal::API(%args);
IPAddress => '10.0.0.1',
MerchantSessionID => '10113301',
);
#$Business::PayPal::API::Debug=0;
if ( like( $respsale{'Ack'}, qr/Success/, 'Direct Payment Sale' ) ) {
$transale = $respsale{'TransactionID'};
#$Business::PayPal::API::Debug=1;
$pprefund = new Business::PayPal::API( %args );
%resprefund = $pprefund->RefundTransaction(
@ -60,6 +67,7 @@ if(like( $respsale{'Ack'}, qr/Success/, 'Direct Payment Sale')) {
RefundType => 'Full',
Memo => 'Full direct sale refund',
);
#$Business::PayPal::API::Debug=0;
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
%args = do_args();
#$Business::PayPal::API::Debug=0;
$ppbasic = new Business::PayPal::API( %args );
%respbasic = $ppbasic->DoDirectPaymentRequest(
@ -94,7 +103,12 @@ $ppbasic = new Business::PayPal::API(%args);
);
#$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
@ -107,6 +121,7 @@ if( like( $respbasic{'Ack'}, qr/Success/, 'Direct Payment Basic Authorization')
Amount => '3.00',
Note => 'Partial Capture',
);
#$Business::PayPal::API::Debug=0;
like( $respcap{'Ack'}, qr/Success/, 'Partial Capture' );
@ -118,12 +133,12 @@ if( like( $respbasic{'Ack'}, qr/Success/, 'Direct Payment Basic Authorization')
CompleteType => 'Complete',
Amount => '6.00',
);
#$Business::PayPal::API::Debug=0;
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(
@ -152,7 +167,10 @@ $ppbasic = new Business::PayPal::API(%args);
#$Business::PayPal::API::Debug=1;
$ppvoid = new Business::PayPal::API( %args );
%respvoid = $ppvoid->DoVoidRequest ( AuthorizationID => $respbasic{TransactionID},
Note => 'Authorization Void', );
%respvoid = $ppvoid->DoVoidRequest(
AuthorizationID => $respbasic{TransactionID},
Note => 'Authorization Void',
);
#$Business::PayPal::API::Debug=0;
like( $respvoid{'Ack'}, qr/Success/, 'Authorization Voided' );

View file

@ -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';
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,7 +65,8 @@ _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;
@ -76,7 +81,8 @@ 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',

View file

@ -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';
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,7 +67,8 @@ _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;
@ -78,7 +83,8 @@ 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',
@ -89,6 +95,7 @@ my %payment = ( Token => $details{Token},
##
#$Business::PayPal::API::Debug = 1;
my %payinfo = $pp->DoExpressCheckoutPayment( %payment );
#$Business::PayPal::API::Debug = 0;
#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';
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);
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' );
%resp1 = $ppvoid->DoVoidRequest(
AuthorizationID => $transid,
Note => 'Voided'
);
like( $resp1{Ack}, qr/Success/, 'Successful order void' );
}

View file

@ -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';
plan skip_all =>
'No WPP_TEST env var set. Please see README to run tests';
}
else {
plan tests => 2;
@ -34,7 +35,8 @@ _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;

View file

@ -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';
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" );
%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" );

View file

@ -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';
plan skip_all =>
'No WPP_TEST env var set. Please see README to run tests';
}
else {
plan tests => 3;
@ -17,14 +18,14 @@ my %args = do_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};
@ -34,11 +35,12 @@ 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',
@ -113,10 +114,10 @@ my %profile = $pp->CreateRecurringPaymentsProfile
#$Business::PayPal::API::Debug = 0;
## GetBillingAgreementCustomerDetails
#$Business::PayPal::API::Debug = 1;
my %details = $pp->GetBillingAgreementCustomerDetails( $token );
#$Business::PayPal::API::Debug = 0;
like( $details{Ack}, qr/Success/, "details ok" );

View file

@ -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';
plan skip_all =>
'No WPP_TEST env var set. Please see README to run tests';
}
else {
plan tests => 2;
@ -35,13 +36,16 @@ _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." );

View file

@ -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';
plan skip_all =>
'No WPP_TEST env var set. Please see README to run tests';
}
else {
plan tests => 2;
@ -36,14 +37,16 @@ _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" );