line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::OnlinePayment::Capstone;
|
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
121466
|
use strict;
|
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
240
|
|
4
|
4
|
|
|
4
|
|
22
|
use Carp;
|
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
1726
|
|
5
|
|
|
|
|
|
|
#use Tie::IxHash;
|
6
|
4
|
|
|
4
|
|
4980
|
use URI::Escape;
|
|
4
|
|
|
|
|
7330
|
|
|
4
|
|
|
|
|
298
|
|
7
|
4
|
|
|
4
|
|
2604
|
use Business::OnlinePayment 3;
|
|
4
|
|
|
|
|
8690
|
|
|
4
|
|
|
|
|
139
|
|
8
|
4
|
|
|
4
|
|
4870
|
use Business::OnlinePayment::HTTPS 0.03;
|
|
4
|
|
|
|
|
93030
|
|
|
4
|
|
|
|
|
401
|
|
9
|
4
|
|
|
4
|
|
43
|
use vars qw($VERSION $DEBUG @ISA);
|
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
6920
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
@ISA = qw(Business::OnlinePayment::HTTPS);
|
12
|
|
|
|
|
|
|
$VERSION = '0.02';
|
13
|
|
|
|
|
|
|
$DEBUG = 0;
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub set_defaults {
|
16
|
2
|
|
|
2
|
0
|
94
|
my $self = shift;
|
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
|
|
70
|
$self->server('www.capstonepay.com');
|
19
|
2
|
|
|
|
|
84
|
$self->port('443');
|
20
|
2
|
|
|
|
|
72
|
$self->path('/cgi-bin/client/transaction.cgi');
|
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
|
|
32
|
$self->build_subs(qw( order_number avs_code cvv2_response ));
|
23
|
|
|
|
|
|
|
}
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub submit {
|
26
|
0
|
|
|
0
|
1
|
|
my($self) = @_;
|
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $action = $self->{_content}{'action'};
|
29
|
0
|
0
|
|
|
|
|
if ( $self->{_content}{'action'} =~ /^\s*normal\s*authorization\s*$/i ) {
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
$action = 'authpostauth';
|
31
|
|
|
|
|
|
|
} elsif ( $self->{_content}{'action'} =~ /^\s*authorization\s*only\s*$/i ) {
|
32
|
0
|
|
|
|
|
|
$action = 'auth';
|
33
|
|
|
|
|
|
|
} elsif ( $self->{_content}{'action'} =~ /^\s*post\s*authorization\s*$/i ) {
|
34
|
0
|
|
|
|
|
|
$action = 'postauth';
|
35
|
|
|
|
|
|
|
} elsif ( $self->{_content}{'action'} =~ /^\s*void\s*$/i ) {
|
36
|
0
|
|
|
|
|
|
$action = 'void';
|
37
|
|
|
|
|
|
|
} elsif ( $self->{_content}{'action'} =~ /^\s*credit\s*$/i ) {
|
38
|
0
|
|
|
|
|
|
$action = 'return';
|
39
|
|
|
|
|
|
|
}
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#$self->map_fields();
|
42
|
|
|
|
|
|
|
$self->revmap_fields(
|
43
|
0
|
|
|
|
|
|
merchantid =>'login',
|
44
|
|
|
|
|
|
|
account_password => 'password',
|
45
|
|
|
|
|
|
|
action => \$action,
|
46
|
|
|
|
|
|
|
amount => 'amount',
|
47
|
|
|
|
|
|
|
name => 'name',
|
48
|
|
|
|
|
|
|
address1 => 'address',
|
49
|
|
|
|
|
|
|
#address2
|
50
|
|
|
|
|
|
|
city => 'city',
|
51
|
|
|
|
|
|
|
state => 'state',
|
52
|
|
|
|
|
|
|
postal => 'zip',
|
53
|
|
|
|
|
|
|
country => 'country',
|
54
|
|
|
|
|
|
|
currency => \'USD', #XXX fix me
|
55
|
|
|
|
|
|
|
email => 'email',
|
56
|
|
|
|
|
|
|
ipaddress => 'customer_ip',
|
57
|
|
|
|
|
|
|
card_num => 'card_number',
|
58
|
|
|
|
|
|
|
#card_exp => 'expiration', #strip /
|
59
|
|
|
|
|
|
|
card_cvv => 'cvv2',
|
60
|
|
|
|
|
|
|
#start_date => 'card_start', #strip /
|
61
|
|
|
|
|
|
|
issue_num => 'issue_number',
|
62
|
|
|
|
|
|
|
#bank_name #XXX fix to support ACH
|
63
|
|
|
|
|
|
|
#bank_phone #XXX fix to support ACH
|
64
|
|
|
|
|
|
|
orderid => 'order_number',
|
65
|
|
|
|
|
|
|
custom0 => 'description',
|
66
|
|
|
|
|
|
|
);
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# => 'order_type',
|
69
|
|
|
|
|
|
|
# => 'transaction_type',
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#authorization =>
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
#company =>
|
74
|
|
|
|
|
|
|
#phone =>
|
75
|
|
|
|
|
|
|
#fax =>
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#invoice_number =>
|
78
|
|
|
|
|
|
|
#customer_id =>
|
79
|
|
|
|
|
|
|
#authorization => 'txn_number'
|
80
|
|
|
|
|
|
|
|
81
|
0
|
0
|
|
|
|
|
if ( $action =~ /^auth(postauth)?$/ ) {
|
|
|
0
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
$self->required_fields(qw(
|
84
|
|
|
|
|
|
|
login password action amount
|
85
|
|
|
|
|
|
|
name address city state zip
|
86
|
|
|
|
|
|
|
email
|
87
|
|
|
|
|
|
|
card_number expiration
|
88
|
|
|
|
|
|
|
));
|
89
|
|
|
|
|
|
|
|
90
|
0
|
0
|
|
|
|
|
$self->{_content}{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
|
91
|
|
|
|
|
|
|
or croak "unparsable expiration: ". $self->{_content}{expiration};
|
92
|
0
|
|
|
|
|
|
my( $month, $year ) = ( $1, $2 );
|
93
|
0
|
0
|
|
|
|
|
$month = '0'. $month if $month =~ /^\d$/;
|
94
|
0
|
|
|
|
|
|
$self->{_content}{card_exp} = $month.$year;
|
95
|
|
|
|
|
|
|
|
96
|
0
|
0
|
|
|
|
|
if ( $self->{_content}{'card_start'} ) {
|
97
|
0
|
0
|
|
|
|
|
$self->{_content}{'card_start'} =~ /^(\d+)\D+\d*(\d{2})$/
|
98
|
|
|
|
|
|
|
or croak "unparsable card_start ". $self->{_content}{card_start};
|
99
|
0
|
|
|
|
|
|
my( $month, $year ) = ( $1, $2 );
|
100
|
0
|
0
|
|
|
|
|
$month = '0'. $month if $month =~ /^\d$/;
|
101
|
0
|
|
|
|
|
|
$self->{_content}{start_date} = $month.$year;
|
102
|
|
|
|
|
|
|
}
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# $self->{_content}{amount} = sprintf('%.2f', $self->{_content}{amount} );
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
} elsif ( $action =~ /^(postauth|void|return)$/ ) {
|
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
$self->required_fields(qw(
|
109
|
|
|
|
|
|
|
login password action order_number
|
110
|
|
|
|
|
|
|
));
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
} else {
|
113
|
0
|
|
|
|
|
|
die "unknown action $action";
|
114
|
|
|
|
|
|
|
}
|
115
|
|
|
|
|
|
|
|
116
|
0
|
|
0
|
|
|
|
$self->{'_content'}{country} ||= 'US';
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
#tie my %post_data, 'Tie::IxHash', $self->get_fields(qw(
|
119
|
0
|
|
|
|
|
|
my %post_data = $self->get_fields(qw(
|
120
|
|
|
|
|
|
|
merchantid
|
121
|
|
|
|
|
|
|
account_password
|
122
|
|
|
|
|
|
|
action
|
123
|
|
|
|
|
|
|
amount
|
124
|
|
|
|
|
|
|
name
|
125
|
|
|
|
|
|
|
address1
|
126
|
|
|
|
|
|
|
city
|
127
|
|
|
|
|
|
|
state
|
128
|
|
|
|
|
|
|
postal
|
129
|
|
|
|
|
|
|
country
|
130
|
|
|
|
|
|
|
currency
|
131
|
|
|
|
|
|
|
email
|
132
|
|
|
|
|
|
|
ipaddress
|
133
|
|
|
|
|
|
|
card_num
|
134
|
|
|
|
|
|
|
card_exp
|
135
|
|
|
|
|
|
|
card_cvv
|
136
|
|
|
|
|
|
|
state_date
|
137
|
|
|
|
|
|
|
issue_num
|
138
|
|
|
|
|
|
|
bank_name
|
139
|
|
|
|
|
|
|
bank_phone
|
140
|
|
|
|
|
|
|
orderid
|
141
|
|
|
|
|
|
|
custom0
|
142
|
|
|
|
|
|
|
));
|
143
|
|
|
|
|
|
|
|
144
|
0
|
0
|
|
|
|
|
warn join("\n", map { "$_: ". $post_data{$_} } keys %post_data )
|
|
0
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
if $DEBUG;
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
#my( $page, $response, @reply_headers) = $self->https_post( \%post_data );
|
148
|
0
|
|
|
|
|
|
my( $page, $response, @reply_headers) = $self->https_post( %post_data );
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
#my %reply_headers = @reply_headers;
|
151
|
|
|
|
|
|
|
#warn join('', map { " $_ => $reply_headers{$_}\n" } keys %reply_headers )
|
152
|
|
|
|
|
|
|
# if $DEBUG;
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
#XXX check $response and die if not 200?
|
155
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
$self->server_response($page);
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
#warn "****** $page *******";
|
159
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
$page =~ s/^\n+//;
|
161
|
|
|
|
|
|
|
|
162
|
0
|
0
|
|
|
|
|
my %result = map {
|
163
|
0
|
|
|
|
|
|
/^(\w+)=(.*)$/ or die "can't parse response: $_";
|
164
|
0
|
|
|
|
|
|
($1, uri_unescape($2));
|
165
|
|
|
|
|
|
|
}
|
166
|
|
|
|
|
|
|
split(/\&/, $page);
|
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
$self->result_code( $result{'status_code'} );
|
169
|
0
|
|
|
|
|
|
$self->avs_code( $result{'avs_resp'} );
|
170
|
0
|
|
|
|
|
|
$self->cvv2_response( $result{'cvv_resp'} );
|
171
|
|
|
|
|
|
|
|
172
|
0
|
0
|
|
|
|
|
if ( $result{'status'} eq 'good' ) {
|
|
|
0
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
$self->is_success(1);
|
174
|
0
|
|
|
|
|
|
$self->authorization( $result{'auth_code'} );
|
175
|
0
|
|
|
|
|
|
$self->order_number( $result{'orderid'} );
|
176
|
|
|
|
|
|
|
} elsif ( $result{'status'} =~ /^(bad|error|fraud)$/ ) {
|
177
|
0
|
|
|
|
|
|
$self->is_success(0);
|
178
|
0
|
|
|
|
|
|
$self->error_message("$1: ". $result{'status_msg'});
|
179
|
|
|
|
|
|
|
} else {
|
180
|
0
|
0
|
|
|
|
|
die "unparsable response received from gateway".
|
181
|
|
|
|
|
|
|
( $DEBUG ? ": $page" : '' );
|
182
|
|
|
|
|
|
|
}
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
}
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub revmap_fields {
|
187
|
2
|
|
|
2
|
0
|
30
|
my($self, %map) = @_;
|
188
|
2
|
|
|
|
|
18
|
my %content = $self->content();
|
189
|
2
|
|
|
|
|
42
|
foreach(keys %map) {
|
190
|
|
|
|
|
|
|
# warn "$_ = ". ( ref($map{$_})
|
191
|
|
|
|
|
|
|
# ? ${ $map{$_} }
|
192
|
|
|
|
|
|
|
# : $content{$map{$_}} ). "\n";
|
193
|
4
|
|
|
|
|
10
|
$content{$_} = ref($map{$_})
|
194
|
36
|
100
|
|
|
|
79
|
? ${ $map{$_} }
|
195
|
|
|
|
|
|
|
: $content{$map{$_}};
|
196
|
|
|
|
|
|
|
}
|
197
|
2
|
|
|
|
|
18
|
$self->content(%content);
|
198
|
|
|
|
|
|
|
}
|
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
1;
|
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
__END__
|