dodopayments 2.20.1 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/lib/dodopayments/models/checkout_session_preview_response.rb +30 -4
- data/lib/dodopayments/models/credit_entitlements/balance_create_ledger_entry_params.rb +4 -2
- data/lib/dodopayments/models/discount.rb +95 -3
- data/lib/dodopayments/models/discount_create_params.rb +110 -3
- data/lib/dodopayments/models/discount_list_params.rb +7 -2
- data/lib/dodopayments/models/discount_type.rb +1 -0
- data/lib/dodopayments/models/discount_update_params.rb +108 -3
- data/lib/dodopayments/models/payment.rb +145 -1
- data/lib/dodopayments/models/payment_list_params.rb +163 -1
- data/lib/dodopayments/models/payment_method_types.rb +0 -1
- data/lib/dodopayments/models/price.rb +19 -1
- data/lib/dodopayments/models/subscription.rb +11 -1
- data/lib/dodopayments/models/subscription_create_response.rb +10 -1
- data/lib/dodopayments/models/subscription_list_response.rb +11 -1
- data/lib/dodopayments/resources/credit_entitlements/balances.rb +1 -1
- data/lib/dodopayments/resources/discounts.rb +24 -5
- data/lib/dodopayments/resources/payments.rb +3 -1
- data/lib/dodopayments/version.rb +1 -1
- data/rbi/dodopayments/models/checkout_session_preview_response.rbi +33 -5
- data/rbi/dodopayments/models/credit_entitlements/balance_create_ledger_entry_params.rbi +6 -2
- data/rbi/dodopayments/models/discount.rbi +151 -2
- data/rbi/dodopayments/models/discount_create_params.rbi +197 -2
- data/rbi/dodopayments/models/discount_list_params.rbi +6 -2
- data/rbi/dodopayments/models/discount_type.rbi +1 -0
- data/rbi/dodopayments/models/discount_update_params.rbi +193 -2
- data/rbi/dodopayments/models/payment.rbi +347 -0
- data/rbi/dodopayments/models/payment_list_params.rbi +327 -0
- data/rbi/dodopayments/models/payment_method_types.rbi +0 -1
- data/rbi/dodopayments/models/price.rbi +20 -0
- data/rbi/dodopayments/models/subscription.rbi +15 -3
- data/rbi/dodopayments/models/subscription_create_response.rbi +13 -3
- data/rbi/dodopayments/models/subscription_list_response.rbi +15 -3
- data/rbi/dodopayments/resources/credit_entitlements/balances.rbi +3 -1
- data/rbi/dodopayments/resources/discounts.rbi +57 -3
- data/rbi/dodopayments/resources/payments.rbi +3 -0
- data/sig/dodopayments/models/checkout_session_preview_response.rbs +13 -3
- data/sig/dodopayments/models/discount.rbs +69 -0
- data/sig/dodopayments/models/discount_create_params.rbs +69 -0
- data/sig/dodopayments/models/discount_type.rbs +2 -1
- data/sig/dodopayments/models/discount_update_params.rbs +69 -0
- data/sig/dodopayments/models/payment.rbs +135 -0
- data/sig/dodopayments/models/payment_list_params.rbs +308 -0
- data/sig/dodopayments/models/payment_method_types.rbs +0 -2
- data/sig/dodopayments/models/price.rbs +10 -0
- data/sig/dodopayments/models/subscription.rbs +8 -3
- data/sig/dodopayments/models/subscription_create_response.rbs +8 -3
- data/sig/dodopayments/models/subscription_list_response.rbs +8 -3
- data/sig/dodopayments/resources/discounts.rbs +8 -0
- data/sig/dodopayments/resources/payments.rbs +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cce1a46aa3a586422600889e188f2b401e93246c826b2e96e5dc8c5c0a056014
|
|
4
|
+
data.tar.gz: 295a9d062709d43a862c5f351231a8cb27febbcb36fd8a1ff78b69de75374634
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2aca745d3761996c176af1668be98cc19496aebddc82b6d6aa2e43b7a2784a410e601a0d81608a0c0d855f8634f4959075455c697d286018a9d2bd4a3e3c8573
|
|
7
|
+
data.tar.gz: 35d872f10337c040fc7b90d431a0ca011298cf7daaedff9a6a126cb7c05dc0b261edf3caf826d6c39b70fc4524f7264d17a6c9a104b397292ee9e5b44d1c0ea6
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.21.0](https://github.com/dodopayments/dodopayments-ruby/compare/v2.20.1...v2.21.0) (2026-07-24)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **api:** add discount customers endpoints, trial support, currency options, and failure details ([5aaae29](https://github.com/dodopayments/dodopayments-ruby/commit/5aaae29fb5cabc885b193df6eb5de2f4a3613446))
|
|
9
|
+
* **api:** add discount customers endpoints, trial support, currency options, and failure details ([f71fd20](https://github.com/dodopayments/dodopayments-ruby/commit/f71fd20da899aa0f7f8ea7e6d4e892d60064082e))
|
|
10
|
+
|
|
3
11
|
## [2.20.1](https://github.com/dodopayments/dodopayments-ruby/compare/v2.20.0...v2.20.1) (2026-07-09)
|
|
4
12
|
|
|
5
13
|
|
data/README.md
CHANGED
|
@@ -85,7 +85,22 @@ module Dodopayments
|
|
|
85
85
|
# @return [Integer, nil]
|
|
86
86
|
optional :total_tax, Integer, nil?: true
|
|
87
87
|
|
|
88
|
-
# @!
|
|
88
|
+
# @!attribute trial_amount
|
|
89
|
+
# Per-unit trial amount after discounts, in the price currency's minor units
|
|
90
|
+
# (pre-quantity, pre-tax; see `current_breakup` for the taxed total due today).
|
|
91
|
+
# Only present for a paid trial; `None` for a free trial or no trial.
|
|
92
|
+
#
|
|
93
|
+
# @return [Integer, nil]
|
|
94
|
+
optional :trial_amount, Integer, nil?: true
|
|
95
|
+
|
|
96
|
+
# @!attribute trial_period_days
|
|
97
|
+
# Effective trial duration in days for the subscription line, when there's a trial
|
|
98
|
+
# (free or paid). `None` if no subscription or no trial.
|
|
99
|
+
#
|
|
100
|
+
# @return [Integer, nil]
|
|
101
|
+
optional :trial_period_days, Integer, nil?: true
|
|
102
|
+
|
|
103
|
+
# @!method initialize(billing_country:, currency:, current_breakup:, is_byop:, product_cart:, total_price:, next_billing_date: nil, recurring_breakup: nil, tax_id_business_name: nil, tax_id_err_msg: nil, tax_id_format_name: nil, total_tax: nil, trial_amount: nil, trial_period_days: nil)
|
|
89
104
|
# Some parameter documentations has been truncated, see
|
|
90
105
|
# {Dodopayments::Models::CheckoutSessionPreviewResponse} for more details.
|
|
91
106
|
#
|
|
@@ -114,6 +129,10 @@ module Dodopayments
|
|
|
114
129
|
# @param tax_id_format_name [String, nil] The matched tax ID notation (e.g. "VAT Number", "GSTIN") when valid
|
|
115
130
|
#
|
|
116
131
|
# @param total_tax [Integer, nil] Total tax
|
|
132
|
+
#
|
|
133
|
+
# @param trial_amount [Integer, nil] Per-unit trial amount after discounts, in the price currency's minor units
|
|
134
|
+
#
|
|
135
|
+
# @param trial_period_days [Integer, nil] Effective trial duration in days for the subscription line, when
|
|
117
136
|
|
|
118
137
|
# @see Dodopayments::Models::CheckoutSessionPreviewResponse#current_breakup
|
|
119
138
|
class CurrentBreakup < Dodopayments::Internal::Type::BaseModel
|
|
@@ -245,7 +264,8 @@ module Dodopayments
|
|
|
245
264
|
optional :description, String, nil?: true
|
|
246
265
|
|
|
247
266
|
# @!attribute discount_amount
|
|
248
|
-
#
|
|
267
|
+
# Percentage rate (basis points) of the applicable percentage code; null for flat
|
|
268
|
+
# codes (their deduction is `og_price - discounted_price`).
|
|
249
269
|
#
|
|
250
270
|
# @return [Integer, nil]
|
|
251
271
|
optional :discount_amount, Integer, nil?: true
|
|
@@ -269,6 +289,10 @@ module Dodopayments
|
|
|
269
289
|
optional :tax, Integer, nil?: true
|
|
270
290
|
|
|
271
291
|
# @!method initialize(credit_entitlements:, currency:, discounted_price:, is_subscription:, is_usage_based:, meters:, og_currency:, og_price:, product_id:, quantity:, tax_category:, tax_inclusive:, tax_rate:, addons: nil, description: nil, discount_amount: nil, discount_cycle: nil, name: nil, tax: nil)
|
|
292
|
+
# Some parameter documentations has been truncated, see
|
|
293
|
+
# {Dodopayments::Models::CheckoutSessionPreviewResponse::ProductCart} for more
|
|
294
|
+
# details.
|
|
295
|
+
#
|
|
272
296
|
# @param credit_entitlements [Array<Dodopayments::Models::CheckoutSessionPreviewResponse::ProductCart::CreditEntitlement>] Credit entitlements that will be granted upon purchase
|
|
273
297
|
#
|
|
274
298
|
# @param currency [Symbol, Dodopayments::Models::Currency] the currency in which the calculatiosn were made
|
|
@@ -299,7 +323,7 @@ module Dodopayments
|
|
|
299
323
|
#
|
|
300
324
|
# @param description [String, nil]
|
|
301
325
|
#
|
|
302
|
-
# @param discount_amount [Integer, nil]
|
|
326
|
+
# @param discount_amount [Integer, nil] Percentage rate (basis points) of the applicable percentage code; null
|
|
303
327
|
#
|
|
304
328
|
# @param discount_cycle [Integer, nil] number of cycles the discount will apply
|
|
305
329
|
#
|
|
@@ -438,6 +462,8 @@ module Dodopayments
|
|
|
438
462
|
optional :description, String, nil?: true
|
|
439
463
|
|
|
440
464
|
# @!attribute discount_amount
|
|
465
|
+
# Percentage rate (basis points) of the applicable percentage code; null for flat
|
|
466
|
+
# codes (their deduction is `og_price - discounted_price`).
|
|
441
467
|
#
|
|
442
468
|
# @return [Integer, nil]
|
|
443
469
|
optional :discount_amount, Integer, nil?: true
|
|
@@ -474,7 +500,7 @@ module Dodopayments
|
|
|
474
500
|
#
|
|
475
501
|
# @param description [String, nil]
|
|
476
502
|
#
|
|
477
|
-
# @param discount_amount [Integer, nil]
|
|
503
|
+
# @param discount_amount [Integer, nil] Percentage rate (basis points) of the applicable percentage code; null
|
|
478
504
|
#
|
|
479
505
|
# @param tax [Integer, nil]
|
|
480
506
|
end
|
|
@@ -19,7 +19,9 @@ module Dodopayments
|
|
|
19
19
|
required :customer_id, String
|
|
20
20
|
|
|
21
21
|
# @!attribute amount
|
|
22
|
-
# Amount to credit or debit
|
|
22
|
+
# Amount to credit or debit. Bounded to a `NUMERIC(38,28)` column, so the integer
|
|
23
|
+
# part must have fewer than 10 digits (< 10^10); larger values previously reached
|
|
24
|
+
# the DB and failed with a 22003 overflow surfaced as a 500.
|
|
23
25
|
#
|
|
24
26
|
# @return [String]
|
|
25
27
|
required :amount, String
|
|
@@ -66,7 +68,7 @@ module Dodopayments
|
|
|
66
68
|
#
|
|
67
69
|
# @param customer_id [String]
|
|
68
70
|
#
|
|
69
|
-
# @param amount [String] Amount to credit or debit
|
|
71
|
+
# @param amount [String] Amount to credit or debit. Bounded to a `NUMERIC(38,28)` column, so the
|
|
70
72
|
#
|
|
71
73
|
# @param entry_type [Symbol, Dodopayments::Models::CreditEntitlements::LedgerEntryType] Entry type: credit or debit
|
|
72
74
|
#
|
|
@@ -28,6 +28,12 @@ module Dodopayments
|
|
|
28
28
|
# @return [Time]
|
|
29
29
|
required :created_at, Time
|
|
30
30
|
|
|
31
|
+
# @!attribute customer_eligibility
|
|
32
|
+
# Who may redeem this discount code.
|
|
33
|
+
#
|
|
34
|
+
# @return [Symbol, Dodopayments::Models::Discount::CustomerEligibility]
|
|
35
|
+
required :customer_eligibility, enum: -> { Dodopayments::Discount::CustomerEligibility }
|
|
36
|
+
|
|
31
37
|
# @!attribute discount_id
|
|
32
38
|
# The unique discount ID
|
|
33
39
|
#
|
|
@@ -60,11 +66,19 @@ module Dodopayments
|
|
|
60
66
|
required :times_used, Integer
|
|
61
67
|
|
|
62
68
|
# @!attribute type
|
|
63
|
-
# The type of discount
|
|
69
|
+
# The type of discount (`percentage` or `flat`).
|
|
64
70
|
#
|
|
65
71
|
# @return [Symbol, Dodopayments::Models::DiscountType]
|
|
66
72
|
required :type, enum: -> { Dodopayments::DiscountType }
|
|
67
73
|
|
|
74
|
+
# @!attribute currency_options
|
|
75
|
+
# Per-currency options (flat deduction / percentage cap + minimum subtotal). Empty
|
|
76
|
+
# for discounts without any configured currency options.
|
|
77
|
+
#
|
|
78
|
+
# @return [Array<Dodopayments::Models::Discount::CurrencyOption>, nil]
|
|
79
|
+
optional :currency_options,
|
|
80
|
+
-> { Dodopayments::Internal::Type::ArrayOf[Dodopayments::Discount::CurrencyOption] }
|
|
81
|
+
|
|
68
82
|
# @!attribute expires_at
|
|
69
83
|
# Optional date/time after which discount is expired.
|
|
70
84
|
#
|
|
@@ -77,6 +91,19 @@ module Dodopayments
|
|
|
77
91
|
# @return [String, nil]
|
|
78
92
|
optional :name, String, nil?: true
|
|
79
93
|
|
|
94
|
+
# @!attribute per_customer_usage_limit
|
|
95
|
+
# Maximum number of times a single customer may redeem this discount, if any.
|
|
96
|
+
#
|
|
97
|
+
# @return [Integer, nil]
|
|
98
|
+
optional :per_customer_usage_limit, Integer, nil?: true
|
|
99
|
+
|
|
100
|
+
# @!attribute starts_at
|
|
101
|
+
# Optional date/time before which the discount is not yet active. NULL = active
|
|
102
|
+
# immediately.
|
|
103
|
+
#
|
|
104
|
+
# @return [Time, nil]
|
|
105
|
+
optional :starts_at, Time, nil?: true
|
|
106
|
+
|
|
80
107
|
# @!attribute subscription_cycles
|
|
81
108
|
# Number of subscription billing cycles this discount is valid for. If not
|
|
82
109
|
# provided, the discount will be applied indefinitely to all recurring payments
|
|
@@ -91,7 +118,7 @@ module Dodopayments
|
|
|
91
118
|
# @return [Integer, nil]
|
|
92
119
|
optional :usage_limit, Integer, nil?: true
|
|
93
120
|
|
|
94
|
-
# @!method initialize(amount:, business_id:, code:, created_at:, discount_id:, metadata:, preserve_on_plan_change:, restricted_to:, times_used:, type:, expires_at: nil, name: nil, subscription_cycles: nil, usage_limit: nil)
|
|
121
|
+
# @!method initialize(amount:, business_id:, code:, created_at:, customer_eligibility:, discount_id:, metadata:, preserve_on_plan_change:, restricted_to:, times_used:, type:, currency_options: nil, expires_at: nil, name: nil, per_customer_usage_limit: nil, starts_at: nil, subscription_cycles: nil, usage_limit: nil)
|
|
95
122
|
# Some parameter documentations has been truncated, see
|
|
96
123
|
# {Dodopayments::Models::Discount} for more details.
|
|
97
124
|
#
|
|
@@ -103,6 +130,8 @@ module Dodopayments
|
|
|
103
130
|
#
|
|
104
131
|
# @param created_at [Time] Timestamp when the discount is created
|
|
105
132
|
#
|
|
133
|
+
# @param customer_eligibility [Symbol, Dodopayments::Models::Discount::CustomerEligibility] Who may redeem this discount code.
|
|
134
|
+
#
|
|
106
135
|
# @param discount_id [String] The unique discount ID
|
|
107
136
|
#
|
|
108
137
|
# @param metadata [Hash{Symbol=>String, Float, Boolean}] Arbitrary key-value metadata. Values can be string, integer, number, or boolean.
|
|
@@ -113,15 +142,78 @@ module Dodopayments
|
|
|
113
142
|
#
|
|
114
143
|
# @param times_used [Integer] How many times this discount has been used.
|
|
115
144
|
#
|
|
116
|
-
# @param type [Symbol, Dodopayments::Models::DiscountType] The type of discount
|
|
145
|
+
# @param type [Symbol, Dodopayments::Models::DiscountType] The type of discount (`percentage` or `flat`).
|
|
146
|
+
#
|
|
147
|
+
# @param currency_options [Array<Dodopayments::Models::Discount::CurrencyOption>] Per-currency options (flat deduction / percentage cap + minimum subtotal).
|
|
117
148
|
#
|
|
118
149
|
# @param expires_at [Time, nil] Optional date/time after which discount is expired.
|
|
119
150
|
#
|
|
120
151
|
# @param name [String, nil] Name for the Discount
|
|
121
152
|
#
|
|
153
|
+
# @param per_customer_usage_limit [Integer, nil] Maximum number of times a single customer may redeem this discount, if any.
|
|
154
|
+
#
|
|
155
|
+
# @param starts_at [Time, nil] Optional date/time before which the discount is not yet active. NULL = active im
|
|
156
|
+
#
|
|
122
157
|
# @param subscription_cycles [Integer, nil] Number of subscription billing cycles this discount is valid for.
|
|
123
158
|
#
|
|
124
159
|
# @param usage_limit [Integer, nil] Usage limit for this discount, if any.
|
|
160
|
+
|
|
161
|
+
# Who may redeem this discount code.
|
|
162
|
+
#
|
|
163
|
+
# @see Dodopayments::Models::Discount#customer_eligibility
|
|
164
|
+
module CustomerEligibility
|
|
165
|
+
extend Dodopayments::Internal::Type::Enum
|
|
166
|
+
|
|
167
|
+
ANY = :any
|
|
168
|
+
FIRST_TIME = :first_time
|
|
169
|
+
EXISTING = :existing
|
|
170
|
+
SPECIFIC = :specific
|
|
171
|
+
|
|
172
|
+
# @!method self.values
|
|
173
|
+
# @return [Array<Symbol>]
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
class CurrencyOption < Dodopayments::Internal::Type::BaseModel
|
|
177
|
+
# @!attribute currency
|
|
178
|
+
# The currency this option applies to.
|
|
179
|
+
#
|
|
180
|
+
# @return [Symbol, Dodopayments::Models::Currency]
|
|
181
|
+
required :currency, enum: -> { Dodopayments::Currency }
|
|
182
|
+
|
|
183
|
+
# @!attribute is_default
|
|
184
|
+
# Whether this is the default row FX conversions pivot from.
|
|
185
|
+
#
|
|
186
|
+
# @return [Boolean]
|
|
187
|
+
required :is_default, Dodopayments::Internal::Type::Boolean
|
|
188
|
+
|
|
189
|
+
# @!attribute minimum_subtotal
|
|
190
|
+
# Eligible-cart threshold in this currency's subunits (0 = no minimum).
|
|
191
|
+
#
|
|
192
|
+
# @return [Integer]
|
|
193
|
+
required :minimum_subtotal, Integer
|
|
194
|
+
|
|
195
|
+
# @!attribute max_amount_possible
|
|
196
|
+
# The most this code discounts in this currency's subunits (flat deduction or
|
|
197
|
+
# percentage cap).
|
|
198
|
+
#
|
|
199
|
+
# @return [Integer, nil]
|
|
200
|
+
optional :max_amount_possible, Integer, nil?: true
|
|
201
|
+
|
|
202
|
+
# @!method initialize(currency:, is_default:, minimum_subtotal:, max_amount_possible: nil)
|
|
203
|
+
# Some parameter documentations has been truncated, see
|
|
204
|
+
# {Dodopayments::Models::Discount::CurrencyOption} for more details.
|
|
205
|
+
#
|
|
206
|
+
# A per-currency discount option (response shape). `max_amount_possible` mirrors
|
|
207
|
+
# the DB column of the same name.
|
|
208
|
+
#
|
|
209
|
+
# @param currency [Symbol, Dodopayments::Models::Currency] The currency this option applies to.
|
|
210
|
+
#
|
|
211
|
+
# @param is_default [Boolean] Whether this is the default row FX conversions pivot from.
|
|
212
|
+
#
|
|
213
|
+
# @param minimum_subtotal [Integer] Eligible-cart threshold in this currency's subunits (0 = no minimum).
|
|
214
|
+
#
|
|
215
|
+
# @param max_amount_possible [Integer, nil] The most this code discounts in this currency's subunits (flat deduction
|
|
216
|
+
end
|
|
125
217
|
end
|
|
126
218
|
end
|
|
127
219
|
end
|
|
@@ -17,7 +17,7 @@ module Dodopayments
|
|
|
17
17
|
required :amount, Integer
|
|
18
18
|
|
|
19
19
|
# @!attribute type
|
|
20
|
-
# The discount type
|
|
20
|
+
# The discount type: `percentage` or `flat` (`flat_per_unit` stays blocked).
|
|
21
21
|
#
|
|
22
22
|
# @return [Symbol, Dodopayments::Models::DiscountType]
|
|
23
23
|
required :type, enum: -> { Dodopayments::DiscountType }
|
|
@@ -31,6 +31,29 @@ module Dodopayments
|
|
|
31
31
|
# @return [String, nil]
|
|
32
32
|
optional :code, String, nil?: true
|
|
33
33
|
|
|
34
|
+
# @!attribute currency_options
|
|
35
|
+
# Per-currency options (flat deduction / percentage cap + minimum subtotal).
|
|
36
|
+
# Required for `flat` codes (must include a resolvable default); optional
|
|
37
|
+
# per-currency caps for `percentage` codes. Per-row invariants are checked in
|
|
38
|
+
# `normalize_currency_options`, not via `#[validate(nested)]`.
|
|
39
|
+
#
|
|
40
|
+
# @return [Array<Dodopayments::Models::DiscountCreateParams::CurrencyOption>, nil]
|
|
41
|
+
optional :currency_options,
|
|
42
|
+
-> {
|
|
43
|
+
Dodopayments::Internal::Type::ArrayOf[Dodopayments::DiscountCreateParams::CurrencyOption]
|
|
44
|
+
},
|
|
45
|
+
nil?: true
|
|
46
|
+
|
|
47
|
+
# @!attribute customer_eligibility
|
|
48
|
+
# Who may redeem this discount code. Defaults to `any` (unrestricted). `specific`
|
|
49
|
+
# starts with zero attached customers (fails closed) until customers are attached
|
|
50
|
+
# via `POST /discounts/{id}/customers`.
|
|
51
|
+
#
|
|
52
|
+
# @return [Symbol, Dodopayments::Models::DiscountCreateParams::CustomerEligibility, nil]
|
|
53
|
+
optional :customer_eligibility,
|
|
54
|
+
enum: -> { Dodopayments::DiscountCreateParams::CustomerEligibility },
|
|
55
|
+
nil?: true
|
|
56
|
+
|
|
34
57
|
# @!attribute expires_at
|
|
35
58
|
# When the discount expires, if ever.
|
|
36
59
|
#
|
|
@@ -48,6 +71,13 @@ module Dodopayments
|
|
|
48
71
|
# @return [String, nil]
|
|
49
72
|
optional :name, String, nil?: true
|
|
50
73
|
|
|
74
|
+
# @!attribute per_customer_usage_limit
|
|
75
|
+
# Maximum number of times a single customer may redeem this discount. Must be
|
|
76
|
+
# `<= usage_limit` when both are set.
|
|
77
|
+
#
|
|
78
|
+
# @return [Integer, nil]
|
|
79
|
+
optional :per_customer_usage_limit, Integer, nil?: true
|
|
80
|
+
|
|
51
81
|
# @!attribute preserve_on_plan_change
|
|
52
82
|
# Whether this discount should be preserved when a subscription changes plans.
|
|
53
83
|
# Default: false (discount is removed on plan change)
|
|
@@ -61,6 +91,13 @@ module Dodopayments
|
|
|
61
91
|
# @return [Array<String>, nil]
|
|
62
92
|
optional :restricted_to, Dodopayments::Internal::Type::ArrayOf[String], nil?: true
|
|
63
93
|
|
|
94
|
+
# @!attribute starts_at
|
|
95
|
+
# When the discount becomes active, if scheduled for the future. NULL = active
|
|
96
|
+
# immediately. Must be strictly before `expires_at` when both are set.
|
|
97
|
+
#
|
|
98
|
+
# @return [Time, nil]
|
|
99
|
+
optional :starts_at, Time, nil?: true
|
|
100
|
+
|
|
64
101
|
# @!attribute subscription_cycles
|
|
65
102
|
# Number of subscription billing cycles this discount is valid for. If not
|
|
66
103
|
# provided, the discount will be applied indefinitely to all recurring payments
|
|
@@ -75,31 +112,101 @@ module Dodopayments
|
|
|
75
112
|
# @return [Integer, nil]
|
|
76
113
|
optional :usage_limit, Integer, nil?: true
|
|
77
114
|
|
|
78
|
-
# @!method initialize(amount:, type:, code: nil, expires_at: nil, metadata: nil, name: nil, preserve_on_plan_change: nil, restricted_to: nil, subscription_cycles: nil, usage_limit: nil, request_options: {})
|
|
115
|
+
# @!method initialize(amount:, type:, code: nil, currency_options: nil, customer_eligibility: nil, expires_at: nil, metadata: nil, name: nil, per_customer_usage_limit: nil, preserve_on_plan_change: nil, restricted_to: nil, starts_at: nil, subscription_cycles: nil, usage_limit: nil, request_options: {})
|
|
79
116
|
# Some parameter documentations has been truncated, see
|
|
80
117
|
# {Dodopayments::Models::DiscountCreateParams} for more details.
|
|
81
118
|
#
|
|
82
119
|
# @param amount [Integer] The discount amount in **basis points** (e.g. `540` means `5.4%`, `10000` means
|
|
83
120
|
#
|
|
84
|
-
# @param type [Symbol, Dodopayments::Models::DiscountType] The discount type
|
|
121
|
+
# @param type [Symbol, Dodopayments::Models::DiscountType] The discount type: `percentage` or `flat` (`flat_per_unit` stays blocked).
|
|
85
122
|
#
|
|
86
123
|
# @param code [String, nil] Optionally supply a code (will be uppercased).
|
|
87
124
|
#
|
|
125
|
+
# @param currency_options [Array<Dodopayments::Models::DiscountCreateParams::CurrencyOption>, nil] Per-currency options (flat deduction / percentage cap + minimum subtotal).
|
|
126
|
+
#
|
|
127
|
+
# @param customer_eligibility [Symbol, Dodopayments::Models::DiscountCreateParams::CustomerEligibility, nil] Who may redeem this discount code. Defaults to `any` (unrestricted).
|
|
128
|
+
#
|
|
88
129
|
# @param expires_at [Time, nil] When the discount expires, if ever.
|
|
89
130
|
#
|
|
90
131
|
# @param metadata [Hash{Symbol=>String, Float, Boolean}] Additional metadata for the discount
|
|
91
132
|
#
|
|
92
133
|
# @param name [String, nil]
|
|
93
134
|
#
|
|
135
|
+
# @param per_customer_usage_limit [Integer, nil] Maximum number of times a single customer may redeem this discount.
|
|
136
|
+
#
|
|
94
137
|
# @param preserve_on_plan_change [Boolean] Whether this discount should be preserved when a subscription changes plans.
|
|
95
138
|
#
|
|
96
139
|
# @param restricted_to [Array<String>, nil] List of product IDs to restrict usage (if any).
|
|
97
140
|
#
|
|
141
|
+
# @param starts_at [Time, nil] When the discount becomes active, if scheduled for the future.
|
|
142
|
+
#
|
|
98
143
|
# @param subscription_cycles [Integer, nil] Number of subscription billing cycles this discount is valid for.
|
|
99
144
|
#
|
|
100
145
|
# @param usage_limit [Integer, nil] How many times this discount can be used (if any).
|
|
101
146
|
#
|
|
102
147
|
# @param request_options [Dodopayments::RequestOptions, Hash{Symbol=>Object}]
|
|
148
|
+
|
|
149
|
+
class CurrencyOption < Dodopayments::Internal::Type::BaseModel
|
|
150
|
+
# @!attribute currency
|
|
151
|
+
# The currency this option applies to.
|
|
152
|
+
#
|
|
153
|
+
# @return [Symbol, Dodopayments::Models::Currency]
|
|
154
|
+
required :currency, enum: -> { Dodopayments::Currency }
|
|
155
|
+
|
|
156
|
+
# @!attribute is_default
|
|
157
|
+
# Whether this row is the default to convert from for unconfigured currencies. At
|
|
158
|
+
# most one row per discount may be default.
|
|
159
|
+
#
|
|
160
|
+
# @return [Boolean, nil]
|
|
161
|
+
optional :is_default, Dodopayments::Internal::Type::Boolean
|
|
162
|
+
|
|
163
|
+
# @!attribute max_amount_possible
|
|
164
|
+
# The most this code discounts in this currency's subunits. For `flat` codes this
|
|
165
|
+
# is the deduction; for `percentage` codes it is the max-discount cap. Must be > 0
|
|
166
|
+
# if provided.
|
|
167
|
+
#
|
|
168
|
+
# @return [Integer, nil]
|
|
169
|
+
optional :max_amount_possible, Integer, nil?: true
|
|
170
|
+
|
|
171
|
+
# @!attribute minimum_subtotal
|
|
172
|
+
# Eligible-cart threshold in this currency's subunits (0 = no minimum).
|
|
173
|
+
#
|
|
174
|
+
# @return [Integer, nil]
|
|
175
|
+
optional :minimum_subtotal, Integer
|
|
176
|
+
|
|
177
|
+
# @!method initialize(currency:, is_default: nil, max_amount_possible: nil, minimum_subtotal: nil)
|
|
178
|
+
# Some parameter documentations has been truncated, see
|
|
179
|
+
# {Dodopayments::Models::DiscountCreateParams::CurrencyOption} for more details.
|
|
180
|
+
#
|
|
181
|
+
# A per-currency discount option (request shape).
|
|
182
|
+
#
|
|
183
|
+
# `max_amount_possible` is the most this code discounts in this currency — the
|
|
184
|
+
# flat deduction for `flat` codes, or the max-discount cap for `percentage` codes.
|
|
185
|
+
# Maps to the DB column of the same name.
|
|
186
|
+
#
|
|
187
|
+
# @param currency [Symbol, Dodopayments::Models::Currency] The currency this option applies to.
|
|
188
|
+
#
|
|
189
|
+
# @param is_default [Boolean] Whether this row is the default to convert from for unconfigured
|
|
190
|
+
#
|
|
191
|
+
# @param max_amount_possible [Integer, nil] The most this code discounts in this currency's subunits. For `flat` codes
|
|
192
|
+
#
|
|
193
|
+
# @param minimum_subtotal [Integer] Eligible-cart threshold in this currency's subunits (0 = no minimum).
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# Who may redeem this discount code. Defaults to `any` (unrestricted). `specific`
|
|
197
|
+
# starts with zero attached customers (fails closed) until customers are attached
|
|
198
|
+
# via `POST /discounts/{id}/customers`.
|
|
199
|
+
module CustomerEligibility
|
|
200
|
+
extend Dodopayments::Internal::Type::Enum
|
|
201
|
+
|
|
202
|
+
ANY = :any
|
|
203
|
+
FIRST_TIME = :first_time
|
|
204
|
+
EXISTING = :existing
|
|
205
|
+
SPECIFIC = :specific
|
|
206
|
+
|
|
207
|
+
# @!method self.values
|
|
208
|
+
# @return [Array<Symbol>]
|
|
209
|
+
end
|
|
103
210
|
end
|
|
104
211
|
end
|
|
105
212
|
end
|
|
@@ -8,7 +8,9 @@ module Dodopayments
|
|
|
8
8
|
include Dodopayments::Internal::Type::RequestParameters
|
|
9
9
|
|
|
10
10
|
# @!attribute active
|
|
11
|
-
# Filter by active status
|
|
11
|
+
# Filter by active status. `true` = currently redeemable (started, not expired,
|
|
12
|
+
# not usage-exhausted). `false` = not currently redeemable (expired,
|
|
13
|
+
# usage-exhausted, or pending a future `starts_at`).
|
|
12
14
|
#
|
|
13
15
|
# @return [Boolean, nil]
|
|
14
16
|
optional :active, Dodopayments::Internal::Type::Boolean
|
|
@@ -44,7 +46,10 @@ module Dodopayments
|
|
|
44
46
|
optional :product_id, String
|
|
45
47
|
|
|
46
48
|
# @!method initialize(active: nil, code: nil, discount_type: nil, page_number: nil, page_size: nil, product_id: nil, request_options: {})
|
|
47
|
-
#
|
|
49
|
+
# Some parameter documentations has been truncated, see
|
|
50
|
+
# {Dodopayments::Models::DiscountListParams} for more details.
|
|
51
|
+
#
|
|
52
|
+
# @param active [Boolean] Filter by active status. `true` = currently redeemable (started, not
|
|
48
53
|
#
|
|
49
54
|
# @param code [String] Filter by discount code (partial match, case-insensitive)
|
|
50
55
|
#
|
|
@@ -27,6 +27,27 @@ module Dodopayments
|
|
|
27
27
|
# @return [String, nil]
|
|
28
28
|
optional :code, String, nil?: true
|
|
29
29
|
|
|
30
|
+
# @!attribute currency_options
|
|
31
|
+
# If present, fully replaces the discount's currency options (replace-set
|
|
32
|
+
# semantics, like `restricted_to`). Send an empty array to clear them.
|
|
33
|
+
#
|
|
34
|
+
# @return [Array<Dodopayments::Models::DiscountUpdateParams::CurrencyOption>, nil]
|
|
35
|
+
optional :currency_options,
|
|
36
|
+
-> {
|
|
37
|
+
Dodopayments::Internal::Type::ArrayOf[Dodopayments::DiscountUpdateParams::CurrencyOption]
|
|
38
|
+
},
|
|
39
|
+
nil?: true
|
|
40
|
+
|
|
41
|
+
# @!attribute customer_eligibility
|
|
42
|
+
# If present, update who may redeem this discount. Plain field (not
|
|
43
|
+
# double-option): the DB column is `NOT NULL`, so it can never be cleared back to
|
|
44
|
+
# unset, only changed to another `CustomerEligibility` value.
|
|
45
|
+
#
|
|
46
|
+
# @return [Symbol, Dodopayments::Models::DiscountUpdateParams::CustomerEligibility, nil]
|
|
47
|
+
optional :customer_eligibility,
|
|
48
|
+
enum: -> { Dodopayments::DiscountUpdateParams::CustomerEligibility },
|
|
49
|
+
nil?: true
|
|
50
|
+
|
|
30
51
|
# @!attribute expires_at
|
|
31
52
|
#
|
|
32
53
|
# @return [Time, nil]
|
|
@@ -45,6 +66,14 @@ module Dodopayments
|
|
|
45
66
|
# @return [String, nil]
|
|
46
67
|
optional :name, String, nil?: true
|
|
47
68
|
|
|
69
|
+
# @!attribute per_customer_usage_limit
|
|
70
|
+
# If present, update the per-customer usage limit (double-option: send `null` to
|
|
71
|
+
# clear it back to unlimited). Must be `<= usage_limit` (the value in effect after
|
|
72
|
+
# this patch) when both are set.
|
|
73
|
+
#
|
|
74
|
+
# @return [Integer, nil]
|
|
75
|
+
optional :per_customer_usage_limit, Integer, nil?: true
|
|
76
|
+
|
|
48
77
|
# @!attribute preserve_on_plan_change
|
|
49
78
|
# Whether this discount should be preserved when a subscription changes plans. If
|
|
50
79
|
# not provided, the existing value is kept.
|
|
@@ -59,6 +88,12 @@ module Dodopayments
|
|
|
59
88
|
# @return [Array<String>, nil]
|
|
60
89
|
optional :restricted_to, Dodopayments::Internal::Type::ArrayOf[String], nil?: true
|
|
61
90
|
|
|
91
|
+
# @!attribute starts_at
|
|
92
|
+
# If present, update `starts_at` (double-option: send `null` to clear it).
|
|
93
|
+
#
|
|
94
|
+
# @return [Time, nil]
|
|
95
|
+
optional :starts_at, Time, nil?: true
|
|
96
|
+
|
|
62
97
|
# @!attribute subscription_cycles
|
|
63
98
|
# Number of subscription billing cycles this discount is valid for. If not
|
|
64
99
|
# provided, the discount will be applied indefinitely to all recurring payments
|
|
@@ -68,7 +103,7 @@ module Dodopayments
|
|
|
68
103
|
optional :subscription_cycles, Integer, nil?: true
|
|
69
104
|
|
|
70
105
|
# @!attribute type
|
|
71
|
-
# If present, update the discount type
|
|
106
|
+
# If present, update the discount type (`percentage` or `flat`).
|
|
72
107
|
#
|
|
73
108
|
# @return [Symbol, Dodopayments::Models::DiscountType, nil]
|
|
74
109
|
optional :type, enum: -> { Dodopayments::DiscountType }, nil?: true
|
|
@@ -78,7 +113,7 @@ module Dodopayments
|
|
|
78
113
|
# @return [Integer, nil]
|
|
79
114
|
optional :usage_limit, Integer, nil?: true
|
|
80
115
|
|
|
81
|
-
# @!method initialize(discount_id:, amount: nil, code: nil, expires_at: nil, metadata: nil, name: nil, preserve_on_plan_change: nil, restricted_to: nil, subscription_cycles: nil, type: nil, usage_limit: nil, request_options: {})
|
|
116
|
+
# @!method initialize(discount_id:, amount: nil, code: nil, currency_options: nil, customer_eligibility: nil, expires_at: nil, metadata: nil, name: nil, per_customer_usage_limit: nil, preserve_on_plan_change: nil, restricted_to: nil, starts_at: nil, subscription_cycles: nil, type: nil, usage_limit: nil, request_options: {})
|
|
82
117
|
# Some parameter documentations has been truncated, see
|
|
83
118
|
# {Dodopayments::Models::DiscountUpdateParams} for more details.
|
|
84
119
|
#
|
|
@@ -88,23 +123,93 @@ module Dodopayments
|
|
|
88
123
|
#
|
|
89
124
|
# @param code [String, nil] If present, update the discount code (uppercase).
|
|
90
125
|
#
|
|
126
|
+
# @param currency_options [Array<Dodopayments::Models::DiscountUpdateParams::CurrencyOption>, nil] If present, fully replaces the discount's currency options (replace-set
|
|
127
|
+
#
|
|
128
|
+
# @param customer_eligibility [Symbol, Dodopayments::Models::DiscountUpdateParams::CustomerEligibility, nil] If present, update who may redeem this discount. Plain field (not
|
|
129
|
+
#
|
|
91
130
|
# @param expires_at [Time, nil]
|
|
92
131
|
#
|
|
93
132
|
# @param metadata [Hash{Symbol=>String, Float, Boolean}, nil] Additional metadata for the discount
|
|
94
133
|
#
|
|
95
134
|
# @param name [String, nil]
|
|
96
135
|
#
|
|
136
|
+
# @param per_customer_usage_limit [Integer, nil] If present, update the per-customer usage limit (double-option: send
|
|
137
|
+
#
|
|
97
138
|
# @param preserve_on_plan_change [Boolean, nil] Whether this discount should be preserved when a subscription changes plans.
|
|
98
139
|
#
|
|
99
140
|
# @param restricted_to [Array<String>, nil] If present, replaces all restricted product IDs with this new set.
|
|
100
141
|
#
|
|
142
|
+
# @param starts_at [Time, nil] If present, update `starts_at` (double-option: send `null` to clear it).
|
|
143
|
+
#
|
|
101
144
|
# @param subscription_cycles [Integer, nil] Number of subscription billing cycles this discount is valid for.
|
|
102
145
|
#
|
|
103
|
-
# @param type [Symbol, Dodopayments::Models::DiscountType, nil] If present, update the discount type
|
|
146
|
+
# @param type [Symbol, Dodopayments::Models::DiscountType, nil] If present, update the discount type (`percentage` or `flat`).
|
|
104
147
|
#
|
|
105
148
|
# @param usage_limit [Integer, nil]
|
|
106
149
|
#
|
|
107
150
|
# @param request_options [Dodopayments::RequestOptions, Hash{Symbol=>Object}]
|
|
151
|
+
|
|
152
|
+
class CurrencyOption < Dodopayments::Internal::Type::BaseModel
|
|
153
|
+
# @!attribute currency
|
|
154
|
+
# The currency this option applies to.
|
|
155
|
+
#
|
|
156
|
+
# @return [Symbol, Dodopayments::Models::Currency]
|
|
157
|
+
required :currency, enum: -> { Dodopayments::Currency }
|
|
158
|
+
|
|
159
|
+
# @!attribute is_default
|
|
160
|
+
# Whether this row is the default to convert from for unconfigured currencies. At
|
|
161
|
+
# most one row per discount may be default.
|
|
162
|
+
#
|
|
163
|
+
# @return [Boolean, nil]
|
|
164
|
+
optional :is_default, Dodopayments::Internal::Type::Boolean
|
|
165
|
+
|
|
166
|
+
# @!attribute max_amount_possible
|
|
167
|
+
# The most this code discounts in this currency's subunits. For `flat` codes this
|
|
168
|
+
# is the deduction; for `percentage` codes it is the max-discount cap. Must be > 0
|
|
169
|
+
# if provided.
|
|
170
|
+
#
|
|
171
|
+
# @return [Integer, nil]
|
|
172
|
+
optional :max_amount_possible, Integer, nil?: true
|
|
173
|
+
|
|
174
|
+
# @!attribute minimum_subtotal
|
|
175
|
+
# Eligible-cart threshold in this currency's subunits (0 = no minimum).
|
|
176
|
+
#
|
|
177
|
+
# @return [Integer, nil]
|
|
178
|
+
optional :minimum_subtotal, Integer
|
|
179
|
+
|
|
180
|
+
# @!method initialize(currency:, is_default: nil, max_amount_possible: nil, minimum_subtotal: nil)
|
|
181
|
+
# Some parameter documentations has been truncated, see
|
|
182
|
+
# {Dodopayments::Models::DiscountUpdateParams::CurrencyOption} for more details.
|
|
183
|
+
#
|
|
184
|
+
# A per-currency discount option (request shape).
|
|
185
|
+
#
|
|
186
|
+
# `max_amount_possible` is the most this code discounts in this currency — the
|
|
187
|
+
# flat deduction for `flat` codes, or the max-discount cap for `percentage` codes.
|
|
188
|
+
# Maps to the DB column of the same name.
|
|
189
|
+
#
|
|
190
|
+
# @param currency [Symbol, Dodopayments::Models::Currency] The currency this option applies to.
|
|
191
|
+
#
|
|
192
|
+
# @param is_default [Boolean] Whether this row is the default to convert from for unconfigured
|
|
193
|
+
#
|
|
194
|
+
# @param max_amount_possible [Integer, nil] The most this code discounts in this currency's subunits. For `flat` codes
|
|
195
|
+
#
|
|
196
|
+
# @param minimum_subtotal [Integer] Eligible-cart threshold in this currency's subunits (0 = no minimum).
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# If present, update who may redeem this discount. Plain field (not
|
|
200
|
+
# double-option): the DB column is `NOT NULL`, so it can never be cleared back to
|
|
201
|
+
# unset, only changed to another `CustomerEligibility` value.
|
|
202
|
+
module CustomerEligibility
|
|
203
|
+
extend Dodopayments::Internal::Type::Enum
|
|
204
|
+
|
|
205
|
+
ANY = :any
|
|
206
|
+
FIRST_TIME = :first_time
|
|
207
|
+
EXISTING = :existing
|
|
208
|
+
SPECIFIC = :specific
|
|
209
|
+
|
|
210
|
+
# @!method self.values
|
|
211
|
+
# @return [Array<Symbol>]
|
|
212
|
+
end
|
|
108
213
|
end
|
|
109
214
|
end
|
|
110
215
|
end
|