Stripe/Billing/Plan.pm

filter: Statementstmt 23.5% 8 / 34 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 10.3% 3 / 29 Podpod 100% 26 / 26 totaltotal 41.5% 37 / 89 CC 1 SCAR 6.4
CC
1
Cov
24%
id
2.0
object
2.0
active
2.0
CRAP 1.9
« Stripe/Dispute/Evidence.pm ↑ Summary Stripe/Payment/Intent/Setup.pm »
1 ##----------------------------------------------------------------------------
2 ## Stripe API - ~/lib/Net/API/Stripe/Billing/Plan.pm
3 ## Version v0.100.0
4 ## Copyright(c) 2019 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <@sitael.tokyo.deguest.jp>
6 ## Created 2019/11/02
7 ## Modified 2020/05/15
8 ##
9 ##----------------------------------------------------------------------------
10 ## The product in Billing is the same as the core Product class.
11 ## https://stripe.com/docs/api/service_products/object
12  
13 ## For product objects, see Net::API::Stripe::Product
14 package Net::API::Stripe::Billing::Plan;
15 BEGIN
16 {
17 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶ use parent qw( Net::API::Stripe::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶ our( $VERSION ) = 'v0.100.0';
Subroutine BEGIN: called CC=1 SCAR=0.0
20 };
21  
22 0 ▶sub id { shift->_set_get_scalar( 'id', @_ ); }
Subroutine id: not called CC=1 SCAR=6.9
Pod documented
23  
24 0 ▶sub object { shift->_set_get_scalar( 'object', @_ ); }
Subroutine object: not called CC=1 SCAR=6.9
Pod documented
25  
26 0 ▶sub active { shift->_set_get_boolean( 'active', @_ ); }
Subroutine active: not called CC=1 SCAR=6.9
Pod documented
27  
28 0 ▶sub aggregate_usage { shift->_set_get_scalar( 'aggregate_usage', @_ ); }
Subroutine aggregate_usage: not called CC=1 SCAR=6.9
Pod documented
29  
30 0 ▶sub amount { shift->_set_get_number( 'amount', @_ ); }
Subroutine amount: not called CC=1 SCAR=6.9
Pod documented
31  
32 0 ▶sub amount_decimal { return( shift->_set_get_number( 'amount_decimal', @_ ) ); }
Subroutine amount_decimal: not called CC=1 SCAR=6.9
Pod documented
33  
34 0 ▶sub billing_scheme { shift->_set_get_scalar( 'billing_scheme', @_ ); }
Subroutine billing_scheme: not called CC=1 SCAR=6.9
Pod documented
35  
36 ## Not part of the official api documentation, but found in sub object data like in here
37 ## https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card-installments
38 0 ▶sub count { return( shift->_set_get_number( 'count', @_ ) ); }
Subroutine count: not called CC=1 SCAR=6.9
Pod documented
39  
40 0 ▶sub created { shift->_set_get_datetime( 'created', @_ ); }
Subroutine created: not called CC=1 SCAR=6.9
Pod documented
41  
42 0 ▶sub currency { shift->_set_get_scalar( 'currency', @_ ); }
Subroutine currency: not called CC=1 SCAR=6.9
Pod documented
43  
44 0 ▶sub deleted { return( shift->_set_get_boolean( 'deleted', @_ ) ); }
Subroutine deleted: not called CC=1 SCAR=6.9
Pod documented
45  
46 0 ▶sub interval { shift->_set_get_scalar( 'interval', @_ ); }
Subroutine interval: not called CC=1 SCAR=6.9
Pod documented
47  
48 0 ▶sub interval_count { shift->_set_get_scalar( 'interval_count', @_ ); }
Subroutine interval_count: not called CC=1 SCAR=6.9
Pod documented
49  
50 0 ▶sub livemode { shift->_set_get_boolean( 'livemode', @_ ); }
Subroutine livemode: not called CC=1 SCAR=6.9
Pod documented
51  
52 0 ▶sub metadata { shift->_set_get_hash( 'metadata', @_ ); }
Subroutine metadata: not called CC=1 SCAR=6.9
Pod documented
53  
54 0 ▶sub name { return( shift->_set_get_scalar( 'name', @_ ) ); }
Subroutine name: not called CC=1 SCAR=6.9
Pod documented
55  
56 0 ▶sub nickname { shift->_set_get_scalar( 'nickname', @_ ); }
Subroutine nickname: not called CC=1 SCAR=6.9
Pod documented
57  
58 0 ▶sub product { shift->_set_get_scalar_or_object( 'product', 'Net::API::Stripe::Product', @_ ); }
Subroutine product: not called CC=1 SCAR=6.9
Pod documented
59  
60 0 ▶sub statement_description { return( shift->_set_get_scalar( 'statement_description', @_ ) ); }
Subroutine statement_description: not called CC=1 SCAR=6.9
Pod documented
61  
62 0 ▶sub statement_descriptor { return( shift->_set_get_scalar( 'statement_descriptor', @_ ) ); }
Subroutine statement_descriptor: not called CC=1 SCAR=6.9
Pod documented
63  
64 0 ▶sub tiers { shift->_set_get_object( 'tiers', 'Net::API::Stripe::Billing::Plan::Tiers', @_ ); }
Subroutine tiers: not called CC=1 SCAR=6.9
Pod documented
65  
66 0 ▶sub tiers_mode { shift->_set_get_scalar( 'tiers_mode', @_ ); }
Subroutine tiers_mode: not called CC=1 SCAR=6.9
Pod documented
67  
68 0 ▶sub transform_usage { shift->_set_get_object( 'transform_usage', 'Net::API::Stripe::Billing::Plan::TransformUsage', @_ ); }
Subroutine transform_usage: not called CC=1 SCAR=6.9
Pod documented
69  
70 0 ▶sub trial_period_days { shift->_set_get_number( 'trial_period_days', @_ ); }
Subroutine trial_period_days: not called CC=1 SCAR=6.9
Pod documented
71  
72 ## Not part of the official api documentation, but found in sub object data like in here
73 ## https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card-installments
74 0 ▶sub type { return( shift->_set_get_scalar( 'type', @_ ) ); }
Subroutine type: not called CC=1 SCAR=6.9
Pod documented
75  
76 0 ▶sub usage_type { shift->_set_get_scalar( 'usage_type', @_ ); }
Subroutine usage_type: not called CC=1 SCAR=6.9
Pod documented
77  
78 1 1;
79  
80 __END__
81  
82 =encoding utf8
83  
84 =head1 NAME
85  
86 Net::API::Stripe::Billing::Plan - A Stripe Plan Object
87  
88 =head1 SYNOPSIS
89  
90 my $plan = $stripe->plan({
91 # Or you can just use 1. $stripe->true returns a Module::Generic::Boolean object
92 active => $stripe->true,
93 amount => 2000,
94 billing_scheme => 'per_unit',
95 count => 12,
96 currency => 'jpy',
97 interval => 'month',
98 interval_count => 1,
99 metadata => { transaction_id => 1212, customer_id => 123 },
100 name => 'Professional services subscription gold plan',
101 statement_description => 'Provider, Inc Pro Services',
102 });
103  
104 =head1 VERSION
105  
106 v0.100.0
107  
108 =head1 DESCRIPTION
109  
110 Plans define the base price, currency, and billing cycle for subscriptions. For example, you might have a ¥5/month plan that provides limited access to your products, and a ¥15/month plan that allows full access.
111  
112 =head1 CONSTRUCTOR
113  
114 =over 4
115  
116 =item B<new>( %ARG )
117  
118 Creates a new L<Net::API::Stripe::Billing::Plan> object.
119  
120 =back
121  
122 =head1 METHODS
123  
124 =over 4
125  
126 =item B<id> string
127  
128 Unique identifier for the object.
129  
130 =item B<object> string, value is "plan"
131  
132 String representing the object’s type. Objects of the same type share the same value.
133  
134 =item B<active> boolean
135  
136 Whether the plan is currently available for new subscriptions.
137  
138 =item B<aggregate_usage> string
139  
140 Specifies a usage aggregation strategy for plans of I<usage_type=metered>. Allowed values are I<sum> for summing up all usage during a period, I<last_during_period> for picking the last usage record reported within a period, I<last_ever> for picking the last usage record ever (across period bounds) or I<max> which picks the usage record with the maximum reported usage during a period. Defaults to I<sum>.
141  
142 =item B<amount> positive integer or zero
143  
144 The amount in JPY to be charged on the interval specified.
145  
146 =item B<amount_decimal> decimal string
147  
148 Same as I<amount>, but contains a decimal value with at most 12 decimal places.
149  
150 =item B<billing_scheme> string
151  
152 Describes how to compute the price per period. Either I<per_unit> or I<tiered>. I<per_unit> indicates that the fixed amount (specified in I<amount>) will be charged per unit in I<quantity> (for plans with I<usage_type=licensed>), or per unit of total usage (for plans with I<usage_type=metered>). I<tiered> indicates that the unit pricing will be computed using a tiering strategy as defined using the I<tiers> and I<tiers_mode> attributes.
153  
154 =item B<count> integer
155  
156 For fixed_count installment plans, this is the number of installment payments your customer will make to their credit card.
157  
158 Not part of the official api documentation, but found in sub object data like in here
159 L<https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card-installments>
160  
161 =item B<created> timestamp
162  
163 Time at which the object was created. Measured in seconds since the Unix epoch.
164  
165 =item B<currency> currency
166  
167 Three-letter ISO currency code, in lowercase. Must be a supported currency.
168  
169 =item B<deleted> boolean
170  
171 Appears only when the plan has been deleted.
172  
173 =item B<interval> string
174  
175 One of I<day>, I<week>, I<month> or I<year>. The frequency with which a subscription should be billed.
176  
177 =item B<interval_count> positive integer
178  
179 The number of intervals (specified in the I<interval> property) between subscription billings. For example, I<interval=month> and I<interval_count=3> bills every 3 months.
180  
181 =item B<livemode> boolean
182  
183 Has the value I<true> if the object exists in live mode or the value I<false> if the object exists in test mode.
184  
185 =item B<metadata> hash
186  
187 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.
188  
189 =item B<name> string
190  
191 This is an undocumented property, which appears in data returned by Stripe. This contains the name of the plan.
192  
193 =item B<nickname> string
194  
195 A brief description of the plan, hidden from customers.
196  
197 =item B<product> string (expandable)
198  
199 The product whose pricing this plan determines. When expanded, this is a L<Net::API::Stripe::Product> object.
200  
201 =item B<statement_description> string
202  
203 This is an undocumented property, which appears in data returned by Stripe. This contains a description of the plan.
204  
205 =item B<statement_descriptor> string
206  
207 This is an undocumented property, which appears in data returned by Stripe. This contains a description of the plan.
208  
209 =item B<tiers> array of hashes
210  
211 Each element represents a pricing tier. This parameter requires I<billing_scheme> to be set to I<tiered>. See also the documentation for I<billing_scheme>.
212  
213 This is an array of L<Net::API::Stripe::Billing::Plan::Tiers> objects.
214  
215 =item B<tiers_mode> string
216  
217 Defines if the tiering price should be graduated or volume based. In volume-based tiering, the maximum quantity within a period determines the per unit price, in graduated tiering pricing can successively change as the quantity grows.
218  
219 =item B<transform_usage> hash
220  
221 Apply a transformation to the reported usage or set quantity before computing the billed price. Cannot be combined with tiers.
222  
223 This is a L<Net::API::Stripe::Billing::Plan::TransformUsage> object.
224  
225 =item B<trial_period_days> positive integer
226  
227 Default number of trial days when subscribing a customer to this plan using I<trial_from_plan=true>.
228  
229 =item B<type> string
230  
231 Type of installment plan, one of fixed_count.
232  
233 Not part of the official api documentation, but found in sub object data like in here
234 L<https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card-installments>
235  
236 =item B<usage_type> string
237  
238 Configures how the quantity per period should be determined, can be either I<metered> or I<licensed>. I<licensed> will automatically bill the I<quantity> set for a plan when adding it to a subscription, I<metered> will aggregate the total usage based on usage records. Defaults to I<licensed>.
239  
240 =back
241  
242 =head1 API SAMPLE
243  
244 {
245 "id": "expert-monthly-jpy",
246 "object": "plan",
247 "active": true,
248 "aggregate_usage": null,
249 "amount": 8000,
250 "amount_decimal": "8000",
251 "billing_scheme": "per_unit",
252 "created": 1507273129,
253 "currency": "jpy",
254 "interval": "month",
255 "interval_count": 1,
256 "livemode": false,
257 "metadata": {},
258 "nickname": null,
259 "product": "prod_fake123456789",
260 "tiers": null,
261 "tiers_mode": null,
262 "transform_usage": null,
263 "trial_period_days": null,
264 "usage_type": "licensed"
265 }
266  
267 =head1 ACTUAL API DATA RETURNED
268  
269 As you can see, there are extra properties: I<name>, I<statement_description> and I<statement_descriptior>
270  
271 {
272 "id": "professional-monthly-jpy",
273 "object": "plan",
274 "active": true,
275 "aggregate_usage": null,
276 "amount": 8000,
277 "amount_decimal": "8000",
278 "billing_scheme": "per_unit",
279 "created": 1541833564,
280 "currency": "jpy",
281 "interval": "month",
282 "interval_count": 1,
283 "livemode": false,
284 "metadata": {},
285 "name": "MyShop, Inc monthly membership",
286 "nickname": null,
287 "product": "prod_fake123456789",
288 "statement_description": null,
289 "statement_descriptor": null,
290 "tiers": null,
291 "tiers_mode": null,
292 "transform_usage": null,
293 "trial_period_days": null,
294 "usage_type": "licensed"
295 }
296  
297 =head1 HISTORY
298  
299 =head2 v0.1
300  
301 Initial version
302  
303 =head1 STRIPE HISTORY
304  
305 =head2 2018-02-05
306  
307 Each plan object is now linked to a product object with I<type=service>. The plan object fields I<statement_descriptor> and I<name> attributes have been moved to product objects. Creating a plan now requires passing a I<product> attribute to I<POST /v1/plans>. This may be either an existing product ID or a dictionary of product fields, so that you may continue to create plans without separately creating products.
308  
309 =head1 AUTHOR
310  
311 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
312  
313 =head1 SEE ALSO
314  
315 Stripe API documentation:
316  
317 L<https://stripe.com/docs/api/plans>, L<https://stripe.com/docs/billing/subscriptions/products-and-plans>
318  
319 =head1 COPYRIGHT & LICENSE
320  
321 Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
322  
323 You can use, copy, modify and redistribute this package and associated
324 files under the same terms as Perl itself.
325  
326 =cut
« Stripe/Dispute/Evidence.pm ↑ Summary Stripe/Payment/Intent/Setup.pm »