line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::PayPoint::MCPE; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
67949
|
use strict; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
31
|
use 5.008_005; |
|
1
|
|
|
|
|
4
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
677
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
49622
|
|
|
1
|
|
|
|
|
44
|
|
8
|
1
|
|
|
1
|
|
10
|
use Carp 'croak'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
62
|
|
9
|
1
|
|
|
1
|
|
7
|
use URI::Escape qw/uri_unescape/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
968
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
13
|
0
|
0
|
|
|
|
|
my %args = @_ % 2 ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
0
|
0
|
|
|
|
|
$args{InstID} or croak "InstID is required."; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
0
|
|
|
|
$args{TestMode} ||= 0; |
18
|
0
|
|
0
|
|
|
|
$args{ua} ||= LWP::UserAgent->new(); |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
0
|
|
|
|
$args{POST_URL} ||= 'https://secure.metacharge.com/mcpe/corporate'; |
21
|
0
|
|
0
|
|
|
|
$args{APIVersion} ||= '1.3'; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
bless \%args, $class; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub payment { |
27
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
28
|
0
|
0
|
|
|
|
|
my %args = @_ % 2 ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
$self->request( |
31
|
|
|
|
|
|
|
%args, |
32
|
|
|
|
|
|
|
TransType => 'PAYMENT', |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub refund { |
37
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
38
|
0
|
0
|
|
|
|
|
my %args = @_ % 2 ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
$self->request( |
41
|
|
|
|
|
|
|
%args, |
42
|
|
|
|
|
|
|
TransType => 'REFUND', |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub repeat { |
47
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
48
|
0
|
0
|
|
|
|
|
my %args = @_ % 2 ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
$self->request( |
51
|
|
|
|
|
|
|
%args, |
52
|
|
|
|
|
|
|
TransType => 'REPEAT', |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub capture { |
57
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
58
|
0
|
0
|
|
|
|
|
my %args = @_ % 2 ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$self->request( |
61
|
|
|
|
|
|
|
%args, |
62
|
|
|
|
|
|
|
TransType => 'CAPTURE', |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub void { |
67
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
68
|
0
|
0
|
|
|
|
|
my %args = @_ % 2 ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$self->request( |
71
|
|
|
|
|
|
|
%args, |
72
|
|
|
|
|
|
|
TransType => 'VOID', |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub cancel { |
77
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
78
|
0
|
0
|
|
|
|
|
my %args = @_ % 2 ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
$self->request( |
81
|
|
|
|
|
|
|
%args, |
82
|
|
|
|
|
|
|
TransType => 'CANCEL', |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub confirm { |
87
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
88
|
0
|
0
|
|
|
|
|
my %args = @_ % 2 ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
$self->request( |
91
|
|
|
|
|
|
|
%args, |
92
|
|
|
|
|
|
|
TransType => 'CONFIRM', |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub nonauth { |
97
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
98
|
0
|
0
|
|
|
|
|
my %args = @_ % 2 ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
$self->request( |
101
|
|
|
|
|
|
|
%args, |
102
|
|
|
|
|
|
|
TransType => 'NONAUTH', |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub request { |
107
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
108
|
0
|
0
|
|
|
|
|
my %params = @_ % 2 ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
my @intFields = ('TestMode', 'InstID', 'TransID', 'AccountID', 'AuthMode', 'CountryIP', 'AVS', 'Status', 'Time', 'CV2', 'Reference', 'Recurs', 'CancelAfter', 'ScheduleID'); |
111
|
0
|
|
|
|
|
|
my @fltFields = ('APIVersion', 'Amount', 'OriginalAmount', 'SchAmount', 'FraudScore'); |
112
|
0
|
|
|
|
|
|
my @datFields = ('Fulfillment'); |
113
|
|
|
|
|
|
|
|
114
|
0
|
0
|
|
|
|
|
$params{TestMode} = $self->{TestMode} unless exists $params{TestMode}; |
115
|
0
|
|
0
|
|
|
|
$params{InstID} ||= $self->{InstID}; |
116
|
0
|
|
0
|
|
|
|
$params{APIVersion} ||= $self->{APIVersion}; |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
my %r; |
119
|
0
|
|
|
|
|
|
foreach my $key (keys %params) { |
120
|
0
|
0
|
|
|
|
|
if ($key =~ /^(int|flt|str|dat)/) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
$r{$key} = $params{$key}; |
122
|
0
|
|
|
|
|
|
} elsif (grep { $_ eq $key } @intFields) { |
123
|
0
|
|
|
|
|
|
$r{'int' . $key} = $params{$key}; |
124
|
0
|
|
|
|
|
|
} elsif (grep { $_ eq $key } @fltFields) { |
125
|
0
|
|
|
|
|
|
$r{'flt' . $key} = $params{$key}; |
126
|
0
|
|
|
|
|
|
} elsif (grep { $_ eq $key } @fltFields) { |
127
|
0
|
|
|
|
|
|
$r{'dat' . $key} = $params{$key}; |
128
|
|
|
|
|
|
|
} else { |
129
|
0
|
|
|
|
|
|
$r{'str' . $key} = $params{$key}; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
my $resp = $self->{ua}->post($self->{POST_URL}, \%r); |
134
|
|
|
|
|
|
|
# use Data::Dumper; print STDERR Dumper(\$resp); |
135
|
0
|
0
|
|
|
|
|
unless ($resp->is_success) { |
136
|
0
|
0
|
|
|
|
|
return wantarray ? (error => $resp->status_line) : { error => $resp->status_line }; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
my @parts = split('&', $resp->decoded_content); |
140
|
0
|
|
|
|
|
|
my %parts; |
141
|
0
|
|
|
|
|
|
foreach my $p (@parts) { |
142
|
0
|
|
|
|
|
|
my ($a, $b) = split('=', $p, 2); |
143
|
0
|
|
|
|
|
|
$a =~ s/^(int|flt|str|dat)//; |
144
|
0
|
|
|
|
|
|
$parts{$a} = uri_unescape($b); |
145
|
0
|
|
|
|
|
|
$parts{$a} =~ s/\+/ /g; |
146
|
|
|
|
|
|
|
} |
147
|
0
|
0
|
|
|
|
|
return wantarray ? %parts : \%parts; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
1; |
151
|
|
|
|
|
|
|
__END__ |