line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::OnlinePayment::TransactionCentral; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
122000
|
use 5.005; |
|
8
|
|
|
|
|
33
|
|
|
8
|
|
|
|
|
330
|
|
4
|
8
|
|
|
8
|
|
43
|
use strict; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
269
|
|
5
|
8
|
|
|
8
|
|
60
|
use Carp; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
630
|
|
6
|
8
|
|
|
8
|
|
1816
|
use Business::OnlinePayment 3; |
|
8
|
|
|
|
|
7100
|
|
|
8
|
|
|
|
|
245
|
|
7
|
8
|
|
|
8
|
|
13481
|
use Business::OnlinePayment::HTTPS 0.02; |
|
8
|
|
|
|
|
161350
|
|
|
8
|
|
|
|
|
289
|
|
8
|
8
|
|
|
8
|
|
96
|
use vars qw($VERSION @ISA $DEBUG); |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
11919
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
@ISA = qw(Business::OnlinePayment::HTTPS); |
11
|
|
|
|
|
|
|
$VERSION = '0.06'; |
12
|
|
|
|
|
|
|
$DEBUG = 0; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub set_defaults { |
15
|
6
|
|
|
6
|
0
|
247
|
my $self = shift; |
16
|
|
|
|
|
|
|
|
17
|
6
|
|
|
|
|
188
|
$self->server('webservices.primerchants.com'); |
18
|
6
|
|
|
|
|
256
|
$self->port('443'); |
19
|
6
|
|
|
|
|
204
|
$self->path('/billing/TransactionCentral/'); |
20
|
|
|
|
|
|
|
|
21
|
6
|
|
|
|
|
90
|
$self->build_subs(qw( order_number avs_code cvv2_response |
22
|
|
|
|
|
|
|
response_page response_code response_headers |
23
|
|
|
|
|
|
|
)); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub submit { |
27
|
0
|
|
|
0
|
1
|
|
my($self) = @_; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$self->revmap_fields( |
30
|
|
|
|
|
|
|
'MerchantID' => 'login', |
31
|
|
|
|
|
|
|
'RegKey' => 'password', |
32
|
|
|
|
|
|
|
'Amount' => 'amount', |
33
|
|
|
|
|
|
|
# 'CreditAmount' => 'amount', |
34
|
|
|
|
|
|
|
'AccountNo' => 'card_number', |
35
|
|
|
|
|
|
|
'NameonAccount' => 'name', |
36
|
|
|
|
|
|
|
'AVSADDR' => 'address', |
37
|
|
|
|
|
|
|
'AVSZIP' => 'zip', |
38
|
|
|
|
|
|
|
'Email' => 'email', |
39
|
|
|
|
|
|
|
'CCRURL' => \'', |
40
|
|
|
|
|
|
|
'CVV2' => 'cvv2', |
41
|
|
|
|
|
|
|
'TransID' => 'order_number', |
42
|
|
|
|
|
|
|
'TRANSROUTE' => 'routing_code', |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
#XXX also set required fields here... |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my @required_fields = qw(login password); |
48
|
0
|
|
|
|
|
|
my %content = $self->content(); |
49
|
0
|
|
|
|
|
|
my $action = $content{'action'}; |
50
|
0
|
|
|
|
|
|
my $url = $self->path; |
51
|
0
|
0
|
|
|
|
|
if ( |
|
|
0
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$content{'type'} =~ /^(cc|visa|mastercard|american express|discover)$/i |
53
|
|
|
|
|
|
|
) { |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
if ( $action =~ /^\s*normal\s*authorization\s*$/i ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$url .= 'processCC.asp'; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#REFID |
59
|
0
|
|
|
|
|
|
$content{'REFID'} = int(rand(2**31)); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
#CCMonth & CCYear |
62
|
0
|
0
|
|
|
|
|
$content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/ |
63
|
|
|
|
|
|
|
or croak "unparsable expiration ". $content{'expiration'}; |
64
|
0
|
|
|
|
|
|
my( $month, $year ) = ( $1, $2 ); |
65
|
0
|
0
|
|
|
|
|
$month = '0'. $month if $month =~ /^\d$/; |
66
|
0
|
|
|
|
|
|
$content{'CCMonth'} = $month; |
67
|
0
|
|
|
|
|
|
$content{'CCYear'} = $year; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
push @required_fields, qw( amount card_number expiration |
70
|
|
|
|
|
|
|
name address zip |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} elsif ( $action =~ /^\s*authorization\s*only\s*$/i ) { |
74
|
0
|
|
|
|
|
|
croak "Authorizaiton Only is not supported by Transaction Central"; |
75
|
|
|
|
|
|
|
} elsif ( $action =~ /^\s*post\s*authorization\s*$/i ) { |
76
|
0
|
|
|
|
|
|
croak "Post Authorizaiton is not supported by Transaction Central"; |
77
|
|
|
|
|
|
|
} elsif ( $action =~ /^\s*(void|credit)\s*$/i ) { |
78
|
0
|
|
|
|
|
|
$url .= 'voidcreditcconline.asp'; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
$content{'CreditAmount'} = delete $content{'Amount'}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
} else { |
83
|
0
|
|
|
|
|
|
croak "Unknown action $action"; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} elsif ( $content{'type'} =~ /^e?check$/i ) { |
87
|
|
|
|
|
|
|
|
88
|
0
|
0
|
|
|
|
|
if ( $action =~ /^\s*normal\s*authorization\s*$/i ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
$url .= 'processcheckonline.asp'; |
90
|
0
|
|
|
|
|
|
$content{'AccountNo'} = $content{'account_number'}; |
91
|
0
|
0
|
0
|
|
|
|
$content{'TRANSTYPE'} = |
92
|
|
|
|
|
|
|
( exists($content{account_type}) && $content{account_type} =~ /^s/i ) |
93
|
|
|
|
|
|
|
? 'SA' |
94
|
|
|
|
|
|
|
: 'CK'; |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
push @required_fields, qw( amount account_number routing_code |
97
|
|
|
|
|
|
|
name |
98
|
|
|
|
|
|
|
); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} elsif ( $action =~ /^\s*authorization\s*only\s*$/i ) { |
101
|
0
|
|
|
|
|
|
croak "Authorizaiton Only is not supported by Transaction Central"; |
102
|
|
|
|
|
|
|
} elsif ( $action =~ /^\s*post\s*authorization\s*$/i ) { |
103
|
0
|
|
|
|
|
|
croak "Post Authorizaiton is not supported by Transaction Central"; |
104
|
|
|
|
|
|
|
} elsif ( $action =~ /^\s*(void|credit)\s*$/i ) { |
105
|
0
|
|
|
|
|
|
$url .= 'addckcreditupdtonline.asp'; |
106
|
|
|
|
|
|
|
} else { |
107
|
0
|
|
|
|
|
|
croak "Unknown action $action"; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
} else { |
111
|
0
|
|
|
|
|
|
croak 'Unknown type: '. $content{'type'}; |
112
|
|
|
|
|
|
|
} |
113
|
0
|
|
|
|
|
|
$self->path($url); |
114
|
0
|
|
|
|
|
|
$self->content(%content); |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
$self->required_fields(@required_fields); |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
my @fields = qw( |
119
|
|
|
|
|
|
|
MerchantID RegKey Amount REFID AccountNo CCMonth CCYear NameonAccount |
120
|
|
|
|
|
|
|
AVSADDR AVSZIP CCRURL CVV2 USER1 USER2 USER3 USER4 TrackData |
121
|
|
|
|
|
|
|
TransID CreditAmount |
122
|
|
|
|
|
|
|
DESCRIPTION DESCDATE TRANSTYPE TRANSROUTE |
123
|
|
|
|
|
|
|
); |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
my( $page, $response, %reply_headers ) = |
126
|
|
|
|
|
|
|
$self->https_post( $self->get_fields( @fields ) ); |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
$self->response_code( $response ); |
129
|
0
|
|
|
|
|
|
$self->response_page( $page ); |
130
|
0
|
|
|
|
|
|
$self->response_headers( \%reply_headers ); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
#trim off around the response we want |
133
|
0
|
|
|
|
|
|
$page =~ s/^[\s\n]*[\s\n]*[\s\n]*//; |
134
|
0
|
|
|
|
|
|
$page =~ s/[\s\n]*<\/body>[\s\n]*<\/html>[\s\n]*$//; |
135
|
|
|
|
|
|
|
|
136
|
0
|
0
|
|
|
|
|
my %return = map { /^(\w+)=(.*)$/ ? ( $1 => $2 ) : () } split(/&/, $page); |
|
0
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
0
|
0
|
|
|
|
|
if ( $DEBUG ) { warn "$_ => $return{$_}\n" foreach keys %return; } |
|
0
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
#$self->result_code( $return{'AVSCode'} ); |
141
|
0
|
|
|
|
|
|
$self->avs_code( $return{'AVSCode'} ); |
142
|
0
|
|
|
|
|
|
$self->cvv2_response( $return{'CVV2ResponseMsg'} ); |
143
|
|
|
|
|
|
|
|
144
|
0
|
0
|
0
|
|
|
|
if ( $return{'Auth'} =~ /^\s*(\w+)\s*$/ && lc($1) ne 'declined' ) { |
145
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
$self->is_success(1); |
147
|
0
|
|
|
|
|
|
$self->authorization( $return{'Auth'} ); |
148
|
0
|
|
|
|
|
|
$self->order_number( $return{'TransID'} ); |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
} else { |
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
$self->is_success(0); |
153
|
0
|
|
|
|
|
|
$self->error_message( $return{'Notes'} ); |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub revmap_fields { |
160
|
6
|
|
|
6
|
0
|
58
|
my($self, %map) = @_; |
161
|
6
|
|
|
|
|
24
|
my %content = $self->content(); |
162
|
6
|
|
|
|
|
122
|
foreach(keys %map) { |
163
|
|
|
|
|
|
|
# warn "$_ = ". ( ref($map{$_}) |
164
|
|
|
|
|
|
|
# ? ${ $map{$_} } |
165
|
|
|
|
|
|
|
# : $content{$map{$_}} ). "\n"; |
166
|
6
|
|
|
|
|
18
|
$content{$_} = ref($map{$_}) |
167
|
72
|
100
|
|
|
|
190
|
? ${ $map{$_} } |
168
|
|
|
|
|
|
|
: $content{$map{$_}}; |
169
|
|
|
|
|
|
|
} |
170
|
6
|
|
|
|
|
55
|
$self->content(%content); |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
1; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
__END__ |