File Coverage

blib/lib/Net/API/Stripe/Order.pm
Criterion Covered Total %
statement 7 30 23.3
branch n/a
condition n/a
subroutine 3 26 11.5
pod 23 23 100.0
total 33 79 41.7


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Order.pm
3             ## Version v0.100.0
4             ## Copyright(c) 2019 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <@sitael.tokyo.deguest.jp>
6             ## Created 2019/11/02
7             ## Modified 2020/05/15
8             ##
9             ##----------------------------------------------------------------------------
10             ## https://stripe.com/docs/api/orders/object
11             package Net::API::Stripe::Order;
12             BEGIN
13             {
14 1     1   816 use strict;
  1         2  
  1         27  
15 1     1   5 use parent qw( Net::API::Stripe::Generic );
  1         2  
  1         4  
16 1     1   386 our( $VERSION ) = 'v0.100.0';
17             };
18              
19 0     0 1   sub id { shift->_set_get_scalar( 'id', @_ ); }
20              
21 0     0 1   sub object { shift->_set_get_scalar( 'object', @_ ); }
22              
23 0     0 1   sub amount { shift->_set_get_number( 'amount', @_ ); }
24              
25 0     0 1   sub amount_returned { shift->_set_get_number( 'amount_returned', @_ ); }
26              
27 0     0 1   sub application { shift->_set_get_scalar_or_object( 'application', 'Net::API::Stripe::Connect::Account', @_ ); }
28              
29 0     0 1   sub application_fee { shift->_set_get_number( 'application_fee', @_ ); }
30              
31 0     0 1   sub charge { shift->_set_get_scalar_or_object( 'charge', 'Net::API::Stripe::Charge', @_ ); }
32              
33 0     0 1   sub created { shift->_set_get_datetime( 'created', @_ ); }
34              
35 0     0 1   sub currency { shift->_set_get_scalar( 'currency', @_ ); }
36              
37 0     0 1   sub customer { shift->_set_get_scalar_or_object( 'customer', 'Net::API::Stripe::Customer', @_ ); }
38              
39 0     0 1   sub email { shift->_set_get_scalar( 'email', @_ ); }
40              
41 0     0 1   sub external_coupon_code { shift->_set_get_scalar( 'external_coupon_code', @_ ); }
42              
43             ## Array of Net::API::Stripe::Order::Item
44 0     0 1   sub items { shift->_set_get_object_array( 'items', 'Net::API::Stripe::Order::Item', @_ ); }
45              
46 0     0 1   sub livemode { shift->_set_get_boolean( 'livemode', @_ ); }
47              
48 0     0 1   sub metadata { shift->_set_get_hash( 'metadata', @_ ); }
49              
50 0     0 1   sub returns { shift->_set_get_object( 'returns', 'Net::API::Stripe::Order::Returns', @_ ); }
51              
52 0     0 1   sub selected_shipping_method { shift->_set_get_scalar( 'selected_shipping_method', @_ ); }
53              
54 0     0 1   sub shipping { shift->_set_get_object( 'shipping', 'Net::API::Stripe::Shipping', @_ ); }
55              
56 0     0 1   sub shipping_methods { shift->_set_get_object_array( 'shipping_methods', 'Net::API::Stripe::Order::ShippingMethod', @_ ); }
57              
58 0     0 1   sub status { shift->_set_get_scalar( 'status', @_ ); }
59              
60 0     0 1   sub status_transitions { shift->_set_get_object( 'status_transitions', 'Net::API::Stripe::Order::StatusTransitions', @_ ); }
61              
62 0     0 1   sub updated { shift->_set_get_datetime( 'updated', @_ ); }
63              
64 0     0 1   sub upstream_id { shift->_set_get_scalar( 'upstream_id', @_ ); }
65              
66             1;
67              
68             __END__
69              
70             =encoding utf8
71              
72             =head1 NAME
73              
74             Net::API::Stripe::Order - A Stripe Order Object
75              
76             =head1 SYNOPSIS
77              
78             my $order = $stripe->order({
79             amount => 2000,
80             amount_returned => undef,
81             application => $connect_account_object,
82             application_fee => 20,
83             charge => $charge_object,
84             currency => 'jpy',
85             customer => $customer_object,
86             email => 'john.doe@example.com',
87             metadata => { transaction_id => 123, customer_id => 456 },
88             returns => [],
89             status => 'paid',
90             status_transitions => $status_transitions_object,
91             });
92              
93             See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
94              
95             =head1 VERSION
96              
97             v0.100.0
98              
99             =head1 DESCRIPTION
100              
101             Order objects are created to handle end customers' purchases of previously defined products (L<https://stripe.com/docs/api/orders#products>). You can create, retrieve, and pay individual orders, as well as list all orders. Orders are identified by a unique, random ID.
102              
103             =head1 CONSTRUCTOR
104              
105             =over 4
106              
107             =item B<new>( %ARG )
108              
109             =back
110              
111             =head1 METHODS
112              
113             =over 4
114              
115             =item B<id> string
116              
117             Unique identifier for the object.
118              
119             =item B<object> string, value is "order"
120              
121             String representing the object’s type. Objects of the same type share the same value.
122              
123             =item B<amount> integer
124              
125             A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for Â¥1, Japanese Yen being a zero-decimal currency) representing the total amount for the order.
126              
127             =item B<amount_returned> integer
128              
129             =item B<application> string
130              
131             ID of the Connect Application that created the order.
132              
133             If this was somehow expanded, this would be a L<Net::API::Stripe::Connect::Account> object.
134              
135             =item B<application_fee> integer
136              
137             =item B<charge> string (expandable)
138              
139             The ID of the payment used to pay for the order. Present if the order status is paid, fulfilled, or refunded.
140              
141             When expanded, this is a L<Net::API::Stripe::Charge> object.
142              
143             =item B<created> timestamp
144              
145             Time at which the object was created. Measured in seconds since the Unix epoch.
146              
147             =item B<currency> currency
148              
149             Three-letter ISO currency code, in lowercase. Must be a supported currency.
150              
151             =item B<customer> string (expandable)
152              
153             The customer used for the order.
154              
155             When expanded, this is a L<Net::API::Stripe::Customer> object.
156              
157             =item B<email> string
158              
159             The email address of the customer placing the order.
160              
161             =item B<external_coupon_code> string
162              
163             =item B<items> array of hashes
164              
165             List of items constituting the order. An order can have up to 25 items.
166              
167             This is an array of L<Net::API::Stripe::Order::Item> objects.
168              
169             =item B<livemode> boolean
170              
171             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
172              
173             =item B<metadata> hash
174              
175             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.
176              
177             =item B<returns> list
178              
179             This is an array of L<Net::API::Stripe::Order::Returns> objects.
180              
181             =item B<selected_shipping_method> string
182              
183             The shipping method that is currently selected for this order, if any. If present, it is equal to one of the ids of shipping methods in the shipping_methods array. At order creation time, if there are multiple shipping methods, Stripe will automatically selected the first method.
184              
185             =item B<shipping> hash
186              
187             The shipping address for the order. Present if the order is for goods to be shipped.
188              
189             This is a L<Net::API::Stripe::Shipping> object.
190              
191             =item B<shipping_methods> array of hashes
192              
193             A list of supported shipping methods for this order. The desired shipping method can be specified either by updating the order, or when paying it.
194              
195             This is an array of L<Net::API::Stripe::Order::ShippingMethod> objects.
196              
197             =item B<status> string
198              
199             Current order status. One of created, paid, canceled, fulfilled, or returned. More details in the Orders Guide.
200              
201             =item B<status_transitions> hash
202              
203             The timestamps at which the order status was updated.
204              
205             This is a L<Net::API::Stripe::Order::StatusTransitions> object.
206              
207             =item B<updated> timestamp
208              
209             =item B<upstream_id> string
210              
211             The user’s order ID if it is different from the Stripe order ID.
212              
213             =back
214              
215             =head1 API SAMPLE
216              
217             {
218             "id": "or_fake123456789",
219             "object": "order",
220             "amount": 1500,
221             "amount_returned": null,
222             "application": null,
223             "application_fee": null,
224             "charge": null,
225             "created": 1571480453,
226             "currency": "jpy",
227             "customer": null,
228             "email": null,
229             "items": [
230             {
231             "object": "order_item",
232             "amount": 1500,
233             "currency": "jpy",
234             "description": "T-shirt",
235             "parent": "sk_fake123456789",
236             "quantity": null,
237             "type": "sku"
238             }
239             ],
240             "livemode": false,
241             "metadata": {},
242             "returns": {
243             "object": "list",
244             "data": [],
245             "has_more": false,
246             "url": "/v1/order_returns?order=or_fake123456789"
247             },
248             "selected_shipping_method": null,
249             "shipping": {
250             "address": {
251             "city": "Anytown",
252             "country": "US",
253             "line1": "1234 Main street",
254             "line2": null,
255             "postal_code": "123456",
256             "state": null
257             },
258             "carrier": null,
259             "name": "Jenny Rosen",
260             "phone": null,
261             "tracking_number": null
262             },
263             "shipping_methods": null,
264             "status": "created",
265             "status_transitions": {
266             "canceled": null,
267             "fulfiled": null,
268             "paid": null,
269             "returned": null
270             },
271             "updated": 1571480453
272             }
273              
274             =head1 HISTORY
275              
276             =head2 v0.1
277              
278             Initial version
279              
280             =head1 AUTHOR
281              
282             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
283              
284             =head1 SEE ALSO
285              
286             Stripe API documentation:
287              
288             L<https://stripe.com/docs/api/orders>, L<https://stripe.com/docs/orders>
289              
290             =head1 COPYRIGHT & LICENSE
291              
292             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
293              
294             You can use, copy, modify and redistribute this package and associated
295             files under the same terms as Perl itself.
296              
297             =cut