File Coverage

blib/lib/Net/API/Stripe/Payment/Intent/Setup.pm
Criterion Covered Total %
statement 6 28 21.4
branch n/a
condition n/a
subroutine 2 24 8.3
pod 21 21 100.0
total 29 73 39.7


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Payment/Intent/Setup.pm
3             ## Version v0.1.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             package Net::API::Stripe::Payment::Intent::Setup;
11             BEGIN
12 0           {
13 1     1   887 use strict;
  1         2  
  1         28  
14 1     1   5 use parent qw( Net::API::Stripe::Generic );
  1     0   2  
  1         4  
15             };
16              
17 0     0 1   sub id { return( shift->_set_get_scalar( 'id', @_ ) ); }
18              
19             ## setup_intent
20 0     0 1   sub object { return( shift->_set_get_scalar( 'object', @_ ) ); }
21              
22 0     0 1   sub application { shift->_set_get_scalar_or_object( 'application', 'Net::API::Stripe::Connect::Account', @_ ); }
23              
24 0     0 1   sub cancellation_reason { return( shift->_set_get_scalar( 'cancellation_reason', @_ ) ); }
25              
26 0     0 1   sub client_secret { return( shift->_set_get_scalar( 'client_secret', @_ ) ); }
27              
28 0     0 1   sub created { return( shift->_set_get_datetime( 'created', @_ ) ); }
29              
30 0     0 1   sub customer { shift->_set_get_scalar_or_object( 'customer', 'Net::API::Stripe::Customer', @_ ); }
31              
32 0     0 1   sub description { shift->_set_get_scalar( 'description', @_ ); }
33              
34 0     0 1   sub last_setup_error { shift->_set_get_object( 'last_setup_error', 'Net::API::Stripe::Error', @_ ); }
35              
36 0     0 1   sub livemode { shift->_set_get_boolean( 'livemode', @_ ); }
37              
38 0     0 1   sub mandate { return( shift->_set_get_scalar_or_object( 'mandate', 'Net::API::Stripe::Mandate', @_ ) ); }
39              
40 0     0 1   sub metadata { shift->_set_get_hash( 'metadata', @_ ); }
41              
42 0     0 1   sub next_action { return( shift->_set_get_hash( 'next_action', @_ ) ); }
43              
44 0     0 1   sub on_behalf_of { return( shift->_set_get_object_variant( 'on_behalf_of', @_ ) ); }
45              
46 0     0 1   sub payment_method { return( shift->_set_get_scalar_or_object( 'payment_method', 'Net::API::Stripe::Payment::Method', @_ ) ); }
47              
48 0     0 1   sub payment_method_options { return( shift->_set_get_hash( 'payment_method_options', @_ ) ); }
49              
50 0     0 1   sub payment_method_types { return( shift->_set_get_array( 'payment_method_types', @_ ) ); }
51              
52 0     0 1   sub review { return( shift->_set_get_scalar_or_object( 'review', '', @_ ) ); }
53              
54 0     0 1   sub single_use_mandate { return( shift->_set_get_scalar_or_object( 'single_use_mandate', 'Net::API::Stripe::Mandate', @_ ) ); }
55              
56             ## requires_payment_method, requires_confirmation, requires_action, processing, requires_capture, canceled, or succeeded
57 0     0 1   sub status { return( shift->_set_get_scalar( 'status', @_ ) ); }
58              
59 0     0 1   sub usage { return( shift->_set_get_scalar( 'usage', @_ ) ); }
60              
61             1;
62              
63             __END__
64              
65             =encoding utf8
66              
67             =head1 NAME
68              
69             Net::API::Stripe::Payment::Intent::Setup - A Stripe Charge Setup Intent
70              
71             =head1 SYNOPSIS
72              
73             my $setup = $stripe->setup_intent({
74             cancellation_reason => undef,
75             customer => $customer_object,
76             description => 'Preparing for payment',
77             mandate => $mandate_object,
78             metadata => { transaction_id => 123, customer_id => 456 },
79             next_action =>
80             {
81             redirect_to_url =>
82             {
83             return_url => 'https://example.com/pay/return',
84             url => 'https://example.com/pay/auth',
85             },
86             type => 'redirect_to_url',
87             },
88             payment_method => $payment_method_object,
89             });
90              
91             See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
92              
93             =head1 VERSION
94              
95             v0.1.0
96              
97             =head1 DESCRIPTION
98              
99             A SetupIntent guides you through the process of setting up a customer's payment credentials for future payments. For example, you could use a SetupIntent to set up your customer's card without immediately collecting a payment. Later, you can use PaymentIntents (L<Net::API::Stripe::Payment::Intent> / L<https://stripe.com/docs/api/setup_intents#payment_intents>) to drive the payment flow.
100              
101             Create a SetupIntent as soon as you're ready to collect your customer's payment credentials. Do not maintain long-lived, unconfirmed SetupIntents as they may no longer be valid. The SetupIntent then transitions through multiple statuses as it guides you through the setup process.
102              
103             Successful SetupIntents result in payment credentials that are optimized for future payments. For example, cardholders in certain regions may need to be run through Strong Customer Authentication at the time of payment method collection in order to streamline later off-session payments.
104              
105             By using SetupIntents, you ensure that your customers experience the minimum set of required friction, even as regulations change over time.
106              
107             =head1 CONSTRUCTOR
108              
109             =over 4
110              
111             =item B<new>( %ARG )
112              
113             Creates a new L<Net::API::Stripe::Payment::Intent::Setup> object.
114             It may also take an hash like arguments, that also are method of the same name.
115              
116             =back
117              
118             =head1 METHODS
119              
120             =over 4
121              
122             =item B<id> retrievable with publishable key string
123              
124             Unique identifier for the object.
125              
126             =item B<object> retrievable with publishable key string, value is "setup_intent"
127              
128             String representing the object’s type. Objects of the same type share the same value.
129              
130             =item B<application> string expandable "application"
131              
132             ID of the Connect application that created the SetupIntent. This is a string of the account or a L<Net::API::Stripe::Connect::Account> object.
133              
134             =item B<cancellation_reason> retrievable with publishable key string
135              
136             Reason for cancellation of this SetupIntent, one of abandoned, requested_by_customer, or duplicate.
137              
138             =item B<client_secret> retrievable with publishable key string
139              
140             The client secret of this SetupIntent. Used for client-side retrieval using a publishable key.
141              
142             The client secret can be used to complete payment setup from your frontend. It should not be stored, logged, embedded in URLs, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.
143              
144             =item B<created> retrievable with publishable key timestamp
145              
146             Time at which the object was created. Measured in seconds since the Unix epoch.
147              
148             =item B<customer> string (expandable)
149              
150             ID of the Customer this SetupIntent belongs to, if one exists, or the corresponding L<Net::API::Stripe::Customer> object.
151              
152             If present, payment methods used with this SetupIntent can only be attached to this Customer, and payment methods attached to other Customers cannot be used with this SetupIntent.
153              
154             =item B<description> retrievable with publishable key string
155              
156             An arbitrary string attached to the object. Often useful for displaying to users.
157              
158             =item B<last_setup_error> retrievable with publishable key hash
159              
160             The error encountered in the previous SetupIntent confirmation.
161              
162             This is a L<Net::API::Stripe::Error> object.
163              
164             =item B<livemode> retrievable with publishable key boolean
165              
166             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
167              
168             =item B<mandate> string expandable
169              
170             ID of the multi use Mandate generated by the SetupIntent. When expanded, this is a L<Net::API::Stripe::Mandate> object.
171              
172             =item B<metadata> hash
173              
174             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.
175              
176             =item B<next_action> retrievable with publishable key hash
177              
178             If present, this property tells you what actions you need to take in order for your customer to continue payment setup.
179              
180             This is a L<Net::API::Stripe::Payment::Intent::NextAction> object with the following properties:
181              
182             =over 8
183              
184             =item B<redirect_to_url> hash
185              
186             Contains instructions for authenticating a payment by redirecting your customer to another page or application.
187              
188             =over 12
189              
190             =item I<return_url> string
191              
192             If the customer does not exit their browser while authenticating, they will be redirected to this specified URL after completion.
193              
194             =item I<url> string
195              
196             The URL you must redirect your customer to in order to authenticate the payment.
197              
198             =back
199              
200             =item B<type> string
201              
202             Type of the next action to perform, one of redirect_to_url or use_stripe_sdk.
203              
204             =item B<use_stripe_sdk> hash
205              
206             When confirming a PaymentIntent with Stripe.js, Stripe.js depends on the contents of this dictionary to invoke authentication flows. The shape of the contents is subject to change and is only intended to be used by Stripe.js.
207              
208             =back
209              
210             =item B<on_behalf_of> string (expandable)
211              
212             The account (if any) for which the setup is intended.
213              
214             =item B<payment_method> retrievable with publishable key string (expandable)
215              
216             ID of the payment method used with this SetupIntent.
217              
218             When expanded, this is a L<Net::API::Stripe::Payment::Method> object.
219              
220             =item B<payment_method_options> hash
221              
222             Payment-method-specific configuration for this SetupIntent.
223              
224             =over 8
225              
226             =item I<card>
227              
228             If the PaymentIntent’s payment_method_types includes card, this hash contains the configurations that will be applied to each payment attempt of that type.
229              
230             =over 12
231              
232             =item I<installments>
233              
234             =over 16
235              
236             =item I<available_plans>
237              
238             Instalment plans that may be selected for this PaymentIntent.
239              
240             =over 20
241              
242             =item I<count>
243              
244             For fixed_count installment plans, this is the number of installment payments your customer will make to their credit card.
245              
246             =item I<interval>
247              
248             For fixed_count installment plans, this is the interval between installment payments your customer will make to their credit card. One of month.
249              
250             =item I<type>
251              
252             Type of installment plan, one of fixed_count
253              
254             =back
255              
256             =item I<enabled>
257              
258             Whether Installments are enabled for this PaymentIntent.
259              
260             =item I<plan>
261              
262             Instalment plan selected for this PaymentIntent.
263              
264             =over 20
265              
266             =item I<count>
267              
268             For fixed_count installment plans, this is the number of installment payments your customer will make to their credit card.
269              
270             =item I<interval>
271              
272             For fixed_count installment plans, this is the interval between installment payments your customer will make to their credit card. One of month.
273              
274             =item I<type>
275              
276             Type of installment plan, one of fixed_count.
277              
278             =back
279              
280             =back
281              
282             =item I<request_three_d_secure>
283              
284             Stripe strongly recommend that you rely on their SCA Engine to automatically prompt your customers for L<authentication based on risk level and other requirements|https://stripe.com/docs/strong-customer-authentication>. However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. Permitted values include: automatic or any. If not provided, defaults to automatic. Read Stripe guide on manually requesting 3D Secure for more information on how this configuration interacts with Radar and Stripe SCA Engine
285              
286             =back
287              
288             =back
289              
290             =item B<payment_method_types> retrievable with publishable key array containing strings
291              
292             The list of payment method types (e.g. card) that this SetupIntent is allowed to set up.
293              
294             =item B<review> scalar or object
295              
296             ID of the review associated with this PaymentIntent, if any.
297              
298             When expanded, this is a a L<Net::API::Stripe::Fraud::Review> object
299              
300             =item B<single_use_mandate> string expandable
301              
302             ID of the single_use Mandate generated by the SetupIntent. When expanded, this is a L<Net::API::Stripe::Mandate> object.
303              
304             =item B<status> retrievable with publishable key string
305              
306             Status of this SetupIntent, one of requires_payment_method, requires_confirmation, requires_action, processing, canceled, or succeeded.
307              
308             =item B<usage> retrievable with publishable key string
309              
310             Indicates how the payment method is intended to be used in the future.
311              
312             Use on_session if you intend to only reuse the payment method when the customer is in your checkout flow. Use off_session if your customer may or may not be in your checkout flow. If not provided, this value defaults to off_session.
313              
314             =back
315              
316             =head1 API SAMPLE
317              
318             {
319             "id": "seti_123456789",
320             "object": "setup_intent",
321             "application": null,
322             "cancellation_reason": null,
323             "client_secret": null,
324             "created": 123456789,
325             "customer": null,
326             "description": null,
327             "last_setup_error": null,
328             "livemode": false,
329             "metadata": {
330             "user_id": "guest"
331             },
332             "next_action": null,
333             "on_behalf_of": null,
334             "payment_method": null,
335             "payment_method_options": {},
336             "payment_method_types": [
337             "card"
338             ],
339             "status": "requires_payment_method",
340             "usage": "off_session"
341             }
342              
343             =head1 HISTORY
344              
345             =head2 v0.1
346              
347             Initial version
348              
349             =head1 STRIPE HISTORY
350              
351             =head2 2019-12-24
352              
353             Stripe has added 2 new properties: B<mandate> and B<single_use_mandate>
354              
355             =head1 AUTHOR
356              
357             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
358              
359             =head1 SEE ALSO
360              
361             Stripe API documentation:
362              
363             L<https://stripe.com/docs/api/setup_intents>
364              
365             =head1 COPYRIGHT & LICENSE
366              
367             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
368              
369             You can use, copy, modify and redistribute this package and associated
370             files under the same terms as Perl itself.
371              
372             =cut