dodopayments 2.20.0 → 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 +16 -0
- data/README.md +1 -1
- data/lib/dodopayments/models/checkout_session_preview_response.rb +41 -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 +162 -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_params.rb +12 -1
- data/lib/dodopayments/models/subscription_list_response.rb +11 -1
- data/lib/dodopayments/models/subscription_update_payment_method_webhook_event.rb +40 -0
- data/lib/dodopayments/models/unsafe_unwrap_webhook_event.rb +4 -1
- data/lib/dodopayments/models/unwrap_webhook_event.rb +4 -1
- data/lib/dodopayments/models/webhook_event_type.rb +1 -0
- data/lib/dodopayments/models.rb +3 -0
- 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/resources/subscriptions.rb +6 -1
- data/lib/dodopayments/resources/webhooks.rb +2 -2
- data/lib/dodopayments/version.rb +1 -1
- data/lib/dodopayments.rb +1 -0
- data/rbi/dodopayments/models/checkout_session_preview_response.rbi +47 -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 +365 -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_params.rbi +11 -0
- data/rbi/dodopayments/models/subscription_list_response.rbi +15 -3
- data/rbi/dodopayments/models/subscription_update_payment_method_webhook_event.rbi +67 -0
- data/rbi/dodopayments/models/unsafe_unwrap_webhook_event.rbi +1 -0
- data/rbi/dodopayments/models/unwrap_webhook_event.rbi +1 -0
- data/rbi/dodopayments/models/webhook_event_type.rbi +5 -0
- data/rbi/dodopayments/models.rbi +3 -0
- 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/rbi/dodopayments/resources/subscriptions.rbi +3 -0
- data/rbi/dodopayments/resources/webhooks.rbi +2 -0
- data/sig/dodopayments/models/checkout_session_preview_response.rbs +18 -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 +145 -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_params.rbs +7 -0
- data/sig/dodopayments/models/subscription_list_response.rbs +8 -3
- data/sig/dodopayments/models/subscription_update_payment_method_webhook_event.rbs +35 -0
- data/sig/dodopayments/models/unsafe_unwrap_webhook_event.rbs +1 -0
- data/sig/dodopayments/models/unwrap_webhook_event.rbs +1 -0
- data/sig/dodopayments/models/webhook_event_type.rbs +2 -0
- data/sig/dodopayments/models.rbs +2 -0
- data/sig/dodopayments/resources/discounts.rbs +8 -0
- data/sig/dodopayments/resources/payments.rbs +1 -0
- data/sig/dodopayments/resources/subscriptions.rbs +1 -0
- data/sig/dodopayments/resources/webhooks.rbs +2 -0
- metadata +5 -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,21 @@
|
|
|
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
|
+
|
|
11
|
+
## [2.20.1](https://github.com/dodopayments/dodopayments-ruby/compare/v2.20.0...v2.20.1) (2026-07-09)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **api:** add subscription.update_payment_method webhook and payment-method fields ([67881e2](https://github.com/dodopayments/dodopayments-ruby/commit/67881e21860b5692c69085d56a58534bb243fed8))
|
|
17
|
+
* **api:** add subscription.update_payment_method webhook and payment-method fields ([4f62da1](https://github.com/dodopayments/dodopayments-ruby/commit/4f62da18abf750e179ebd2c697958fb00bf0320e))
|
|
18
|
+
|
|
3
19
|
## [2.20.0](https://github.com/dodopayments/dodopayments-ruby/compare/v2.19.0...v2.20.0) (2026-07-06)
|
|
4
20
|
|
|
5
21
|
|
data/README.md
CHANGED
|
@@ -44,6 +44,15 @@ module Dodopayments
|
|
|
44
44
|
# @return [Integer]
|
|
45
45
|
required :total_price, Integer
|
|
46
46
|
|
|
47
|
+
# @!attribute next_billing_date
|
|
48
|
+
# The upcoming billing date for subscriptions, computed relative to now: with a
|
|
49
|
+
# trial it is `now + trial_period_days`, otherwise `now + payment frequency`.
|
|
50
|
+
# `None` for one-time-only carts. This is a preview estimate; the authoritative
|
|
51
|
+
# value is set when the subscription activates.
|
|
52
|
+
#
|
|
53
|
+
# @return [Time, nil]
|
|
54
|
+
optional :next_billing_date, Time, nil?: true
|
|
55
|
+
|
|
47
56
|
# @!attribute recurring_breakup
|
|
48
57
|
# Breakup of recurring payments (None for one-time only)
|
|
49
58
|
#
|
|
@@ -76,7 +85,22 @@ module Dodopayments
|
|
|
76
85
|
# @return [Integer, nil]
|
|
77
86
|
optional :total_tax, Integer, nil?: true
|
|
78
87
|
|
|
79
|
-
# @!
|
|
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)
|
|
80
104
|
# Some parameter documentations has been truncated, see
|
|
81
105
|
# {Dodopayments::Models::CheckoutSessionPreviewResponse} for more details.
|
|
82
106
|
#
|
|
@@ -94,6 +118,8 @@ module Dodopayments
|
|
|
94
118
|
#
|
|
95
119
|
# @param total_price [Integer] Total calculate price of the product cart
|
|
96
120
|
#
|
|
121
|
+
# @param next_billing_date [Time, nil] The upcoming billing date for subscriptions, computed relative to now:
|
|
122
|
+
#
|
|
97
123
|
# @param recurring_breakup [Dodopayments::Models::CheckoutSessionPreviewResponse::RecurringBreakup, nil] Breakup of recurring payments (None for one-time only)
|
|
98
124
|
#
|
|
99
125
|
# @param tax_id_business_name [String, nil] Registered business name from the official registry (EU/GB/AU) when found
|
|
@@ -103,6 +129,10 @@ module Dodopayments
|
|
|
103
129
|
# @param tax_id_format_name [String, nil] The matched tax ID notation (e.g. "VAT Number", "GSTIN") when valid
|
|
104
130
|
#
|
|
105
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
|
|
106
136
|
|
|
107
137
|
# @see Dodopayments::Models::CheckoutSessionPreviewResponse#current_breakup
|
|
108
138
|
class CurrentBreakup < Dodopayments::Internal::Type::BaseModel
|
|
@@ -234,7 +264,8 @@ module Dodopayments
|
|
|
234
264
|
optional :description, String, nil?: true
|
|
235
265
|
|
|
236
266
|
# @!attribute discount_amount
|
|
237
|
-
#
|
|
267
|
+
# Percentage rate (basis points) of the applicable percentage code; null for flat
|
|
268
|
+
# codes (their deduction is `og_price - discounted_price`).
|
|
238
269
|
#
|
|
239
270
|
# @return [Integer, nil]
|
|
240
271
|
optional :discount_amount, Integer, nil?: true
|
|
@@ -258,6 +289,10 @@ module Dodopayments
|
|
|
258
289
|
optional :tax, Integer, nil?: true
|
|
259
290
|
|
|
260
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
|
+
#
|
|
261
296
|
# @param credit_entitlements [Array<Dodopayments::Models::CheckoutSessionPreviewResponse::ProductCart::CreditEntitlement>] Credit entitlements that will be granted upon purchase
|
|
262
297
|
#
|
|
263
298
|
# @param currency [Symbol, Dodopayments::Models::Currency] the currency in which the calculatiosn were made
|
|
@@ -288,7 +323,7 @@ module Dodopayments
|
|
|
288
323
|
#
|
|
289
324
|
# @param description [String, nil]
|
|
290
325
|
#
|
|
291
|
-
# @param discount_amount [Integer, nil]
|
|
326
|
+
# @param discount_amount [Integer, nil] Percentage rate (basis points) of the applicable percentage code; null
|
|
292
327
|
#
|
|
293
328
|
# @param discount_cycle [Integer, nil] number of cycles the discount will apply
|
|
294
329
|
#
|
|
@@ -427,6 +462,8 @@ module Dodopayments
|
|
|
427
462
|
optional :description, String, nil?: true
|
|
428
463
|
|
|
429
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`).
|
|
430
467
|
#
|
|
431
468
|
# @return [Integer, nil]
|
|
432
469
|
optional :discount_amount, Integer, nil?: true
|
|
@@ -463,7 +500,7 @@ module Dodopayments
|
|
|
463
500
|
#
|
|
464
501
|
# @param description [String, nil]
|
|
465
502
|
#
|
|
466
|
-
# @param discount_amount [Integer, nil]
|
|
503
|
+
# @param discount_amount [Integer, nil] Percentage rate (basis points) of the applicable percentage code; null
|
|
467
504
|
#
|
|
468
505
|
# @param tax [Integer, nil]
|
|
469
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
|
#
|