dodopayments 2.9.1 → 2.10.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.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/README.md +1 -1
  4. data/lib/dodopayments/internal/transport/base_client.rb +2 -0
  5. data/lib/dodopayments/internal/type/union.rb +21 -7
  6. data/lib/dodopayments/models/abandoned_checkout_detected_webhook_event.rb +4 -16
  7. data/lib/dodopayments/models/abandoned_checkout_recovered_webhook_event.rb +4 -16
  8. data/lib/dodopayments/models/checkout_session_request.rb +15 -2
  9. data/lib/dodopayments/models/credit_added_webhook_event.rb +4 -16
  10. data/lib/dodopayments/models/credit_balance_low_webhook_event.rb +4 -16
  11. data/lib/dodopayments/models/credit_deducted_webhook_event.rb +4 -16
  12. data/lib/dodopayments/models/credit_expired_webhook_event.rb +4 -16
  13. data/lib/dodopayments/models/credit_manual_adjustment_webhook_event.rb +4 -16
  14. data/lib/dodopayments/models/credit_overage_charged_webhook_event.rb +4 -16
  15. data/lib/dodopayments/models/credit_overage_reset_webhook_event.rb +4 -16
  16. data/lib/dodopayments/models/credit_rolled_over_webhook_event.rb +4 -16
  17. data/lib/dodopayments/models/credit_rollover_forfeited_webhook_event.rb +4 -16
  18. data/lib/dodopayments/models/dispute_accepted_webhook_event.rb +4 -16
  19. data/lib/dodopayments/models/dispute_cancelled_webhook_event.rb +4 -16
  20. data/lib/dodopayments/models/dispute_challenged_webhook_event.rb +4 -16
  21. data/lib/dodopayments/models/dispute_expired_webhook_event.rb +4 -16
  22. data/lib/dodopayments/models/dispute_lost_webhook_event.rb +4 -16
  23. data/lib/dodopayments/models/dispute_opened_webhook_event.rb +4 -16
  24. data/lib/dodopayments/models/dispute_won_webhook_event.rb +4 -16
  25. data/lib/dodopayments/models/dunning_recovered_webhook_event.rb +4 -16
  26. data/lib/dodopayments/models/dunning_started_webhook_event.rb +4 -16
  27. data/lib/dodopayments/models/entitlement_grant_created_webhook_event.rb +4 -16
  28. data/lib/dodopayments/models/entitlement_grant_delivered_webhook_event.rb +4 -16
  29. data/lib/dodopayments/models/entitlement_grant_failed_webhook_event.rb +4 -16
  30. data/lib/dodopayments/models/entitlement_grant_revoked_webhook_event.rb +4 -16
  31. data/lib/dodopayments/models/license_key_created_webhook_event.rb +4 -16
  32. data/lib/dodopayments/models/payment.rb +153 -3
  33. data/lib/dodopayments/models/payment_cancelled_webhook_event.rb +4 -16
  34. data/lib/dodopayments/models/payment_create_params.rb +15 -3
  35. data/lib/dodopayments/models/payment_create_response.rb +14 -3
  36. data/lib/dodopayments/models/payment_failed_webhook_event.rb +4 -16
  37. data/lib/dodopayments/models/payment_processing_webhook_event.rb +4 -16
  38. data/lib/dodopayments/models/payment_succeeded_webhook_event.rb +4 -16
  39. data/lib/dodopayments/models/payout_list_response.rb +6 -3
  40. data/lib/dodopayments/models/price.rb +20 -48
  41. data/lib/dodopayments/models/product.rb +3 -3
  42. data/lib/dodopayments/models/product_create_params.rb +3 -3
  43. data/lib/dodopayments/models/product_item_req.rb +42 -1
  44. data/lib/dodopayments/models/product_update_params.rb +3 -3
  45. data/lib/dodopayments/models/refund_failed_webhook_event.rb +4 -16
  46. data/lib/dodopayments/models/refund_succeeded_webhook_event.rb +4 -16
  47. data/lib/dodopayments/models/subscription.rb +153 -5
  48. data/lib/dodopayments/models/subscription_active_webhook_event.rb +4 -16
  49. data/lib/dodopayments/models/subscription_cancelled_webhook_event.rb +4 -16
  50. data/lib/dodopayments/models/subscription_create_params.rb +15 -3
  51. data/lib/dodopayments/models/subscription_create_response.rb +14 -3
  52. data/lib/dodopayments/models/subscription_expired_webhook_event.rb +4 -16
  53. data/lib/dodopayments/models/subscription_failed_webhook_event.rb +4 -16
  54. data/lib/dodopayments/models/subscription_list_response.rb +36 -5
  55. data/lib/dodopayments/models/subscription_on_hold_webhook_event.rb +4 -16
  56. data/lib/dodopayments/models/subscription_plan_changed_webhook_event.rb +4 -16
  57. data/lib/dodopayments/models/subscription_preview_change_plan_response.rb +21 -49
  58. data/lib/dodopayments/models/subscription_renewed_webhook_event.rb +4 -16
  59. data/lib/dodopayments/models/subscription_update_payment_method_params.rb +12 -30
  60. data/lib/dodopayments/models/subscription_updated_webhook_event.rb +4 -16
  61. data/lib/dodopayments/models/unsafe_unwrap_webhook_event.rb +41 -39
  62. data/lib/dodopayments/models/unwrap_webhook_event.rb +41 -39
  63. data/lib/dodopayments/models/update_subscription_plan_req.rb +17 -6
  64. data/lib/dodopayments/models/webhook_event_type.rb +3 -0
  65. data/lib/dodopayments/models/webhook_payload.rb +52 -143
  66. data/lib/dodopayments/resources/checkout_sessions.rb +8 -4
  67. data/lib/dodopayments/resources/payments.rb +4 -2
  68. data/lib/dodopayments/resources/subscriptions.rb +12 -6
  69. data/lib/dodopayments/version.rb +1 -1
  70. data/rbi/dodopayments/models/abandoned_checkout_detected_webhook_event.rbi +4 -40
  71. data/rbi/dodopayments/models/abandoned_checkout_recovered_webhook_event.rbi +4 -40
  72. data/rbi/dodopayments/models/checkout_session_request.rbi +14 -0
  73. data/rbi/dodopayments/models/credit_added_webhook_event.rbi +4 -29
  74. data/rbi/dodopayments/models/credit_balance_low_webhook_event.rbi +4 -33
  75. data/rbi/dodopayments/models/credit_deducted_webhook_event.rbi +4 -33
  76. data/rbi/dodopayments/models/credit_expired_webhook_event.rbi +4 -33
  77. data/rbi/dodopayments/models/credit_manual_adjustment_webhook_event.rbi +4 -39
  78. data/rbi/dodopayments/models/credit_overage_charged_webhook_event.rbi +4 -36
  79. data/rbi/dodopayments/models/credit_overage_reset_webhook_event.rbi +4 -36
  80. data/rbi/dodopayments/models/credit_rolled_over_webhook_event.rbi +4 -33
  81. data/rbi/dodopayments/models/credit_rollover_forfeited_webhook_event.rbi +4 -40
  82. data/rbi/dodopayments/models/dispute_accepted_webhook_event.rbi +4 -33
  83. data/rbi/dodopayments/models/dispute_cancelled_webhook_event.rbi +4 -33
  84. data/rbi/dodopayments/models/dispute_challenged_webhook_event.rbi +4 -34
  85. data/rbi/dodopayments/models/dispute_expired_webhook_event.rbi +4 -33
  86. data/rbi/dodopayments/models/dispute_lost_webhook_event.rbi +4 -29
  87. data/rbi/dodopayments/models/dispute_opened_webhook_event.rbi +4 -33
  88. data/rbi/dodopayments/models/dispute_won_webhook_event.rbi +4 -29
  89. data/rbi/dodopayments/models/dunning_recovered_webhook_event.rbi +4 -33
  90. data/rbi/dodopayments/models/dunning_started_webhook_event.rbi +4 -33
  91. data/rbi/dodopayments/models/entitlement_grant_created_webhook_event.rbi +4 -40
  92. data/rbi/dodopayments/models/entitlement_grant_delivered_webhook_event.rbi +4 -40
  93. data/rbi/dodopayments/models/entitlement_grant_failed_webhook_event.rbi +4 -39
  94. data/rbi/dodopayments/models/entitlement_grant_revoked_webhook_event.rbi +4 -40
  95. data/rbi/dodopayments/models/license_key_created_webhook_event.rbi +4 -34
  96. data/rbi/dodopayments/models/payment.rbi +170 -2
  97. data/rbi/dodopayments/models/payment_cancelled_webhook_event.rbi +4 -33
  98. data/rbi/dodopayments/models/payment_create_params.rbi +14 -2
  99. data/rbi/dodopayments/models/payment_create_response.rbi +12 -2
  100. data/rbi/dodopayments/models/payment_failed_webhook_event.rbi +4 -33
  101. data/rbi/dodopayments/models/payment_processing_webhook_event.rbi +4 -34
  102. data/rbi/dodopayments/models/payment_succeeded_webhook_event.rbi +4 -33
  103. data/rbi/dodopayments/models/price.rbi +18 -90
  104. data/rbi/dodopayments/models/product_item_req.rbi +74 -3
  105. data/rbi/dodopayments/models/refund_failed_webhook_event.rbi +4 -31
  106. data/rbi/dodopayments/models/refund_succeeded_webhook_event.rbi +4 -33
  107. data/rbi/dodopayments/models/subscription.rbi +173 -4
  108. data/rbi/dodopayments/models/subscription_active_webhook_event.rbi +4 -36
  109. data/rbi/dodopayments/models/subscription_cancelled_webhook_event.rbi +4 -36
  110. data/rbi/dodopayments/models/subscription_create_params.rbi +14 -2
  111. data/rbi/dodopayments/models/subscription_create_response.rbi +12 -2
  112. data/rbi/dodopayments/models/subscription_expired_webhook_event.rbi +4 -36
  113. data/rbi/dodopayments/models/subscription_failed_webhook_event.rbi +4 -36
  114. data/rbi/dodopayments/models/subscription_list_response.rbi +67 -4
  115. data/rbi/dodopayments/models/subscription_on_hold_webhook_event.rbi +4 -36
  116. data/rbi/dodopayments/models/subscription_plan_changed_webhook_event.rbi +4 -40
  117. data/rbi/dodopayments/models/subscription_preview_change_plan_response.rbi +18 -123
  118. data/rbi/dodopayments/models/subscription_renewed_webhook_event.rbi +4 -36
  119. data/rbi/dodopayments/models/subscription_update_payment_method_params.rbi +12 -96
  120. data/rbi/dodopayments/models/subscription_updated_webhook_event.rbi +4 -36
  121. data/rbi/dodopayments/models/update_subscription_plan_req.rbi +18 -8
  122. data/rbi/dodopayments/models/webhook_event_type.rbi +15 -0
  123. data/rbi/dodopayments/models/webhook_payload.rbi +46 -466
  124. data/rbi/dodopayments/resources/checkout_sessions.rbi +12 -0
  125. data/rbi/dodopayments/resources/payments.rbi +6 -1
  126. data/rbi/dodopayments/resources/subscriptions.rbi +22 -9
  127. data/sig/dodopayments/models/abandoned_checkout_detected_webhook_event.rbs +4 -14
  128. data/sig/dodopayments/models/abandoned_checkout_recovered_webhook_event.rbs +4 -14
  129. data/sig/dodopayments/models/checkout_session_request.rbs +5 -0
  130. data/sig/dodopayments/models/credit_added_webhook_event.rbs +4 -14
  131. data/sig/dodopayments/models/credit_balance_low_webhook_event.rbs +4 -14
  132. data/sig/dodopayments/models/credit_deducted_webhook_event.rbs +4 -14
  133. data/sig/dodopayments/models/credit_expired_webhook_event.rbs +4 -14
  134. data/sig/dodopayments/models/credit_manual_adjustment_webhook_event.rbs +4 -14
  135. data/sig/dodopayments/models/credit_overage_charged_webhook_event.rbs +4 -14
  136. data/sig/dodopayments/models/credit_overage_reset_webhook_event.rbs +4 -14
  137. data/sig/dodopayments/models/credit_rolled_over_webhook_event.rbs +4 -14
  138. data/sig/dodopayments/models/credit_rollover_forfeited_webhook_event.rbs +4 -14
  139. data/sig/dodopayments/models/dispute_accepted_webhook_event.rbs +4 -14
  140. data/sig/dodopayments/models/dispute_cancelled_webhook_event.rbs +4 -14
  141. data/sig/dodopayments/models/dispute_challenged_webhook_event.rbs +4 -14
  142. data/sig/dodopayments/models/dispute_expired_webhook_event.rbs +4 -14
  143. data/sig/dodopayments/models/dispute_lost_webhook_event.rbs +4 -14
  144. data/sig/dodopayments/models/dispute_opened_webhook_event.rbs +4 -14
  145. data/sig/dodopayments/models/dispute_won_webhook_event.rbs +4 -14
  146. data/sig/dodopayments/models/dunning_recovered_webhook_event.rbs +4 -14
  147. data/sig/dodopayments/models/dunning_started_webhook_event.rbs +4 -14
  148. data/sig/dodopayments/models/entitlement_grant_created_webhook_event.rbs +4 -14
  149. data/sig/dodopayments/models/entitlement_grant_delivered_webhook_event.rbs +4 -14
  150. data/sig/dodopayments/models/entitlement_grant_failed_webhook_event.rbs +4 -14
  151. data/sig/dodopayments/models/entitlement_grant_revoked_webhook_event.rbs +4 -14
  152. data/sig/dodopayments/models/license_key_created_webhook_event.rbs +4 -14
  153. data/sig/dodopayments/models/payment.rbs +97 -0
  154. data/sig/dodopayments/models/payment_cancelled_webhook_event.rbs +4 -14
  155. data/sig/dodopayments/models/payment_create_params.rbs +5 -0
  156. data/sig/dodopayments/models/payment_create_response.rbs +5 -0
  157. data/sig/dodopayments/models/payment_failed_webhook_event.rbs +4 -14
  158. data/sig/dodopayments/models/payment_processing_webhook_event.rbs +4 -14
  159. data/sig/dodopayments/models/payment_succeeded_webhook_event.rbs +4 -14
  160. data/sig/dodopayments/models/price.rbs +15 -45
  161. data/sig/dodopayments/models/product_item_req.rbs +27 -3
  162. data/sig/dodopayments/models/refund_failed_webhook_event.rbs +4 -14
  163. data/sig/dodopayments/models/refund_succeeded_webhook_event.rbs +4 -14
  164. data/sig/dodopayments/models/subscription.rbs +97 -0
  165. data/sig/dodopayments/models/subscription_active_webhook_event.rbs +4 -14
  166. data/sig/dodopayments/models/subscription_cancelled_webhook_event.rbs +4 -14
  167. data/sig/dodopayments/models/subscription_create_params.rbs +5 -0
  168. data/sig/dodopayments/models/subscription_create_response.rbs +5 -0
  169. data/sig/dodopayments/models/subscription_expired_webhook_event.rbs +4 -14
  170. data/sig/dodopayments/models/subscription_failed_webhook_event.rbs +4 -14
  171. data/sig/dodopayments/models/subscription_list_response.rbs +24 -0
  172. data/sig/dodopayments/models/subscription_on_hold_webhook_event.rbs +4 -14
  173. data/sig/dodopayments/models/subscription_plan_changed_webhook_event.rbs +4 -14
  174. data/sig/dodopayments/models/subscription_preview_change_plan_response.rbs +15 -45
  175. data/sig/dodopayments/models/subscription_renewed_webhook_event.rbs +4 -14
  176. data/sig/dodopayments/models/subscription_update_payment_method_params.rbs +8 -48
  177. data/sig/dodopayments/models/subscription_updated_webhook_event.rbs +4 -14
  178. data/sig/dodopayments/models/update_subscription_plan_req.rbs +5 -0
  179. data/sig/dodopayments/models/webhook_event_type.rbs +6 -0
  180. data/sig/dodopayments/models/webhook_payload.rbs +50 -213
  181. data/sig/dodopayments/resources/checkout_sessions.rbs +2 -0
  182. data/sig/dodopayments/resources/payments.rbs +1 -0
  183. data/sig/dodopayments/resources/subscriptions.rbs +3 -0
  184. metadata +2 -2
