File Coverage

blib/lib/Business/MaxMind/CreditCardFraudDetection.pm
Criterion Covered Total %
statement 26 30 86.6
branch 2 8 25.0
condition 1 2 50.0
subroutine 7 7 100.0
pod 0 1 0.0
total 36 48 75.0


line stmt bran cond sub pod time code
1             package Business::MaxMind::CreditCardFraudDetection;
2              
3 2     2   8014 use strict;
  2         5  
  2         89  
4              
5 2     2   13 use vars qw($VERSION);
  2         5  
  2         101  
6              
7 2     2   13 use Digest::MD5;
  2         9  
  2         87  
8 2     2   2422 use LWP::UserAgent;
  2         121245  
  2         75  
9 2     2   23 use base 'Business::MaxMind::HTTPBase';
  2         6  
  2         1530  
10              
11             # input fields
12             my @allowed_fields = qw/i city region postal country domain bin binName binPhone
13             custPhone emailMD5 usernameMD5 passwordMD5 shipAddr shipCity
14             shipRegion shipPostal shipCountry txnID sessionID user_agent
15             accept_language order_amount order_currency shopID avs_result
16             cvv_result txn_type license_key requested_type forwardedIP/;
17              
18             $VERSION = '1.54';
19              
20             sub _init {
21 2     2   5 my $self = shift;
22 2         7 $self->{url} = 'app/ccv2r';
23 2         7 $self->{check_field} = 'countryMatch';
24 2   50     17 $self->{timeout} ||= 10; # provide a default value of 10 seconds for timeout if not set by user
25 2         6 %{$self->{allowed_fields}} = map {$_ => 1} @allowed_fields
  2         52  
  62         97  
26             }
27              
28             sub filter_field {
29 14     14 0 21 my ($self, $name, $value) = @_;
30              
31 14 50       28 if ($name eq 'emailMD5') {
32 0 0       0 if ($value =~ m!\@!) {
33 0         0 return Digest::MD5::md5_hex(lc($value));
34             }
35             }
36              
37 14 50       28 if ($name =~ m!(username|password)MD5$!) {
38 0 0       0 if (length($value) != 32) {
39 0         0 return Digest::MD5::md5_hex(lc($value));
40             }
41             }
42              
43 14         73 return $value;
44             }
45              
46             1;
47             __END__