line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::OnlinePayment::Ingotz; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
803
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
970
|
use Business::OnlinePayment; |
|
1
|
|
|
|
|
3169
|
|
|
1
|
|
|
|
|
27
|
|
5
|
1
|
|
|
1
|
|
1138
|
use Net::SSLeay qw/make_form post_https/; |
|
1
|
|
|
|
|
15882
|
|
|
1
|
|
|
|
|
527
|
|
6
|
1
|
|
|
1
|
|
10
|
use vars qw/@ISA $VERSION @EXPORT @EXPORT_OK $DEBUG %ERRORS/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
874
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$DEBUG = 1; |
9
|
|
|
|
|
|
|
@ISA = qw(Exporter AutoLoader Business::OnlinePayment); |
10
|
|
|
|
|
|
|
@EXPORT = qw(); |
11
|
|
|
|
|
|
|
@EXPORT_OK = qw(); |
12
|
|
|
|
|
|
|
$VERSION = '0.01'; |
13
|
|
|
|
|
|
|
%ERRORS = ( |
14
|
|
|
|
|
|
|
'-1' => "Not enough points for the transactions (not enough funds)", |
15
|
|
|
|
|
|
|
'-2' => "Invalid card/pin number", |
16
|
|
|
|
|
|
|
'-3' => "Invalid merchant number", |
17
|
|
|
|
|
|
|
'-4' => "System error", |
18
|
|
|
|
|
|
|
'-5' => "System unavailable", |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub set_defaults{ |
23
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
24
|
0
|
|
|
|
|
|
$self->server('secure.ingotz.com'); |
25
|
0
|
|
|
|
|
|
$self->port('443'); |
26
|
0
|
|
|
|
|
|
$self->path('/process/process.jsp'); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub map_fields{ |
31
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
32
|
0
|
|
|
|
|
|
my %content = $self->content(); |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my %actions = ( 'normal authorization' => 'raw' ); |
35
|
0
|
|
0
|
|
|
|
$content{action} = $actions{lc $content{action}} || 'raw'; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
$self->content(%content); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub remap_fields{ |
42
|
0
|
|
|
0
|
1
|
|
my ($self, %map) = @_; |
43
|
0
|
|
|
|
|
|
my %content = $self->content(); |
44
|
0
|
|
0
|
|
|
|
for (keys %map){ $content{$map{$_}} = $content{$_} || '' } |
|
0
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$self->content(%content); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub get_fields{ |
50
|
0
|
|
|
0
|
1
|
|
my ($self,@fields) = @_; |
51
|
0
|
|
|
|
|
|
my %content = $self->content(); |
52
|
0
|
|
|
|
|
|
my %new = (); |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
0
|
|
|
|
for (@fields){ $new{$_} = $content{$_} || '' } |
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return %new; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub submit{ |
61
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
$self->map_fields(); |
64
|
0
|
|
|
|
|
|
$self->remap_fields( |
65
|
|
|
|
|
|
|
login => 'merchant_id', |
66
|
|
|
|
|
|
|
action => 'ingtype', |
67
|
|
|
|
|
|
|
description => 'info', |
68
|
|
|
|
|
|
|
amount => 'amount', |
69
|
|
|
|
|
|
|
card_number => 'card_number', |
70
|
|
|
|
|
|
|
pin => 'pin', |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
$self->required_fields( qw/login action amount card_number pin/ ); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Now we are ready to post request |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my %post_data = $self->get_fields( |
78
|
|
|
|
|
|
|
qw/merchant_id ingtype info amount card_number pin/ |
79
|
|
|
|
|
|
|
); |
80
|
0
|
|
|
|
|
|
my $pd = make_form(%post_data); |
81
|
0
|
|
|
|
|
|
my ($page, $server_response, %headers) = post_https( |
82
|
|
|
|
|
|
|
$self->server(), |
83
|
|
|
|
|
|
|
$self->port(), |
84
|
|
|
|
|
|
|
$self->path(), |
85
|
|
|
|
|
|
|
'', |
86
|
|
|
|
|
|
|
$pd, |
87
|
|
|
|
|
|
|
); |
88
|
0
|
|
|
|
|
|
$self->response_code($server_response); |
89
|
0
|
|
|
|
|
|
$self->response_headers(%headers); |
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
|
if ($server_response =~/200 OK/) { |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# Handling server response |
94
|
|
|
|
|
|
|
# the response will either be |
95
|
|
|
|
|
|
|
# > 0 a valid transaction this number is the transaction number for |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$page=~s/\s//msg; |
98
|
0
|
0
|
|
|
|
|
print STDERR "Server Response:\n$page\n" if $DEBUG; |
99
|
0
|
0
|
|
|
|
|
if ($page > 0) { |
100
|
0
|
|
|
|
|
|
$self->is_success(1); |
101
|
0
|
|
|
|
|
|
$self->result_code($page); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
else { |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# -1 Not enough points for the transactions (not enough funds) |
106
|
|
|
|
|
|
|
# -2 Invalid card/pin number |
107
|
|
|
|
|
|
|
# -3 invalid merchant number |
108
|
|
|
|
|
|
|
# -4 System Error |
109
|
|
|
|
|
|
|
# -5 System unavailable |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
$self->is_success(0); |
112
|
0
|
|
|
|
|
|
$self->result_code($page); |
113
|
0
|
|
0
|
|
|
|
$self->error_message($ERRORS{$page} || 'Unknown Error'); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
else { |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# HTTP Error |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
$self->is_success(0); |
122
|
0
|
|
|
|
|
|
$self->result_code('-6'); |
123
|
0
|
|
|
|
|
|
$self->error_message('HTTP error: check response code'); |
124
|
0
|
|
|
|
|
|
$self->server_response($page); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub response_headers{ |
130
|
0
|
|
|
0
|
1
|
|
my ($self, %headers) = @_; |
131
|
0
|
0
|
|
|
|
|
$self->{headers} = join "\n", map{"$_: $headers{$_}"} keys %headers |
|
0
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
if %headers; |
133
|
0
|
|
|
|
|
|
$self->{headers}; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub response_code{ |
138
|
0
|
|
|
0
|
1
|
|
my ($self, $code) = @_; |
139
|
0
|
0
|
|
|
|
|
$self->{code} = $code if $code; |
140
|
0
|
|
|
|
|
|
$self->{code}; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
### |
145
|
|
|
|
|
|
|
# That's all |
146
|
|
|
|
|
|
|
# |
147
|
|
|
|
|
|
|
1; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
__END__ |