@@ -179,17 +179,25 @@ module Dodopayments
179
179
  nil?: true
180
180
 
181
181
  # @!attribute discount_cycles_remaining
182
- # Number of remaining discount cycles if discount is applied
182
+ # DEPRECATED: Use discounts[].cycles_remaining instead.
183
183
  #
184
184
  # @return [Integer, nil]
185
185
  optional :discount_cycles_remaining, Integer, nil?: true
186
186
 
187
187
  # @!attribute discount_id
188
- # The discount id if discount is applied
188
+ # DEPRECATED: Use discounts instead. Returns the first discount's ID if present.
189
189
  #
190
190
  # @return [String, nil]
191
191
  optional :discount_id, String, nil?: true
192
192
 
193
+ # @!attribute discounts
194
+ # All stacked discounts applied, ordered by position
195
+ #
196
+ # @return [Array<Dodopayments::Models::Subscription::Discount>, nil]
197
+ optional :discounts,
198
+ -> { Dodopayments::Internal::Type::ArrayOf[Dodopayments::Subscription::Discount] },
199
+ nil?: true
200
+
193
201
  # @!attribute expires_at
194
202
  # Timestamp when the subscription will expire
195
203
  #
@@ -214,7 +222,7 @@ module Dodopayments
214
222
  # @return [String, nil]
