Simplify/Authorization.pm untested

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