File Coverage

lib/Net/API/Stripe/Customer.pm
Criterion Covered Total %
statement 19 58 32.7
branch n/a
condition n/a
subroutine 7 46 15.2
pod 38 39 97.4
total 64 143 44.7


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Customer.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/customers/object
11             BEGIN
12             {
13             use strict;
14 2     2   25374359 use warnings;
  2         14  
  2         64  
15 2     2   12 use parent qw( Net::API::Stripe::Generic );
  2         7  
  2         59  
16 2     2   11 use vars qw( $VERSION );
  2         5  
  2         10  
17 2     2   168 our( $VERSION ) = 'v0.101.0';
  2         5  
  2         114  
18 2     2   39 };
19              
20             use strict;
21 2     2   11 use warnings;
  2         4  
  2         35  
22 2     2   43  
  2         6  
  2         1397  
23              
24 0     0 1    
25              
26 0     0 1   # sub address { return( shift->_set_get_scalar( 'address', @_ ) ); }
27              
28 0     0 1    
29              
30              
31             ## Used when creating a customer object
32 0     0 1    
33              
34 0     0 1    
35              
36 0     0 1    
37              
38              
39              
40 0     0 1    
41              
42 0     0 1    
43              
44 0     0 1    
45              
46 0     0 1    
47             # sub invoice_settings { return( shift->_set_get_hash( 'invoice_settings', @_ ) ); }
48 0     0 1    
49              
50 0     0 0    
51              
52 0     0 1    
53              
54 0     0 1    
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   # sub tax_info_verification { return( shift->_set_get_object( 'tax_info_verification', 'Net::API::Stripe::Customer::TaxInfoVerification', @_ ) ); }
67              
68              
69              
70 0     0 1   1;
71              
72 0     0 1    
73             =encoding utf8
74 0     0 1    
75             =head1 NAME
76 0     0 1    
77             Net::API::Stripe::Customer - A Customer object in Stripe API
78 0     0 1    
79             =head1 SYNOPSIS
80 0     0 1    
81             my $cust = $stripe->customer({
82 0     0 1   address => $address_object,
83             balance => 20000,
84 0     0 1   coupon => 'VIP2020_20POFF',
85             currency => 'jpy',
86 0     0 1   description => 'Webstore customer',
87             email => 'john.doe@example.com',
88 0     0 1   invoice_prefix => 'JD123',
89             invoice_settings =>
90 0     0 1   {
91             # or it could just contain an id such as pm_fake124567890
92 0     0 1   default_payment_method => $payment_method_object,
93             footer => 'Big Corp, Inc web store',
94 0     0 1   },
95             metadata => { customer_id => 123 },
96 0     0 1   name => 'John Doe',
97             phone => '+81-(0)90-1234-5678',
98 0     0 1   preferred_locales => [qw( ja en fr )],
99             shipping => $address_object,
100 0     0 1   });
101              
102 0     0 1   See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
103              
104             =head1 VERSION
105              
106 0     0 1   v0.101.0
107              
108 0     0 1   =head1 DESCRIPTION
109              
110             From the documentation:
111              
112             Stripe Customer objects allow you to perform recurring charges, and to track multiple charges, that are associated with the same customer. The API allows you to create, delete, and update your customers. You can retrieve individual customers as well as a list of all your customers.
113              
114             =head1 CONSTRUCTOR
115              
116             =head2 new( %ARG )
117              
118             Creates a new L<Net::API::Stripe::Customer> object.
119             It may also take an hash like arguments, that also are method of the same name.
120              
121             =head1 METHODS
122              
123             =head2 id string
124              
125             Unique identifier for the object.
126              
127             =head2 object string, value is "customer"
128              
129             String representing the object’s type. Objects of the same type share the same value.
130              
131             =head2 account_balance
132              
133             It seems not in use anymore as of 2019-10-16, at least by the look of the API documentation.
134              
135             =head2 address hash
136              
137             The customer’s address. This is a L<Net::API::Stripe::Address> object.
138              
139             =head2 balance integer
140              
141             Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied to any invoice. This balance is only taken into account as invoices are finalized.
142              
143             =head2 cards
144              
145             This represents a L<Net::API::Stripe::Customer::Sources> object.
146              
147             It seems that as of 2019-10-16, it is not in Stripe API, but it was seen in Stripe response.
148              
149             =head2 cash_balance object
150              
151             The current funds being held by Stripe on behalf of the customer. These funds can be applied towards payment intents with source "cashI<balance".The settings[reconciliation>mode] field describes whether these funds are applied to such payment intents manually or automatically.
152              
153             This is a L<Net::API::Stripe::Cash::Balance> object.
154              
155             =head2 coupon optional
156              
157             If you provide a coupon code, the customer will have a discount applied on all recurring charges. Charges you create through the API will not have the discount.
158              
159             This is used only when creating a customer object.
160              
161             =head2 created timestamp
162              
163             Time at which the object was created. Measured in seconds since the Unix epoch.
164              
165             =head2 currency string
166              
167             Three-letter ISO code for the currency the customer can be charged in for recurring billing purposes.
168              
169             =head2 default_card
170              
171             The API does not mention this, but it was part of some response. Deprecated or omission?
172              
173             =head2 default_source string (expandable)
174              
175             ID of the default payment source for the customer. This is a L<Net::API::Stripe::Payment::Source> object.
176              
177             =head2 deleted
178              
179             A flag that is being used, but not part of the API documentation.
180              
181             =head2 delinquent boolean
182              
183             When the customer’s latest invoice is billed by charging automatically, delinquent is true if the invoice’s latest charge is failed. When the customer’s latest invoice is billed by sending an invoice, delinquent is true if the invoice is not paid by its due date.
184              
185             =head2 description string
186              
187             An arbitrary string attached to the object. Often useful for displaying to users.
188              
189             =head2 discount hash, discount object
190              
191             Describes the current discount active on the customer, if there is one. This is a L<Net::API::Stripe::Billing::Discount> object.
192              
193             =head2 email string
194              
195             The customer’s email address.
196              
197             =head2 invoice_credit_balance hash
198              
199             The current multi-currency balances, if any, being stored on the customer.If positive in a currency, the customer has a credit to apply to their next invoice denominated in that currency.If negative, the customer has an amount owed that will be added to their next invoice denominated in that currency. These balances do not refer to any unpaid invoices.They solely track amounts that have yet to be successfully applied to any invoice. A balance in a particular currency is only applied to any invoice as an invoice in that currency is finalized.
200              
201             =head2 invoice_prefix string
202              
203             The prefix for the customer used to generate unique invoice numbers. This prefix must be unique otherwise it will generated an error such as C<This invoice number prefix is taken by customer: cus_fake1234567890. Please enter a different prefix>
204              
205             =head2 invoice_settings hash
206              
207             The customer’s default invoice settings. This is a L<Net::API::Stripe::Billing::Invoice::Settings> object.
208              
209             =over 4
210              
211             =item I<custom_fields> array of hashes
212              
213             Default custom fields to be displayed on invoices for this customer. This is an array of L<Net::API::Stripe::CustomField> object.
214              
215             =over 8
216              
217             =item I<name> string
218              
219             The name of the custom field.
220              
221             =item I<value> string
222              
223             The value of the custom field.
224              
225             =back
226              
227             =item I<default_payment_method> string (expandable)
228              
229             ID of the default payment method used for subscriptions and invoices for the customer. When expanded, this is a L<Net::API::Stripe::Payment::Method> object.
230              
231             =item I<footer> string
232              
233             Default footer to be displayed on invoices for this customer.
234              
235             =back
236              
237             =head2 livemode boolean
238              
239             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
240              
241             =head2 metadata hash
242              
243             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.
244              
245             =head2 name string
246              
247             The customer’s full name or business name.
248              
249             =head2 next_invoice_sequence string
250              
251             The sequence to be used on the customer’s next invoice. Defaults to 1.
252              
253             =head2 payment_method optional
254              
255             The ID of the PaymentMethod to attach to the customer.
256              
257             This is used when creating a customer object.
258              
259             =head2 phone string
260              
261             The customer’s phone number.
262              
263             =head2 preferred_locales array containing strings
264              
265             The customer’s preferred locales (languages), ordered by preference.
266              
267             =head2 shipping hash
268              
269             Mailing and shipping address for the customer. Appears on invoices emailed to this customer. This is a L<Net::API::Stripe::Shipping> object.
270              
271             =head2 source optional
272              
273             A Token’s (L<https://stripe.com/docs/api#tokens>) or a Source’s (L<https://stripe.com/docs/api#sources>) ID, as returned by Elements (L<https://stripe.com/docs/elements>). Passing source will create a new source object, make it the new customer default source, and delete the old customer default if one exists. If you want to add additional sources instead of replacing the existing default, use the card creation API (L<https://stripe.com/docs/api#create_card>). Whenever you attach a card to a customer, Stripe will automatically validate the card.
274              
275             This is used when creating a customer object.
276              
277             =head2 sources list
278              
279             The customer’s payment sources, if any. This is a L<Net::API::Stripe::Customer::Sources> object.
280              
281             =head2 subscriptions list
282              
283             The customer’s current subscriptions, if any. This is a L<Net::API::Stripe::List> object of L<Net::API::Stripe::Billing::Subscription> objects.
284              
285             =head2 tax object
286              
287             Tax details for the customer.
288              
289             This is a L<Net::API::Stripe::Terminal::Reader> object.
290              
291             =head2 tax_exempt string
292              
293             Describes the customer’s tax exemption status. One of none, exempt, or reverse. When set to reverse, invoice and receipt PDFs include the text “Reverse charge”.
294              
295             =head2 tax_id_data optional array of hashes
296              
297             The customer’s tax IDs.
298              
299             This is used when creating a customer object.
300              
301             =over 4
302              
303             =item I<type> required
304              
305             Type of the tax ID, one of au_abn, ch_vat, eu_vat, in_gst, mx_rfc, no_vat, nz_gst, or za_vat
306              
307             =item I<value> required
308              
309             Value of the tax ID.
310              
311             =back
312              
313             =head2 tax_ids list
314              
315             The customer’s tax IDs. This is represented by a L<Net::API::Stripe::Customer::TaxIds> object.
316              
317             =over 4
318              
319             =item I<object> string, value is "list"
320              
321             String representing the object's type. Objects of the same type share the same value. Always has the value list.
322              
323             =item I<data> array of L<Net::API::Stripe::Customer::TaxId> object
324              
325             =item I<has_more> boolean
326              
327             True if this list has another page of items after this one that can be fetched.
328              
329             =item I<url> string
330              
331             The URL where this list can be accessed.
332              
333             =back
334              
335             =head2 tax_info deprecated hash
336              
337             The customer’s tax information. Appears on invoices emailed to this customer. This field has been deprecated and will be removed in a future API version, for further information view the migration guide.
338              
339             This is a L<Net::API::Stripe::Customer::TaxInfo> object.
340              
341             =head2 tax_info_verification deprecated hash
342              
343             Describes the status of looking up the tax ID provided in tax_info. This field has been deprecated and will be removed in a future API version, for further information view the migration guide.
344              
345             This is a L<Net::API::Stripe::Customer::TaxInfoVerification> object
346              
347             =head2 test_clock expandable
348              
349             ID of the test clock this customer belongs to.
350              
351             When expanded this is an L<Net::API::Stripe::Billing::TestHelpersTestClock> object.
352              
353             =head1 API SAMPLE
354              
355             {
356             "id": "cus_fake123456789",
357             "object": "customer",
358             "account_balance": 0,
359             "address": null,
360             "balance": 0,
361             "created": 1571176460,
362             "currency": "jpy",
363             "default_source": null,
364             "delinquent": false,
365             "description": null,
366             "discount": null,
367             "email": null,
368             "invoice_prefix": "0822CFA",
369             "invoice_settings": {
370             "custom_fields": null,
371             "default_payment_method": null,
372             "footer": null
373             },
374             "livemode": false,
375             "metadata": {},
376             "name": null,
377             "phone": null,
378             "preferred_locales": [],
379             "shipping": null,
380             "sources": {
381             "object": "list",
382             "data": [],
383             "has_more": false,
384             "url": "/v1/customers/cus_fake123456789/sources"
385             },
386             "subscriptions": {
387             "object": "list",
388             "data": [],
389             "has_more": false,
390             "url": "/v1/customers/cus_fake123456789/subscriptions"
391             },
392             "tax_exempt": "none",
393             "tax_ids": {
394             "object": "list",
395             "data": [],
396             "has_more": false,
397             "url": "/v1/customers/cus_fake123456789/tax_ids"
398             },
399             "tax_info": null,
400             "tax_info_verification": null
401             }
402              
403             =head1 HISTORY
404              
405             =head2 v0.1
406              
407             Initial version
408              
409             =head1 STRIPE HISTORY
410              
411             =head2 2019-12-03
412              
413             Deprecated tax information for Customers have been removed.
414              
415             =over 4
416              
417             =item The deprecated tax_info and tax_info_verification fields on the Customer object are now removed in favor of tax_ids.
418              
419             =item The deprecated tax_info parameter on the Customer create and update methods are removed in favor of tax_id_data.
420              
421             =item For more information, view the migration guide.
422              
423             =back
424              
425             =head1 AUTHOR
426              
427             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
428              
429             =head1 SEE ALSO
430              
431             Stripe API documentation:
432              
433             L<https://stripe.com/docs/api/customers>
434              
435             =head1 COPYRIGHT & LICENSE
436              
437             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
438              
439             You can use, copy, modify and redistribute this package and associated
440             files under the same terms as Perl itself.
441              
442             =cut