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