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