File Coverage

lib/Net/API/Stripe/Payment/Intent/Setup.pm
Criterion Covered Total %
statement 19 45 42.2
branch n/a
condition n/a
subroutine 7 33 21.2
pod 24 26 92.3
total 50 104 48.0


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