line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::OnlinePayment::SecureHostingUPG;
|
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
65110
|
use strict;
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
111
|
|
4
|
3
|
|
|
3
|
|
17
|
use Carp;
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
198
|
|
5
|
3
|
|
|
3
|
|
897
|
use Business::OnlinePayment 3;
|
|
3
|
|
|
|
|
3942
|
|
|
3
|
|
|
|
|
149
|
|
6
|
3
|
|
|
3
|
|
2488
|
use Business::OnlinePayment::HTTPS;
|
|
3
|
|
|
|
|
43161
|
|
|
3
|
|
|
|
|
125
|
|
7
|
3
|
|
|
3
|
|
30
|
use vars qw($VERSION $DEBUG @ISA);
|
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
3547
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
@ISA = qw(Business::OnlinePayment::HTTPS);
|
10
|
|
|
|
|
|
|
$VERSION = '0.03';
|
11
|
|
|
|
|
|
|
$DEBUG = 0;
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub set_defaults {
|
14
|
2
|
|
|
2
|
0
|
98
|
my $self = shift;
|
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
|
|
67
|
$self->server('www.secure-server-hosting.com');
|
17
|
2
|
|
|
|
|
88
|
$self->port('443');
|
18
|
2
|
|
|
|
|
88
|
$self->path('/secutran/transactionjs1.php');
|
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
27
|
$self->build_subs(qw(
|
21
|
|
|
|
|
|
|
order_number avs_code
|
22
|
|
|
|
|
|
|
));
|
23
|
|
|
|
|
|
|
# order_type
|
24
|
|
|
|
|
|
|
# md5 cvv2_response cavv_response
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
}
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub submit {
|
29
|
0
|
|
|
0
|
1
|
|
my($self) = @_;
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#$self->map_fields();
|
32
|
0
|
|
|
|
|
|
$self->remap_fields(
|
33
|
|
|
|
|
|
|
# => 'order_type',
|
34
|
|
|
|
|
|
|
# => 'transaction_type',
|
35
|
|
|
|
|
|
|
login => 'shreference',
|
36
|
|
|
|
|
|
|
password => 'checkcode',
|
37
|
|
|
|
|
|
|
#authorization =>
|
38
|
|
|
|
|
|
|
#customer_ip =>
|
39
|
|
|
|
|
|
|
name => 'cardholdersname',
|
40
|
|
|
|
|
|
|
#first_name =>
|
41
|
|
|
|
|
|
|
#last_name =>
|
42
|
|
|
|
|
|
|
#company =>
|
43
|
|
|
|
|
|
|
address => 'cardholderaddr1',
|
44
|
|
|
|
|
|
|
# => 'cardholderaddr2',
|
45
|
|
|
|
|
|
|
city => 'cardholdercity',
|
46
|
|
|
|
|
|
|
state => 'cardholderstate',
|
47
|
|
|
|
|
|
|
zip => 'cardholderpostcode',
|
48
|
|
|
|
|
|
|
#country =>
|
49
|
|
|
|
|
|
|
phone => 'cardholdertelephonenumber',
|
50
|
|
|
|
|
|
|
#fax =>
|
51
|
|
|
|
|
|
|
email => 'cardholdersemail',
|
52
|
|
|
|
|
|
|
card_number => 'cardnumber',
|
53
|
|
|
|
|
|
|
# => 'cardexpiremonth',
|
54
|
|
|
|
|
|
|
# => 'cardexpireyear',
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
'amount' => 'transactionamount',
|
57
|
|
|
|
|
|
|
#invoice_number =>
|
58
|
|
|
|
|
|
|
#customer_id =>
|
59
|
|
|
|
|
|
|
#order_number =>
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
currency => 'transactioncurrency',
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#expiration =>
|
64
|
|
|
|
|
|
|
cvv2 => 'cv2',
|
65
|
|
|
|
|
|
|
issue_number => 'switchnumber',
|
66
|
|
|
|
|
|
|
);
|
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
die "only Normal Authorization is currently supported"
|
69
|
|
|
|
|
|
|
unless $self->{_content}{'action'} =~ /^\s*normal\s*authorization\s*$/i;
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#cardexpiremonth & cardexpireyear
|
72
|
0
|
0
|
|
|
|
|
$self->{_content}{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
|
73
|
|
|
|
|
|
|
or croak "unparsable expiration ". $self->{_content}{expiration};
|
74
|
0
|
|
|
|
|
|
my( $month, $year ) = ( $1, $2 );
|
75
|
0
|
0
|
|
|
|
|
$month = '0'. $month if $month =~ /^\d$/;
|
76
|
0
|
|
|
|
|
|
$self->{_content}{cardexpiremonth} = $month;
|
77
|
0
|
|
|
|
|
|
$self->{_content}{cardexpireyear} = $year;
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#cardstartmonth & cardstartyear
|
80
|
0
|
0
|
|
|
|
|
$self->{_content}{'card_start'} =~ /^(\d+)\D+\d*(\d{2})$/
|
81
|
|
|
|
|
|
|
or croak "unparsable card_start ". $self->{_content}{expiration};
|
82
|
0
|
|
|
|
|
|
my( $smonth, $syear ) = ( $1, $2 );
|
83
|
0
|
0
|
|
|
|
|
$smonth = '0'. $smonth if $smonth =~ /^\d$/;
|
84
|
0
|
|
|
|
|
|
$self->{_content}{cardstartmonth} = $smonth;
|
85
|
0
|
|
|
|
|
|
$self->{_content}{cardstartyear} = $syear;
|
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
$self->required_fields(qw(
|
88
|
|
|
|
|
|
|
shreference checkcode transactionamount transactioncurrency
|
89
|
|
|
|
|
|
|
cardexpireyear cardexpiremonth cardstartyear cardstartmonth
|
90
|
|
|
|
|
|
|
switchnumber cv2 cardnumber cardholdersname cardholdersemail
|
91
|
|
|
|
|
|
|
));
|
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my( $page, $response, @reply_headers) =
|
94
|
|
|
|
|
|
|
$self->https_post( $self->get_fields( $self->fields ) );
|
95
|
|
|
|
|
|
|
#my( $page, $response, @reply_headers) =
|
96
|
|
|
|
|
|
|
# $self->https_get( $self->get_fields( $self->fields ) );
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
#my %reply_headers = @reply_headers;
|
99
|
|
|
|
|
|
|
#warn join('', map { " $_ => $reply_headers{$_}\n" } keys %reply_headers )
|
100
|
|
|
|
|
|
|
# if $DEBUG;
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
#XXX check $response and die if not 200?
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# avs_code
|
105
|
|
|
|
|
|
|
# is_success
|
106
|
|
|
|
|
|
|
# result_code
|
107
|
|
|
|
|
|
|
# authorization
|
108
|
|
|
|
|
|
|
#md5 cvv2_response cavv_response ...?
|
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
$self->server_response($page);
|
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
my $result = $self->GetXMLProp($page, 'result');
|
113
|
|
|
|
|
|
|
|
114
|
0
|
0
|
0
|
|
|
|
if ( defined($result) && $result eq 'success' ) {
|
|
|
0
|
0
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$self->is_success(1);
|
116
|
0
|
|
|
|
|
|
$self->avs_code( $self->GetXMLProp($page, 'cv2asvresult') );
|
117
|
|
|
|
|
|
|
} elsif ( defined($result) && $result eq 'failed' ) {
|
118
|
0
|
|
|
|
|
|
$self->is_success(0);
|
119
|
0
|
|
|
|
|
|
my $error = '';
|
120
|
0
|
|
|
|
|
|
my $tranerrdesc = $self->GetXMLProp($page, 'tranerrdesc');
|
121
|
0
|
|
|
|
|
|
my $tranerrdetail = $self->GetXMLProp($page, 'tranerrdetail');
|
122
|
0
|
0
|
|
|
|
|
$error = $tranerrdesc if defined $tranerrdesc;
|
123
|
0
|
0
|
0
|
|
|
|
$error .= " - $tranerrdetail"
|
124
|
|
|
|
|
|
|
if defined $tranerrdetail && length $tranerrdetail;
|
125
|
0
|
|
|
|
|
|
$self->error_message($error);
|
126
|
|
|
|
|
|
|
} else {
|
127
|
0
|
0
|
|
|
|
|
die "unparsable response received from gateway".
|
128
|
|
|
|
|
|
|
( $DEBUG ? ": $page" : '' );
|
129
|
|
|
|
|
|
|
}
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
}
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub fields {
|
135
|
2
|
|
|
2
|
0
|
4
|
my $self = shift;
|
136
|
|
|
|
|
|
|
|
137
|
2
|
|
|
|
|
21
|
qw(
|
138
|
|
|
|
|
|
|
shreference
|
139
|
|
|
|
|
|
|
checkcode
|
140
|
|
|
|
|
|
|
transactionamout
|
141
|
|
|
|
|
|
|
transactioncurrency
|
142
|
|
|
|
|
|
|
cardexpireyear
|
143
|
|
|
|
|
|
|
cardexpiremonth
|
144
|
|
|
|
|
|
|
cardstartyear
|
145
|
|
|
|
|
|
|
cardstartmonth
|
146
|
|
|
|
|
|
|
switchnumber
|
147
|
|
|
|
|
|
|
cv2
|
148
|
|
|
|
|
|
|
cardnumber
|
149
|
|
|
|
|
|
|
cardholdersname
|
150
|
|
|
|
|
|
|
cardholdersemail
|
151
|
|
|
|
|
|
|
cardholderaddr1
|
152
|
|
|
|
|
|
|
cardholderaddr2
|
153
|
|
|
|
|
|
|
cardholdercity
|
154
|
|
|
|
|
|
|
cardholderstate
|
155
|
|
|
|
|
|
|
cardholderpostcode
|
156
|
|
|
|
|
|
|
cardholdertelephonenumber
|
157
|
|
|
|
|
|
|
);
|
158
|
|
|
|
|
|
|
}
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub GetXMLProp {
|
161
|
2
|
|
|
2
|
0
|
7
|
my( $self, $raw, $prop ) = @_;
|
162
|
2
|
|
|
|
|
38
|
local $^W=0;
|
163
|
|
|
|
|
|
|
|
164
|
2
|
|
|
|
|
4
|
my $data;
|
165
|
2
|
|
|
|
|
85
|
($data) = $raw =~ m"<$prop>(.*?)$prop>"gsi;
|
166
|
|
|
|
|
|
|
#$data =~ s/<.*?>/ /gs;
|
167
|
2
|
|
|
|
|
9
|
chomp $data;
|
168
|
2
|
|
|
|
|
10
|
return $data;
|
169
|
|
|
|
|
|
|
}
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
1;
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
__END__
|