File Coverage

blib/lib/Net/API/Stripe/Checkout/Session.pm
Criterion Covered Total %
statement 7 28 25.0
branch n/a
condition n/a
subroutine 3 24 12.5
pod 20 21 95.2
total 30 73 41.1


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Checkout/Session.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/checkout/sessions
11             package Net::API::Stripe::Checkout::Session;
12             BEGIN
13             {
14 1     1   824 use strict;
  1         3  
  1         29  
15 1     1   4 use parent qw( Net::API::Stripe::Generic );
  1         2  
  1         4  
16 1     1   374 our( $VERSION ) = 'v0.100.0';
17             };
18              
19 0     0 1   sub id { return( shift->_set_get_scalar( 'id', @_ ) ); }
20              
21 0     0 1   sub object { return( shift->_set_get_scalar( 'object', @_ ) ); }
22              
23 0     0 1   sub billing_address_collection { return( shift->_set_get_scalar( 'billing_address_collection', @_ ) ); }
24              
25 0     0 1   sub cancel_url { return( shift->_set_get_uri( 'cancel_url', @_ ) ); }
26              
27 0     0 1   sub client_reference_id { return( shift->_set_get_scalar( 'client_reference_id', @_ ) ); }
28              
29 0     0 1   sub customer { return( shift->_set_get_scalar_or_object( 'customer', 'Net::API::Stripe::Customer', @_ ) ); }
30              
31 0     0 1   sub customer_email { return( shift->_set_get_scalar( 'customer_email', @_ ) ); }
32              
33 0     0 1   sub display_items { return( shift->_set_get_object_array( 'display_items', 'Net::API::Stripe::Checkout::Item', @_ ) ); }
34              
35 0     0 0   sub line_items { return( shift->_set_get_object_array( 'line_items', 'Net::API::Stripe::Checkout::Item', @_ ) ); }
36              
37 0     0 1   sub livemode { return( shift->_set_get_boolean( 'livemode', @_ ) ); }
38              
39 0     0 1   sub locale { return( shift->_set_get_scalar( 'locale', @_ ) ); }
40              
41             ## payment, setup, or subscription
42 0     0 1   sub mode { return( shift->_set_get_scalar( 'mode', @_ ) ); }
43              
44 0     0 1   sub payment_intent { return( shift->_set_get_scalar_or_object( 'payment_intent', 'Net::API::Stripe::Payment::Intent', @_ ) ); }
45              
46 0     0 1   sub payment_intent_data { return( shift->_set_get_object( 'payment_intent_data', 'Net::API::Stripe::Payment::Intent', @_ ) ); }
47              
48 0     0 1   sub payment_method_types { return( shift->_set_get_array( 'payment_method_types', @_ ) ); }
49              
50 0     0 1   sub setup_intent { return( shift->_set_get_scalar_or_object( 'setup_intent', 'Net::API::Stripe::Payment::Intent::Setup', @_ ) ); }
51              
52 0     0 1   sub setup_intent_data { return( shift->_set_get_object( 'setup_intent_data', 'Net::API::Stripe::Payment::Intent::Setup', @_ ) ); }
53              
54 0     0 1   sub submit_type { return( shift->_set_get_scalar( 'submit_type', @_ ) ); }
55              
56 0     0 1   sub subscription { return( shift->_set_get_scalar_or_object( 'subscription', 'Net::API::Stripe::Billing::Subscription', @_ ) ); }
57              
58 0     0 1   sub subscription_data { return( shift->_set_get_object( 'subscription_data', 'Net::API::Stripe::Billing::Subscription', @_ ) ); }
59              
60 0     0 1   sub success_url { return( shift->_set_get_uri( 'success_url', @_ ) ); }
61              
62             1;
63              
64             __END__
65              
66             =encoding utf8
67              
68             =head1 NAME
69              
70             Net::API::Stripe::Checkout::Session - A Stripe Checkout Session Object
71              
72             =head1 SYNOPSIS
73              
74             my $session = $stripe->session({
75             # This easy to implement with Net::API::REST
76             cancel_url => 'https://api.example.com/v1/stripe/cancel',
77             success_url => 'https://api.example.com/v1/stripe/success',
78             client_reference_id => '1F7F749C-D9C9-46EB-B692-986628BD7302',
79             customer => $customer_object,
80             customer_email => 'john.doe@example.com',
81             # Japanese please
82             locale => 'ja',
83             mode => 'subscription',
84             payment_intent => $payment_intent_object,
85             submit_type => 'pay',
86             subscription => $subscription_object,
87             });
88              
89             =head1 VERSION
90              
91             v0.100.0
92              
93             =head1 DESCRIPTION
94              
95             A Checkout Session represents your customer's session as they pay for one-time purchases or subscriptions through Checkout (L<https://stripe.com/docs/payments/checkout>). Stripe recommends creating a new Session each time your customer attempts to pay.
96              
97             Once payment is successful, the Checkout Session will contain a reference to the Customer (L<Net::API::Stripe::Customer> / L<https://stripe.com/docs/api/customers>), and either the successful PaymentIntent (L<Net::API::Stripe::Payment::Intent> / L<https://stripe.com/docs/api/payment_intents>) or an active Subscription (L<Net::API::Stripe::Billing::Subscription> / L<https://stripe.com/docs/api/subscriptions>).
98              
99             You can create a Checkout Session on your server and pass its ID to the client to begin Checkout.
100              
101             =head1 CONSTRUCTOR
102              
103             =over 4
104              
105             =item B<new>( %ARG )
106              
107             Creates a new L<Net::API::Stripe::Checkout::Session> object.
108              
109             =back
110              
111             =head1 METHODS
112              
113             =over 4
114              
115             =item B<id> string
116              
117             Unique identifier for the object. Used to pass to redirectToCheckout in Stripe.js.
118              
119             =item B<object> string, value is "checkout.session"
120              
121             String representing the object’s type. Objects of the same type share the same value.
122              
123             =item B<billing_address_collection> string
124              
125             The value (auto or required) for whether Checkout collected the customer’s billing address.
126              
127             =item B<cancel_url> string
128              
129             The URL the customer will be directed to if they decide to cancel payment and return to your website.
130              
131             This is a L<URI> object.
132              
133             =item B<client_reference_id> string
134              
135             A unique string to reference the Checkout Session. This can be a customer ID, a cart ID, or similar, and can be used to reconcile the session with your internal systems.
136              
137             =item B<customer> string (expandable)
138              
139             The ID of the customer for this session. For Checkout Sessions in payment or subscription mode, Checkout will create a new customer object based on information provided during the session unless an existing customer was provided when the session was created.
140              
141             When expanded, this is a L<Net::API::Stripe::Customer> object.
142              
143             =item B<customer_email> string
144              
145             If provided, this value will be used when the Customer object is created. If not provided, customers will be asked to enter their email address. Use this parameter to prefill customer data if you already have an email on file. To access information about the customer once a session is complete, use the customer field.
146              
147             =item B<display_items> array of hashes
148              
149             The line items, plans, or SKUs purchased by the customer.
150              
151             This is an array of L<Net::API::Stripe::Checkout::Item> objects.
152              
153             =item B<livemode> boolean
154              
155             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
156              
157             =item B<locale> string
158              
159             The IETF language tag of the locale Checkout is displayed in. If blank or auto, the browser’s locale is used.
160              
161             =item B<mode> string
162              
163             The mode of the Checkout Session, one of payment, setup, or subscription.
164              
165             =item B<payment_intent> string (expandable)
166              
167             The ID of the PaymentIntent for Checkout Sessions in payment mode. If it is expanded, it contains a L<Net::API::Stripe::Payment::Intent> object.
168              
169             =item B<payment_intent_data> object
170              
171             A subset of parameters to be passed to PaymentIntent creation for Checkout Sessions in payment mode.
172              
173             This is a L<Net::API::Stripe::Payment::Intent> object and used to create a checkout session.
174              
175             =item B<payment_method_types> array containing strings
176              
177             A list of the types of payment methods (e.g. card) this Checkout Session is allowed to accept.
178              
179             =item B<setup_intent> string (expandable)
180              
181             The ID of the SetupIntent for Checkout Sessions in setup mode.
182              
183             When expanded, this is a L<Net::API::Stripe::Payment::Intent> object.
184              
185             =item B<setup_intent_data> object
186              
187             A subset of parameters to be passed to SetupIntent creation for Checkout Sessions in setup mode.
188              
189             This is a L<Net::API::Stripe::Payment::Intent> object and used to create a checkout session.
190              
191             =item B<submit_type> string
192              
193             Describes the type of transaction being performed by Checkout in order to customize relevant text on the page, such as the submit button. submit_type can only be specified on Checkout Sessions in payment mode, but not Checkout Sessions in subscription or setup mode. Supported values are auto, book, donate, or pay.
194              
195             =item B<subscription> string (expandable)
196              
197             The ID of the subscription for Checkout Sessions in subscription mode. If it is expanded, this is the L<Net::API::Stripe::Billing::Subscription> object.
198              
199             =item B<subscription_data> object
200              
201             A subset of parameters to be passed to subscription creation for Checkout Sessions in subscription mode.
202              
203             This is a L<Net::API::Stripe::Billing::Subscription> object and used to create a checkout session.
204              
205             =item B<success_url> string
206              
207             The URL the customer will be directed to after the payment or subscription creation is successful.
208              
209             =back
210              
211             =head1 API SAMPLE
212              
213             {
214             "id": "cs_test_ksjfkjfkljslfkjlfkflsfklskflskflskfs",
215             "object": "checkout.session",
216             "billing_address_collection": null,
217             "cancel_url": "https://example.com/cancel",
218             "client_reference_id": null,
219             "customer": null,
220             "customer_email": null,
221             "display_items": [
222             {
223             "amount": 1500,
224             "currency": "usd",
225             "custom": {
226             "description": "Comfortable cotton t-shirt",
227             "images": null,
228             "name": "T-shirt"
229             },
230             "quantity": 2,
231             "type": "custom"
232             }
233             ],
234             "livemode": false,
235             "locale": null,
236             "mode": null,
237             "payment_intent": "pi_fake123456789",
238             "payment_method_types": [
239             "card"
240             ],
241             "setup_intent": null,
242             "submit_type": null,
243             "subscription": null,
244             "success_url": "https://example.com/success"
245             }
246              
247             =head1 HISTORY
248              
249             =head2 v0.1
250              
251             Initial version
252              
253             =head1 AUTHOR
254              
255             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
256              
257             =head1 SEE ALSO
258              
259             Stripe API documentation:
260              
261             L<https://stripe.com/docs/api/checkout/sessions>, L<https://stripe.com/docs/payments/checkout/api>
262              
263             =head1 COPYRIGHT & LICENSE
264              
265             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
266              
267             You can use, copy, modify and redistribute this package and associated
268             files under the same terms as Perl itself.
269              
270             =cut
271