215
223
  optional :tax_id, String, nil?: true
216
224
 
217
- # @!method initialize(addons:, billing:, cancel_at_next_billing_date:, created_at:, credit_entitlement_cart:, currency:, customer:, metadata:, meter_credit_entitlement_cart:, meters:, next_billing_date:, on_demand:, payment_frequency_count:, payment_frequency_interval:, previous_billing_date:, product_id:, quantity:, recurring_pre_tax_amount:, status:, subscription_id:, subscription_period_count:, subscription_period_interval:, tax_inclusive:, trial_period_days:, cancellation_comment: nil, cancellation_feedback: nil, cancelled_at: nil, custom_field_responses: nil, discount_cycles_remaining: nil, discount_id: nil, expires_at: nil, payment_method_id: nil, scheduled_change: nil, tax_id: nil)
225
+ # @!method initialize(addons:, billing:, cancel_at_next_billing_date:, created_at:, credit_entitlement_cart:, currency:, customer:, metadata:, meter_credit_entitlement_cart:, meters:, next_billing_date:, on_demand:, payment_frequency_count:, payment_frequency_interval:, previous_billing_date:, product_id:, quantity:, recurring_pre_tax_amount:, status:, subscription_id:, subscription_period_count:, subscription_period_interval:, tax_inclusive:, trial_period_days:, cancellation_comment: nil, cancellation_feedback: nil, cancelled_at: nil, custom_field_responses: nil, discount_cycles_remaining: nil, discount_id: nil, discounts: nil, expires_at: nil, payment_method_id: nil, scheduled_change: nil, tax_id: nil)
218
226
  # Some parameter documentations has been truncated, see
