File Coverage

lib/Net/API/Stripe/Charge.pm
Criterion Covered Total %
statement 19 70 27.1
branch n/a
condition n/a
subroutine 7 58 12.0
pod 51 51 100.0
total 77 179 43.0


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Charge.pm
3             ## Version v0.101.0
4             ## Copyright(c) 2019 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2019/11/02
7             ## Modified 2022/10/29
8             ##
9             ##----------------------------------------------------------------------------
10             ## https://stripe.com/docs/api/charges/object
11             BEGIN
12             {
13             use strict;
14 2     2   23888226 use warnings;
  2         15  
  2         59  
15 2     2   11 use parent qw( Net::API::Stripe::Generic );
  2         4  
  2         63  
16 2     2   10 use vars qw( $VERSION );
  2         3  
  2         10  
17 2     2   147 our( $VERSION ) = 'v0.101.0';
  2         4  
  2         111  
18 2     2   37 };
19              
20             use strict;
21 2     2   10 use warnings;
  2         4  
  2         35  
22 2     2   9  
  2         4  
  2         1888  
23              
24 0     0 1    
25              
26 0     0 1    
27              
28 0     0 1    
29              
30 0     0 1    
31              
32 0     0 1    
33              
34 0     0 1    
35              
36 0     0 1    
37              
38 0     0 1   ## Expandable so either we get an id or we get the underlying object
39              
40 0     0 1    
41              
42 0     0 1    
43              
44 0     0 1    
45              
46 0     0 1    
47              
48 0     0 1   ## sub fraud_details { return( shift->_set_get_hash( 'fraud_details', @_ ) ); }
49              
50 0     0 1   stripe_report => { type => 'scalar' },
51             user_report => { type => 'scalar' },
52 0     0 1   }, @_ ) ); }
53              
54              
55              
56 0     0 1    
57              
58 0     0 1    
59              
60 0     0 1    
61              
62 0     0 1    
63              
64 0     0 1    
65              
66 0     0 1    
67              
68 0     0 1    
69             ## A list of refunds that have been applied to the charge.
70 0     0 1   ## Net::API::Stripe::Charge::Refunds
71              
72              
73              
74 0     0 1    
75              
76              
77              
78              
79 0     0 1    
80             ## 2019-10-16: gone?
81 0     0 1    
82              
83 0     0 1    
84              
85 0     0 1    
86             1;
87 0     0 1    
88              
89 0     0 1   =encoding utf8
90              
91 0     0 1   =head1 NAME
92              
93 0     0 1   Net::API::Stripe::Charge - The Charge object of Stripe API
94              
95 0     0 1   =head1 SYNOPSIS
96              
97 0     0 1   my $charge = $stripe->charge({
98             amount => 2000,
99 0     0 1   application_fee => $stripe->application_fee({
100             amount => 2000,
101 0     0 1   currency => 'jpy',
102             }),
103 0     0 1   card => $card_object,
104             currency => 'jpy',
105 0     0 1   customer => $customer_object,
106             description => 'Description of the charge',
107 0     0 1   invoice => $invoice_object,
108             metadata => { transaction_id => 144, customer_id => 123 },
109             order => $order_object,
110             payment_intent => $payment_intent_object,
111             receipt_email => 'john.doe@example.com',
112 0     0 1   receipt_number => 'RCP2020040103-123',
113             });
114 0     0 1    
115             =head1 VERSION
116 0     0 1    
117             v0.101.0
118 0     0 1    
119             =head1 DESCRIPTION
120 0     0 1    
121             To charge a credit or a debit card, you create a Charge object. You can retrieve and refund individual charges as well as list all charges. Charges are identified by a unique, random ID.
122 0     0 1    
123             =head1 CONSTRUCTOR
124 0     0 1    
125             =head2 new( %ARG )
126 0     0 1    
127             Creates a new L<Net::API::Stripe::Charge> object.
128             It may also take an hash like arguments, that also are method of the same name.
129              
130 0     0 1   =head1 METHODS
131              
132 0     0 1   =head2 id string
133              
134 0     0 1   Unique identifier for the object.
135              
136 0     0 1   =head2 object string, value is "charge"
137              
138             String representing the object’s type. Objects of the same type share the same value.
139              
140             =head2 amount positive integer or zero
141              
142             A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or equivalent in charge currency. The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99).
143              
144             =head2 amount_captured positive integer or zero
145              
146             Amount in JPY captured (can be less than the amount attribute on the charge if a partial capture was made).
147              
148             =head2 amount_refunded positive integer or zero
149              
150             Amount in JPY refunded (can be less than the amount attribute on the charge if a partial refund was issued).
151              
152             =head2 application string expandable "application"
153              
154             ID of the Connect application that created the charge. This represents a L<Net::API::Stripe::Connect::Account> object
155              
156             =head2 application_fee string (expandable)
157              
158             The application fee (if any) for the charge. See the Connect documentation for details. This is a L<Net::API::Stripe::Connect::ApplicationFee> object.
159              
160             =head2 application_fee_amount integer
161              
162             The amount of the application fee (if any) for the charge. See the Connect documentation for details.
163              
164             =head2 balance_transaction string (expandable)
165              
166             ID of the balance transaction that describes the impact of this charge on your account balance (not including refunds or disputes).
167              
168             This is an L<Net::API::Stripe::Balance::Transaction> object.
169              
170             =head2 billing_details hash
171              
172             Billing information associated with the payment method at the time of the transaction. This is a L<Net::API::Stripe::Billing::Details> object.
173              
174             Hash properties are:
175              
176             =over 4
177              
178             =item I<address> This is a L<Net::API::Stripe::Address>
179              
180             =item I<email> String
181              
182             =item I<name> String
183              
184             =item I<phone> String
185              
186             =back
187              
188             =head2 calculated_statement_descriptor string
189              
190             The full statement descriptor that is passed to card networks, and that is displayed on your customers’ credit card and bank statements. Allows you to see what the statement descriptor looks like after the static and dynamic portions are combined.
191              
192             =head2 captured boolean
193              
194             If the charge was created without capturing, this Boolean represents whether it is still uncaptured or has since been captured.
195              
196             =head2 card
197              
198             This is a L<Net::API::Stripe::Payment::Card> object. It seems it is no documented, but from experience, Stripe has replied with data containing this property.
199              
200             =head2 created timestamp
201              
202             Time at which the object was created. Measured in seconds since the Unix epoch.
203              
204             =head2 currency currency
205              
206             Three-letter ISO currency code, in lowercase. Must be a supported currency.
207              
208             =head2 customer string (expandable)
209              
210             ID of the customer this charge is for if one exists.
211              
212             This is a L<Net::API::Stripe::Customer> object.
213              
214             =head2 description string
215              
216             An arbitrary string attached to the object. Often useful for displaying to users.
217              
218             =head2 destination
219              
220             This is a L<Net::API::Stripe::Connect::Account> object. But, as of 2019-10-16, it seems absent from Stripe API documentation, so maybe it was removed?
221              
222             =head2 dispute string (expandable)
223              
224             Details about the dispute if the charge has been disputed.
225              
226             When expanded, this is a L<Net::API::Stripe::Dispute> object.
227              
228             =head2 disputed boolean
229              
230             Whether the charge has been disputed.
231              
232             =head2 failure_balance_transaction expandable
233              
234             ID of the balance transaction that describes the reversal of the balance on your account due to payment failure.
235              
236             When expanded this is an L<Net::API::Stripe::Balance::Transaction> object.
237              
238             =head2 failure_code string
239              
240             Error code explaining reason for charge failure if available (see the errors section for a list of codes).
241              
242             =head2 failure_message string
243              
244             Message to user further explaining reason for charge failure if available.
245              
246             =head2 fraud_details hash
247              
248             Information on fraud assessments for the charge.
249              
250             =over 4
251              
252             =item I<stripe_report> string
253              
254             Assessments from Stripe. If set, the value is fraudulent.
255              
256             =item I<user_report> string
257              
258             Assessments reported by you. If set, possible values of are safe and fraudulent.
259              
260             =back
261              
262             =head2 invoice string (expandable)
263              
264             ID of the invoice this charge is for if one exists.
265              
266             When expanded, this is a L<Net::API::Stripe::Billing::Invoice> object.
267              
268             =head2 livemode boolean
269              
270             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
271              
272             =head2 metadata hash
273              
274             Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
275              
276             =head2 on_behalf_of string (expandable)
277              
278             The account (if any) the charge was made on behalf of without triggering an automatic transfer. See the Connect documentation for details.
279              
280             When expanded, this is a L<Net::API::Stripe::Connect::Account> object
281              
282             =head2 order string (expandable)
283              
284             ID of the order this charge is for if one exists.
285              
286             When expanded, this is a L<Net::API::Stripe::Order> object.
287              
288             =head2 outcome hash
289              
290             Details about whether the payment was accepted, and why. See understanding declines for details.
291              
292             This is a L<Net::API::Stripe::Charge::Outcome> object.
293              
294             =head2 paid boolean
295              
296             true if the charge succeeded, or was successfully authorized for later capture.
297              
298             =head2 payment_intent string
299              
300             ID of the PaymentIntent associated with this charge, if one exists.
301              
302             This is a <Net::API::Stripe::Payment::Intent> object if any.
303              
304             =head2 payment_method string
305              
306             ID of the payment method used in this charge.
307              
308             =head2 payment_method_details hash
309              
310             Details about the payment method at the time of the transaction.
311              
312             This is a L<Net::API::Stripe::Payment::Method::Details> object.
313              
314             =head2 radar_options object
315              
316             Options to configure Radar. See L<Radar Session|https://stripe.com/docs/radar/radar-session> for more information.
317              
318             This is a L<Net::API::Stripe::Fraud::Review> object.
319              
320             =head2 receipt_email string
321              
322             This is the email address that the receipt for this charge was sent to.
323              
324             =head2 receipt_number string
325              
326             This is the transaction number that appears on email receipts sent for this charge. This attribute will be null until a receipt has been sent.
327              
328             =head2 receipt_url string
329              
330             This is the URL to view the receipt for this charge. The receipt is kept up-to-date to the latest state of the charge, including any refunds. If the charge is for an Invoice, the receipt will be stylized as an Invoice receipt.
331              
332             =head2 refunded boolean
333              
334             Whether the charge has been fully refunded. If the charge is only partially refunded, this attribute will still be false.
335              
336             =head2 refunds list
337              
338             A list of refunds that have been applied to the charge.
339              
340             This is a L<Net::API::Stripe::Charge::Refunds> object.
341              
342             =head2 review string (expandable)
343              
344             ID of the review associated with this charge if one exists.
345              
346             When expanded, this is a L<Net::API::Stripe::Fraud::Review> object.
347              
348             =head2 shipping hash
349              
350             Shipping information for the charge. This is a L<Net::API::Stripe::Shipping> object.
351              
352             =head2 source
353              
354             This represents a L<Net::API::Stripe::Payment::Card> object.
355              
356             It was present before, or at least used in Stripe response, but it is not anymore on the API documentation as of 2019-10-16.
357              
358             =head2 source_transfer string (expandable)
359              
360             The transfer ID which created this charge. Only present if the charge came from another Stripe account. See the Connect documentation for details here: L<https://stripe.com/docs/connect/destination-charges>
361              
362             When expanded, this is a L<Net::API::Stripe::Connect::Transfer> object.
363              
364             =head2 statement_description
365              
366             This is an alternative found in data returned by Stripe. Probably an old property deprecated?
367              
368             =head2 statement_descriptor string
369              
370             For card charges, use statement_descriptor_suffix instead. Otherwise, you can use this value as the complete description of a charge on your customers’ statements. Must contain at least one letter, maximum 22 characters.
371              
372             =head2 statement_descriptor_suffix string
373              
374             Provides information about the charge that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor.
375              
376             =head2 status string
377              
378             The status of the payment is either succeeded, pending, or failed.
379              
380             =head2 transfer string (expandable)
381              
382             ID of the transfer to the destination account (only applicable if the charge was created using the destination parameter).
383              
384             When expanded, this is a L<Net::API::Stripe::Connect::Transfer> object.
385              
386             =head2 transfer_data hash
387              
388             An optional dictionary including the account to automatically transfer to as part of a destination charge. See the Connect documentation for details.
389              
390             This is a L<Net::API::Stripe::Connect::Transfer> object, although in the documentation only the following 2 properties are used:
391              
392             =over 4
393              
394             =item I<amount> integer
395              
396             The amount transferred to the destination account, if specified. By default, the entire charge amount is transferred to the destination account.
397              
398             =item I<destination> string (expandable)
399              
400             ID of an existing, connected Stripe account to transfer funds to if transfer_data was specified in the charge request.
401              
402             If expanded, this is a L<Net::API::Stripe::Connect::Account> object.
403              
404             =back
405              
406             =head2 transfer_group string
407              
408             A string that identifies this transaction as part of a group. See the Connect documentation for details.
409              
410             =head1 API SAMPLE
411              
412             {
413             "id": "ch_fake123456789",
414             "object": "charge",
415             "amount": 100,
416             "amount_refunded": 0,
417             "application": null,
418             "application_fee": null,
419             "application_fee_amount": null,
420             "balance_transaction": "txn_fake123456789",
421             "billing_details": {
422             "address": {
423             "city": null,
424             "country": null,
425             "line1": null,
426             "line2": null,
427             "postal_code": null,
428             "state": null
429             },
430             "email": null,
431             "name": null,
432             "phone": null
433             },
434             "captured": false,
435             "created": 1571176460,
436             "currency": "jpy",
437             "customer": null,
438             "description": "My First Test Charge (created for API docs)",
439             "dispute": null,
440             "failure_code": null,
441             "failure_message": null,
442             "fraud_details": {},
443             "invoice": null,
444             "livemode": false,
445             "metadata": {},
446             "on_behalf_of": null,
447             "order": null,
448             "outcome": null,
449             "paid": true,
450             "payment_intent": null,
451             "payment_method": "card_fake123456789",
452             "payment_method_details": {
453             "card": {
454             "brand": "visa",
455             "checks": {
456             "address_line1_check": null,
457             "address_postal_code_check": null,
458             "cvc_check": null
459             },
460             "country": "US",
461             "exp_month": 4,
462             "exp_year": 2024,
463             "fingerprint": "fake123456789",
464             "funding": "credit",
465             "installments": null,
466             "last4": "4242",
467             "network": "visa",
468             "three_d_secure": null,
469             "wallet": null
470             },
471             "type": "card"
472             },
473             "receipt_email": null,
474             "receipt_number": null,
475             "receipt_url": "https://pay.stripe.com/receipts/acct_fake123456789/ch_fake123456789/rcpt_fake123456789",
476             "refunded": false,
477             "refunds": {
478             "object": "list",
479             "data": [],
480             "has_more": false,
481             "url": "/v1/charges/ch_fake123456789/refunds"
482             },
483             "review": null,
484             "shipping": null,
485             "source_transfer": null,
486             "statement_descriptor": null,
487             "statement_descriptor_suffix": null,
488             "status": "succeeded",
489             "transfer_data": null,
490             "transfer_group": null
491             }
492              
493             =head1 HISTORY
494              
495             =head2 v0.1
496              
497             Initial version
498              
499             =head1 AUTHOR
500              
501             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
502              
503             =head1 SEE ALSO
504              
505             Stripe API documentation:
506              
507             L<https://stripe.com/docs/api/charges>, L<https://stripe.com/docs/charges>
508              
509             =head1 COPYRIGHT & LICENSE
510              
511             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
512              
513             You can use, copy, modify and redistribute this package and associated
514             files under the same terms as Perl itself.
515              
516             =cut