Simplify/Payment.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 47 CC 1 SCAR 6.9
CC
1
Cov
0%
create
2.0
list
2.0
find
2.0
CRAP 2.0
1 package Net::Simplify::Payment;
2  
3 =head1 NAME
4  
5 Net::Simplify::Payment - A Simplify Commerce Payment object
6  
7 =head1 SYNOPSIS
8  
9 use Net::Simplify;
10  
11  
12 $Net::Simplify::public_key = 'YOUR PUBLIC KEY';
13 $Net::Simplify::private_key = 'YOUR PRIVATE KEY';
14  
15 # Create a new Payment.
16 my $payment = Net::Simplify::Payment->create{ {...});
17  
18 # Retrieve a Payment given its ID.
19 my $payment = Net::Simplify::Payment->find('a7e41');
20  
21 # Update existing Payment.
22 my $payment = Net::Simplify::Payment->find('a7e41');
23 $payment->{PROPERTY} = "NEW VALUE";
24 $payment->update();
25  
26 # Retrieve a list of objects
27 my $payments = Net::Simplify::Payment->list({max => 10});
28 foreach my $v ($payments->list) {
29 # ...
30 }
31  
32 =head1 DESCRIPTION
33  
34 =head2 METHODS
35  
36 =head3 create(%params, $auth)
37  
38 Creates a C<Net::Simplify::Payment> object. The parameters are:
39  
40 =over 4
41  
42 =item C<%params>
43  
44 Hash map containing initial values for the object. Valid keys are:
45  
46 =over 4
47  
48 =item amount
49  
50 Amount of the payment (in the smallest unit of your currency). Example: 100 = $1.00
51  
52 =item authorization
53  
54 The ID of the authorization being used to capture the payment.
55  
56  
57  
58 =item card.addressCity
59  
60 City of the cardholder. [max length: 50, min length: 2]
61  
62 =item card.addressCountry
63  
64 Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2]
65  
66 =item card.addressLine1
67  
68 Address of the cardholder. [max length: 255]
69  
70 =item card.addressLine2
71  
72 Address of the cardholder if needed. [max length: 255]
73  
74 =item card.addressState
75  
76 State of residence of the cardholder. State abbreviations should be used. [max length: 255]
77  
78 =item card.addressZip
79  
80 Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. [max length: 32]
81  
82 =item card.cvc
83  
84 CVC security code of the card. This is the code on the back of the card. Example: 123
85  
86 =item card.expMonth
87  
88 Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12]
89  
90 =item card.expYear
91  
92 Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99]
93  
94 =item card.name
95  
96 Name as it appears on the card. [max length: 50, min length: 2]
97  
98 =item card.number
99  
100 Card number as it appears on the card. [max length: 19, min length: 13]
101  
102 =item currency
103  
104 Currency code (ISO-4217) for the transaction. Must match the currency associated with your account. [default: USD] (B<required>)
105  
106 =item customer
107  
108 ID of customer. If specified, card on file of customer will be used.
109  
110 =item description
111  
112 Free form text field to be used as a description of the payment. This field is echoed back with the payment on any find or list operations. [max length: 1024]
113  
114 =item invoice
115  
116 ID of invoice for which this payment is being made.
117  
118  
119  
120 =item order.commodityCode
121  
122 Standard classification code for products and services. [max length: 5]
123  
124 =item order.customer
125  
126 ID of the customer associated with the order.
127  
128 =item order.customerEmail
129  
130 Customer email address.
131  
132 =item order.customerName
133  
134 Customer name.
135  
136 =item order.customerNote
137  
138 Additional notes provided by the customer. [max length: 255]
139  
140 =item order.customerReference
141  
142 A merchant reference for the customer.
143  
144  
145  
146 =item order.items.amount
147  
148 Cost of the item.
149  
150 =item order.items.description
151  
152 Description of the item.
153  
154 =item order.items.name
155  
156 Item name.
157  
158 =item order.items.product
159  
160 Product information associated with the item.
161  
162 =item order.items.quantity
163  
164 Quantity of the item contained in the order [min value: 1, max value: 999999, default: 1] (B<required>)
165  
166 =item order.items.reference
167  
168 A merchant reference for the item. [max length: 255]
169  
170 =item order.items.tax
171  
172 Taxes associated with the item.
173  
174 =item order.merchantNote
175  
176 Additional notes provided by the merchant. [max length: 255]
177  
178 =item order.payment
179  
180 ID of the payment associated with the order.
181  
182 =item order.reference
183  
184 A merchant reference for the order. [max length: 255]
185  
186  
187  
188 =item order.shippingAddress.city
189  
190 City, town, or municipality. [max length: 255, min length: 2]
191  
192 =item order.shippingAddress.country
193  
194 2-character country code. [max length: 2, min length: 2]
195  
196 =item order.shippingAddress.line1
197  
198 Street address. [max length: 255]
199  
200 =item order.shippingAddress.line2
201  
202 (Opt) Street address continued. [max length: 255]
203  
204 =item order.shippingAddress.name
205  
206 Name of the entity being shipped to. [max length: 255]
207  
208 =item order.shippingAddress.state
209  
210 State or province. [max length: 255]
211  
212 =item order.shippingAddress.zip
213  
214 Postal code. [max length: 32]
215  
216  
217  
218 =item order.shippingFromAddress.city
219  
220 City, town, or municipality. [max length: 255, min length: 2]
221  
222 =item order.shippingFromAddress.country
223  
224 2-character country code. [max length: 2, min length: 2]
225  
226 =item order.shippingFromAddress.line1
227  
228 Street address. [max length: 255]
229  
230 =item order.shippingFromAddress.line2
231  
232 (Opt) Street address continued. [max length: 255]
233  
234 =item order.shippingFromAddress.name
235  
236 Name of the entity performing the shipping. [max length: 255]
237  
238 =item order.shippingFromAddress.state
239  
240 State or province. [max length: 255]
241  
242 =item order.shippingFromAddress.zip
243  
244 Postal code. [max length: 32]
245  
246 =item order.shippingName
247  
248 Name of the entity being shipped to.
249  
250 =item order.source
251  
252 Order source. [default: WEB] (B<required>)
253  
254 =item order.status
255  
256 Status of the order. [default: INCOMPLETE] (B<required>)
257  
258 =item reference
259  
260 Custom reference field to be used with outside systems.
261  
262 =item replayId
263  
264 An identifier that can be sent to uniquely identify a payment request to facilitate retries due to I/O related issues. This identifier must be unique for your account (sandbox or live) across all of your payments. If supplied, we will check for a payment on your account that matches this identifier. If found will attempt to return an identical response of the original request. [max length: 50, min length: 1]
265  
266  
267  
268 =item statementDescription.name
269  
270 Merchant name. (B<required>)
271  
272 =item statementDescription.phoneNumber
273  
274 Merchant contact phone number.
275  
276 =item taxExempt
277  
278 Specify true to indicate that the payment is tax-exempt.
279  
280 =item token
281  
282 If specified, card associated with card token will be used. [max length: 255]
283  
284  
285 =back
286  
287 =item C<$auth>
288  
289 Authentication object for accessing the API. If no value is passed the global keys
290 C<$Net::Simplify::public_key> and C<$Net::Simplify::private_key> are used.
291  
292 =back
293  
294  
295  
296  
297 =head3 list(%criteria, $auth)
298  
299 Retrieve a list of C<Net::Simplify::Payment> objects. The parameters are:
300  
301 =over 4
302  
303 =item C<%criteria>
304  
305 Hash map representing the criteria to limit the results of the list operation. Valid keys are:
306  
307 =over 4
308  
309 =item C<filter>
310  
311 <table class="filter_list"><tr><td>filter.id</td><td>Filter by the payment Id</td></tr><tr><td>filter.replayId</td><td>Filter by the compoundReplayId</td></tr><tr><td>filter.last4</td><td>Filter by the card number (last 4 digits)</td></tr><tr><td>filter.amount</td><td>Filter by the payment amount (in the smallest unit of your currency)</td></tr><tr><td>filter.text</td><td>Filter by the description of the payment</td></tr><tr><td>filter.amountMin & filter.amountMax</td><td>The filter amountMin must be used with amountMax to find payments with payments amounts between the min and max figures</td></tr><tr><td>filter.dateCreatedMin<sup>*</sup></td><td>Filter by the minimum created date you are searching for - Date in UTC millis</td></tr><tr><td>filter.dateCreatedMax<sup>*</sup></td><td>Filter by the maximum created date you are searching for - Date in UTC millis</td></tr><tr><td>filter.deposit</td><td>Filter by the deposit id connected to the payment</td></tr><tr><td>filter.customer</td><td>Filter using the Id of the customer to find the payments for that customer</td></tr><tr><td>filter.status</td><td>Filter by the payment status text</td></tr><tr><td>filter.reference</td><td>Filter by the payment reference text</td></tr><tr><td>filter.authCode</td><td>Filter by the payment authorization code (Not the authorization ID)</td></tr><tr><td>filter.q</td><td>You can use this to filter by the Id, the authCode or the amount of the payment</td></tr></table><br><sup>*</sup>Use dateCreatedMin with dateCreatedMax in the same filter if you want to search between two created dates
312  
313  
314  
315 =item C<max>
316  
317 Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
318  
319  
320  
321 =item C<offset>
322  
323 Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
324  
325  
326  
327 =item C<sorting>
328  
329 Allows for ascending or descending sorting of the list.
330 The value maps properties to the sort direction (either C<asc> for ascending or C<desc> for descending). Sortable properties are:
331  
332 =over 4
333  
334 =item C<dateCreated>
335  
336 =item C<createdBy>
337  
338 =item C<amount>
339  
340 =item C<id>
341  
342 =item C<description>
343  
344 =item C<paymentDate>
345  
346  
347 =back
348  
349  
350  
351  
352 =back
353  
354 =back
355  
356  
357  
358 =head3 find($id, $auth)
359  
360 Retrieve a C<Net::Simplify::Payment> object from the API. Parameters are:
361  
362 =over 4
363  
364 =item C<$id>
365  
366 Identifier of the object to retrieve.
367  
368 =item C<$auth>
369  
370 Authentication object for accessing the API. If no value is passed the global keys
371 C<$Net::Simplify::public_key> and C<$Net::Simplify::private_key> are used.
372  
373 =back
374  
375  
376  
377  
378 =head3 update()
379  
380 Update C<Net::Simplify::Payment> object.
381 The properties that can be updated are:
382  
383 =over 4
384  
385  
386  
387 Authentication is done using the same credentials used when the AccessToken was created.
388  
389 =back
390  
391  
392  
393  
394 =head1 SEE ALSO
395  
396 L<Net::Simplify>,
397 L<Net::Simplify::Domain>,
398 L<Net::Simplify::DomainList>,
399 L<Net::Simplify::Authentication>,
400 L<Net::Simplify::ApiException>,
401 L<http://www.simplify.com>
402  
403 =head1 VERSION
404  
405 1.6.0
406  
407 =head1 LICENSE
408  
409 Copyright (c) 2013 - 2022 MasterCard International Incorporated
410 All rights reserved.
411  
412 Redistribution and use in source and binary forms, with or without modification, are
413 permitted provided that the following conditions are met:
414  
415 Redistributions of source code must retain the above copyright notice, this list of
416 conditions and the following disclaimer.
417 Redistributions in binary form must reproduce the above copyright notice, this list of
418 conditions and the following disclaimer in the documentation and/or other materials
419 provided with the distribution.
420 Neither the name of the MasterCard International Incorporated nor the names of its
421 contributors may be used to endorse or promote products derived from this software
422 without specific prior written permission.
423 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
424 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
425 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
426 SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
427 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
428 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
429 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
430 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
431 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
432 SUCH DAMAGE.
433  
434 =head1 SEE ALSO
435  
436 =cut
437  
438 use 5.006;
439 use strict;
440 use warnings FATAL => 'all';
441  
442 use Net::Simplify::Domain;
443 use Net::Simplify::DomainList;
444  
445 our @ISA = qw(Net::Simplify::Domain);
446  
447 sub create {
448  
449 my ($class, $params, $auth) = @_;
450
451 $auth = Net::Simplify::SimplifyApi->get_authentication($auth);
452 my $result = Net::Simplify::SimplifyApi->send_api_request("payment", 'create', $params, $auth);
453  
454 $class->SUPER::new($result, $auth);
455 }
456  
457 sub list {
458 my ($class, $criteria, $auth) = @_;
459
460 $auth = Net::Simplify::SimplifyApi->get_authentication($auth);
461 my $result = Net::Simplify::SimplifyApi->send_api_request("payment", 'list', $criteria, $auth);
462  
463 Net::Simplify::DomainList->new($result, $class, $auth);
464 }
465  
466 sub find {
467 my ($class, $id, $auth) = @_;
468  
469 $auth = Net::Simplify::SimplifyApi->get_authentication($auth);
470 my $result = Net::Simplify::SimplifyApi->send_api_request("payment", 'find', { id => $id }, $auth);
471  
472 $class->SUPER::new($result, $auth);
473 }
474  
475 sub update {
476  
477 my ($self) = @_;
478  
479 my $auth = Net::Simplify::SimplifyApi->get_authentication($self->{_authentication});
480 my $params = { %$self };
481 delete $params->{_authentication};
482  
483 $self->merge(Net::Simplify::SimplifyApi->send_api_request("payment", 'update', $params, $auth));
484 }
485  
486  
487 1;