File Coverage

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