219
227
  # {Dodopayments::Models::Subscription} for more details.
220
228
  #
@@ -276,9 +284,11 @@ module Dodopayments
276
284
  #
277
285
  # @param custom_field_responses [Array<Dodopayments::Models::CustomFieldResponse>, nil] Customer's responses to custom fields collected during checkout
278
286
  #
279
- # @param discount_cycles_remaining [Integer, nil] Number of remaining discount cycles if discount is applied
287
+ # @param discount_cycles_remaining [Integer, nil] DEPRECATED: Use discounts[].cycles_remaining instead.
280
288
  #
281
- # @param discount_id [String, nil] The discount id if discount is applied
289
+ # @param discount_id [String, nil] DEPRECATED: Use discounts instead. Returns the first discount's ID if present.
290
+ #
291
+ # @param discounts [Array<Dodopayments::Models::Subscription::Discount>, nil] All stacked discounts applied, ordered by position
282
292
  #
283
293
  # @param expires_at [Time, nil] Timestamp when the subscription will expire
284
294
  #
@@ -287,6 +297,144 @@ module Dodopayments
287
297
  # @param scheduled_change [Dodopayments::Models::ScheduledPlanChange, nil] Scheduled plan change details, if any
288
298
  #
289
299
  # @param tax_id [String, nil] Tax identifier provided for this subscription (if applicable)
