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