line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::OnlinePayment::BankOfAmerica; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: BankOfAmerica.pm,v 1.3 2002/11/19 23:41:24 ivan Exp $ |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1448
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp qw(croak); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
73
|
|
7
|
1
|
|
|
1
|
|
1065
|
use Business::OnlinePayment; |
|
1
|
|
|
|
|
4174
|
|
|
1
|
|
|
|
|
37
|
|
8
|
1
|
|
|
1
|
|
1465
|
use Net::SSLeay qw/make_form post_https make_headers/; |
|
1
|
|
|
|
|
24412
|
|
|
1
|
|
|
|
|
669
|
|
9
|
|
|
|
|
|
|
#use Text::CSV; |
10
|
1
|
|
|
1
|
|
12
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1801
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require Exporter; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
@ISA = qw(Exporter AutoLoader Business::OnlinePayment); |
15
|
|
|
|
|
|
|
@EXPORT = qw(); |
16
|
|
|
|
|
|
|
@EXPORT_OK = qw(); |
17
|
|
|
|
|
|
|
$VERSION = '1.02'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub set_defaults { |
20
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
$self->server('cart.bamart.com'); |
23
|
0
|
|
|
|
|
|
$self->port('443'); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub revmap_fields { |
28
|
0
|
|
|
0
|
0
|
|
my($self, %map) = @_; |
29
|
0
|
|
|
|
|
|
my %content = $self->content(); |
30
|
0
|
|
|
|
|
|
foreach(keys %map) { |
31
|
|
|
|
|
|
|
# warn "$_ = ". ( ref($map{$_}) |
32
|
|
|
|
|
|
|
# ? ${ $map{$_} } |
33
|
|
|
|
|
|
|
# : $content{$map{$_}} ). "\n"; |
34
|
0
|
|
|
|
|
|
$content{$_} = ref($map{$_}) |
35
|
0
|
0
|
|
|
|
|
? ${ $map{$_} } |
36
|
|
|
|
|
|
|
: $content{$map{$_}}; |
37
|
|
|
|
|
|
|
} |
38
|
0
|
|
|
|
|
|
$self->content(%content); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub get_fields { |
42
|
0
|
|
|
0
|
1
|
|
my($self,@fields) = @_; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my %content = $self->content(); |
45
|
0
|
|
|
|
|
|
my %new = (); |
46
|
0
|
|
|
|
|
|
foreach( grep defined $content{$_}, @fields) { $new{$_} = $content{$_}; } |
|
0
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return %new; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub order_number { |
51
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
52
|
0
|
0
|
|
|
|
|
if (@_) { |
53
|
0
|
|
|
|
|
|
$self->{order_number} = shift; |
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
|
|
|
return $self->{order_number}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub submit { |
59
|
0
|
|
|
0
|
1
|
|
my($self) = @_; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my %content = $self->content; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $action = lc($content{'action'}); |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
die 'Normal Authorization not supported' |
66
|
|
|
|
|
|
|
if $action eq 'normal authorization'; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my @fields; |
69
|
0
|
|
|
|
|
|
my $ioc_indicator = ''; |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
if ( $action eq 'authorization only' ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$self->path('/payment.mart'); |
73
|
0
|
|
|
|
|
|
@fields = qw( |
74
|
|
|
|
|
|
|
ioc_merchant_id ioc_order_total_amount ioc_merchant_shopper_id |
75
|
|
|
|
|
|
|
ioc_merchant_order_id ecom_billto_postal_name_first |
76
|
|
|
|
|
|
|
ecom_billto_postal_name_last ecom_billto_postal_street_line1 |
77
|
|
|
|
|
|
|
ecom_billto_postal_street_line2 ecom_billto_postal_city |
78
|
|
|
|
|
|
|
ecom_billto_postal_stateprov ecom_billto_postal_postalcode |
79
|
|
|
|
|
|
|
ecom_billto_postal_countrycode ecom_billto_telecom_phone_number |
80
|
|
|
|
|
|
|
ecom_billto_online_email ecom_payment_card_name |
81
|
|
|
|
|
|
|
ecom_payment_card_number ecom_payment_card_expdate_month |
82
|
|
|
|
|
|
|
ecom_payment_card_expdate_year |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
} elsif ( $action eq 'credit' ) { |
85
|
0
|
|
|
|
|
|
$self->path('/Settlement.mart'); |
86
|
0
|
|
|
|
|
|
$ioc_indicator = 'R'; |
87
|
0
|
|
|
|
|
|
@fields = qw( |
88
|
|
|
|
|
|
|
ioc_handshake_id ioc_merchant_id ioc_user_name ioc_password |
89
|
|
|
|
|
|
|
ioc_order_number ioc_indicator ioc_settlement_amount |
90
|
|
|
|
|
|
|
ioc_authorization_code ioc_email_flag |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
# ioc_email_flag ioc_close_flag ioc_invoice_notes ioc_email_notes_flag |
93
|
|
|
|
|
|
|
} elsif ( $action eq 'post authorization' ) { |
94
|
0
|
|
|
|
|
|
$self->path('/Settlement.mart'); |
95
|
0
|
|
|
|
|
|
$ioc_indicator = 'S'; |
96
|
0
|
|
|
|
|
|
@fields = qw( |
97
|
|
|
|
|
|
|
ioc_handshake_id ioc_merchant_id ioc_user_name ioc_password |
98
|
|
|
|
|
|
|
ioc_order_number ioc_indicator ioc_settlement_amount |
99
|
|
|
|
|
|
|
ioc_authorization_code ioc_email_flag |
100
|
|
|
|
|
|
|
); |
101
|
|
|
|
|
|
|
# ioc_email_flag ioc_close_flag ioc_invoice_notes ioc_email_notes_flag |
102
|
|
|
|
|
|
|
} else { |
103
|
0
|
|
|
|
|
|
die "unknown action $action"; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# $self->required_fields(qw/type login password action amount last_name |
107
|
|
|
|
|
|
|
# first_name card_number expiration/); |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
my($month, $year); |
110
|
0
|
0
|
|
|
|
|
unless ( $action eq 'post authorization' ) { |
111
|
|
|
|
|
|
|
|
112
|
0
|
0
|
|
|
|
|
if ( $self->transaction_type() =~ |
113
|
|
|
|
|
|
|
/^(cc|visa|mastercard|american express|discover)$/i |
114
|
|
|
|
|
|
|
) { |
115
|
|
|
|
|
|
|
} else { |
116
|
0
|
|
|
|
|
|
Carp::croak("BankOfAmerica can't handle transaction type: ". |
117
|
|
|
|
|
|
|
$self->transaction_type()); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
0
|
0
|
|
|
|
|
$content{'expiration'} =~ /^(\d+)\D+(\d+)$/ |
121
|
|
|
|
|
|
|
or croak "unparsable expiration $content{expiration}"; |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
( $month, $year ) = ( $1, $2 ); |
124
|
0
|
0
|
|
|
|
|
$year += 2000 if $year < 2000; #not y4k safe, oh shit |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
$self->revmap_fields( |
129
|
0
|
|
0
|
|
|
|
ioc_merchant_id => \($self->merchant_id()), |
130
|
|
|
|
|
|
|
ioc_user_name => 'login', |
131
|
|
|
|
|
|
|
ioc_password => 'password', |
132
|
|
|
|
|
|
|
ioc_invoice_notes => 'description', |
133
|
|
|
|
|
|
|
ioc_order_total_amount => 'amount', |
134
|
|
|
|
|
|
|
ioc_settlement_amount => 'amount', |
135
|
|
|
|
|
|
|
ioc_merchant_order_id => 'invoice_number', |
136
|
|
|
|
|
|
|
ioc_order_number => 'order_number', |
137
|
|
|
|
|
|
|
ioc_merchant_shopper_id => 'customer_id', |
138
|
|
|
|
|
|
|
ecom_billto_postal_name_last => 'last_name', |
139
|
|
|
|
|
|
|
ecom_billto_postal_name_first => 'first_name', |
140
|
|
|
|
|
|
|
ecom_billto_postal_street_line1 => 'address', |
141
|
|
|
|
|
|
|
#!!! ecom_billto_postal_street_line2 => 'address', |
142
|
|
|
|
|
|
|
ecom_billto_postal_city => 'city', |
143
|
|
|
|
|
|
|
ecom_billto_postal_stateprov => 'state', |
144
|
|
|
|
|
|
|
ecom_billto_postal_postalcode => 'zip', |
145
|
|
|
|
|
|
|
ecom_payment_card_number => 'card_number', |
146
|
|
|
|
|
|
|
ecom_billto_postal_countrycode => 'country', |
147
|
|
|
|
|
|
|
ecom_billto_telecom_phone_number => 'phone', |
148
|
|
|
|
|
|
|
ecom_billto_online_email => 'email', |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
ecom_payment_card_name => |
151
|
|
|
|
|
|
|
\( $content{'name'} || "$content{first_name} $content{last_name}" ), |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
ecom_payment_card_expdate_month => \$month, |
154
|
|
|
|
|
|
|
ecom_payment_card_expdate_year => \$year, |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
ioc_authorization_code => 'authorization', |
157
|
|
|
|
|
|
|
ioc_indicator => \$ioc_indicator, |
158
|
|
|
|
|
|
|
ioc_handshake_id => 'order_number', |
159
|
|
|
|
|
|
|
ioc_email_flag => \'No', |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
); |
162
|
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
my %post_data = $self->get_fields( @fields ); |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
# warn "$_ => $post_data{$_}\n" for keys %post_data; |
166
|
|
|
|
|
|
|
# warn "\n"; |
167
|
0
|
|
|
|
|
|
my $pd = make_form(%post_data); |
168
|
0
|
|
|
|
|
|
my $s = $self->server(); |
169
|
0
|
|
|
|
|
|
my $p = $self->port(); |
170
|
0
|
|
|
|
|
|
my $t = $self->path(); |
171
|
0
|
0
|
|
|
|
|
my $headers = make_headers('Referer' => $content{'referer'} ) |
172
|
|
|
|
|
|
|
unless $action eq 'post authorization'; |
173
|
0
|
|
|
|
|
|
my($page,$server_response,%headers) = post_https($s,$p,$t,$headers,$pd); |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
my %response; |
176
|
0
|
0
|
|
|
|
|
if ( $action eq 'post authorization' ) { |
177
|
|
|
|
|
|
|
# warn $page; |
178
|
|
|
|
|
|
|
#$page =~ s/.*//s; |
179
|
|
|
|
|
|
|
#$page =~ s/\n+$//g; |
180
|
0
|
|
|
|
|
|
$page =~ s/\r//g; |
181
|
0
|
0
|
0
|
|
|
|
%response = |
182
|
0
|
|
|
|
|
|
map { /^(\w+)\=(.*)$/ or /^()()$/ or die "unparsable response: $_"; |
183
|
0
|
|
|
|
|
|
lc($1) => $2 } |
184
|
|
|
|
|
|
|
#split(/\r/, $page); |
185
|
|
|
|
|
|
|
split(/\n/, $page); |
186
|
|
|
|
|
|
|
} else { |
187
|
0
|
0
|
|
|
|
|
%response = |
188
|
0
|
|
|
|
|
|
map { /^(\w+)\=(.*)$/ or die "unparsable response: $_"; |
189
|
0
|
|
|
|
|
|
lc($1) => $2 } |
190
|
|
|
|
|
|
|
split(/\ /i, $page); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
#warn "$_ => $response{$_}\n" for keys %response; |
194
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
$self->server_response($page); |
196
|
|
|
|
|
|
|
|
197
|
0
|
0
|
|
|
|
|
if ( $response{'ioc_response_code'} eq '0' ) { |
198
|
0
|
|
|
|
|
|
$self->is_success(1); |
199
|
0
|
|
|
|
|
|
$self->result_code($response{'ioc_response_code'}); |
200
|
0
|
|
|
|
|
|
$self->authorization($response{'ioc_authorization_code'}); |
201
|
0
|
|
|
|
|
|
$self->order_number($response{'ioc_order_id'}); |
202
|
|
|
|
|
|
|
} else { |
203
|
0
|
|
|
|
|
|
$self->is_success(0); |
204
|
0
|
|
|
|
|
|
$self->result_code($response{'ioc_response_code'}); |
205
|
0
|
0
|
|
|
|
|
my $error = |
206
|
|
|
|
|
|
|
$action eq 'post authorization' |
207
|
|
|
|
|
|
|
? $response{'ioc_response_desc'} |
208
|
|
|
|
|
|
|
: $response{'ioc_reject_description'}; |
209
|
0
|
0
|
|
|
|
|
$error .= ': '. $response{'ioc_missing_fields'} |
210
|
|
|
|
|
|
|
if $response{'ioc_missing_fields'}; |
211
|
0
|
0
|
|
|
|
|
$error .= ': '. $response{'ioc_invalid_fields'} |
212
|
|
|
|
|
|
|
if $response{'ioc_invalid_fields'}; |
213
|
0
|
|
|
|
|
|
$self->error_message($error); |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
1; |
219
|
|
|
|
|
|
|
__END__ |