300
+
301
+ class Discount < Dodopayments::Internal::Type::BaseModel
302
+ # @!attribute amount
303
+ # The discount amount (basis points for percentage, USD cents for flat)
304
+ #
305
+ # @return [Integer]
306
+ required :amount, Integer
307
+
308
+ # @!attribute business_id
309
+ # The business this discount belongs to
310
+ #
311
+ # @return [String]
312
+ required :business_id, String
313
+
314
+ # @!attribute code
315
+ # The discount code
316
+ #
317
+ # @return [String]
318
+ required :code, String
319
+
320
+ # @!attribute created_at
321
+ # Timestamp when the discount was created
322
+ #
323
+ # @return [Time]
324
+ required :created_at, Time
325
+
326
+ # @!attribute discount_id
327
+ # The unique discount ID
328
+ #
329
+ # @return [String]
330
+ required :discount_id, String
331
+
332
+ # @!attribute metadata
333
+ # Additional metadata
334
+ #
335
+ # @return [Hash{Symbol=>String}]
336
+ required :metadata, Dodopayments::Internal::Type::HashOf[String]
337
+
338
+ # @!attribute position
339
+ # Position of this discount in the stack (0-based)
340
+ #
341
+ # @return [Integer]
342
+ required :position, Integer
343
+
344
+ # @!attribute preserve_on_plan_change
345
+ # Whether this discount should be preserved when a subscription changes plans
346
+ #
347
+ # @return [Boolean]
348
+ required :preserve_on_plan_change, Dodopayments::Internal::Type::Boolean
349
+
350
+ # @!attribute restricted_to
351
+ # List of product IDs to which this discount is restricted
352
+ #
353
+ # @return [Array<String>]
354
+ required :restricted_to, Dodopayments::Internal::Type::ArrayOf[String]
355
+
356
+ # @!attribute times_used
357
+ # How many times this discount has been used
358
+ #
359
+ # @return [Integer]
360
+ required :times_used, Integer
361
+
362
+ # @!attribute type
363
+ # The type of discount
364
+ #
365
+ # @return [Symbol, Dodopayments::Models::DiscountType]
366
+ required :type, enum: -> { Dodopayments::DiscountType }
367
+
368
+ # @!attribute cycles_remaining
369
+ # Remaining billing cycles for this discount on this subscription (None for
370
+ # one-time payments)
371
+ #
372
+ # @return [Integer, nil]
373
+ optional :cycles_remaining, Integer, nil?: true
374
+
375
+ # @!attribute expires_at
376
+ # Optional date/time after which discount is expired
377
+ #
378
+ # @return [Time, nil]
379
+ optional :expires_at, Time, nil?: true
380
+
381
+ # @!attribute name
382
+ # Name for the Discount
383
+ #
384
+ # @return [String, nil]
385
+ optional :name, String, nil?: true
386
+
387
+ # @!attribute subscription_cycles
388
+ # Number of subscription billing cycles this discount is valid for
389
+ #
390
+ # @return [Integer, nil]
391
+ optional :subscription_cycles, Integer, nil?: true
392
+
393
+ # @!attribute usage_limit
394
+ # Usage limit for this discount, if any
395
+ #
396
+ # @return [Integer, nil]
397
+ optional :usage_limit, Integer, nil?: true
398
+
399
+ # @!method initialize(amount:, business_id:, code:, created_at:, discount_id:, metadata:, position:, preserve_on_plan_change:, restricted_to:, times_used:, type:, cycles_remaining: nil, expires_at: nil, name: nil, subscription_cycles: nil, usage_limit: nil)
400
+ # Some parameter documentations has been truncated, see
401
+ # {Dodopayments::Models::Subscription::Discount} for more details.
402
+ #
403
+ # Response struct for a discount with its position in a stack and optional
404
+ # cycle-tracking information (for subscriptions).
405
+ #
406
+ # @param amount [Integer] The discount amount (basis points for percentage, USD cents for flat)
407
+ #
408
+ # @param business_id [String] The business this discount belongs to
409
+ #
410
+ # @param code [String] The discount code
411
+ #
412
+ # @param created_at [Time] Timestamp when the discount was created
413
+ #
414
+ # @param discount_id [String] The unique discount ID
415
+ #
416
+ # @param metadata [Hash{Symbol=>String}] Additional metadata
417
+ #
418
+ # @param position [Integer] Position of this discount in the stack (0-based)
419
+ #
420
+ # @param preserve_on_plan_change [Boolean] Whether this discount should be preserved when a subscription changes plans
421
+ #
422
+ # @param restricted_to [Array<String>] List of product IDs to which this discount is restricted
423
+ #
424
+ # @param times_used [Integer] How many times this discount has been used
425
+ #
426
+ # @param type [Symbol, Dodopayments::Models::DiscountType] The type of discount
427
+ #
428
+ # @param cycles_remaining [Integer, nil] Remaining billing cycles for this discount on this subscription (None for one-ti
429
+ #
430
+ # @param expires_at [Time, nil] Optional date/time after which discount is expired
431
+ #
432
+ # @param name [String, nil] Name for the Discount
433
+ #
434
+ # @param subscription_cycles [Integer, nil] Number of subscription billing cycles this discount is valid for
435
+ #
436
+ # @param usage_limit [Integer, nil] Usage limit for this discount, if any
437
+ end
290
438
  end
291
439
  end
292
440
  end
@@ -24,29 +24,17 @@ module Dodopayments
24
24
  # @!attribute type
25
25
  # The event type
26
26
  #
27
- # @return [Symbol, Dodopayments::Models::SubscriptionActiveWebhookEvent::Type]
28
- required :type, enum: -> { Dodopayments::SubscriptionActiveWebhookEvent::Type }
27
+ # @return [Symbol, :"subscription.active"]
28
+ required :type, const: :"subscription.active"
29
29
 
30
- # @!method initialize(business_id:, data:, timestamp:, type:)
30
+ # @!method initialize(business_id:, data:, timestamp:, type: :"subscription.active")
31
31
  # @param business_id [String] The business identifier
32
32
  #
33
33
  # @param data [Dodopayments::Models::Subscription] Response struct representing subscription details
34
34
  #
35
35
  # @param timestamp [Time] The timestamp of when the event occurred
36
36
  #
37
- # @param type [Symbol, Dodopayments::Models::SubscriptionActiveWebhookEvent::Type] The event type
38
-
39
- # The event type
40
- #
41
- # @see Dodopayments::Models::SubscriptionActiveWebhookEvent#type
42
- module Type
43
- extend Dodopayments::Internal::Type::Enum
44
-
45
- SUBSCRIPTION_ACTIVE = :"subscription.active"
46
-
47
- # @!method self.values
48
- # @return [Array<Symbol>]
49
- end
37
+ # @param type [Symbol, :"subscription.active"] The event type
50
38
  end
51
39
  end
52
40
  end
@@ -24,29 +24,17 @@ module Dodopayments
24
24
  # @!attribute type
25
25
  # The event type
26
26
  #
27
- # @return [Symbol, Dodopayments::Models::SubscriptionCancelledWebhookEvent::Type]
28
- required :type, enum: -> { Dodopayments::SubscriptionCancelledWebhookEvent::Type }
27
+ # @return [Symbol, :"subscription.cancelled"]
28
+ required :type, const: :"subscription.cancelled"
29
29
 
30
- # @!method initialize(business_id:, data:, timestamp:, type:)
30
+ # @!method initialize(business_id:, data:, timestamp:, type: :"subscription.cancelled")
31
31
  # @param business_id [String] The business identifier
32
32
  #
33
33
  # @param data [Dodopayments::Models::Subscription] Response struct representing subscription details
34
34
  #
35
35
  # @param timestamp [Time] The timestamp of when the event occurred
36
36
  #
37
- # @param type [Symbol, Dodopayments::Models::SubscriptionCancelledWebhookEvent::Type] The event type
38
-
39
- # The event type
40
- #
41
- # @see Dodopayments::Models::SubscriptionCancelledWebhookEvent#type
42
- module Type
43
- extend Dodopayments::Internal::Type::Enum
44
-
45
- SUBSCRIPTION_CANCELLED = :"subscription.cancelled"
46
-
47
- # @!method self.values
48
- # @return [Array<Symbol>]
49
- end
37
+ # @param type [Symbol, :"subscription.cancelled"] The event type
50
38
  end
