line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Card::Magnetic; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
2941
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
179
|
|
4
|
5
|
|
|
5
|
|
22
|
use warnings; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
2545
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Magnetic Stripe parser |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
4
|
|
|
4
|
1
|
1878
|
my ( $class ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
|
|
10
|
my $self = { stripe => undef }; |
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
|
|
14
|
return bless $self, $class; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub stripe{ |
18
|
4
|
|
|
4
|
1
|
15
|
my ( $self , $stripe ) = @_; |
19
|
|
|
|
|
|
|
|
20
|
4
|
50
|
|
|
|
13
|
return $self->{ stripe } if ! $stripe; |
21
|
|
|
|
|
|
|
|
22
|
4
|
|
|
|
|
20
|
$self->{ stripe } = $stripe; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub parse{ |
26
|
4
|
|
|
4
|
1
|
13
|
my ( $self ) = @_; |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
8
|
my $stripe = $self->{ stripe }; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
#track1 |
31
|
4
|
100
|
|
|
|
24
|
if ( $stripe =~ /^%[\w|\^]+\?\n/ ){ |
32
|
2
|
|
|
|
|
5
|
my $track1 = $&; |
33
|
2
|
|
|
|
|
5
|
$stripe = $` . $'; |
34
|
2
|
|
|
|
|
6
|
$self->{ track1 }{ track } = $track1; |
35
|
2
|
|
|
|
|
4
|
chomp $track1; |
36
|
2
|
50
|
|
|
|
15
|
if( $track1 =~ /^%(\w)(\d+)\^(\w+)\^(\d{4})(\d{3})(\d{5})(\d{3})/ ) { |
37
|
|
|
|
|
|
|
$self->{ track1 } = { |
38
|
2
|
|
|
|
|
20
|
FORMAT_CODE => $1, |
39
|
|
|
|
|
|
|
PAN => $2, |
40
|
|
|
|
|
|
|
NAME => $3, |
41
|
|
|
|
|
|
|
EXPIRATION_DATE => $4, |
42
|
|
|
|
|
|
|
SERVICE_CODE => $5, |
43
|
|
|
|
|
|
|
PVV => $6, |
44
|
|
|
|
|
|
|
CVV => $7, |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
#track2 |
49
|
4
|
100
|
100
|
|
|
40
|
if( $stripe =~ /\;[\w\^]+\?\n/ and ( length $& < 39 ) ){ # stripe... |
50
|
2
|
|
|
|
|
4
|
my $track2 = $&; |
51
|
2
|
|
|
|
|
4
|
$stripe = $` . $'; |
52
|
2
|
|
|
|
|
3
|
$self->{ track2 }{ track } = $track2; |
53
|
2
|
|
|
|
|
4
|
chomp $track2; |
54
|
2
|
50
|
|
|
|
9
|
if( $track2 =~ /(\d+)\^(\d{4})(\d{3})(\d{5})(\d{3})/ ) { |
55
|
|
|
|
|
|
|
$self->{ track2 } = { |
56
|
2
|
|
|
|
|
11
|
PAN => $1, |
57
|
|
|
|
|
|
|
EXPIRATION_DATE => $2, |
58
|
|
|
|
|
|
|
SERVICE_CODE => $3, |
59
|
|
|
|
|
|
|
PVV => $4, |
60
|
|
|
|
|
|
|
CVV => $5, |
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
#track3 |
65
|
4
|
100
|
|
|
|
18
|
if( $stripe =~ /\;[\w\^]+\?\n/ ){ |
66
|
2
|
|
|
|
|
3
|
my $track3 = $&; |
67
|
2
|
|
|
|
|
3
|
$stripe = $` . $'; |
68
|
2
|
|
|
|
|
426
|
$self->{ track3 }{ track } = $track3; |
69
|
2
|
|
|
|
|
5
|
chomp $track3; |
70
|
2
|
50
|
|
|
|
15
|
if( $track3 =~ / |
71
|
|
|
|
|
|
|
(?\d{2}) |
72
|
|
|
|
|
|
|
(?\d+)\^ |
73
|
|
|
|
|
|
|
(?\d{3}) |
74
|
|
|
|
|
|
|
(?\d{3}) |
75
|
|
|
|
|
|
|
(?\d{4}) |
76
|
|
|
|
|
|
|
(?\d{4}) |
77
|
|
|
|
|
|
|
(?\d{4}) |
78
|
|
|
|
|
|
|
(?\d{2}) |
79
|
|
|
|
|
|
|
(?\d{1}) |
80
|
|
|
|
|
|
|
(?\d{6}) |
81
|
|
|
|
|
|
|
(?\d{1}) |
82
|
|
|
|
|
|
|
(?\d{2}) |
83
|
|
|
|
|
|
|
(?\d{2}) |
84
|
|
|
|
|
|
|
(?\d{2}) |
85
|
|
|
|
|
|
|
(?\d{4}) |
86
|
|
|
|
|
|
|
(?\d{1}) |
87
|
|
|
|
|
|
|
(?\d{9}) |
88
|
|
|
|
|
|
|
(?\d{1}) |
89
|
|
|
|
|
|
|
(?\d{6}) |
90
|
|
|
|
|
|
|
/x){ |
91
|
|
|
|
|
|
|
$self->{ track3 } = { |
92
|
5
|
|
|
5
|
|
2477
|
FORMAT_CODE => $+{fc}, |
|
5
|
|
|
|
|
2061
|
|
|
5
|
|
|
|
|
696
|
|
|
2
|
|
|
|
|
76
|
|
93
|
|
|
|
|
|
|
PAN => $+{pan}, |
94
|
|
|
|
|
|
|
COUNTRY_CODE => $+{cc}, |
95
|
|
|
|
|
|
|
CURRENCY_CODE => $+{cur}, |
96
|
|
|
|
|
|
|
AMOUNTAUTH => $+{amountauth}, |
97
|
|
|
|
|
|
|
AMOUNTREMAINING => $+{amountremaining}, |
98
|
|
|
|
|
|
|
CYCLE_BEGIN => $+{cyclebegin}, |
99
|
|
|
|
|
|
|
CYCLE_LENGHT => $+{cyclelenght}, |
100
|
|
|
|
|
|
|
RETRY_COUNT => $+{retrycount}, |
101
|
|
|
|
|
|
|
PINCP => $+{pincp}, |
102
|
|
|
|
|
|
|
INTERCHANGE => $+{interchange}, |
103
|
|
|
|
|
|
|
PANSR => $+{pansr}, |
104
|
|
|
|
|
|
|
SAN1 => $+{san1}, |
105
|
|
|
|
|
|
|
SAN2 => $+{san2}, |
106
|
|
|
|
|
|
|
EXPIRATION_DATE => $+{expirationdate}, |
107
|
|
|
|
|
|
|
CARD_SEQUENCE => $+{cardsequence}, |
108
|
|
|
|
|
|
|
CARD_SECURITY => $+{cardsecurity}, |
109
|
|
|
|
|
|
|
RELAY_MARKER => $+{relaymarker}, |
110
|
|
|
|
|
|
|
CRYPTO_CHECK => $+{cryptocheck}, |
111
|
|
|
|
|
|
|
}; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__END__ |