File Coverage

lib/Net/API/Stripe/Payment/Intent.pm
Criterion Covered Total %
statement 19 62 30.6
branch n/a
condition n/a
subroutine 7 50 14.0
pod 39 43 90.7
total 65 155 41.9


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Payment/Intent.pm
3             ## Version v0.102.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             ## https://stripe.com/docs/api/payment_intents
14             BEGIN
15             {
16             use strict;
17 2     2   20617923 use warnings;
  2         14  
  2         57  
18 2     2   10 use parent qw( Net::API::Stripe::Generic );
  2         5  
  2         56  
19 2     2   8 use vars qw( $VERSION );
  2         4  
  2         11  
20 2     2   131 our( $VERSION ) = 'v0.102.0';
  2         4  
  2         101  
21 2     2   36 };
22              
23             use strict;
24 2     2   9 use warnings;
  2         5  
  2         50  
25 2     2   11  
  2         4  
  2         1821  
26              
27 0     0 1    
28             ## 2019-02-11
29 0     0 1   ## Stripe: allowed_source_types has been renamed to payment_method_types.
30             ## sub allowed_source_types { return( shift->_set_get_scalar( 'allowed_source_types', @_ ) ); }
31              
32              
33              
34              
35 0     0 0   {
36             tip => {
37 0     0 1   package => "Net::API::Stripe::Balance::ConnectReserved",
38             type => "object",
39 0     0 1   },
40             }, @_ ) ); }
41 0     0 1    
42              
43              
44              
45             ## 2019-02-11
46             ## Stripe: authorize_with_url within has been renamed to redirect_to_url.
47              
48              
49 0     0 1    
50              
51 0     0 1    
52              
53 0     0 1    
54              
55              
56              
57              
58 0     0 0    
59              
60 0     0 1    
61              
62 0     0 1    
63              
64 0     0 1    
65             # 2019-02-11
66 0     0 1   # Stripe: The next_source_action property on PaymentIntent has been renamed to next_action
67             # sub next_source_action { shift->_set_get_scalar( 'next_source_action', @_ ); }
68 0     0 1    
69              
70 0     0 1    
71              
72 0     0 1    
73              
74 0     0 1    
75              
76 0     0 1    
77              
78 0     0 1    
79              
80 0     0 1    
81              
82 0     0 1    
83              
84 0     0 1    
85              
86 0     0 1   1;
87              
88 0     0 1    
89             =encoding utf8
90 0     0 1    
91             =head1 NAME
92              
93             Net::API::Stripe::PaymentIntent - The PaymentIntent object
94              
95             =head1 SYNOPSIS
96 0     0 0    
97             my $intent = $stripe->payment_intent({
98 0     0 1   amount => 2000,
99             amount_capturable => 2000,
100 0     0 1   application => $connect_account_object,
101             application_fee_amount => 20,
102 0     0 1   capture_method => 'automatic',
103             customer => $customer_object,
104 0     0 1   description => 'Preparation for payment',
105             invoice => $invoice_object,
106 0     0 1   metadata => { transaction_id => 123, customer_id => 456 },
107             receipt_email => 'john.doe@example.com',
108 0     0 1   });
109              
110 0     0 0   See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
111              
112 0     0 1   =head1 VERSION
113              
114 0     0 1   v0.102.0
115              
116 0     0 1   =head1 DESCRIPTION
117              
118 0     0 1   A PaymentIntent guides you through the process of collecting a payment from your customer.
119             We recommend that you create exactly one PaymentIntent for each order or customer session in your system. You can reference the PaymentIntent later to see the history of payment attempts for a particular session.
120 0     0 1   A PaymentIntent transitions through L<multiple statuses|https://stripe.com/docs/payments/intents#intent-statuses> throughout its lifetime as it interfaces with Stripe.js to perform authentication flows and ultimately creates at most one successful charge.
121              
122 0     0 1   Related guide: L<Payment Intents API|https://stripe.com/docs/payments/payment-intents>.
123              
124 0     0 1   Creating payments takes five steps:
125              
126 0     0 1   =over 4
127              
128 0     0 1   =item 1. Create a PaymentIntent on the server
129              
130             =item 2. Pass the PaymentIntent’s client secret to the client
131              
132             =item 3. Collect payment method details on the client
133              
134             =item 4. Submit the payment to Stripe from the client
135              
136             =item 5. Asynchronously fulfill the customer’s order
137              
138             =back
139              
140             More info here: L<https://stripe.com/docs/payments/payment-intents/web>
141              
142             =head1 METHODS
143              
144             =head2 id string
145              
146             Unique identifier for the object.
147              
148             =head2 object string
149              
150             String representing the object's type. Objects of the same type share the same value.
151              
152             =head2 amount integer
153              
154             Amount intended to be collected by this PaymentIntent. A positive integer representing how much to charge in the L<smallest currency unit|https://stripe.com/docs/currencies#zero-decimal> (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or L<equivalent in charge currency|https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts>. The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99).
155              
156             =head2 amount_capturable integer
157              
158             Amount that can be captured from this PaymentIntent.
159              
160             =head2 amount_details hash
161              
162             Details about items included in the amount
163              
164             It has the following properties:
165              
166             =over 4
167              
168             =item C<tip> hash
169              
170             Details about the tip.
171              
172             When expanded, this is a L<Net::API::Stripe::Balance::ConnectReserved> object.
173              
174             =back
175              
176             =head2 amount_received integer
177              
178             Amount that was collected by this PaymentIntent.
179              
180             =head2 application expandable
181              
182             ID of the Connect application that created the PaymentIntent.
183              
184             When expanded this is an L<Net::API::Stripe::Connect::Account> object.
185              
186             =head2 application_fee_amount integer
187              
188             The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner's Stripe account. The amount of the application fee collected will be capped at the total payment amount. For more information, see the PaymentIntents L<use case for connected accounts|https://stripe.com/docs/payments/connected-accounts>.
189              
190             =head2 automatic_payment_methods object
191              
192             Settings to configure compatible payment methods from the L<Stripe Dashboard|https://dashboard.stripe.com/settings/payment_methods>
193              
194             This is a L<Net::API::Stripe::Payment::Installment> object.
195              
196             =head2 canceled_at timestamp
197              
198             Populated when C<status> is C<canceled>, this is the time at which the PaymentIntent was canceled. Measured in seconds since the Unix epoch.
199              
200             =head2 cancellation_reason string
201              
202             Reason for cancellation of this PaymentIntent, either user-provided (C<duplicate>, C<fraudulent>, C<requested_by_customer>, or C<abandoned>) or generated by Stripe internally (C<failed_invoice>, C<void_invoice>, or C<automatic>).
203              
204             =head2 capture_method string
205              
206             Controls when the funds will be captured from the customer's account.
207              
208             =head2 charges object
209              
210             Charges that were created by this PaymentIntent, if any.
211              
212             This is a L<Net::API::Stripe::List> object.
213              
214             =head2 client_secret string
215              
216             The client secret of this PaymentIntent. Used for client-side retrieval using a publishable key.
217              
218             The client secret can be used to complete a payment 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.
219              
220             Refer to our docs to L<accept a payment|https://stripe.com/docs/payments/accept-a-payment?integration=elements> and learn about how C<client_secret> should be handled.
221              
222             =head2 confirmation_method string
223              
224             Possible enum values
225              
226             =over 4
227              
228             =item I<automatic>
229              
230             (Default) PaymentIntent can be confirmed using a publishable key. After next_actions are handled, no additional confirmation is required to complete the payment.
231              
232             =item I<manual>
233              
234             All payment attempts must be made using a secret key. The PaymentIntent returns to the requires_confirmation state after handling next_actions, and requires your server to initiate each payment attempt with an explicit confirmation.
235              
236             =back
237              
238             =head2 created timestamp
239              
240             Time at which the object was created. Measured in seconds since the Unix epoch.
241              
242             =head2 currency currency
243              
244             Three-letter L<ISO currency code|https://www.iso.org/iso-4217-currency-codes.html>, in lowercase. Must be a L<supported currency|https://stripe.com/docs/currencies>.
245              
246             =head2 customer expandable
247              
248             ID of the Customer this PaymentIntent belongs to, if one exists.
249              
250             Payment methods attached to other Customers cannot be used with this PaymentIntent.
251              
252             If present in combination with L<setup_future_usage|https://stripe.com#payment_intent_object-setup_future_usage>, this PaymentIntent's payment method will be attached to the Customer after the PaymentIntent has been confirmed and any required actions from the user are complete.
253              
254             When expanded this is an L<Net::API::Stripe::Customer> object.
255              
256             =head2 description string
257              
258             An arbitrary string attached to the object. Often useful for displaying to users.
259              
260             =head2 invoice expandable
261              
262             ID of the invoice that created this PaymentIntent, if it exists.
263              
264             When expanded this is an L<Net::API::Stripe::Billing::Invoice> object.
265              
266             =head2 last_payment_error hash
267              
268             The payment error encountered in the previous PaymentIntent confirmation. It will be cleared if the PaymentIntent is later updated for any reason.
269              
270             This is a L<Net::API::Stripe::Error> object.
271              
272             =head2 livemode boolean
273              
274             Has the value C<true> if the object exists in live mode or the value C<false> if the object exists in test mode.
275              
276             =head2 metadata hash
277              
278             Set of L<key-value pairs|https://stripe.com/docs/api/metadata> that you can attach to an object. This can be useful for storing additional information about the object in a structured format. For more information, see the L<documentation|https://stripe.com/docs/payments/payment-intents/creating-payment-intents#storing-information-in-metadata>.
279              
280             =head2 next_action object
281              
282             If present, this property tells you what actions you need to take in order for your customer to fulfill a payment using the provided source.
283              
284             This is a L<Net::API::Stripe::Payment::Intent::NextAction> object.
285              
286             =head2 on_behalf_of expandable
287              
288             The account (if any) for which the funds of the PaymentIntent are intended. See the PaymentIntents L<use case for connected accounts|https://stripe.com/docs/payments/connected-accounts> for details.
289              
290             When expanded this is an L<Net::API::Stripe::Connect::Account> object.
291              
292             =head2 payment_method expandable
293              
294             ID of the payment method used in this PaymentIntent.
295              
296             When expanded this is an L<Net::API::Stripe::Payment::Method> object.
297              
298             =head2 payment_method_options object
299              
300             Payment-method-specific configuration for this PaymentIntent.
301              
302             This is a L<Net::API::Stripe::Payment::Method> object.
303              
304             =head2 payment_method_types array of string
305              
306             The list of payment method types (e.g. card) that this PaymentIntent is allowed to use.
307              
308             =head2 processing object
309              
310             If present, this property tells you about the processing state of the payment.
311              
312             This is a L<Net::API::Stripe::Issuing::Authorization::Transaction> object.
313              
314             =head2 receipt_email string
315              
316             Email address that the receipt for the resulting payment will be sent to. If C<receipt_email> is specified for a payment in live mode, a receipt will be sent regardless of your L<email settings|https://dashboard.stripe.com/account/emails>.
317              
318             =head2 review expandable
319              
320             ID of the review associated with this PaymentIntent, if any.
321              
322             When expanded this is an L<Net::API::Stripe::Fraud::Review> object.
323              
324             =head2 setup_future_usage string
325              
326             Indicates that you intend to make future payments with this PaymentIntent's payment method.
327              
328             Providing this parameter will L<attach the payment method|https://stripe.com/docs/payments/save-during-payment> to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be L<attached|https://stripe.com/docs/api/payment_methods/attach> to a Customer after the transaction completes.
329              
330             When processing card payments, Stripe also uses C<setup_future_usage> to dynamically optimize your payment flow and comply with regional legislation and network rules, such as L<SCA|https://stripe.com/docs/strong-customer-authentication>.
331              
332             =head2 shipping object
333              
334             Shipping information for this PaymentIntent.
335              
336             This is a L<Net::API::Stripe::Shipping> object.
337              
338             =head2 source
339              
340             This is a L<Net::API::Stripe::Payment::Source>, but it seems it is not documented on the Stripe API although it is found in its response.
341              
342             =head2 statement_descriptor string
343              
344             For non-card charges, you can use this value as the complete description that appears on your customers’ statements. Must contain at least one letter, maximum 22 characters.
345              
346             =head2 statement_descriptor_suffix string
347              
348             Provides information about a card payment that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor.
349              
350             =head2 status string
351              
352             Status of this PaymentIntent, one of C<requires_payment_method>, C<requires_confirmation>, C<requires_action>, C<processing>, C<requires_capture>, C<canceled>, or C<succeeded>. Read more about each PaymentIntent L<status|https://stripe.com/docs/payments/intents#intent-statuses>.
353              
354             =head2 transfer_data object
355              
356             The data with which to automatically create a Transfer when the payment is finalized. See the PaymentIntents L<use case for connected accounts|https://stripe.com/docs/payments/connected-accounts> for details.
357              
358             This is a L<Net::API::Stripe::Connect::Transfer> object.
359              
360             It uses the following methods:
361              
362             =over 4
363              
364             =item I<amount> integer
365              
366             Amount intended to be collected by this PaymentIntent. A positive integer representing how much to charge in the L<smallest currency unit|https://stripe.com/docs/currencies#zero-decimal> (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or L<equivalent in charge currency|https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts>. The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99).
367              
368             =item I<destination> string expandable
369              
370             The account (if any) the payment will be attributed to for tax reporting, and where funds from the payment will be transferred to upon
371             payment success.
372              
373             When expanded this is an L<Net::API::Stripe::Connect::Account> object.
374              
375             =back
376              
377             =head2 transfer_group string
378              
379             A string that identifies the resulting payment as part of a group. See the PaymentIntents L<use case for connected accounts|https://stripe.com/docs/payments/connected-accounts> for details.
380              
381             =head1 API SAMPLE
382              
383             {
384             "id": "pi_1Dik5W2eZvKYlo2CDeNJH1A5",
385             "object": "payment_intent",
386             "amount": 1999,
387             "amount_capturable": 0,
388             "amount_received": 0,
389             "application": null,
390             "application_fee_amount": null,
391             "canceled_at": null,
392             "cancellation_reason": null,
393             "capture_method": "automatic",
394             "charges": {
395             "object": "list",
396             "data": [
397             ],
398             "has_more": false,
399             "url": "/v1/charges?payment_intent=pi_1Dik5W2eZvKYlo2CDeNJH1A5"
400             },
401             "client_secret": "pi_1Dik5W2eZvKYlo2CDeNJH1A5_secret_YsxmIGlVxOrzmONrMv6KzeqGS",
402             "confirmation_method": "automatic",
403             "created": 1545145346,
404             "currency": "gbp",
405             "customer": null,
406             "description": null,
407             "invoice": null,
408             "last_payment_error": null,
409             "livemode": false,
410             "metadata": {
411             },
412             "next_action": null,
413             "on_behalf_of": null,
414             "payment_method": null,
415             "payment_method_options": {
416             },
417             "payment_method_types": [
418             "card"
419             ],
420             "receipt_email": null,
421             "review": null,
422             "setup_future_usage": null,
423             "shipping": null,
424             "statement_descriptor": null,
425             "statement_descriptor_suffix": null,
426             "status": "requires_payment_method",
427             "transfer_data": null,
428             "transfer_group": null
429             }
430              
431             =head1 HISTORY
432              
433             =head2 v0.1.0
434              
435             Initial version
436              
437             =head1 STRIPE HISTORY
438              
439             =head2 2019-02-11
440              
441             allowed_source_types has been renamed to payment_method_types.
442              
443             =head2 2019-02-11
444              
445             The next_source_action property on PaymentIntent has been renamed to next_action, and the authorize_with_url within has been renamed to redirect_to_url.
446              
447             =head1 AUTHOR
448              
449             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
450              
451             =head1 SEE ALSO
452              
453             Stripe API documentation:
454              
455             L<https://stripe.com/docs/api/payment_intents>, L<https://stripe.com/docs/payments/payment-intents/creating-payment-intents>
456              
457             =head1 COPYRIGHT & LICENSE
458              
459             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
460              
461             You can use, copy, modify and redistribute this package and associated
462             files under the same terms as Perl itself.
463              
464             =cut