line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Card::Magnetic; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
969
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
63
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
993
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Magnetic Stripe parser |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
1
|
|
|
1
|
1
|
426
|
my ( $class ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
|
|
1
|
my $self = { stripe => undef }; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
3
|
return bless $self, $class; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub stripe{ |
18
|
1
|
|
|
1
|
1
|
2
|
my ( $self , $stripe ) = @_; |
19
|
|
|
|
|
|
|
|
20
|
1
|
50
|
|
|
|
4
|
return $self->{ stripe } if ! $stripe; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
4
|
$self->{ stripe } = $stripe; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub parse{ |
27
|
1
|
|
|
1
|
1
|
2
|
my ( $self ) = @_; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
2
|
my $stripe = $self->{ stripe }; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#track1 |
32
|
1
|
50
|
|
|
|
6
|
if ( $stripe =~ /^%[\w|\^]+\?\n/ ){ |
33
|
1
|
|
|
|
|
2
|
my $track1 = $&; |
34
|
1
|
|
|
|
|
2
|
$stripe = $` . $'; |
35
|
1
|
|
|
|
|
2
|
$self->{ track1 }{ track } = $track1; |
36
|
1
|
|
|
|
|
2
|
chomp $track1; |
37
|
1
|
50
|
|
|
|
4
|
if( $track1 =~ /^%(\w)(\d+)\^(\w+)\^(\d{4})(\d{3})(\d{4})(\d{3})/ ) { |
38
|
|
|
|
|
|
|
$self->{ track1 } = { |
39
|
1
|
|
|
|
|
15
|
format_code => $1, |
40
|
|
|
|
|
|
|
PAN => $2, |
41
|
|
|
|
|
|
|
NAME => $3, |
42
|
|
|
|
|
|
|
EXPIRATION_DATE => $4, |
43
|
|
|
|
|
|
|
SERVICE_CODE => $5, |
44
|
|
|
|
|
|
|
PVV => $6, |
45
|
|
|
|
|
|
|
CVV => $7, |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
#track2 |
50
|
1
|
50
|
|
|
|
7
|
if( $stripe =~ /\;[\w\^]+\?\n/ ){ |
51
|
1
|
|
|
|
|
2
|
my $track2 = $&; |
52
|
1
|
|
|
|
|
2
|
$stripe = $` . $'; |
53
|
1
|
|
|
|
|
2
|
$self->{ track2 }{ track } = $track2; |
54
|
1
|
|
|
|
|
2
|
chomp $track2; |
55
|
1
|
50
|
|
|
|
6
|
if( $track2 =~ /(\d+)\^(\d{4})(\d{3})(\d{4})(\d{3})/ ) { |
56
|
|
|
|
|
|
|
$self->{ track2 } = { |
57
|
1
|
|
|
|
|
7
|
PAN => $1, |
58
|
|
|
|
|
|
|
EXPIRATION_DATE => $2, |
59
|
|
|
|
|
|
|
SERVICE_CODE => $3, |
60
|
|
|
|
|
|
|
PVV => $4, |
61
|
|
|
|
|
|
|
CVV => $5, |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
#track3 |
66
|
1
|
50
|
|
|
|
8
|
if( $stripe =~ /\;[\w\^]+\?\n/ ){ |
67
|
1
|
|
|
|
|
3
|
my $track3 = $&; |
68
|
1
|
|
|
|
|
2
|
$stripe = $` . $'; |
69
|
1
|
|
|
|
|
3
|
$self->{ track3 }{ track } = $track3; |
70
|
1
|
|
|
|
|
1
|
chomp $track3; |
71
|
1
|
50
|
|
|
|
7
|
if( $track3 =~ / |
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
|
1
|
|
|
|
|
17
|
PAN => $1, |
93
|
|
|
|
|
|
|
COUNTRY_CODE => $2, |
94
|
|
|
|
|
|
|
CURRENCY_CODE => $3, |
95
|
|
|
|
|
|
|
AMOUNTAUTH => $4, |
96
|
|
|
|
|
|
|
AMOUNTREMAINING => $5, |
97
|
|
|
|
|
|
|
CYCLE_BEGIN => $6, |
98
|
|
|
|
|
|
|
CYCLE_LENGHT => $7, |
99
|
|
|
|
|
|
|
RETRY_COUNT => $8, |
100
|
|
|
|
|
|
|
PINCP => $9, |
101
|
|
|
|
|
|
|
INTERCHANGE => $10, |
102
|
|
|
|
|
|
|
PANSR => $11, |
103
|
|
|
|
|
|
|
SAN1 => $12, |
104
|
|
|
|
|
|
|
SAN2 => $13, |
105
|
|
|
|
|
|
|
EXPIRATION_DATE => "1717", |
106
|
|
|
|
|
|
|
CARD_SEQUENCE => "1", |
107
|
|
|
|
|
|
|
CARD_SECURITY => "234567890", |
108
|
|
|
|
|
|
|
RELAY_MARKER => "3", |
109
|
|
|
|
|
|
|
CRYPTO_CHECK => "456789", |
110
|
|
|
|
|
|
|
}; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
__END__ |