line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::OnlinePayment::iAuthorizer; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: iAuthorizer.pm,v 1.6 2003/09/11 05:30:38 db48x Exp $ |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
2568
|
use Data::Dumper; |
|
1
|
|
|
|
|
12888
|
|
|
1
|
|
|
|
|
82
|
|
6
|
1
|
|
|
1
|
|
9
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
7
|
1
|
|
|
1
|
|
829
|
use Business::OnlinePayment; |
|
1
|
|
|
|
|
3520
|
|
|
1
|
|
|
|
|
37
|
|
8
|
1
|
|
|
1
|
|
1665
|
use Net::SSLeay qw/make_form post_https make_headers/; |
|
1
|
|
|
|
|
21189
|
|
|
1
|
|
|
|
|
581
|
|
9
|
1
|
|
|
1
|
|
11
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1255
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require Exporter; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
@ISA = qw(Exporter AutoLoader Business::OnlinePayment); |
14
|
|
|
|
|
|
|
@EXPORT = qw(); |
15
|
|
|
|
|
|
|
@EXPORT_OK = qw(); |
16
|
|
|
|
|
|
|
$VERSION = '0.2'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub set_defaults { |
19
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
$self->server('tran1.iAuthorizer.net'); |
22
|
0
|
|
|
|
|
|
$self->port('443'); |
23
|
0
|
|
|
|
|
|
$self->path('/trans/postto.asp'); |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$self->build_subs('action'); |
26
|
0
|
|
|
|
|
|
$self->build_subs('debug'); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub map_fields { |
30
|
0
|
|
|
0
|
0
|
|
my($self) = @_; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my %content = $self->content(); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# ACTION MAP |
35
|
0
|
|
|
|
|
|
my %actions = ('normal authorization' => '5', |
36
|
|
|
|
|
|
|
'authorization only' => '6', |
37
|
|
|
|
|
|
|
'credit' => '0', |
38
|
|
|
|
|
|
|
'post authorization' => '2', |
39
|
|
|
|
|
|
|
'void' => '1', |
40
|
|
|
|
|
|
|
); |
41
|
0
|
|
|
|
|
|
$content{'action'} = $actions{lc($content{'action'})}; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my %methods = ('manual' => '0', |
44
|
|
|
|
|
|
|
'swipe' => '1', |
45
|
|
|
|
|
|
|
'swipe, track 1' => '1', |
46
|
|
|
|
|
|
|
'swipe, track 2' => '2', |
47
|
|
|
|
|
|
|
); |
48
|
0
|
|
|
|
|
|
$content{'entry_method'} = $methods{lc($content{'entry_method'})}; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
($content{'expMonth'}, $content{'expYear'}) = split('/', $content{'expiration'}); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# stuff it back into %content |
53
|
0
|
|
|
|
|
|
$self->content(%content); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub remap_fields { |
57
|
0
|
|
|
0
|
1
|
|
my($self,%map) = @_; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my %content = $self->content(); |
60
|
0
|
|
|
|
|
|
foreach(keys %map) { |
61
|
0
|
|
|
|
|
|
$content{$map{$_}} = $content{$_}; |
62
|
|
|
|
|
|
|
} |
63
|
0
|
|
|
|
|
|
$self->content(%content); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub get_fields { |
67
|
0
|
|
|
0
|
1
|
|
my($self,@fields) = @_; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my %content = $self->content(); |
70
|
0
|
|
|
|
|
|
my %new = (); |
71
|
0
|
|
|
|
|
|
foreach(grep defined $content{$_}, @fields) { $new{$_} = $content{$_}; } |
|
0
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
return %new; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub transaction_type { |
77
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
78
|
0
|
|
|
|
|
|
return $self->content()->{'action'}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub submit { |
82
|
0
|
|
|
0
|
1
|
|
my($self) = @_; |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
$self->map_fields(); |
85
|
0
|
|
|
|
|
|
$self->remap_fields( |
86
|
|
|
|
|
|
|
entry_method => 'EntryMethod', |
87
|
|
|
|
|
|
|
login => 'MerchantCode', |
88
|
|
|
|
|
|
|
password => 'MerchantPWD', |
89
|
|
|
|
|
|
|
serial => 'MerchantSerial', |
90
|
|
|
|
|
|
|
action => 'Trantype', |
91
|
|
|
|
|
|
|
amount => 'amount', |
92
|
|
|
|
|
|
|
invoice_number => 'invoicenum', |
93
|
|
|
|
|
|
|
order_number => 'referencenum', |
94
|
|
|
|
|
|
|
authorization => 'appcode', |
95
|
|
|
|
|
|
|
customer_id => 'customer', |
96
|
|
|
|
|
|
|
address => 'Address', |
97
|
|
|
|
|
|
|
zip => 'ZipCode', |
98
|
|
|
|
|
|
|
card_number => 'ccnumber', |
99
|
|
|
|
|
|
|
cvv2 => 'CVV2', |
100
|
|
|
|
|
|
|
); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# if ($self->action() == 0 || $self->action() == 1) # void or force |
103
|
|
|
|
|
|
|
# { |
104
|
|
|
|
|
|
|
# $self->required_fields(qw/login password serial action card_number expiration amount authorization/); |
105
|
|
|
|
|
|
|
# } |
106
|
|
|
|
|
|
|
# else |
107
|
|
|
|
|
|
|
# { |
108
|
0
|
|
|
|
|
|
$self->required_fields(qw/login password serial action card_number expiration amount/); |
109
|
|
|
|
|
|
|
# } |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my %post_data = $self->get_fields(qw/MerchantCode MerchantPWD MerchantSerial ccnumber |
112
|
|
|
|
|
|
|
expYear expMonth Trantype EntryMethod amount |
113
|
|
|
|
|
|
|
invoicenum ordernum Zipcode Address CVV2 CF appcode/); |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$post_data{'EntryMethod'} = 0; # hand entered, as opposed to swiped through a card reader |
116
|
0
|
|
|
|
|
|
$post_data{'CF'} = 'ON'; # return comma-delimited data |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
my $pd = make_form(%post_data); |
119
|
0
|
|
|
|
|
|
my $s = $self->server(); |
120
|
0
|
|
|
|
|
|
my $p = $self->port(); |
121
|
0
|
|
|
|
|
|
my $t = $self->path(); |
122
|
0
|
|
|
|
|
|
my $r = $self->{_content}->{referer}; |
123
|
0
|
|
|
|
|
|
my($page,$server_response,%headers) = post_https($s,$p,$t,$r,$pd); |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
my @col = split(',', $page); |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
$self->server_response($page); |
128
|
0
|
0
|
|
|
|
|
if($col[0] eq "0" ) { |
129
|
0
|
|
|
|
|
|
$self->is_success(1); |
130
|
0
|
|
|
|
|
|
$self->result_code($col[1]); |
131
|
0
|
|
|
|
|
|
$self->authorization($col[1]); |
132
|
|
|
|
|
|
|
} else { |
133
|
0
|
|
|
|
|
|
$self->is_success(0); |
134
|
0
|
|
|
|
|
|
$self->result_code($col[1]); |
135
|
0
|
|
|
|
|
|
$self->error_message($col[2]); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
$self->debug("<no response code, debug info follows>\n". |
139
|
|
|
|
|
|
|
"HTTPS response:\n $server_response\n\n". |
140
|
|
|
|
|
|
|
"HTTPS headers:\n ". |
141
|
0
|
|
|
|
|
|
join("\n ", map { "$_ => ". $headers{$_} } keys %headers ). "\n\n". |
142
|
|
|
|
|
|
|
"POST Data:\n ". |
143
|
0
|
|
|
|
|
|
join("\n ", map { "$_ => ". $post_data{$_} } keys %post_data ). "\n\n". |
144
|
|
|
|
|
|
|
"Raw HTTPS content:\n $page"); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |
148
|
|
|
|
|
|
|
__END__ |