Business-PayPal-SDK
view release on metacpan or search on metacpan
lib/Business/PayPal/SDK.pm view on Meta::CPAN
if ($@) {
$s->error("getAddress failed: [" . $@->getMessage() . '] [' . $@->toString() . ']');
return undef;
} else {
return $AddressObj;
}
}
sub _getCountryCode {
my $s = shift;
my $cc = shift;
$cc ||= '';
unless ($cc && $cc =~ /^[A-Z]{2}$/) {
$s->error("You must pass a valid code to _getCountryCode. [$cc]");
return
}
package main;
require Inline::Java;
Inline::Java::study_classes(
[
qw(
com.paypal.soap.api.CountryCodeType
)
]
);
package Business::PayPal::SDK;
my $code;
eval {
$code = com::paypal::soap::api::CountryCodeType->fromString($cc);
};
if ($@) {
if ((ref $@) eq 'main::java::lang::IllegalArgumentException') {
$s->error("getCountryCode failed: [$cc] is not a valid country code.");
} elsif (ref $@) {
$s->error("getCountryCode failed: [" . $@->getMessage() . '] [' . $@ . ']');
} else {
$s->error("getCountryCode failed: [$@]");
}
return undef;
} else {
return $code;
}
}
sub _checkRequires {
my $s = shift;
my $reqs = shift;
my $args = shift;
unless (ref $reqs) {
$s->error('You must pass an arrayref to check_requires.');
return undef;
}
foreach my $req (@$reqs) {
unless ($args->{$req}) {
my @stack = caller(1);
$s->error("$req is required for method $stack[3]");
return undef;
}
}
return 1;
}
=head2 TransactionSearch()
This is not really completed yet.
=cut
sub TransactionSearch {
my $s = shift;
my $args = shift;
unless ($s->paypal) {
unless ($s->init_java) {
$s->error("could not init_java.");
return undef;
}
}
package main;
Inline::Java::study_classes(
[
qw(
com.paypal.soap.api.TransactionSearchRequestType
com.paypal.soap.api.TransactionSearchResponseType
com.paypal.sdk.exceptions.TransactionException
java.util.Calendar
java.lang.String
)
]
);
package Business::PayPal::SDK;
my $resp;
eval {
my $request = com::paypal::soap::api::TransactionSearchRequestType->new();
my $jcal = Inline::Java::cast('java.util.Calendar', java::util::Calendar->getInstance());
$jcal->set(@{$args->{date}});
$request->setStartDate($jcal);
my $resp = $s->paypal->call("TransactionSearch", $request);
};
my $ackcode = $resp->getAck();
if ($@) {
my $var = $@;
if (ref $@) {
$s->error("RefundTransaction failed: [" . $var->getMessage() . '] [' . $var . ']');
} else {
$s->error("RefundTransaction failed: [$var]");
}
return undef;
}
my $ret = {};
( run in 2.551 seconds using v1.01-cache-2.11-cpan-364913b4093 )