File Coverage

lib/Net/API/Stripe/Payment/Link.pm
Criterion Covered Total %
statement 19 46 41.3
branch n/a
condition n/a
subroutine 7 34 20.5
pod 21 27 77.7
total 47 107 43.9


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Payment/Link.pm
3             ## Version v0.2.0
4             ## Copyright(c) 2022 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2022/01/28
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   24244068 use warnings;
  2         14  
  2         62  
17 2     2   12 use parent qw( Net::API::Stripe::Generic );
  2         4  
  2         59  
18 2     2   10 use vars qw( $VERSION );
  2         5  
  2         11  
19 2     2   148 our $VERSION = 'v0.2.0';
  2         4  
  2         116  
20 2     2   38 };
21              
22             use strict;
23 2     2   13 use warnings;
  2         3  
  2         57  
24 2     2   14  
  2         5  
  2         1437  
25              
26 0     0 1    
27              
28 0     0 1   {
29             hosted_confirmation => { type => 'class', definition =>
30 0     0 1   {
31             custom_message => { type => 'scalar' }
32 0     0 1   } },
33             redirect => { type => 'class', definition =>
34             {
35             url => { type => 'uri' },
36             } },
37             type => { type => 'scalar' },
38             }, @_ ) ); }
39              
40              
41              
42              
43             {
44             enabled => { type => 'boolean' },
45 0     0 1   }, @_ ) ); }
46              
47 0     0 1    
48             {
49 0     0 1   promotions => { type => 'string' },
50             }, @_ ) ); }
51 0     0 1    
52              
53              
54              
55              
56 0     0 1    
57              
58 0     0 0   {
59             capture_method => { type => 'string' },
60             setup_future_usage => { type => 'string' },
61             }, @_ ) ); }
62              
63 0     0 1    
64              
65 0     0 0   {
66             enabled => { type => 'boolean' },
67 0     0 1   }, @_ ) ); }
68              
69 0     0 1   {
70             allowed_countries => { type => 'string' },
71 0     0 1   }, @_ ) ); }
72              
73 0     0 1   {
74             shipping_amount => { type => 'integer' },
75 0     0 0   shipping_rate => { type => 'scalar_or_object', class => 'Net::API::Stripe::Tax::Rate' },
76             }, @_ ) ); }
77              
78              
79              
80             {
81 0     0 1   enabled => { type => 'boolean' },
82             }, @_ ) ); }
83 0     0 1    
84             {
85 0     0 1   amount => { type => 'integer' },
86             destination => { type => 'scalar_or_object', class => 'Net::API::Stripe::Connect::Account' },
87             }, @_ ) ); }
88              
89              
90 0     0 1   1;
91              
92              
93             =encoding utf8
94              
95 0     0 0   =head1 NAME
96              
97             Net::API::Stripe::Payment::Link - A Stripe Payment Link Object
98              
99             =head1 SYNOPSIS
100              
101 0     0 0   my $link = $stripe->payment_link({
102             active => $stripe->true,
103 0     0 1   after_completion =>
104             {
105 0     0 0   hosted_confirmation =>
106             {
107             custom_message => $some_message,
108             },
109             redirect =>
110 0     0 1   {
111             url => 'https://example.org/some/where',
112             },
113             type => 'hosted_confirmation',
114             },
115             allow_promotion_codes => $stripe->true,
116 0     0 1   application_fee_amount => 1000,
117             application_fee_percent => 20,
118             automatic_tax => { enabled => $stripe->true },
119             billing_address_collection => {},
120             line_items => {},
121             livemode => $stripe->false,
122             metadata => { tax_id => 123, customer_id => 456 },
123             object => $object,
124             on_behalf_of => $account,
125             payment_method_types => 'card',
126             phone_number_collection => { enabled => $stripe->true },
127             shipping_address_collection =>
128             {
129             allowed_countries => [qw( JP US FR DE UK )],
130             },
131             subscription_data => { trial_period_days => 30 },
132             transfer_data =>
133             {
134             amount => 10000,
135             destination => 'acct_1234567890qwertyuiop',
136             },
137             url => 'https://buy.stripe.com/test_123456789qwertyuiop',
138             });
139              
140             See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
141              
142             =head1 VERSION
143              
144             v0.2.0
145              
146             =head1 DESCRIPTION
147              
148             A payment link is a shareable URL that will take your customers to a hosted payment page. A payment link can be shared and used multiple times.
149              
150             When a customer opens a payment link it will open a L<new checkout session|https://stripe.com/docs/api/payment_links/payment_links#checkout_sessions> to render the payment page. L<You can use checkout session events|https://stripe.com/docs/api/events/types#event_types-checkout.session.completed> to track payments through payment links.
151              
152             Related guide: L<Payment Links API|https://stripe.com/docs/payments/payment-links/api>.
153              
154             =head1 CONSTRUCTOR
155              
156             =head2 new
157              
158             Creates a new L<Net::API::Stripe::Tax::Rate> object.
159             It may also take an hash like arguments, that also are method of the same name.
160              
161             =head1 METHODS
162              
163             =head2 id string
164              
165             Unique identifier for the object.
166              
167             =head2 object string, value is "payment_link"
168              
169             String representing the object’s type. Objects of the same type share the same value.
170              
171             =head2 active boolean
172              
173             Whether the payment link’s C<url> is active. If C<false>, customers visiting the URL will be shown a page saying that the link has been deactivated.
174              
175             =head2 after_completion hash
176              
177             Behavior after the purchase is complete.
178              
179             =over 4
180              
181             =item hosted_confirmation hash
182              
183             Configuration when C<type=hosted_confirmation>.
184              
185             =over 8
186              
187             =item custom_message string
188              
189             The custom message that is displayed to the customer after the purchase is complete.
190              
191             =back
192              
193             =item redirect hash
194              
195             Configuration when type=redirect.
196              
197             =over 8
198              
199             =item url string
200              
201             The URL the customer will be redirected to after the purchase is complete.
202              
203             =back
204              
205             =item type enum
206              
207             The specified behavior after the purchase is complete.
208              
209             Possible enum values
210              
211             =over 8
212              
213             =item redirect
214              
215             Redirects the customer to the specified C<url> after the purchase is complete.
216              
217             =item hosted_confirmation
218              
219             Displays a message on the hosted surface after the purchase is complete.
220              
221             =back
222              
223             =back
224              
225             =head2 allow_promotion_codes boolean
226              
227             Whether user redeemable promotion codes are enabled.
228              
229             =head2 application_fee_amount integer
230              
231             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.
232              
233             =head2 application_fee_percent decimal
234              
235             This represents the percentage of the subscription invoice subtotal that will be transferred to the application owner’s Stripe account.
236              
237             =head2 automatic_tax hash
238              
239             Configuration details for automatic tax collection.
240              
241             =over 4
242              
243             =item enabled boolean
244              
245             If true, tax will be calculated automatically using the customer’s location.
246              
247             =back
248              
249             =head2 billing_address_collection enum
250              
251             Configuration for collecting the customer’s billing address.
252              
253             Possible enum values
254              
255             =over 4
256              
257             =item auto Default
258              
259             Checkout will only collect the billing address when necessary.
260              
261             =item required
262              
263             Checkout will always collect the customer’s billing address.
264              
265             =back
266              
267             =head2 currency currency
268              
269             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>.
270              
271             =head2 line_items list
272              
273             The line items representing what is being sold.
274              
275             This field is not included by default. To include it in the response, expand the line_items field.
276              
277             =over 4
278              
279             =item object string, value is "list"
280              
281             String representing the object’s type. Objects of the same type share the same value. Always has the value list.
282              
283             =item data array of hashes
284              
285             Details about each object.
286              
287             =item has_more boolean
288              
289             True if this list has another page of items after this one that can be fetched.
290              
291             =item url string
292              
293             The URL where this list can be accessed.
294              
295             =back
296              
297             =head2 livemode boolean
298              
299             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
300              
301             =head2 metadata hash
302              
303             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.
304              
305             =head2 on_behalf_of string expandable
306              
307             The account on behalf of which to charge. See the Connect documentation for details.
308              
309             =head2 payment_method_collection string
310              
311             Configuration for collecting a payment method during checkout.
312              
313             =head2 payment_method_types array of enum values
314              
315             The list of payment method types that customers can use. When C<null>, Stripe will dynamically show relevant payment methods you’ve enabled in your L<payment method settings|https://dashboard.stripe.com/settings/payment_methods>.
316              
317             Possible enum values: C<card>
318              
319             =head2 phone_number_collection hash
320              
321             Controls phone number collection settings during checkout.
322              
323             =over 4
324              
325             =item enabled boolean
326              
327             If true, a phone number will be collected during checkout.
328              
329             =back
330              
331             =head2 shipping_address_collection hash
332              
333             Configuration for collecting the customer’s shipping address.
334              
335             shipping_address_collection.allowed_countries array of enum values
336              
337             An array of two-letter ISO country codes representing which countries Checkout should provide as options for shipping locations. Unsupported country codes: AS, CX, CC, CU, HM, IR, KP, MH, FM, NF, MP, PW, SD, SY, UM, VI.
338              
339             =head2 subscription_data object
340              
341             When creating a subscription, the specified configuration data will be used. There must be at least one line item with a recurring price to use C<subscription_data>.
342              
343             This is a L<Net::API::Stripe::Billing::Subscription> object.
344              
345             =head2 transfer_data hash
346              
347             The account (if any) the payments will be attributed to for tax reporting, and where funds from each payment will be transferred to.
348              
349             =over 4
350              
351             =item amount integer
352              
353             The amount in JPY that will be transferred to the destination account. By default, the entire amount is transferred to the destination.
354              
355             =item destination string
356              
357             The connected account receiving the transfer.
358              
359             =back
360              
361             =head2 url
362              
363             The public URL that can be shared with customers.
364              
365             =head1 API SAMPLE
366              
367             {
368             "id": "plink_1234567890qwertyuiop",
369             "object": "payment_link",
370             "active": true,
371             "after_completion": {
372             "hosted_confirmation": {
373             "custom_message": null
374             },
375             "type": "hosted_confirmation"
376             },
377             "allow_promotion_codes": false,
378             "application_fee_amount": null,
379             "application_fee_percent": null,
380             "automatic_tax": {
381             "enabled": false
382             },
383             "billing_address_collection": "auto",
384             "livemode": false,
385             "metadata": {},
386             "on_behalf_of": null,
387             "payment_method_types": null,
388             "phone_number_collection": {
389             "enabled": false
390             },
391             "shipping_address_collection": null,
392             "subscription_data": null,
393             "transfer_data": null,
394             "url": "https://buy.stripe.com/test_1234567890qwertyuiop"
395             }
396              
397             =head1 HISTORY
398              
399             =head2 v0.1.0
400              
401             Initial version
402              
403             =head1 AUTHOR
404              
405             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
406              
407             =head1 SEE ALSO
408              
409             Stripe API documentation:
410              
411             L<https://stripe.com/docs/api/payment_links/payment_links/object#payment_link_object>
412              
413             =head1 COPYRIGHT & LICENSE
414              
415             Copyright (c) 2019-2022 DEGUEST Pte. Ltd.
416              
417             You can use, copy, modify and redistribute this package and associated
418             files under the same terms as Perl itself.
419              
420             =cut