line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::PayPal::PaymentsAdvanced::Mocker::PayflowPro; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
49
|
use Mojolicious::Lite; |
|
6
|
|
|
|
|
29
|
|
|
6
|
|
|
|
|
44
|
|
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
43312
|
use namespace::autoclean; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
70
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.000027'; |
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
770
|
use feature qw( state ); |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
212
|
|
10
|
|
|
|
|
|
|
|
11
|
6
|
|
|
6
|
|
474
|
use Data::GUID (); |
|
6
|
|
|
|
|
14307
|
|
|
6
|
|
|
|
|
172
|
|
12
|
6
|
|
|
6
|
|
640
|
use List::AllUtils qw( none ); |
|
6
|
|
|
|
|
9146
|
|
|
6
|
|
|
|
|
484
|
|
13
|
6
|
|
|
6
|
|
455
|
use URI::FromHash qw( uri_object ); |
|
6
|
|
|
|
|
3510
|
|
|
6
|
|
|
|
|
337
|
|
14
|
6
|
|
|
6
|
|
2006
|
use WebService::PayPal::PaymentsAdvanced::Mocker::Helper; |
|
6
|
|
|
|
|
136
|
|
|
6
|
|
|
|
|
1220
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $helper = WebService::PayPal::PaymentsAdvanced::Mocker::Helper->new; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
## no critic (RequireExplicitInclusion) |
19
|
|
|
|
|
|
|
app->types->type( nvp => 'text/namevalue' ); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
post '/' => sub { |
22
|
|
|
|
|
|
|
my $c = shift; |
23
|
|
|
|
|
|
|
my $params = _filter_params($c); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
if ( $params->{CREATESECURETOKEN} && $params->{CREATESECURETOKEN} eq 'Y' ) |
26
|
|
|
|
|
|
|
{ |
27
|
|
|
|
|
|
|
my %return = ( |
28
|
|
|
|
|
|
|
RESULT => 0, |
29
|
|
|
|
|
|
|
RESPMSG => 'Approved', |
30
|
|
|
|
|
|
|
SECURETOKENID => $params->{SECURETOKENID}, |
31
|
|
|
|
|
|
|
SECURETOKEN => Data::GUID->new->as_string, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
_render_response( $c, \%return ); |
35
|
|
|
|
|
|
|
return; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
if ( |
39
|
|
|
|
|
|
|
!$params->{TRXTYPE} |
40
|
|
|
|
|
|
|
|| none { $params->{TRXTYPE} eq $_ } |
41
|
|
|
|
|
|
|
( 'A', 'C', 'D', 'I', 'S', 'V', ) |
42
|
|
|
|
|
|
|
) { |
43
|
|
|
|
|
|
|
$c->render( text => 'Mocked URL not found', status => 404 ); |
44
|
|
|
|
|
|
|
return; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
if ( $params->{TRXTYPE} eq 'A' ) { |
48
|
|
|
|
|
|
|
my %return; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
if ( $params->{TENDER} eq 'C' ) { |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
%return = ( |
53
|
|
|
|
|
|
|
ACCT => 1762, |
54
|
|
|
|
|
|
|
AMT => $params->{AMT}, |
55
|
|
|
|
|
|
|
AUTHCODE => 111111, |
56
|
|
|
|
|
|
|
AVSADDR => 'Y', |
57
|
|
|
|
|
|
|
AVSZIP => 'Y', |
58
|
|
|
|
|
|
|
CARDTYPE => 3, |
59
|
|
|
|
|
|
|
CORRELATIONID => $helper->correlationid, |
60
|
|
|
|
|
|
|
CVV2MATCH => 'Y', |
61
|
|
|
|
|
|
|
EXPDATE => 1221, |
62
|
|
|
|
|
|
|
IAVS => 'N', |
63
|
|
|
|
|
|
|
LASTNAME => 'NotProvided', |
64
|
|
|
|
|
|
|
PNREF => $helper->pnref, |
65
|
|
|
|
|
|
|
PPREF => $helper->ppref, |
66
|
|
|
|
|
|
|
PROCAVS => 'X', |
67
|
|
|
|
|
|
|
PROCCVV2 => 'M', |
68
|
|
|
|
|
|
|
RESPMSG => 'Approved', |
69
|
|
|
|
|
|
|
RESULT => 0, |
70
|
|
|
|
|
|
|
TRANSTIME => $helper->transtime, |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
elsif ( $params->{TENDER} eq 'P' ) { |
75
|
|
|
|
|
|
|
%return = ( |
76
|
|
|
|
|
|
|
AMT => $params->{AMT}, |
77
|
|
|
|
|
|
|
BAID => $helper->baid, |
78
|
|
|
|
|
|
|
CORRELATIONID => $helper->correlationid, |
79
|
|
|
|
|
|
|
PAYMENTTYPE => 'instant', |
80
|
|
|
|
|
|
|
PENDINGREASON => 'authorization', |
81
|
|
|
|
|
|
|
PNREF => $helper->pnref, |
82
|
|
|
|
|
|
|
PPREF => $helper->ppref, |
83
|
|
|
|
|
|
|
RESPMSG => 'Approved', |
84
|
|
|
|
|
|
|
RESULT => 0, |
85
|
|
|
|
|
|
|
TRANSTIME => $helper->transtime, |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
_render_response( $c, \%return ); |
89
|
|
|
|
|
|
|
return; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
if ( $params->{TRXTYPE} eq 'D' ) { |
93
|
|
|
|
|
|
|
my %return = ( |
94
|
|
|
|
|
|
|
CORRELATIONID => $helper->correlationid, |
95
|
|
|
|
|
|
|
FEEAMT => 1.75, |
96
|
|
|
|
|
|
|
PAYMENTTYPE => 'instant', |
97
|
|
|
|
|
|
|
PENDINGREASON => 'completed', |
98
|
|
|
|
|
|
|
PNREF => $helper->pnref, |
99
|
|
|
|
|
|
|
PPREF => $helper->ppref, |
100
|
|
|
|
|
|
|
RESPMSG => 'Approved', |
101
|
|
|
|
|
|
|
RESULT => 0, |
102
|
|
|
|
|
|
|
TRANSTIME => $helper->transtime, |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
_render_response( $c, \%return ); |
106
|
|
|
|
|
|
|
return; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
if ( $params->{TRXTYPE} eq 'I' ) { |
110
|
|
|
|
|
|
|
my %return = ( |
111
|
|
|
|
|
|
|
ACCT => 7603, |
112
|
|
|
|
|
|
|
AMT => 50.00, |
113
|
|
|
|
|
|
|
CARDTYPE => 1, |
114
|
|
|
|
|
|
|
CORRELATIONID => $helper->correlationid, |
115
|
|
|
|
|
|
|
EXPDATE => 1221, |
116
|
|
|
|
|
|
|
LASTNAME => 'NotProvided', |
117
|
|
|
|
|
|
|
ORIGPNREF => $params->{ORIGID}, |
118
|
|
|
|
|
|
|
ORIGPPREF => $helper->ppref, |
119
|
|
|
|
|
|
|
ORIGRESULT => 0, |
120
|
|
|
|
|
|
|
PNREF => $helper->pnref, |
121
|
|
|
|
|
|
|
RESPMSG => 'Approved', |
122
|
|
|
|
|
|
|
RESULT => 0, |
123
|
|
|
|
|
|
|
SETTLE_DATE => $helper->transtime, |
124
|
|
|
|
|
|
|
TRANSSTATE => 8, |
125
|
|
|
|
|
|
|
TRANSTIME => $helper->transtime, |
126
|
|
|
|
|
|
|
); |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
_render_response( $c, \%return ); |
129
|
|
|
|
|
|
|
return; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
if ( $params->{TRXTYPE} eq 'S' ) { |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
if ( $params->{TENDER} && $params->{TENDER} eq 'C' ) { |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
my %return = ( |
137
|
|
|
|
|
|
|
ACCT => 4482, |
138
|
|
|
|
|
|
|
AMT => $params->{AMT}, |
139
|
|
|
|
|
|
|
AUTHCODE => 111111, |
140
|
|
|
|
|
|
|
AVSADDR => 'Y', |
141
|
|
|
|
|
|
|
AVSZIP => 'Y', |
142
|
|
|
|
|
|
|
CARDTYPE => 3, |
143
|
|
|
|
|
|
|
CORRELATIONID => $helper->correlationid, |
144
|
|
|
|
|
|
|
CVV2MATCH => 'Y', |
145
|
|
|
|
|
|
|
EXPDATE => 1221, |
146
|
|
|
|
|
|
|
IAVS => 'N', |
147
|
|
|
|
|
|
|
LASTNAME => 'NotProvided', |
148
|
|
|
|
|
|
|
PNREF => $helper->pnref, |
149
|
|
|
|
|
|
|
PPREF => $helper->ppref, |
150
|
|
|
|
|
|
|
PROCAVS => 'X', |
151
|
|
|
|
|
|
|
PROCCVV2 => 'M', |
152
|
|
|
|
|
|
|
RESPMSG => 'Approved', |
153
|
|
|
|
|
|
|
RESULT => 0, |
154
|
|
|
|
|
|
|
TRANSTIME => $helper->transtime, |
155
|
|
|
|
|
|
|
); |
156
|
|
|
|
|
|
|
_render_response( $c, \%return ); |
157
|
|
|
|
|
|
|
return; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
if ( $params->{TENDER} && $params->{TENDER} eq 'P' ) { |
161
|
|
|
|
|
|
|
my %return = ( |
162
|
|
|
|
|
|
|
AMT => $params->{AMT}, |
163
|
|
|
|
|
|
|
BAID => $helper->baid, |
164
|
|
|
|
|
|
|
CORRELATIONID => $helper->correlationid, |
165
|
|
|
|
|
|
|
CVV2MATCH => 'Y', |
166
|
|
|
|
|
|
|
PNREF => $helper->pnref, |
167
|
|
|
|
|
|
|
PPREF => $helper->ppref, |
168
|
|
|
|
|
|
|
PROCAVS => 'X', |
169
|
|
|
|
|
|
|
PROCCVV2 => 'M', |
170
|
|
|
|
|
|
|
RESPMSG => 'Approved', |
171
|
|
|
|
|
|
|
RESULT => 0, |
172
|
|
|
|
|
|
|
TRANSTIME => $helper->transtime, |
173
|
|
|
|
|
|
|
); |
174
|
|
|
|
|
|
|
_render_response( $c, \%return ); |
175
|
|
|
|
|
|
|
return; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
if ( $params->{TRXTYPE} eq 'C' ) { |
180
|
|
|
|
|
|
|
my %return = ( |
181
|
|
|
|
|
|
|
CORRELATIONID => $helper->correlationid, |
182
|
|
|
|
|
|
|
PNREF => $helper->pnref, |
183
|
|
|
|
|
|
|
PPREF => $helper->ppref, |
184
|
|
|
|
|
|
|
RESPMSG => 'Approved', |
185
|
|
|
|
|
|
|
RESULT => 0, |
186
|
|
|
|
|
|
|
TRANSTIME => $helper->transtime, |
187
|
|
|
|
|
|
|
); |
188
|
|
|
|
|
|
|
_render_response( $c, \%return ); |
189
|
|
|
|
|
|
|
return; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
if ( $params->{TRXTYPE} eq 'V' ) { |
193
|
|
|
|
|
|
|
my %return = ( |
194
|
|
|
|
|
|
|
CORRELATIONID => $helper->correlationid, |
195
|
|
|
|
|
|
|
PENDINGREASON => 'authorization', |
196
|
|
|
|
|
|
|
PNREF => $helper->pnref, |
197
|
|
|
|
|
|
|
PPREF => $helper->ppref, |
198
|
|
|
|
|
|
|
RESPMSG => 'Approved', |
199
|
|
|
|
|
|
|
RESULT => 0, |
200
|
|
|
|
|
|
|
TRANSTIME => $helper->transtime, |
201
|
|
|
|
|
|
|
); |
202
|
|
|
|
|
|
|
_render_response( $c, \%return ); |
203
|
|
|
|
|
|
|
return; |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
$c->render( text => 'Mocked URL not found', status => 404 ); |
207
|
|
|
|
|
|
|
}; |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub _render_response { |
210
|
12
|
|
|
12
|
|
38
|
my $c = shift; |
211
|
12
|
|
|
|
|
22
|
my $response = shift; |
212
|
12
|
|
|
|
|
30
|
my $params = _filter_params($c); |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
# Echo some params back to make the responses more DRY |
215
|
12
|
100
|
100
|
|
|
104
|
if ( |
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
216
|
|
|
|
|
|
|
( |
217
|
|
|
|
|
|
|
$params->{TRXTYPE} |
218
|
|
|
|
|
|
|
&& ( $params->{TRXTYPE} eq 'A' || $params->{TRXTYPE} eq 'S' ) |
219
|
|
|
|
|
|
|
) |
220
|
|
|
|
|
|
|
&& $params->{INVNUM} |
221
|
|
|
|
|
|
|
) { |
222
|
2
|
|
|
|
|
5
|
$response->{INVNUM} = $params->{INVNUM}; |
223
|
2
|
|
|
|
|
5
|
$response->{INVOICE} = $params->{INVNUM}; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
12
|
|
|
|
|
54
|
my $response_as_uri = uri_object( query => $response ); |
227
|
12
|
|
|
|
|
3880
|
$c->render( text => $response_as_uri->query, format => 'nvp' ); |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub _filter_params { |
231
|
24
|
|
|
24
|
|
35
|
my $c = shift; |
232
|
24
|
|
|
|
|
79
|
my $params = $c->req->params->to_hash; |
233
|
24
|
|
|
|
|
8137
|
my %filtered; |
234
|
24
|
|
|
|
|
49
|
foreach my $key ( keys %{$params} ) { |
|
24
|
|
|
|
|
105
|
|
235
|
202
|
|
|
|
|
386
|
my $value = $params->{$key}; |
236
|
202
|
|
|
|
|
525
|
$key =~ s{\[\d*\]}{}; |
237
|
202
|
|
|
|
|
452
|
$filtered{$key} = $value; |
238
|
|
|
|
|
|
|
} |
239
|
24
|
|
|
|
|
107
|
return \%filtered; |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
sub to_app { |
243
|
31
|
|
|
31
|
1
|
116
|
app->secrets( ['Tempus fugit'] ); |
244
|
31
|
|
|
|
|
379
|
app->start; |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
1; |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=pod |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=encoding UTF-8 |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=head1 NAME |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
WebService::PayPal::PaymentsAdvanced::Mocker::PayflowPro - A simple app to enable easy PPA mocking |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head1 VERSION |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
version 0.000027 |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head1 DESCRIPTION |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
A simple app to enable easy PPA mocking. |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=head2 to_app |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
use WebService::PayPal::PaymentsAdvanced::Mocker::PayflowPro; |
268
|
|
|
|
|
|
|
my $app = WebService::PayPal::PaymentsAdvanced::Mocker::PayflowPro->to_app; |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
If you require a Plack app to be returned, you'll need to give Mojo the correct |
271
|
|
|
|
|
|
|
hint: |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
use WebService::PayPal::PaymentsAdvanced::Mocker::PayflowPro; |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
local $ENV{PLACK_ENV} = 'development'; # |
276
|
|
|
|
|
|
|
my $app = WebService::PayPal::PaymentsAdvanced::Mocker::PayflowPro->to_app; |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=head1 SUPPORT |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
Bugs may be submitted through L<https://github.com/maxmind/webservice-paypal-paymentsadvanced/issues>. |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=head1 AUTHOR |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
Olaf Alders <olaf@wundercounter.com> |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
This software is copyright (c) 2021 by MaxMind, Inc. |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
291
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=cut |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
__END__ |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
# ABSTRACT: A simple app to enable easy PPA mocking |
298
|
|
|
|
|
|
|
|