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 <@sitael.tokyo.deguest.jp> |
6
|
|
|
|
|
|
|
## Created 2019/11/02 |
7
|
|
|
|
|
|
|
## Modified 2020/05/15 |
8
|
|
|
|
|
|
|
## |
9
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
10
|
|
|
|
|
|
|
## https://stripe.com/docs/api/discounts |
11
|
|
|
|
|
|
|
package Net::API::Stripe::Billing::Discount; |
12
|
|
|
|
|
|
|
BEGIN |
13
|
|
|
|
|
|
|
{ |
14
|
1
|
|
|
1
|
|
804
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
15
|
1
|
|
|
1
|
|
5
|
use parent qw( Net::API::Stripe::Generic ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
16
|
1
|
|
|
1
|
|
188
|
our( $VERSION ) = 'v0.100.0'; |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
0
|
1
|
|
sub object { shift->_set_get_scalar( 'object', @_ ); } |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
0
|
1
|
|
sub coupon { shift->_set_get_object( 'coupon', 'Net::API::Stripe::Billing::Coupon', @_ ); } |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
0
|
1
|
|
sub customer { return( shift->_set_get_scalar_or_object( 'customer', 'Net::API::Stripe::Customer', @_ ) ); } |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
0
|
1
|
|
sub end { shift->_set_get_datetime( 'end', @_ ); } |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
0
|
1
|
|
sub start { shift->_set_get_datetime( 'start', @_ ); } |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
0
|
1
|
|
sub subscription { shift->_set_get_scalar( 'subscription', @_ ); } |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__END__ |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=encoding utf8 |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Net::API::Stripe::Billing::Discount - A Stripe Discount |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 SYNOPSIS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $discount = $stripe->discount({ |
44
|
|
|
|
|
|
|
coupon => $stripe->coupon({ |
45
|
|
|
|
|
|
|
id => 'SUMMER10POFF', |
46
|
|
|
|
|
|
|
currency => 'usd', |
47
|
|
|
|
|
|
|
duration_in_months => 2, |
48
|
|
|
|
|
|
|
max_redemptions => 12, |
49
|
|
|
|
|
|
|
name => 'Summer 10% reduction', |
50
|
|
|
|
|
|
|
percent_off => 10, |
51
|
|
|
|
|
|
|
valid => 1 |
52
|
|
|
|
|
|
|
}), |
53
|
|
|
|
|
|
|
customer => $customer_object, |
54
|
|
|
|
|
|
|
# undef() for once or forever |
55
|
|
|
|
|
|
|
end => '2020-12-31', |
56
|
|
|
|
|
|
|
start => '2020-06-01', |
57
|
|
|
|
|
|
|
subscription => 'sub_fake1234567', |
58
|
|
|
|
|
|
|
}); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 VERSION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
v0.100.0 |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 DESCRIPTION |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
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. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=over 4 |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item B<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
|
|
|
|
|
|
|
=back |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 METHODS |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=over 4 |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item B<object> string, value is "discount" |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
String representing the objectâs type. Objects of the same type share the same value. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item B<coupon> hash, coupon object |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Hash describing the coupon applied to create this discount. This is a L<Net::API::Stripe::Billing::Coupon> object. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item B<customer> string (expandable) |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This is the Stripe customer id, or when expanded, this is the L<Net::API::Stripe::Customer> object. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item B<end> timestamp |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
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. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item B<start> timestamp |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Date that the coupon was applied. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item B<subscription> string |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
The subscription that this coupon is applied to, if it is applied to a particular subscription. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=back |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 API SAMPLE |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
{ |
112
|
|
|
|
|
|
|
"object": "discount", |
113
|
|
|
|
|
|
|
"coupon": { |
114
|
|
|
|
|
|
|
"id": "25_5OFF", |
115
|
|
|
|
|
|
|
"object": "coupon", |
116
|
|
|
|
|
|
|
"amount_off": null, |
117
|
|
|
|
|
|
|
"created": 1571397911, |
118
|
|
|
|
|
|
|
"currency": null, |
119
|
|
|
|
|
|
|
"duration": "repeating", |
120
|
|
|
|
|
|
|
"duration_in_months": 3, |
121
|
|
|
|
|
|
|
"livemode": false, |
122
|
|
|
|
|
|
|
"max_redemptions": null, |
123
|
|
|
|
|
|
|
"metadata": {}, |
124
|
|
|
|
|
|
|
"name": "25.5% off", |
125
|
|
|
|
|
|
|
"percent_off": 25.5, |
126
|
|
|
|
|
|
|
"redeem_by": null, |
127
|
|
|
|
|
|
|
"times_redeemed": 0, |
128
|
|
|
|
|
|
|
"valid": true |
129
|
|
|
|
|
|
|
}, |
130
|
|
|
|
|
|
|
"customer": "cus_fake124567890", |
131
|
|
|
|
|
|
|
"end": 1579346711, |
132
|
|
|
|
|
|
|
"start": 1571397911, |
133
|
|
|
|
|
|
|
"subscription": null |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 HISTORY |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 v0.1 |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Initial version |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 AUTHOR |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 SEE ALSO |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Stripe API documentation: |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
L<https://stripe.com/docs/api>, L<https://stripe.com/docs/billing/subscriptions/discounts> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Copyright (c) 2019-2020 DEGUEST Pte. Ltd. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
You can use, copy, modify and redistribute this package and associated |
157
|
|
|
|
|
|
|
files under the same terms as Perl itself. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |