summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorplobbes <plobbes>2006-11-29 03:58:49 +0000
committerplobbes <plobbes>2006-11-29 03:58:49 +0000
commitd5e830c6afd72c3cfd0a4d8b9a4a0a7f181ea6dd (patch)
treefd367d224120c065fa9400c10dc1b88300406d8a
parent3785f360382e1a9d906e61ddaa9d2ff4b0881704 (diff)
- CPAN Bug# 23587: _pre_submit() would return success if fraud detection isBUSINESS_ONLINEPAYMENT_3_00_05
used but not found. Fix: croak() if unable to load the fraud detection class.
-rw-r--r--OnlinePayment.pm17
-rw-r--r--t/bop.t3
2 files changed, 12 insertions, 8 deletions
diff --git a/OnlinePayment.pm b/OnlinePayment.pm
index dbb28ce..f0b1a92 100644
--- a/OnlinePayment.pm
+++ b/OnlinePayment.pm
@@ -92,6 +92,8 @@ sub _risk_detect {
return 0;
}
+my @Fraud_Class_Path = qw(Business::OnlinePayment Business::FraudDetect);
+
sub _pre_submit {
my ($self) = @_;
my $fraud_detection = $self->fraud_detect();
@@ -100,14 +102,13 @@ sub _pre_submit {
return 1 unless $fraud_detection;
# Search for an appropriate FD module
- foreach my $subclass ( q(Business::OnlinePayment::) . $fraud_detection,
- q(Business::FraudDetect::) . $fraud_detection) {
-
+ foreach my $fraud_class ( @Fraud_Class_Path ) {
+ my $subclass = $fraud_class . "::" . $fraud_detection;
if (!defined(&$subclass)) {
- eval "use $subclass";
+ eval "use $subclass ()";
if ($@) {
- Carp::croak("serious problem loading fraud_detection module ($@)") unless
- $@ =~ m/^Can\'t locate/;
+ Carp::croak("error loading fraud_detection module ($@)")
+ unless ( $@ =~ m/^Can\'t locate/ );
} else {
my $risk_tx = bless ( { processor => $fraud_detection } , $subclass );
$risk_tx->build_subs(keys %fields);
@@ -119,7 +120,9 @@ sub _pre_submit {
}
}
}
- return 1; # BUG?: success if fraud_detection module not found!
+ Carp::croak("Unable to locate fraud_detection module $fraud_detection"
+ . " in \@INC under Fraud_Class_Path (\@Fraud_Class_Path"
+ . " contains: @Fraud_Class_Path) (\@INC contains: @INC)");
}
sub content {
diff --git a/t/bop.t b/t/bop.t
index 8eb762d..d34ed76 100644
--- a/t/bop.t
+++ b/t/bop.t
@@ -115,7 +115,8 @@ foreach my $drv (@drivers) {
is( $obj->fraud_detect($bogus), $bogus, "fraud_detect set to '$bogus'" );
eval { $obj->submit; };
- is( $@, "", "fraud_detect ignores non-existant processors" );
+ like( $@, qr/^Unable to locate fraud_detection /,
+ "fraud_detect with unknown processor croaks" );
is( $obj->fraud_detect($valid), $valid, "fraud_detect set to '$valid'" );
eval { $obj->submit; };