line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FormValidator::Simple::Plugin::CreditCard; |
2
|
2
|
|
|
2
|
|
488539
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
62
|
|
3
|
2
|
|
|
2
|
|
11
|
use FormValidator::Simple::Exception; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
17
|
|
4
|
2
|
|
|
2
|
|
44
|
use FormValidator::Simple::Constants; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
669
|
|
5
|
|
|
|
|
|
|
require Business::CreditCard; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $__creditcard_types = { |
10
|
|
|
|
|
|
|
VISA => 'VISA card', |
11
|
|
|
|
|
|
|
MASTER => 'MasterCard', |
12
|
|
|
|
|
|
|
DISCOVER => 'Discovoer card', |
13
|
|
|
|
|
|
|
AMEX => 'American Express card', |
14
|
|
|
|
|
|
|
DINERS => "Diner's Club/Carte Blanche", |
15
|
|
|
|
|
|
|
ENROUTE => 'enRoute', |
16
|
|
|
|
|
|
|
JCB => 'JCB', |
17
|
|
|
|
|
|
|
BANKCARD => 'BankCard', |
18
|
|
|
|
|
|
|
SWITCH => 'Switch', |
19
|
|
|
|
|
|
|
SOLO => 'Solo', |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub __creditcard_get_type { |
23
|
3
|
|
|
3
|
|
8
|
my ($self, $abbreviation) = @_; |
24
|
3
|
50
|
|
|
|
10
|
if ( exists $__creditcard_types->{$abbreviation} ) { |
25
|
3
|
|
|
|
|
15
|
return $__creditcard_types->{$abbreviation}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
else { |
28
|
0
|
|
|
|
|
0
|
FormValidator::Simple::Exception->throw( |
29
|
|
|
|
|
|
|
qq/Unknown Card Type "$abbreviation"./ |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub CREDIT_CARD { |
35
|
4
|
|
|
4
|
0
|
7707
|
my ($self, $params, $args) = @_; |
36
|
4
|
|
|
|
|
6
|
my $data = $params->[0]; |
37
|
4
|
100
|
66
|
|
|
25
|
if ($args && scalar(@$args) > 0) { |
38
|
2
|
|
|
|
|
4
|
foreach my $type (@$args) { |
39
|
3
|
100
|
|
|
|
49
|
if ($self->__creditcard_get_type($type) eq Business::CreditCard::cardtype($data) ) { |
40
|
1
|
|
|
|
|
22
|
return TRUE; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
1
|
|
|
|
|
16
|
return FALSE; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
else { |
46
|
2
|
100
|
|
|
|
7
|
return Business::CreditCard::validate($data) ? TRUE : FALSE; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
__END__ |