File Coverage

lib/Net/API/Stripe/Product.pm
Criterion Covered Total %
statement 19 42 45.2
branch n/a
condition n/a
subroutine 7 30 23.3
pod 23 23 100.0
total 49 95 51.5


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Product.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             ## "A list of up to 5 attributes that each SKU can provide values for (e.g., ["color", "size"]). Only applicable to products of type=good."
11             BEGIN
12             {
13             use strict;
14 2     2   24290494 use warnings;
  2         16  
  2         66  
15 2     2   10 use parent qw( Net::API::Stripe::Generic );
  2         5  
  2         64  
16 2     2   10 use vars qw( $VERSION );
  2         5  
  2         13  
17 2     2   138 our( $VERSION ) = 'v0.101.0';
  2         5  
  2         112  
18 2     2   40 };
19              
20             use strict;
21 2     2   10 use warnings;
  2         6  
  2         56  
22 2     2   11  
  2         4  
  2         1032  
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    
39             ## List of Net::API::Stripe::Order::SKU objects
40 0     0 1    
41              
42 0     0 1    
43              
44 0     0 1    
45              
46 0     0 1    
47              
48 0     0 1   1;
49              
50 0     0 1    
51             =encoding utf8
52 0     0 1    
53             =head1 NAME
54 0     0 1    
55             Net::API::Stripe::Product - A Stripe Product Object
56              
57             =head1 SYNOPSIS
58 0     0 1    
59             my $prod = $stripe->product({
60 0     0 1   active => $stripe->true,
61             attributes => [qw( colour size gender )],
62 0     0 1   caption => 'Fashionable T-shirt',
63             description => 'Product for limited edition t-shirt',
64 0     0 1   images => [qw(
65             https://img.example.com/p12/file1.jpg
66 0     0 1   https://img.example.com/p12/file2.jpg
67             https://img.example.com/p12/file3.jpg
68 0     0 1   )],
69             livemode => $stripe->false,
70 0     0 1   metadata => { product_id => 123, customer_id => 456 },
71             name => 'Limited Edition Shirt',
72             package_dimensions =>
73             {
74             use_metric => 1,
75             width => 30,
76             length => 50,
77             height => 15,
78             weight => 500,
79             },
80             shippable => $stripe->true,
81             type => 'good',
82             url => 'https://store.example.com/p12/',
83             });
84              
85             See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
86              
87             =head1 VERSION
88              
89             v0.101.0
90              
91             =head1 DESCRIPTION
92              
93             Store representations of products you sell in Product objects, used in conjunction with L<SKUs|https://stripe.com/docs/api/products#skus>. Products may be physical goods, to be shipped, or digital.
94              
95             Documentation on Products for use with Subscriptions can be found at L<Subscription Products|https://stripe.com/docs/api/products#service_products>.
96              
97             =head1 CONSTRUCTOR
98              
99             =head2 new( %ARG )
100              
101             Creates a new L<Net::API::Stripe::Product> object.
102              
103             =head1 METHODS
104              
105             =head2 id string
106              
107             Unique identifier for the object.
108              
109             =head2 object string, value is "product"
110              
111             String representing the object’s type. Objects of the same type share the same value.
112              
113             =head2 active boolean
114              
115             Whether the product is currently available for purchase.
116              
117             =head2 attributes array containing strings
118              
119             A list of up to 5 attributes that each SKU can provide values for (e.g., ["color", "size"]). Only applicable to products of type=good.
120              
121             =head2 caption string
122              
123             A short one-line description of the product, meant to be displayable to the customer. Only applicable to products of type=good.
124              
125             =head2 created timestamp
126              
127             Time at which the object was created. Measured in seconds since the Unix epoch.
128              
129             =head2 deactivate_on array containing strings
130              
131             An array of connect application identifiers that cannot purchase this product. Only applicable to products of type=good.
132              
133             =head2 default_price expandable
134              
135             The ID of the L<Price|https://stripe.com/docs/api/prices> object that is the default price for this product.
136              
137             When expanded this is an L<Net::API::Stripe::Price> object.
138              
139             =head2 deleted boolean
140              
141             Set to true when the product has been deleted.
142              
143             =head2 description string
144              
145             The product’s description, meant to be displayable to the customer. Only applicable to products of type=good.
146              
147             =head2 images array containing strings
148              
149             A list of up to 8 URLs of images for this product, meant to be displayable to the customer. Only applicable to products of type=good.
150              
151             =head2 livemode boolean
152              
153             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
154              
155             =head2 metadata hash
156              
157             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.
158              
159             =head2 name string
160              
161             The product’s name, meant to be displayable to the customer. Applicable to both service and good types.
162              
163             =head2 package_dimensions hash
164              
165             The dimensions of this product for shipping purposes. A SKU associated with this product can override this value by having its own package_dimensions. Only applicable to products of type=good.
166              
167             This is a L<Net::API::Stripe::Product::PackageDimension> object.
168              
169             =head2 shippable boolean
170              
171             Whether this product is a shipped good. Only applicable to products of type=good.
172              
173             =head2 skus list
174              
175             This is a list (L<Net::API::Stripe::List>) of L<Net::API::Stripe::Order::SKU> objects.
176              
177             This is an undocumented property.
178              
179             =head2 statement_descriptor string
180              
181             Extra information about a product which will appear on your customer’s credit card statement. In the case that multiple products are billed at once, the first statement descriptor will be used. Only available on products of type=service.
182              
183             =head2 tax_code expandable
184              
185             A L<tax code|https://stripe.com/docs/tax/tax-categories> ID.
186              
187             When expanded this is an L<Net::API::Stripe::Product::TaxCode> object.
188              
189             =head2 type string
190              
191             The type of the product. The product is either of type good, which is eligible for use with Orders and SKUs, or service, which is eligible for use with Subscriptions and Plans.
192              
193             =head2 unit_label string
194              
195             A label that represents units of this product, such as seat(s), in Stripe and on customers’ receipts and invoices. Only available on products of type=service.
196              
197             =head2 updated timestamp
198              
199             Time at which the object was last updated. Measured in seconds since the Unix epoch.
200              
201             =head2 url string
202              
203             A URL of a publicly-accessible webpage for this product. Only applicable to products of type=good
204              
205             This returns a L<URI> object.
206              
207             =head1 API SAMPLE
208              
209             {
210             "id": "prod_fake123456789",
211             "object": "product",
212             "active": true,
213             "attributes": [],
214             "caption": null,
215             "created": 1541833574,
216             "deactivate_on": [],
217             "description": null,
218             "images": [],
219             "livemode": false,
220             "metadata": {},
221             "name": "Provider, Inc investor yearly membership",
222             "package_dimensions": null,
223             "shippable": null,
224             "statement_descriptor": null,
225             "type": "service",
226             "unit_label": null,
227             "updated": 1565089803,
228             "url": null
229             }
230              
231             =head1 HISTORY
232              
233             =head2 v0.1
234              
235             Initial version
236              
237             =head1 STRIPE HISTORY
238              
239             =head2 2018-05-21
240              
241             Products no longer have SKU lists embedded.
242              
243             =head1 AUTHOR
244              
245             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
246              
247             =head1 SEE ALSO
248              
249             Stripe API documentation:
250              
251             L<https://stripe.com/docs/api/products>, L<https://stripe.com/docs/orders#define-products-skus>, L<https://stripe.com/docs/billing/subscriptions/products-and-plans#products>
252              
253             =head1 COPYRIGHT & LICENSE
254              
255             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
256              
257             You can use, copy, modify and redistribute this package and associated
258             files under the same terms as Perl itself.
259              
260             =cut