51
39
  end
52
40
  end
@@ -58,11 +58,21 @@ module Dodopayments
58
58
  optional :billing_currency, enum: -> { Dodopayments::Currency }, nil?: true
59
59
 
60
60
  # @!attribute discount_code
61
- # Discount Code to apply to the subscription
61
+ # @deprecated Use `discount_id` instead.
62
+ #
63
+ # DEPRECATED: Use discount_codes instead. Cannot be used together with
64
+ # discount_codes.
62
65
  #
63
66
  # @return [String, nil]
64
67
  optional :discount_code, String, nil?: true
65
68
 
69
+ # @!attribute discount_codes
70
+ # Stacked discount codes to apply, in order of application. Max 20. Cannot be used
71
+ # together with discount_code.
72
+ #
73
+ # @return [Array<String>, nil]
74
+ optional :discount_codes, Dodopayments::Internal::Type::ArrayOf[String], nil?: true
75
+
66
76
  # @!attribute force_3ds
67
77
  # Override merchant default 3DS behaviour for this subscription
68
78
  #
@@ -161,7 +171,7 @@ module Dodopayments
161
171
  # @return [Integer, nil]
162
172
  optional :trial_period_days, Integer, nil?: true
163
173
 
164
- # @!method initialize(billing:, customer:, product_id:, quantity:, addons: nil, allowed_payment_method_types: nil, billing_currency: nil, discount_code: nil, force_3ds: nil, mandate_min_amount_inr_paise: nil, metadata: nil, on_demand: nil, one_time_product_cart: nil, payment_link: nil, payment_method_id: nil, redirect_immediately: nil, require_phone_number: nil, return_url: nil, short_link: nil, show_saved_payment_methods: nil, tax_id: nil, trial_period_days: nil, request_options: {})
174
+ # @!method initialize(billing:, customer:, product_id:, quantity:, addons: nil, allowed_payment_method_types: nil, billing_currency: nil, discount_code: nil, discount_codes: nil, force_3ds: nil, mandate_min_amount_inr_paise: nil, metadata: nil, on_demand: nil, one_time_product_cart: nil, payment_link: nil, payment_method_id: nil, redirect_immediately: nil, require_phone_number: nil, return_url: nil, short_link: nil, show_saved_payment_methods: nil, tax_id: nil, trial_period_days: nil, request_options: {})
165
175
  # Some parameter documentations has been truncated, see
166
176
  # {Dodopayments::Models::SubscriptionCreateParams} for more details.
167
177
  #
@@ -179,7 +189,9 @@ module Dodopayments
179
189
  #
180
190
  # @param billing_currency [Symbol, Dodopayments::Models::Currency, nil] Fix the currency in which the end customer is billed.
181
191
  #
182
- # @param discount_code [String, nil] Discount Code to apply to the subscription
192
+ # @param discount_code [String, nil] DEPRECATED: Use discount_codes instead. Cannot be used together with discount_co
193
+ #
194
+ # @param discount_codes [Array<String>, nil] Stacked discount codes to apply, in order of application. Max 20.
183
195
  #
184
196
  # @param force_3ds [Boolean, nil] Override merchant default 3DS behaviour for this subscription
185
197
  #
@@ -49,11 +49,20 @@ module Dodopayments
49
49
  optional :client_secret, String, nil?: true
50
50
 
51
51
  # @!attribute discount_id
52
- # The discount id if discount is applied
52
+ # @deprecated Use `discounts` instead.
53
+ #
54
+ # DEPRECATED: Use discount_ids instead. Returns the first discount's ID if
55
+ # present.
53
56
  #
54
57
  # @return [String, nil]
55
58
  optional :discount_id, String, nil?: true
56
59
 
60
+ # @!attribute discount_ids
61
+ # All stacked discount IDs applied, in order of application
62
+ #
63
+ # @return [Array<String>, nil]
64
+ optional :discount_ids, Dodopayments::Internal::Type::ArrayOf[String], nil?: true
65
+
57
66
  # @!attribute expires_on
58
67
  # Expiry timestamp of the payment link
59
68
  #
@@ -74,7 +83,7 @@ module Dodopayments
74
83
  # @return [String, nil]
75
84
  optional :payment_link, String, nil?: true
76
85
 
77
- # @!method initialize(addons:, customer:, metadata:, payment_id:, recurring_pre_tax_amount:, subscription_id:, client_secret: nil, discount_id: nil, expires_on: nil, one_time_product_cart: nil, payment_link: nil)
86
+ # @!method initialize(addons:, customer:, metadata:, payment_id:, recurring_pre_tax_amount:, subscription_id:, client_secret: nil, discount_id: nil, discount_ids: nil, expires_on: nil, one_time_product_cart: nil, payment_link: nil)
78
87
  # Some parameter documentations has been truncated, see
79
88
  # {Dodopayments::Models::SubscriptionCreateResponse} for more details.
80
89
  #
@@ -92,7 +101,9 @@ module Dodopayments
92
101
  #
93
102
  # @param client_secret [String, nil] Client secret used to load Dodo checkout SDK
94
103
  #
95
- # @param discount_id [String, nil] The discount id if discount is applied
104
+ # @param discount_id [String, nil] DEPRECATED: Use discount_ids instead. Returns the first discount's ID if present
105
+ #
106
+ # @param discount_ids [Array<String>, nil] All stacked discount IDs applied, in order of application
96
107
  #
97
108
  # @param expires_on [Time, nil] Expiry timestamp of the payment link
98
109
  #
@@ -24,29 +24,17 @@ module Dodopayments
24
24
  # @!attribute type
