line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::OnlinePayment::eSec; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
2879
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
119
|
|
4
|
3
|
|
|
3
|
|
15
|
use Carp; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
241
|
|
5
|
3
|
|
|
3
|
|
906
|
use Business::OnlinePayment; |
|
3
|
|
|
|
|
3322
|
|
|
3
|
|
|
|
|
74
|
|
6
|
3
|
|
|
3
|
|
2907
|
use Business::CreditCard; |
|
3
|
|
|
|
|
5646
|
|
|
3
|
|
|
|
|
254
|
|
7
|
3
|
|
|
3
|
|
3326
|
use Net::SSLeay qw( make_form post_https ); |
|
3
|
|
|
|
|
56090
|
|
|
3
|
|
|
|
|
1635
|
|
8
|
3
|
|
|
3
|
|
33
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $DEBUG); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
3128
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
@ISA = qw(Exporter AutoLoader Business::OnlinePayment); |
13
|
|
|
|
|
|
|
@EXPORT = qw(); |
14
|
|
|
|
|
|
|
@EXPORT_OK = qw(); |
15
|
|
|
|
|
|
|
$VERSION = '0.02'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$DEBUG = 0; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub set_defaults { |
20
|
2
|
|
|
2
|
0
|
118
|
my $self = shift; |
21
|
2
|
|
|
|
|
65
|
$self->server('sec.aba.net.au'); |
22
|
2
|
|
|
|
|
85
|
$self->port('443'); |
23
|
2
|
|
|
|
|
62
|
$self->path('/cgi-bin/service/authint'); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub revmap_fields { |
27
|
2
|
|
|
2
|
0
|
28
|
my($self,%map) = @_; |
28
|
2
|
|
|
|
|
6
|
my %content = $self->content(); |
29
|
2
|
|
|
|
|
32
|
foreach(keys %map) { |
30
|
12
|
|
|
|
|
22
|
$content{$_} = ref($map{$_}) |
31
|
22
|
100
|
|
|
|
41
|
? ${ $map{$_} } |
32
|
|
|
|
|
|
|
: $content{$map{$_}}; |
33
|
|
|
|
|
|
|
} |
34
|
2
|
|
|
|
|
15
|
$self->content(%content); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub get_fields { |
38
|
2
|
|
|
2
|
1
|
6
|
my($self,@fields) = @_; |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
6
|
my %content = $self->content(); |
41
|
2
|
|
|
|
|
36
|
my %new = (); |
42
|
2
|
|
|
|
|
12
|
foreach( grep defined $content{$_}, @fields) { $new{$_} = $content{$_}; } |
|
21
|
|
|
|
|
31
|
|
43
|
2
|
|
|
|
|
20
|
return %new; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub submit { |
47
|
0
|
|
|
0
|
1
|
|
my($self) = @_; |
48
|
0
|
|
|
|
|
|
my %content = $self->content; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $action = lc($content{'action'}); |
51
|
0
|
0
|
|
|
|
|
die 'eSec only supports "Authorization Only" transactions' |
52
|
|
|
|
|
|
|
unless $action eq 'authorization only'; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my %typemap = ( |
55
|
|
|
|
|
|
|
"VISA card" => 'visa', |
56
|
|
|
|
|
|
|
"MasterCard" => 'mastercard', |
57
|
|
|
|
|
|
|
"Discover card" => 'discover', #not supported... |
58
|
|
|
|
|
|
|
"American Express card" => 'amex', |
59
|
|
|
|
|
|
|
"Diner's Club/Carte Blanche" => 'dinersclub', |
60
|
|
|
|
|
|
|
"enRoute" => 'enroute', #not supported... |
61
|
|
|
|
|
|
|
"JCB" => 'jcb', |
62
|
|
|
|
|
|
|
"BankCard" => 'bankcard', |
63
|
|
|
|
|
|
|
); |
64
|
0
|
0
|
|
|
|
|
my $cardtype = $self->test_transaction |
65
|
|
|
|
|
|
|
? 'testcard' |
66
|
|
|
|
|
|
|
: $typemap{cardtype($content{'card_number'})}; |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
$content{'expiration'} =~ /^(\d+)\D+(\d+)$/ |
69
|
|
|
|
|
|
|
or croak "unparsable expiration $content{expiration}"; |
70
|
0
|
|
|
|
|
|
my ($month, $year) = ( $1, $2 ); |
71
|
0
|
|
|
|
|
|
$month += 0; |
72
|
0
|
0
|
|
|
|
|
$year += 2000 if $year < 2000; #not y4k safe, oh shit |
73
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
$self->revmap_fields( |
75
|
|
|
|
|
|
|
EPS_MERCHANT => 'login', |
76
|
|
|
|
|
|
|
EPS_REFERENCEID => 'invoice_number', |
77
|
|
|
|
|
|
|
EPS_CARDNUMBER => 'card_number', |
78
|
|
|
|
|
|
|
EPS_CARDTYPE => \$cardtype, |
79
|
|
|
|
|
|
|
EPS_EXPIRYMONTH => \$month, |
80
|
|
|
|
|
|
|
EPS_EXPIRYYEAR => \$year, |
81
|
|
|
|
|
|
|
EPS_NAMEONCARD => 'name', |
82
|
|
|
|
|
|
|
EPS_AMOUNT => 'amount', |
83
|
|
|
|
|
|
|
EPS_CCV => \'', |
84
|
|
|
|
|
|
|
EPS_VERSION => \'2', |
85
|
|
|
|
|
|
|
EPS_TEST => \( $self->test_transaction() ? 'true' : 'false' ), |
86
|
|
|
|
|
|
|
); |
87
|
0
|
|
|
|
|
|
%content = $self->content; |
88
|
0
|
0
|
|
|
|
|
if ( $DEBUG ) { |
89
|
0
|
|
|
|
|
|
warn "content:$_ => $content{$_}\n" foreach keys %content; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
if ($self->transaction_type() eq 'CC' ) { |
93
|
0
|
|
|
|
|
|
$self->required_fields(qw/type action amount card_number expiration/); |
94
|
|
|
|
|
|
|
} else { |
95
|
0
|
|
|
|
|
|
croak("eSec can't handle transaction type: ". |
96
|
|
|
|
|
|
|
$self->transaction_type()); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
my %post_data = $self->get_fields( map "EPS_$_", qw( |
100
|
|
|
|
|
|
|
MERCHANT REFERENCEID CARDNUMBER CARDTYPE EXPIRYMONTH EXPIRYYEAR |
101
|
|
|
|
|
|
|
NAMEONCARD AMOUNT CCV VERSION TEST |
102
|
|
|
|
|
|
|
) ); |
103
|
0
|
0
|
|
|
|
|
if ( $DEBUG ) { |
104
|
0
|
|
|
|
|
|
warn "post_data:$_ => $post_data{$_}\n" foreach keys %post_data; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
my $pd = make_form(%post_data); |
108
|
0
|
|
|
|
|
|
my $server = $self->server(); |
109
|
0
|
|
|
|
|
|
my $port = $self->port(); |
110
|
0
|
|
|
|
|
|
my $path = $self->path(); |
111
|
0
|
|
|
|
|
|
my($page,$server_response,%headers) = |
112
|
|
|
|
|
|
|
post_https($server,$port,$path,'',$pd); |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
my( $r, $a, $m, $s, $e ) = |
115
|
0
|
|
|
|
|
|
map { /^\s*\w+\s*\=\s*(.*)$/; $1; } split("\n", $page); |
|
0
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
0
|
0
|
|
|
|
|
if ( $m =~ /^200/ ) { |
118
|
0
|
|
|
|
|
|
$self->is_success(1); |
119
|
0
|
|
|
|
|
|
$self->result_code($e); |
120
|
0
|
|
|
|
|
|
$self->authorization($a); |
121
|
|
|
|
|
|
|
} else { |
122
|
0
|
|
|
|
|
|
$self->is_success(0); |
123
|
0
|
|
|
|
|
|
$self->result_code($e); |
124
|
0
|
|
|
|
|
|
$self->error_message($m); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |
130
|
|
|
|
|
|
|
__END__ |