File Coverage

lib/Net/API/Stripe/Billing/Discount.pm
Criterion Covered Total %
statement 19 30 63.3
branch n/a
condition n/a
subroutine 7 18 38.8
pod 11 11 100.0
total 37 59 62.7


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Billing/Discount.pm
3             ## Version v0.100.0
4             ## Copyright(c) 2019 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2019/11/02
7             ## Modified 2020/05/15
8             ##
9             ##----------------------------------------------------------------------------
10             ## https://stripe.com/docs/api/discounts
11             BEGIN
12             {
13             use strict;
14 2     2   25693682 use warnings;
  2         13  
  2         63  
15 2     2   11 use parent qw( Net::API::Stripe::Generic );
  2         3  
  2         57  
16 2     2   10 use vars qw( $VERSION );
  2         5  
  2         8  
17 2     2   148 our( $VERSION ) = 'v0.100.0';
  2         5  
  2         117  
18 2     2   40 };
19              
20             use strict;
21 2     2   9 use warnings;
  2         4  
  2         36  
22 2     2   10  
  2         6  
  2         475  
23              
24 0     0 1    
25              
26 0     0 1    
27              
28 0     0 1    
29              
30 0     0 1    
31              
32 0     0 1    
33              
34 0     0 1   1;
35              
36 0     0 1    
37             =encoding utf8
38 0     0 1    
39             =head1 NAME
40 0     0 1    
41             Net::API::Stripe::Billing::Discount - A Stripe Discount
42 0     0 1    
43             =head1 SYNOPSIS
44 0     0 1    
45             my $discount = $stripe->discount({
46             coupon => $stripe->coupon({
47             id => 'SUMMER10POFF',
48             currency => 'usd',
49             duration_in_months => 2,
50             max_redemptions => 12,
51             name => 'Summer 10% reduction',
52             percent_off => 10,
53             valid => 1
54             }),
55             customer => $customer_object,
56             # undef() for once or forever
57             end => '2020-12-31',
58             start => '2020-06-01',
59             subscription => 'sub_fake1234567',
60             });
61              
62             =head1 VERSION
63              
64             v0.100.0
65              
66             =head1 DESCRIPTION
67              
68             A discount represents the actual application of a coupon to a particular customer. It contains information about when the discount began and when it will end.
69              
70             =head1 CONSTRUCTOR
71              
72             =head2 new( %ARG )
73              
74             Creates a new L<Net::API::Stripe::Billing::Discount> object.
75             It may also take an hash like arguments, that also are method of the same name.
76              
77             =head1 METHODS
78              
79             =head2 object string, value is "discount"
80              
81             String representing the object’s type. Objects of the same type share the same value.
82              
83             =head2 id string
84              
85             The ID of the discount object. Discounts cannot be fetched by ID. Use C<expand[]=discounts> in API calls to expand discount IDs in an array.
86              
87             =head2 checkout_session string
88              
89             The Checkout session that this coupon is applied to, if it is applied to a particular session in payment mode. Will not be present for subscription mode.
90              
91             =head2 coupon hash, coupon object
92              
93             Hash describing the coupon applied to create this discount. This is a L<Net::API::Stripe::Billing::Coupon> object.
94              
95             =head2 customer string (expandable)
96              
97             This is the Stripe customer id, or when expanded, this is the L<Net::API::Stripe::Customer> object.
98              
99             =head2 end timestamp
100              
101             If the coupon has a duration of repeating, the date that this discount will end. If the coupon has a duration of once or forever, this attribute will be null.
102              
103             =head2 invoice string
104              
105             The invoice that the discount's coupon was applied to, if it was applied directly to a particular invoice.
106              
107             =head2 invoice_item string
108              
109             The invoice item C<id> (or invoice line item C<id> for invoice line items of type='subscription') that the discount's coupon was applied to, if it was applied directly to a particular invoice item or invoice line item.
110              
111             =head2 promotion_code expandable
112              
113             The promotion code applied to create this discount.
114              
115             When expanded this is an L<Net::API::Stripe::Billing::PromotionCode> object.
116              
117             =head2 start timestamp
118              
119             Date that the coupon was applied.
120              
121             =head2 subscription string
122              
123             The subscription that this coupon is applied to, if it is applied to a particular subscription.
124              
125             =head1 API SAMPLE
126              
127             {
128             "object": "discount",
129             "coupon": {
130             "id": "25_5OFF",
131             "object": "coupon",
132             "amount_off": null,
133             "created": 1571397911,
134             "currency": null,
135             "duration": "repeating",
136             "duration_in_months": 3,
137             "livemode": false,
138             "max_redemptions": null,
139             "metadata": {},
140             "name": "25.5% off",
141             "percent_off": 25.5,
142             "redeem_by": null,
143             "times_redeemed": 0,
144             "valid": true
145             },
146             "customer": "cus_fake124567890",
147             "end": 1579346711,
148             "start": 1571397911,
149             "subscription": null
150             }
151              
152             =head1 HISTORY
153              
154             =head2 v0.1
155              
156             Initial version
157              
158             =head1 AUTHOR
159              
160             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
161              
162             =head1 SEE ALSO
163              
164             Stripe API documentation:
165              
166             L<https://stripe.com/docs/api>, L<https://stripe.com/docs/billing/subscriptions/discounts>
167              
168             =head1 COPYRIGHT & LICENSE
169              
170             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
171              
172             You can use, copy, modify and redistribute this package and associated
173             files under the same terms as Perl itself.
174              
175             =cut