line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
## Stripe API - ~/lib/Net/API/Stripe/Billing/Coupon.pm |
3
|
|
|
|
|
|
|
## Version v0.101.0 |
4
|
|
|
|
|
|
|
## Copyright(c) 2020 DEGUEST Pte. Ltd. |
5
|
|
|
|
|
|
|
## Author: Jacques Deguest <jack@deguest.jp> |
6
|
|
|
|
|
|
|
## Created 2019/11/02 |
7
|
|
|
|
|
|
|
## Modified 2020/11/15 |
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
|
|
|
|
|
|
|
## https://stripe.com/docs/api/coupons/object |
14
|
|
|
|
|
|
|
package Net::API::Stripe::Product::Coupon; |
15
|
|
|
|
|
|
|
BEGIN |
16
|
|
|
|
|
|
|
{ |
17
|
2
|
|
|
2
|
|
821
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
67
|
|
18
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
56
|
|
19
|
2
|
|
|
2
|
|
11
|
use parent qw( Net::API::Stripe::Generic ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
20
|
2
|
|
|
2
|
|
135
|
use vars qw( $VERSION ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
109
|
|
21
|
2
|
|
|
2
|
|
36
|
our( $VERSION ) = 'v0.101.0'; |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
35
|
|
25
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
671
|
|
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
0
|
1
|
|
sub id { return( shift->_set_get_scalar( 'id', @_ ) ); } |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
0
|
1
|
|
sub object { return( shift->_set_get_scalar( 'object', @_ ) ); } |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
0
|
1
|
|
sub amount_off { return( shift->_set_get_number( 'amount_off', @_ ) ); } |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
0
|
1
|
|
sub applies_to { return( shift->_set_get_class( 'applies_to', { |
34
|
|
|
|
|
|
|
products => { type => "array" } |
35
|
|
|
|
|
|
|
}, @_ ) ); } |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
0
|
1
|
|
sub created { return( shift->_set_get_datetime( 'created', @_ ) ); } |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
1
|
|
sub currency { return( shift->_set_get_scalar( 'currency', @_ ) ); } |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
0
|
1
|
|
sub deleted { return( shift->_set_get_boolean( 'deleted', @_ ) ); } |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
0
|
1
|
|
sub duration { return( shift->_set_get_scalar( 'duration', @_ ) ); } |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
1
|
|
sub duration_in_months { return( shift->_set_get_scalar( 'duration_in_months', @_ ) ); } |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
0
|
1
|
|
sub livemode { return( shift->_set_get_boolean( 'livemode', @_ ) ); } |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
0
|
1
|
|
sub max_redemptions { return( shift->_set_get_scalar( 'max_redemptions', @_ ) ); } |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
0
|
1
|
|
sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); } |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
0
|
1
|
|
sub name { return( shift->_set_get_scalar( 'name', @_ ) ); } |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
0
|
1
|
|
sub percent_off { return( shift->_set_get_scalar( 'percent_off', @_ ) ); } |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
0
|
1
|
|
sub redeem_by { return( shift->_set_get_datetime( 'redeem_by', @_ ) ); } |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
0
|
1
|
|
sub times_redeemed { return( shift->_set_get_scalar( 'times_redeemed', @_ ) ); } |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
0
|
1
|
|
sub valid { return( shift->_set_get_boolean( 'valid', @_ ) ); } |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=encoding utf8 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Net::API::Stripe::Product::Coupon - A Stripe Coupon Object |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 SYNOPSIS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $coupon = $stripe->coupons( create => |
76
|
|
|
|
|
|
|
{ |
77
|
|
|
|
|
|
|
id => 'SUMMER10POFF', |
78
|
|
|
|
|
|
|
currency => 'usd', |
79
|
|
|
|
|
|
|
duration_in_months => 2, |
80
|
|
|
|
|
|
|
max_redemptions => 12, |
81
|
|
|
|
|
|
|
name => 'Summer 10% reduction', |
82
|
|
|
|
|
|
|
percent_off => 10, |
83
|
|
|
|
|
|
|
valid => 1 |
84
|
|
|
|
|
|
|
}) || die( $stripe->error ); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 VERSION |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
v0.101.0 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 DESCRIPTION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
A coupon contains information about a percent-off or amount-off discount you might want to apply to a customer. Coupons may be applied to invoices (L<Net::API::Stripe::Billing::Invoice> / L<https://stripe.com/docs/api/coupons#invoices>) or orders (L<Net::API::Stripe::Order> / L<https://stripe.com/docs/api/coupons#create_order-coupon>). Coupons do not work with conventional one-off charges (L<Net::API::Stripe::Charge> / L<https://stripe.com/docs/api/coupons#create_charge>), but you can implement a custom coupon system (L<https://stripe.com/docs/recipes/coupons-for-charges>) in your application. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 new( %ARG ) |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Creates a new L<Net::API::Stripe::Product::Coupon> object. |
99
|
|
|
|
|
|
|
It may also take an hash like arguments, that also are method of the same name. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 METHODS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 id string |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Unique identifier for the object. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 object string, value is "coupon" |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
String representing the object’s type. Objects of the same type share the same value. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 amount_off positive integer |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Amount (in the currency specified) that will be taken off the subtotal of any invoices for this customer. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 applies_to hash |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Contains information about what this coupon applies to. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
It has the following properties: |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=over 4 |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item I<products> array of strings |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
A list of product IDs this coupon applies to |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=back |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 created timestamp |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Time at which the object was created. Measured in seconds since the Unix epoch. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 currency currency |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
If amount_off has been set, the three-letter ISO code for the currency of the amount to take off. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 deleted boolean |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
This property exists only when the object has been deleted. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 duration string |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
One of forever, once, and repeating. Describes how long a customer who applies this coupon will get the discount. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 duration_in_months positive integer |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
If duration is repeating, the number of months the coupon applies. Null if coupon duration is forever or once. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 livemode boolean |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Has the value true if the object exists in live mode or the value false if the object exists in test mode. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 max_redemptions positive integer |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Maximum number of times this coupon can be redeemed, in total, across all customers, before it is no longer valid. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 metadata hash |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
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. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 name string |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Name of the coupon displayed to customers on for instance invoices or receipts. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 percent_off decimal |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Percent that will be taken off the subtotal of any invoices for this customer for the duration of the coupon. For example, a coupon with percent_off of 50 will make a ¥100 invoice ¥50 instead. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head2 redeem_by timestamp |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Date after which the coupon can no longer be redeemed. This is a C<DateTime> object. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head2 times_redeemed positive integer or zero |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Number of times this coupon has been applied to a customer. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 valid boolean |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Taking account of the above properties, whether this coupon can still be applied to a customer. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 API SAMPLE |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
{ |
184
|
|
|
|
|
|
|
"id": "25_5OFF", |
185
|
|
|
|
|
|
|
"object": "coupon", |
186
|
|
|
|
|
|
|
"amount_off": null, |
187
|
|
|
|
|
|
|
"created": 1571397911, |
188
|
|
|
|
|
|
|
"currency": null, |
189
|
|
|
|
|
|
|
"duration": "repeating", |
190
|
|
|
|
|
|
|
"duration_in_months": 3, |
191
|
|
|
|
|
|
|
"livemode": false, |
192
|
|
|
|
|
|
|
"max_redemptions": null, |
193
|
|
|
|
|
|
|
"metadata": {}, |
194
|
|
|
|
|
|
|
"name": "25.5% off", |
195
|
|
|
|
|
|
|
"percent_off": 25.5, |
196
|
|
|
|
|
|
|
"redeem_by": null, |
197
|
|
|
|
|
|
|
"times_redeemed": 0, |
198
|
|
|
|
|
|
|
"valid": true |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 HISTORY |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head2 v0.1 |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Initial version |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 STRIPE HISTORY |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head2 2018-07-27 |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
The percent_off field of coupons was changed from Integer to Float, with a precision of two decimal places. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 AUTHOR |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 SEE ALSO |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Stripe API documentation: |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
L<https://stripe.com/docs/api/coupons/object> |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Copyright (c) 2019-2020 DEGUEST Pte. Ltd. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
You can use, copy, modify and redistribute this package and associated |
228
|
|
|
|
|
|
|
files under the same terms as Perl itself. |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=cut |