line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::PayPal::PaymentsAdvanced::Mocker::SilentPOST; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
335197
|
use Moo; |
|
3
|
|
|
|
|
36732
|
|
|
3
|
|
|
|
|
72
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
6241
|
use namespace::autoclean; |
|
3
|
|
|
|
|
41698
|
|
|
3
|
|
|
|
|
13
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.000028'; |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
1873
|
use Types::Common::String qw( NonEmptyStr ); |
|
3
|
|
|
|
|
390359
|
|
|
3
|
|
|
|
|
43
|
|
10
|
3
|
|
|
3
|
|
1954
|
use Types::Standard qw( InstanceOf ); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
82
|
|
11
|
3
|
|
|
3
|
|
3907
|
use WebService::PayPal::PaymentsAdvanced::Mocker::Helper (); |
|
3
|
|
|
|
|
18
|
|
|
3
|
|
|
|
|
2806
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has _helper => ( |
14
|
|
|
|
|
|
|
is => 'lazy', |
15
|
|
|
|
|
|
|
isa => |
16
|
|
|
|
|
|
|
InstanceOf ['WebService::PayPal::PaymentsAdvanced::Mocker::Helper'], |
17
|
|
|
|
|
|
|
default => |
18
|
|
|
|
|
|
|
sub { WebService::PayPal::PaymentsAdvanced::Mocker::Helper->new }, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has _secure_token_id => ( |
22
|
|
|
|
|
|
|
is => 'ro', |
23
|
|
|
|
|
|
|
isa => NonEmptyStr, |
24
|
|
|
|
|
|
|
required => 1, |
25
|
|
|
|
|
|
|
init_arg => 'secure_token_id', |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub paypal_success { |
29
|
2
|
|
|
2
|
1
|
2583
|
my $self = shift; |
30
|
2
|
|
|
|
|
9
|
my %args = @_; |
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
|
|
89
|
return $self->_massage_args( |
33
|
|
|
|
|
|
|
{ |
34
|
|
|
|
|
|
|
ADDRESSTOSHIP => '1 Main St', |
35
|
|
|
|
|
|
|
AMT => '50.00', |
36
|
|
|
|
|
|
|
AVSADDR => 'Y', |
37
|
|
|
|
|
|
|
AVSDATA => 'YYY', |
38
|
|
|
|
|
|
|
AVSZIP => 'Y', |
39
|
|
|
|
|
|
|
BAID => 'XXX', |
40
|
|
|
|
|
|
|
BILLTOCOUNTRY => 'US', |
41
|
|
|
|
|
|
|
BILLTOEMAIL => 'paypal_buyer@example.com', |
42
|
|
|
|
|
|
|
BILLTOFIRSTNAME => 'Test', |
43
|
|
|
|
|
|
|
BILLTOLASTNAME => 'Buyer', |
44
|
|
|
|
|
|
|
BILLTONAME => 'Test Buyer', |
45
|
|
|
|
|
|
|
CITYTOSHIP => 'San Jose', |
46
|
|
|
|
|
|
|
CORRELATIONID => 'XXX', |
47
|
|
|
|
|
|
|
COUNTRY => 'US', |
48
|
|
|
|
|
|
|
COUNTRYTOSHIP => 'US', |
49
|
|
|
|
|
|
|
EMAIL => 'paypal_buyer@example.com', |
50
|
|
|
|
|
|
|
FIRSTNAME => 'Test', |
51
|
|
|
|
|
|
|
INVNUM => 61, |
52
|
|
|
|
|
|
|
INVOICE => 61, |
53
|
|
|
|
|
|
|
LASTNAME => 'Buyer', |
54
|
|
|
|
|
|
|
METHOD => 'P', |
55
|
|
|
|
|
|
|
NAME => 'Test Buyer', |
56
|
|
|
|
|
|
|
NAMETOSHIP => 'Test Buyer', |
57
|
|
|
|
|
|
|
PAYERID => 'R8RAGUNASE6VA', |
58
|
|
|
|
|
|
|
PAYMENTTYPE => 'instant', |
59
|
|
|
|
|
|
|
PENDINGREASON => 'authorization', |
60
|
|
|
|
|
|
|
PNREF => 'XXX', |
61
|
|
|
|
|
|
|
PPREF => 'XXX', |
62
|
|
|
|
|
|
|
RESPMSG => 'Approved', |
63
|
|
|
|
|
|
|
RESULT => '0', |
64
|
|
|
|
|
|
|
SECURETOKEN => 'XXX', |
65
|
|
|
|
|
|
|
SHIPTOCITY => 'San Jose', |
66
|
|
|
|
|
|
|
SHIPTOCOUNTRY => 'US', |
67
|
|
|
|
|
|
|
SHIPTOSTATE => 'CA', |
68
|
|
|
|
|
|
|
SHIPTOSTREET => '1 Main St', |
69
|
|
|
|
|
|
|
SHIPTOZIP => 95131, |
70
|
|
|
|
|
|
|
STATETOSHIP => 'CA', |
71
|
|
|
|
|
|
|
TAX => '0.00', |
72
|
|
|
|
|
|
|
TENDER => 'P', |
73
|
|
|
|
|
|
|
TOKEN => 'XXX', |
74
|
|
|
|
|
|
|
TRANSTIME => 'XXX', |
75
|
|
|
|
|
|
|
TRXTYPE => 'A', |
76
|
|
|
|
|
|
|
TYPE => 'A', |
77
|
|
|
|
|
|
|
ZIPTOSHIP => 95131, |
78
|
|
|
|
|
|
|
}, |
79
|
|
|
|
|
|
|
\%args, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub credit_card_success { |
84
|
14
|
|
|
14
|
1
|
4563
|
my $self = shift; |
85
|
14
|
|
|
|
|
57
|
my %args = @_; |
86
|
|
|
|
|
|
|
|
87
|
14
|
|
|
|
|
609
|
return $self->_massage_args( |
88
|
|
|
|
|
|
|
{ |
89
|
|
|
|
|
|
|
ACCT => 4482, |
90
|
|
|
|
|
|
|
AMT => 50.00, |
91
|
|
|
|
|
|
|
AUTHCODE => 111111, |
92
|
|
|
|
|
|
|
AVSADDR => 'Y', |
93
|
|
|
|
|
|
|
AVSDATA => 'YYY', |
94
|
|
|
|
|
|
|
AVSZIP => 'Y', |
95
|
|
|
|
|
|
|
BILLTOCOUNTRY => 'US', |
96
|
|
|
|
|
|
|
CARDTYPE => 3, |
97
|
|
|
|
|
|
|
CORRELATIONID => 'fb36aaa2675e', |
98
|
|
|
|
|
|
|
COUNTRY => 'US', |
99
|
|
|
|
|
|
|
COUNTRYTOSHIP => 'US', |
100
|
|
|
|
|
|
|
CVV2MATCH => 'Y', |
101
|
|
|
|
|
|
|
EMAILTOSHIP => q{}, |
102
|
|
|
|
|
|
|
EXPDATE => 1231, |
103
|
|
|
|
|
|
|
IAVS => 'N', |
104
|
|
|
|
|
|
|
INVNUM => 69, |
105
|
|
|
|
|
|
|
INVOICE => 69, |
106
|
|
|
|
|
|
|
LASTNAME => 'NotProvided', |
107
|
|
|
|
|
|
|
METHOD => 'CC', |
108
|
|
|
|
|
|
|
PNREF => 'XXX', |
109
|
|
|
|
|
|
|
PPREF => 'XXX', |
110
|
|
|
|
|
|
|
PROCAVS => 'X', |
111
|
|
|
|
|
|
|
PROCCVV2 => 'M', |
112
|
|
|
|
|
|
|
RESPMSG => 'Approved', |
113
|
|
|
|
|
|
|
RESULT => 0, |
114
|
|
|
|
|
|
|
SECURETOKEN => '9dWh93jXhkkOi4C3INWBAWgxN', |
115
|
|
|
|
|
|
|
SECURETOKENID => 'XXX', |
116
|
|
|
|
|
|
|
SHIPTOCOUNTRY => 'US', |
117
|
|
|
|
|
|
|
TAX => 0.00, |
118
|
|
|
|
|
|
|
TENDER => 'CC', |
119
|
|
|
|
|
|
|
TRANSTIME => '2015-08-27 15:01:42', |
120
|
|
|
|
|
|
|
TRXTYPE => 'A', |
121
|
|
|
|
|
|
|
TYPE => 'A', |
122
|
|
|
|
|
|
|
}, |
123
|
|
|
|
|
|
|
\%args |
124
|
|
|
|
|
|
|
); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub credit_card_duplicate_invoice_id { |
128
|
1
|
|
|
1
|
1
|
598
|
my $self = shift; |
129
|
1
|
|
|
|
|
3
|
my %args = @_; |
130
|
|
|
|
|
|
|
|
131
|
1
|
|
|
|
|
20
|
return $self->_massage_args( |
132
|
|
|
|
|
|
|
{ |
133
|
|
|
|
|
|
|
ACCT => 4482, |
134
|
|
|
|
|
|
|
AMT => '50.00', |
135
|
|
|
|
|
|
|
AVSDATA => 'XXN', |
136
|
|
|
|
|
|
|
BILLTOCOUNTRY => 'US', |
137
|
|
|
|
|
|
|
CARDTYPE => 3, |
138
|
|
|
|
|
|
|
COUNTRY => 'US', |
139
|
|
|
|
|
|
|
COUNTRYTOSHIP => 'US', |
140
|
|
|
|
|
|
|
EMAILTOSHIP => q{}, |
141
|
|
|
|
|
|
|
EXPDATE => 1231, |
142
|
|
|
|
|
|
|
HOSTCODE => 10536, |
143
|
|
|
|
|
|
|
INVNUM => 64, |
144
|
|
|
|
|
|
|
INVOICE => 64, |
145
|
|
|
|
|
|
|
LASTNAME => 'NotProvided', |
146
|
|
|
|
|
|
|
METHOD => 'CC', |
147
|
|
|
|
|
|
|
PNREF => 'XXX', |
148
|
|
|
|
|
|
|
RESULT => 30, |
149
|
|
|
|
|
|
|
SECURETOKEN => 'XXX', |
150
|
|
|
|
|
|
|
SHIPTOCOUNTRY => 'US', |
151
|
|
|
|
|
|
|
TAX => '0.00', |
152
|
|
|
|
|
|
|
TENDER => 'CC', |
153
|
|
|
|
|
|
|
TRANSTIME => 'XXX', |
154
|
|
|
|
|
|
|
TRXTYPE => 'A', |
155
|
|
|
|
|
|
|
TYPE => 'A', |
156
|
|
|
|
|
|
|
RESPMSG => |
157
|
|
|
|
|
|
|
'Duplicate trans: 10536-The transaction was refused as a result of a duplicate invoice ID supplied. Attempt with a new invoice ID', |
158
|
|
|
|
|
|
|
}, |
159
|
|
|
|
|
|
|
\%args |
160
|
|
|
|
|
|
|
); |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub credit_card_auth_verification_success { |
164
|
1
|
|
|
1
|
1
|
2260
|
my $self = shift; |
165
|
1
|
|
|
|
|
4
|
my %args = @_; |
166
|
|
|
|
|
|
|
|
167
|
1
|
|
|
|
|
32
|
return $self->_massage_args( |
168
|
|
|
|
|
|
|
\%args, |
169
|
|
|
|
|
|
|
{ |
170
|
|
|
|
|
|
|
ACCT => 5800, |
171
|
|
|
|
|
|
|
AMT => '0.00', |
172
|
|
|
|
|
|
|
AUTHCODE => 111111, |
173
|
|
|
|
|
|
|
AVSADDR => 'Y', |
174
|
|
|
|
|
|
|
AVSDATA => 'YYY', |
175
|
|
|
|
|
|
|
AVSZIP => 'Y', |
176
|
|
|
|
|
|
|
BILLTOCOUNTRY => 'US', |
177
|
|
|
|
|
|
|
CARDTYPE => 0, |
178
|
|
|
|
|
|
|
CORRELATIONID => 'dad41bc8ed27', |
179
|
|
|
|
|
|
|
COUNTRY => 'US', |
180
|
|
|
|
|
|
|
COUNTRYTOSHIP => 'US', |
181
|
|
|
|
|
|
|
CVV2MATCH => 'Y', |
182
|
|
|
|
|
|
|
EMAILTOSHIP => q{}, |
183
|
|
|
|
|
|
|
EXPDATE => 1231, |
184
|
|
|
|
|
|
|
HOSTCODE => 10574, |
185
|
|
|
|
|
|
|
IAVS => 'N', |
186
|
|
|
|
|
|
|
LASTNAME => 'NotProvided', |
187
|
|
|
|
|
|
|
METHOD => 'CC', |
188
|
|
|
|
|
|
|
PNREF => 'XXX', |
189
|
|
|
|
|
|
|
PPREF => 'XXX', |
190
|
|
|
|
|
|
|
PROCAVS => 'X', |
191
|
|
|
|
|
|
|
PROCCVV2 => 'M', |
192
|
|
|
|
|
|
|
RESPMSG => |
193
|
|
|
|
|
|
|
'Verified => 10574-This card authorization verification is not a payment transaction.', |
194
|
|
|
|
|
|
|
SECURETOKEN => 'XXX', |
195
|
|
|
|
|
|
|
RESULT => 0, |
196
|
|
|
|
|
|
|
SHIPTOCOUNTRY => 'US', |
197
|
|
|
|
|
|
|
TAX => '0.00', |
198
|
|
|
|
|
|
|
TENDER => 'CC', |
199
|
|
|
|
|
|
|
TRANSTIME => 'XXX', |
200
|
|
|
|
|
|
|
TRXTYPE => 'A', |
201
|
|
|
|
|
|
|
TYPE => 'A', |
202
|
|
|
|
|
|
|
}, |
203
|
|
|
|
|
|
|
); |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
sub _massage_args { |
207
|
18
|
|
|
18
|
|
60
|
my $self = shift; |
208
|
18
|
|
|
|
|
45
|
my $default_args = shift; |
209
|
18
|
|
|
|
|
48
|
my $user_args = shift; |
210
|
|
|
|
|
|
|
|
211
|
18
|
|
|
|
|
75
|
$default_args = $self->_set_defaults($default_args); |
212
|
|
|
|
|
|
|
|
213
|
18
|
|
|
|
|
44
|
my $args = { %{$default_args}, %{$user_args} }; |
|
18
|
|
|
|
|
182
|
|
|
18
|
|
|
|
|
265
|
|
214
|
18
|
100
|
|
|
|
109
|
if ( $self->_secure_token_id eq 'NOPPREF' ) { |
215
|
12
|
|
|
|
|
31
|
delete $args->{PPREF}; |
216
|
|
|
|
|
|
|
} |
217
|
18
|
|
|
|
|
321
|
return $args; |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub _set_defaults { |
221
|
18
|
|
|
18
|
|
41
|
my $self = shift; |
222
|
18
|
|
|
|
|
45
|
my $defaults = shift; |
223
|
|
|
|
|
|
|
|
224
|
18
|
|
|
|
|
125
|
my %method_for = ( |
225
|
|
|
|
|
|
|
BAID => 'baid', |
226
|
|
|
|
|
|
|
CORRELATIONID => 'correlationid', |
227
|
|
|
|
|
|
|
PNREF => 'pnref', |
228
|
|
|
|
|
|
|
PPREF => 'ppref', |
229
|
|
|
|
|
|
|
TRANSTIME => 'transtime', |
230
|
|
|
|
|
|
|
SECURETOKEN => 'secure_token', |
231
|
|
|
|
|
|
|
TOKEN => 'token', |
232
|
|
|
|
|
|
|
); |
233
|
|
|
|
|
|
|
|
234
|
18
|
|
|
|
|
88
|
for my $key ( keys %method_for ) { |
235
|
126
|
100
|
|
|
|
30413
|
if ( exists $defaults->{$key} ) { |
236
|
87
|
|
|
|
|
183
|
my $method = $method_for{$key}; |
237
|
87
|
|
|
|
|
2367
|
$defaults->{$key} = $self->_helper->$method; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
18
|
|
|
|
|
35276
|
$defaults->{SECURETOKENID} = $self->_secure_token_id; |
242
|
18
|
100
|
|
|
|
92
|
if ( $self->_secure_token_id eq 'NOPPREF' ) { |
243
|
12
|
|
|
|
|
45
|
delete $defaults->{PPREF}; |
244
|
|
|
|
|
|
|
} |
245
|
18
|
|
|
|
|
77
|
return $defaults; |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
1; |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=pod |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=encoding UTF-8 |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=head1 NAME |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
WebService::PayPal::PaymentsAdvanced::Mocker::SilentPOST - Easily mock Silent POST transactions |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=head1 VERSION |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
version 0.000028 |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=head1 SYNOPSIS |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
use LWP::UserAgent; |
265
|
|
|
|
|
|
|
use WebService::PayPal::PaymentsAdvanced::Mocker::SilentPOST; |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
my $mocker |
268
|
|
|
|
|
|
|
= WebService::PayPal::PaymentsAdvanced::Mocker::SilentPOST->new(); |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
my $ua = LWP::UserAgent->new(...); |
271
|
|
|
|
|
|
|
$ua->post( |
272
|
|
|
|
|
|
|
'/silent-post-url', |
273
|
|
|
|
|
|
|
$mocker->paypal_success, |
274
|
|
|
|
|
|
|
'X-Forwarded-For' => '173.0.81.65' |
275
|
|
|
|
|
|
|
); |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=head2 paypal_success |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
Returns a C<HashRef> of POST params which can be used to mock a successful |
280
|
|
|
|
|
|
|
PayPal authorization. |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=head2 credit_card_success |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
Returns a C<HashRef> of POST params which can be used to mock a successful |
285
|
|
|
|
|
|
|
credit card authorization. |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=head2 credit_card_auth_verification_success |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
Returns a C<HashRef> of POST params which can be used to mock a successful zero |
290
|
|
|
|
|
|
|
dollar credit card authorization. |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=head2 credit_card_duplicate_invoice_id |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
Returns a C<HashRef> of POST params which can be used to mock a unsuccessful |
295
|
|
|
|
|
|
|
credit card payment. In this case you've sent an invoice ID which is already |
296
|
|
|
|
|
|
|
attached to a previously successful transaction. |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=head1 DESCRIPTION |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
Use these methods to get a HashRef of params which you can POST to your |
301
|
|
|
|
|
|
|
application's silent POST endpoint. Keep in mind that if you have IP |
302
|
|
|
|
|
|
|
validation enabled you'll either need to spoof the originating IP of the |
303
|
|
|
|
|
|
|
request or disable the IP validation in test mode. I'd encourage you to do |
304
|
|
|
|
|
|
|
the former, if at all possible. |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=head1 SUPPORT |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
Bugs may be submitted through L<https://github.com/maxmind/webservice-paypal-paymentsadvanced/issues>. |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=head1 AUTHOR |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
Olaf Alders <olaf@wundercounter.com> |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
This software is copyright (c) 2022 by MaxMind, Inc. |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
319
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
=cut |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
__END__ |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
# ABSTRACT: Easily mock Silent POST transactions |
326
|
|
|
|
|
|
|
|