25
25
  # The event type
26
26
  #
27
- # @return [Symbol, Dodopayments::Models::SubscriptionExpiredWebhookEvent::Type]
28
- required :type, enum: -> { Dodopayments::SubscriptionExpiredWebhookEvent::Type }
27
+ # @return [Symbol, :"subscription.expired"]
28
+ required :type, const: :"subscription.expired"
29
29
 
30
- # @!method initialize(business_id:, data:, timestamp:, type:)
30
+ # @!method initialize(business_id:, data:, timestamp:, type: :"subscription.expired")
31
31
  # @param business_id [String] The business identifier
32
32
  #
33
33
  # @param data [Dodopayments::Models::Subscription] Response struct representing subscription details
34
34
  #
35
35
  # @param timestamp [Time] The timestamp of when the event occurred
36
36
  #
37
- # @param type [Symbol, Dodopayments::Models::SubscriptionExpiredWebhookEvent::Type] The event type
38
-
39
- # The event type
40
- #
41
- # @see Dodopayments::Models::SubscriptionExpiredWebhookEvent#type
42
- module Type
43
- extend Dodopayments::Internal::Type::Enum
44
-
45
- SUBSCRIPTION_EXPIRED = :"subscription.expired"
46
-
47
- # @!method self.values
48
- # @return [Array<Symbol>]
49
- end
37
+ # @param type [Symbol, :"subscription.expired"] The event type
50
38
  end
51
39
  end
52
40
  end
@@ -24,29 +24,17 @@ module Dodopayments
24
24
  # @!attribute type
25
25
  # The event type
26
26
  #
27
- # @return [Symbol, Dodopayments::Models::SubscriptionFailedWebhookEvent::Type]
28
- required :type, enum: -> { Dodopayments::SubscriptionFailedWebhookEvent::Type }
27
+ # @return [Symbol, :"subscription.failed"]
28
+ required :type, const: :"subscription.failed"
29
29
 
30
- # @!method initialize(business_id:, data:, timestamp:, type:)
30
+ # @!method initialize(business_id:, data:, timestamp:, type: :"subscription.failed")
31
31
  # @param business_id [String] The business identifier
32
32
  #
33
33
  # @param data [Dodopayments::Models::Subscription] Response struct representing subscription details
34
34
  #
35
35
  # @param timestamp [Time] The timestamp of when the event occurred
36
36
  #
37
- # @param type [Symbol, Dodopayments::Models::SubscriptionFailedWebhookEvent::Type] The event type
38
-
39
- # The event type
40
- #
41
- # @see Dodopayments::Models::SubscriptionFailedWebhookEvent#type
42
- module Type
43
- extend Dodopayments::Internal::Type::Enum
44
-
45
- SUBSCRIPTION_FAILED = :"subscription.failed"
46
-
47
- # @!method self.values
48
- # @return [Array<Symbol>]
49
- end
37
+ # @param type [Symbol, :"subscription.failed"] The event type
50
38
  end
51
39
  end
52
40
  end
@@ -34,6 +34,13 @@ module Dodopayments
34
34
  # @return [Dodopayments::Models::CustomerLimitedDetails]
35
35
  required :customer, -> { Dodopayments::CustomerLimitedDetails }
36
36
 
37
+ # @!attribute discounts
38
+ # All stacked discounts applied, in order of application
39
+ #
40
+ # @return [Array<Dodopayments::Models::SubscriptionListResponse::Discount>]
41
+ required :discounts,
42
+ -> { Dodopayments::Internal::Type::ArrayOf[Dodopayments::Models::SubscriptionListResponse::Discount] }
43
+
37
44
  # @!attribute metadata
38
45
  # Additional custom data associated with the subscription
39
46
  #
@@ -133,13 +140,13 @@ module Dodopayments
133
140
  optional :cancelled_at, Time, nil?: true
134
141
 
135
142
  # @!attribute discount_cycles_remaining
136
- # Number of remaining discount cycles if discount is applied
143
+ # DEPRECATED: Use discounts[].cycles_remaining instead.
137
144
  #
138
145
  # @return [Integer, nil]
139
146
  optional :discount_cycles_remaining, Integer, nil?: true
140
147
 
141
148
  # @!attribute discount_id
142
- # The discount id if discount is applied
149
+ # DEPRECATED: Use discounts instead.
143
150
  #
144
151
  # @return [String, nil]
145
152
  optional :discount_id, String, nil?: true
@@ -168,7 +175,7 @@ module Dodopayments
168
175
  # @return [String, nil]
169
176
  optional :tax_id, String, nil?: true
170
177
 
171
- # @!method initialize(billing:, cancel_at_next_billing_date:, created_at:, currency:, customer:, metadata:, next_billing_date:, on_demand:, payment_frequency_count:, payment_frequency_interval:, previous_billing_date:, product_id:, quantity:, recurring_pre_tax_amount:, status:, subscription_id:, subscription_period_count:, subscription_period_interval:, tax_inclusive:, trial_period_days:, cancelled_at: nil, discount_cycles_remaining: nil, discount_id: nil, payment_method_id: nil, product_name: nil, scheduled_change: nil, tax_id: nil)
178
+ # @!method initialize(billing:, cancel_at_next_billing_date:, created_at:, currency:, customer:, discounts:, metadata:, next_billing_date:, on_demand:, payment_frequency_count:, payment_frequency_interval:, previous_billing_date:, product_id:, quantity:, recurring_pre_tax_amount:, status:, subscription_id:, subscription_period_count:, subscription_period_interval:, tax_inclusive:, trial_period_days:, cancelled_at: nil, discount_cycles_remaining: nil, discount_id: nil, payment_method_id: nil, product_name: nil, scheduled_change: nil, tax_id: nil)
172
179
  # Some parameter documentations has been truncated, see
173
180
  # {Dodopayments::Models::SubscriptionListResponse} for more details.
174
181
  #
@@ -184,6 +191,8 @@ module Dodopayments
184
191
  #
185
192
  # @param customer [Dodopayments::Models::CustomerLimitedDetails] Customer details associated with the subscription
186
193
  #
194
+ # @param discounts [Array<Dodopayments::Models::SubscriptionListResponse::Discount>] All stacked discounts applied, in order of application
195
+ #
187
196
  # @param metadata [Hash{Symbol=>String}] Additional custom data associated with the subscription
188
197
  #
189
198
  # @param next_billing_date [Time] Timestamp of the next scheduled billing. Indicates the end of current billing pe
@@ -216,9 +225,9 @@ module Dodopayments
216
225
  #
217
226
  # @param cancelled_at [Time, nil] Cancelled timestamp if the subscription is cancelled
218
227
  #
219
- # @param discount_cycles_remaining [Integer, nil] Number of remaining discount cycles if discount is applied
228
+ # @param discount_cycles_remaining [Integer, nil] DEPRECATED: Use discounts[].cycles_remaining instead.
220
229
  #
221
- # @param discount_id [String, nil] The discount id if discount is applied
230
+ # @param discount_id [String, nil] DEPRECATED: Use discounts instead.
222
231
  #
223
232
  # @param payment_method_id [String, nil] Saved payment method id used for recurring charges
224
233
  #
@@ -227,6 +236,28 @@ module Dodopayments
227
236
  # @param scheduled_change [Dodopayments::Models::ScheduledPlanChange, nil] Scheduled plan change details, if any
228
237
  #
229
238
  # @param tax_id [String, nil] Tax identifier provided for this subscription (if applicable)
239
+
240
+ class Discount < Dodopayments::Internal::Type::BaseModel
241
+ # @!attribute discount_id
242
+ # The unique discount ID
243
+ #
244
+ # @return [String]
245
+ required :discount_id, String
246
+
247
+ # @!attribute discount_cycles_remaining
248
+ # Remaining billing cycles for this discount on this subscription
249
+ #
250
+ # @return [Integer, nil]
251
+ optional :discount_cycles_remaining, Integer, nil?: true
252
+
253
+ # @!method initialize(discount_id:, discount_cycles_remaining: nil)
254
+ # Lightweight discount info for list endpoints. Array order represents position
255
+ # (no explicit position field).
256
+ #
257
+ # @param discount_id [String] The unique discount ID
258
+ #
259
+ # @param discount_cycles_remaining [Integer, nil] Remaining billing cycles for this discount on this subscription
260
+ end
230
261
  end
231
262
  end
232
263
  end
@@ -24,29 +24,17 @@ module Dodopayments
24
24
  # @!attribute type
25
25
  # The event type
26
26
  #
27
- # @return [Symbol, Dodopayments::Models::SubscriptionOnHoldWebhookEvent::Type]
28
- required :type, enum: -> { Dodopayments::SubscriptionOnHoldWebhookEvent::Type }
27
+ # @return [Symbol, :"subscription.on_hold"]
28
+ required :type, const: :"subscription.on_hold"
29
29
 
30
- # @!method initialize(business_id:, data:, timestamp:, type:)
30
+ # @!method initialize(business_id:, data:, timestamp:, type: :"subscription.on_hold")
31
31
  # @param business_id [String] The business identifier
32
32
  #
33
33
  # @param data [Dodopayments::Models::Subscription] Response struct representing subscription details
34
34
  #
35
35
  # @param timestamp [Time] The timestamp of when the event occurred
36
36
  #
37
- # @param type [Symbol, Dodopayments::Models::SubscriptionOnHoldWebhookEvent::Type] The event type
38
-
39
- # The event type
40
- #
41
- # @see Dodopayments::Models::SubscriptionOnHoldWebhookEvent#type
42
- module Type
43
- extend Dodopayments::Internal::Type::Enum
44
-
45
- SUBSCRIPTION_ON_HOLD = :"subscription.on_hold"
46
-
47
- # @!method self.values
48
- # @return [Array<Symbol>]
49
- end
37
+ # @param type [Symbol, :"subscription.on_hold"] The event type
50
38
  end
51
39
  end
52
40
  end
@@ -24,29 +24,17 @@ module Dodopayments
24
24
  # @!attribute type
25
25
  # The event type
26
26
  #
27
- # @return [Symbol, Dodopayments::Models::SubscriptionPlanChangedWebhookEvent::Type]
28
- required :type, enum: -> { Dodopayments::SubscriptionPlanChangedWebhookEvent::Type }
27
+ # @return [Symbol, :"subscription.plan_changed"]
28
+ required :type, const: :"subscription.plan_changed"
29
29
 
30
- # @!method initialize(business_id:, data:, timestamp:, type:)
30
+ # @!method initialize(business_id:, data:, timestamp:, type: :"subscription.plan_changed")
31
31
  # @param business_id [String] The business identifier
32
32
  #
33
33
  # @param data [Dodopayments::Models::Subscription] Response struct representing subscription details
34
34
  #
35
35
  # @param timestamp [Time] The timestamp of when the event occurred
36
36
  #
37
- # @param type [Symbol, Dodopayments::Models::SubscriptionPlanChangedWebhookEvent::Type] The event type
38
-
39
- # The event type
40
- #
41
- # @see Dodopayments::Models::SubscriptionPlanChangedWebhookEvent#type
42
- module Type
43
- extend Dodopayments::Internal::Type::Enum
44
-
45
- SUBSCRIPTION_PLAN_CHANGED = :"subscription.plan_changed"
46
-
47
- # @!method self.values
48
- # @return [Array<Symbol>]
49
- end
37
+ # @param type [Symbol, :"subscription.plan_changed"] The event type
50
38
  end
51
39
  end
52
40
  end