dodopayments 2.30.0 → 2.32.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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/README.md +1 -1
  4. data/lib/dodopayments/models/checkout_session_flags.rb +4 -2
  5. data/lib/dodopayments/models/checkout_session_request.rb +14 -4
  6. data/lib/dodopayments/models/customers/email_policies.rb +3 -2
  7. data/lib/dodopayments/models/refund.rb +22 -1
  8. data/lib/dodopayments/models/refund_list_item.rb +22 -1
  9. data/lib/dodopayments/models/refund_network_reference_type.rb +19 -0
  10. data/lib/dodopayments/models/subscription.rb +10 -1
  11. data/lib/dodopayments/models/subscription_cancelled_by.rb +54 -0
  12. data/lib/dodopayments/models/subscription_list_response.rb +10 -1
  13. data/lib/dodopayments/models/subscription_preview_change_plan_response.rb +18 -7
  14. data/lib/dodopayments/models/update_subscription_plan_req.rb +37 -1
  15. data/lib/dodopayments/models.rb +4 -0
  16. data/lib/dodopayments/resources/checkout_sessions.rb +4 -4
  17. data/lib/dodopayments/resources/subscriptions.rb +10 -2
  18. data/lib/dodopayments/version.rb +1 -1
  19. data/lib/dodopayments.rb +2 -0
  20. data/rbi/dodopayments/models/checkout_session_flags.rbi +8 -4
  21. data/rbi/dodopayments/models/checkout_session_request.rbi +25 -8
  22. data/rbi/dodopayments/models/customers/email_policies.rbi +4 -2
  23. data/rbi/dodopayments/models/refund.rbi +26 -0
  24. data/rbi/dodopayments/models/refund_list_item.rbi +26 -0
  25. data/rbi/dodopayments/models/refund_network_reference_type.rbi +41 -0
  26. data/rbi/dodopayments/models/subscription.rbi +18 -0
  27. data/rbi/dodopayments/models/subscription_cancelled_by.rbi +107 -0
  28. data/rbi/dodopayments/models/subscription_list_response.rbi +18 -0
  29. data/rbi/dodopayments/models/subscription_preview_change_plan_response.rbi +24 -10
  30. data/rbi/dodopayments/models/update_subscription_plan_req.rbi +62 -3
  31. data/rbi/dodopayments/models.rbi +4 -0
  32. data/rbi/dodopayments/resources/checkout_sessions.rbi +24 -4
  33. data/rbi/dodopayments/resources/subscriptions.rbi +52 -0
  34. data/sig/dodopayments/models/checkout_session_request.rbs +4 -6
  35. data/sig/dodopayments/models/refund.rbs +10 -0
  36. data/sig/dodopayments/models/refund_list_item.rbs +10 -0
  37. data/sig/dodopayments/models/refund_network_reference_type.rbs +20 -0
  38. data/sig/dodopayments/models/subscription.rbs +5 -0
  39. data/sig/dodopayments/models/subscription_cancelled_by.rbs +43 -0
  40. data/sig/dodopayments/models/subscription_list_response.rbs +5 -0
  41. data/sig/dodopayments/models/subscription_preview_change_plan_response.rbs +5 -0
  42. data/sig/dodopayments/models/update_subscription_plan_req.rbs +15 -3
  43. data/sig/dodopayments/models.rbs +4 -0
  44. data/sig/dodopayments/resources/checkout_sessions.rbs +2 -2
  45. data/sig/dodopayments/resources/subscriptions.rbs +4 -0
  46. metadata +8 -2
@@ -40,7 +40,14 @@ module Dodopayments
40
40
  end
41
41
  attr_writer :billing_address
42
42
 
43
- # This field is ingored if adaptive pricing is disabled
43
+ # The currency to charge the customer in.
44
+ #
45
+ # Adaptive pricing must be enabled for the business. The customer then pays in
46
+ # this currency. If you do not set it, the currency comes from the billing
47
+ # country.
48
+ #
49
+ # If adaptive pricing is disabled, the API discards this field. The currency then
50
+ # comes from the product price, or from the billing country.
44
51
  sig { returns(T.nilable(Dodopayments::Currency::OrSymbol)) }
45
52
  attr_accessor :billing_currency
46
53
 
@@ -133,11 +140,11 @@ module Dodopayments
133
140
 
134
141
  # If true, only zipcode is required when confirm is true; other address fields
135
142
  # remain optional
143
+ #
144
+ # Default is true when `feature_flags.single_page` is true. Otherwise, default is
145
+ # false.
136
146
  sig { returns(T.nilable(T::Boolean)) }
137
- attr_reader :minimal_address
138
-
139
- sig { params(minimal_address: T::Boolean).void }
140
- attr_writer :minimal_address
147
+ attr_accessor :minimal_address
141
148
 
142
149
  # Optional payment method ID to use for this checkout session. Only allowed when
143
150
  # `confirm` is true. If provided, existing customer id must also be provided.
@@ -208,7 +215,7 @@ module Dodopayments
208
215
  mandate_min_amount_inr_paise: T.nilable(Integer),
209
216
  metadata:
210
217
  T.nilable(T::Hash[Symbol, Dodopayments::MetadataItem::Variants]),
211
- minimal_address: T::Boolean,
218
+ minimal_address: T.nilable(T::Boolean),
212
219
  payment_method_id: T.nilable(String),
213
220
  product_collection_id: T.nilable(String),
214
221
  return_url: T.nilable(String),
@@ -232,7 +239,14 @@ module Dodopayments
232
239
  allowed_payment_method_types: nil,
233
240
  # Billing address information for the session
234
241
  billing_address: nil,
235
- # This field is ingored if adaptive pricing is disabled
242
+ # The currency to charge the customer in.
243
+ #
244
+ # Adaptive pricing must be enabled for the business. The customer then pays in
245
+ # this currency. If you do not set it, the currency comes from the billing
246
+ # country.
247
+ #
248
+ # If adaptive pricing is disabled, the API discards this field. The currency then
249
+ # comes from the product price, or from the billing country.
236
250
  billing_currency: nil,
237
251
  # The URL to redirect the customer if they cancel or go back from the checkout. If
238
252
  # not provided, the back button will not be displayed.
@@ -271,6 +285,9 @@ module Dodopayments
271
285
  metadata: nil,
272
286
  # If true, only zipcode is required when confirm is true; other address fields
273
287
  # remain optional
288
+ #
289
+ # Default is true when `feature_flags.single_page` is true. Otherwise, default is
290
+ # false.
274
291
  minimal_address: nil,
275
292
  # Optional payment method ID to use for this checkout session. Only allowed when
276
293
  # `confirm` is true. If provided, existing customer id must also be provided.
@@ -318,7 +335,7 @@ module Dodopayments
318
335
  mandate_min_amount_inr_paise: T.nilable(Integer),
319
336
  metadata:
320
337
  T.nilable(T::Hash[Symbol, Dodopayments::MetadataItem::Variants]),
321
- minimal_address: T::Boolean,
338
+ minimal_address: T.nilable(T::Boolean),
322
339
  payment_method_id: T.nilable(String),
323
340
  product_collection_id: T.nilable(String),
324
341
  return_url: T.nilable(String),
@@ -12,7 +12,8 @@ module Dodopayments
12
12
  )
13
13
  end
14
14
 
15
- # A permanent failure was recorded, so the same address would be a no-op.
15
+ # A permanent failure was recorded, so a send to the same address delivers
16
+ # nothing. It is false for a suppressed address that a resend can clear.
16
17
  sig { returns(T::Boolean) }
17
18
  attr_accessor :requires_different_address
18
19
 
@@ -46,7 +47,8 @@ module Dodopayments
46
47
  ).returns(T.attached_class)
47
48
  end
48
49
  def self.new(
49
- # A permanent failure was recorded, so the same address would be a no-op.
50
+ # A permanent failure was recorded, so a send to the same address delivers
51
+ # nothing. It is false for a suppressed address that a resend can clear.
50
52
  requires_different_address:,
51
53
  # The row was delivered and may be sent again.
52
54
  resend_allowed:,
@@ -57,6 +57,20 @@ module Dodopayments
57
57
  sig { returns(T.nilable(Dodopayments::Currency::TaggedSymbol)) }
58
58
  attr_accessor :currency
59
59
 
60
+ # The reference number that the card network or the bank gives to the refund. The
61
+ # customer can give this number to their bank to trace the refund. It is null
62
+ # until the reference is available.
63
+ sig { returns(T.nilable(String)) }
64
+ attr_accessor :network_reference
65
+
66
+ # The kind of `network_reference`: ARN, STAN or RRN.
67
+ sig do
68
+ returns(
69
+ T.nilable(Dodopayments::RefundNetworkReferenceType::TaggedSymbol)
70
+ )
71
+ end
72
+ attr_accessor :network_reference_type
73
+
60
74
  # The reason provided for the refund, if any. Optional.
61
75
  sig { returns(T.nilable(String)) }
62
76
  attr_accessor :reason
@@ -74,6 +88,9 @@ module Dodopayments
74
88
  status: Dodopayments::RefundStatus::OrSymbol,
75
89
  amount: T.nilable(Integer),
76
90
  currency: T.nilable(Dodopayments::Currency::OrSymbol),
91
+ network_reference: T.nilable(String),
92
+ network_reference_type:
93
+ T.nilable(Dodopayments::RefundNetworkReferenceType::OrSymbol),
77
94
  reason: T.nilable(String)
78
95
  ).returns(T.attached_class)
79
96
  end
@@ -100,6 +117,12 @@ module Dodopayments
100
117
  amount: nil,
101
118
  # The currency of the refund, represented as an ISO 4217 currency code.
102
119
  currency: nil,
120
+ # The reference number that the card network or the bank gives to the refund. The
121
+ # customer can give this number to their bank to trace the refund. It is null
122
+ # until the reference is available.
123
+ network_reference: nil,
124
+ # The kind of `network_reference`: ARN, STAN or RRN.
125
+ network_reference_type: nil,
103
126
  # The reason provided for the refund, if any. Optional.
104
127
  reason: nil
105
128
  )
@@ -119,6 +142,9 @@ module Dodopayments
119
142
  status: Dodopayments::RefundStatus::TaggedSymbol,
120
143
  amount: T.nilable(Integer),
121
144
  currency: T.nilable(Dodopayments::Currency::TaggedSymbol),
145
+ network_reference: T.nilable(String),
146
+ network_reference_type:
147
+ T.nilable(Dodopayments::RefundNetworkReferenceType::TaggedSymbol),
122
148
  reason: T.nilable(String)
123
149
  }
124
150
  )
@@ -40,6 +40,20 @@ module Dodopayments
40
40
  sig { returns(T.nilable(Dodopayments::Currency::TaggedSymbol)) }
41
41
  attr_accessor :currency
42
42
 
43
+ # The reference number that the card network or the bank gives to the refund. The
44
+ # customer can give this number to their bank to trace the refund. It is null
45
+ # until the reference is available.
46
+ sig { returns(T.nilable(String)) }
47
+ attr_accessor :network_reference
48
+
49
+ # The kind of `network_reference`: ARN, STAN or RRN.
50
+ sig do
51
+ returns(
52
+ T.nilable(Dodopayments::RefundNetworkReferenceType::TaggedSymbol)
53
+ )
54
+ end
55
+ attr_accessor :network_reference_type
56
+
43
57
  # The reason provided for the refund, if any. Optional.
44
58
  sig { returns(T.nilable(String)) }
45
59
  attr_accessor :reason
@@ -54,6 +68,9 @@ module Dodopayments
54
68
  status: Dodopayments::RefundStatus::OrSymbol,
55
69
  amount: T.nilable(Integer),
56
70
  currency: T.nilable(Dodopayments::Currency::OrSymbol),
71
+ network_reference: T.nilable(String),
72
+ network_reference_type:
73
+ T.nilable(Dodopayments::RefundNetworkReferenceType::OrSymbol),
57
74
  reason: T.nilable(String)
58
75
  ).returns(T.attached_class)
59
76
  end
@@ -74,6 +91,12 @@ module Dodopayments
74
91
  amount: nil,
75
92
  # The currency of the refund, represented as an ISO 4217 currency code.
76
93
  currency: nil,
94
+ # The reference number that the card network or the bank gives to the refund. The
95
+ # customer can give this number to their bank to trace the refund. It is null
96
+ # until the reference is available.
97
+ network_reference: nil,
98
+ # The kind of `network_reference`: ARN, STAN or RRN.
99
+ network_reference_type: nil,
77
100
  # The reason provided for the refund, if any. Optional.
78
101
  reason: nil
79
102
  )
@@ -90,6 +113,9 @@ module Dodopayments
90
113
  status: Dodopayments::RefundStatus::TaggedSymbol,
91
114
  amount: T.nilable(Integer),
92
115
  currency: T.nilable(Dodopayments::Currency::TaggedSymbol),
116
+ network_reference: T.nilable(String),
117
+ network_reference_type:
118
+ T.nilable(Dodopayments::RefundNetworkReferenceType::TaggedSymbol),
93
119
  reason: T.nilable(String)
94
120
  }
95
121
  )
@@ -0,0 +1,41 @@
1
+ # typed: strong
2
+
3
+ module Dodopayments
4
+ module Models
5
+ # The kind of reference number that the card network or the bank gives to a
6
+ # refund.
7
+ module RefundNetworkReferenceType
8
+ extend Dodopayments::Internal::Type::Enum
9
+
10
+ TaggedSymbol =
11
+ T.type_alias { T.all(Symbol, Dodopayments::RefundNetworkReferenceType) }
12
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
13
+
14
+ ACQUIRER_REFERENCE_NUMBER =
15
+ T.let(
16
+ :acquirer_reference_number,
17
+ Dodopayments::RefundNetworkReferenceType::TaggedSymbol
18
+ )
19
+ SYSTEM_TRACE_AUDIT_NUMBER =
20
+ T.let(
21
+ :system_trace_audit_number,
22
+ Dodopayments::RefundNetworkReferenceType::TaggedSymbol
23
+ )
24
+ RETRIEVAL_REFERENCE_NUMBER =
25
+ T.let(
26
+ :retrieval_reference_number,
27
+ Dodopayments::RefundNetworkReferenceType::TaggedSymbol
28
+ )
29
+ OTHER =
30
+ T.let(:other, Dodopayments::RefundNetworkReferenceType::TaggedSymbol)
31
+
32
+ sig do
33
+ override.returns(
34
+ T::Array[Dodopayments::RefundNetworkReferenceType::TaggedSymbol]
35
+ )
36
+ end
37
+ def self.values
38
+ end
39
+ end
40
+ end
41
+ end
@@ -139,6 +139,18 @@ module Dodopayments
139
139
  sig { returns(T.nilable(Time)) }
140
140
  attr_accessor :cancelled_at
141
141
 
142
+ # The caller that cancelled the subscription or scheduled its cancel. `null` when
143
+ # no caller is known, for example when the system cancelled the subscription.
144
+ sig { returns(T.nilable(Dodopayments::SubscriptionCancelledBy)) }
145
+ attr_reader :cancelled_by
146
+
147
+ sig do
148
+ params(
149
+ cancelled_by: T.nilable(Dodopayments::SubscriptionCancelledBy::OrHash)
150
+ ).void
151
+ end
152
+ attr_writer :cancelled_by
153
+
142
154
  # Customer's responses to custom fields collected during checkout
143
155
  sig { returns(T.nilable(T::Array[Dodopayments::CustomFieldResponse])) }
144
156
  attr_accessor :custom_field_responses
@@ -229,6 +241,8 @@ module Dodopayments
229
241
  cancellation_feedback:
230
242
  T.nilable(Dodopayments::CancellationFeedback::OrSymbol),
231
243
  cancelled_at: T.nilable(Time),
244
+ cancelled_by:
245
+ T.nilable(Dodopayments::SubscriptionCancelledBy::OrHash),
232
246
  custom_field_responses:
233
247
  T.nilable(T::Array[Dodopayments::CustomFieldResponse::OrHash]),
234
248
  customer_business_name: T.nilable(String),
@@ -306,6 +320,9 @@ module Dodopayments
306
320
  cancellation_feedback: nil,
307
321
  # Cancelled timestamp if the subscription is cancelled
308
322
  cancelled_at: nil,
323
+ # The caller that cancelled the subscription or scheduled its cancel. `null` when
324
+ # no caller is known, for example when the system cancelled the subscription.
325
+ cancelled_by: nil,
309
326
  # Customer's responses to custom fields collected during checkout
310
327
  custom_field_responses: nil,
311
328
  # Business / legal name associated with the tax id (B2B). When set this is used on
@@ -372,6 +389,7 @@ module Dodopayments
372
389
  cancellation_feedback:
373
390
  T.nilable(Dodopayments::CancellationFeedback::TaggedSymbol),
374
391
  cancelled_at: T.nilable(Time),
392
+ cancelled_by: T.nilable(Dodopayments::SubscriptionCancelledBy),
375
393
  custom_field_responses:
376
394
  T.nilable(T::Array[Dodopayments::CustomFieldResponse]),
377
395
  customer_business_name: T.nilable(String),
@@ -0,0 +1,107 @@
1
+ # typed: strong
2
+
3
+ module Dodopayments
4
+ module Models
5
+ class SubscriptionCancelledBy < Dodopayments::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(
9
+ Dodopayments::SubscriptionCancelledBy,
10
+ Dodopayments::Internal::AnyHash
11
+ )
12
+ end
13
+
14
+ # The kind of caller.
15
+ sig do
16
+ returns(Dodopayments::SubscriptionCancelledBy::ActorType::TaggedSymbol)
17
+ end
18
+ attr_accessor :actor_type
19
+
20
+ # Email of the customer or of the dashboard user. `null` for an API key or the
21
+ # Dodo Payments team.
22
+ sig { returns(T.nilable(String)) }
23
+ attr_accessor :email
24
+
25
+ # Name of the customer or of the dashboard user. `null` for an API key or the Dodo
26
+ # Payments team.
27
+ sig { returns(T.nilable(String)) }
28
+ attr_accessor :name
29
+
30
+ # The caller that cancelled a subscription or scheduled its cancel.
31
+ sig do
32
+ params(
33
+ actor_type:
34
+ Dodopayments::SubscriptionCancelledBy::ActorType::OrSymbol,
35
+ email: T.nilable(String),
36
+ name: T.nilable(String)
37
+ ).returns(T.attached_class)
38
+ end
39
+ def self.new(
40
+ # The kind of caller.
41
+ actor_type:,
42
+ # Email of the customer or of the dashboard user. `null` for an API key or the
43
+ # Dodo Payments team.
44
+ email: nil,
45
+ # Name of the customer or of the dashboard user. `null` for an API key or the Dodo
46
+ # Payments team.
47
+ name: nil
48
+ )
49
+ end
50
+
51
+ sig do
52
+ override.returns(
53
+ {
54
+ actor_type:
55
+ Dodopayments::SubscriptionCancelledBy::ActorType::TaggedSymbol,
56
+ email: T.nilable(String),
57
+ name: T.nilable(String)
58
+ }
59
+ )
60
+ end
61
+ def to_hash
62
+ end
63
+
64
+ # The kind of caller.
65
+ module ActorType
66
+ extend Dodopayments::Internal::Type::Enum
67
+
68
+ TaggedSymbol =
69
+ T.type_alias do
70
+ T.all(Symbol, Dodopayments::SubscriptionCancelledBy::ActorType)
71
+ end
72
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
73
+
74
+ CUSTOMER =
75
+ T.let(
76
+ :customer,
77
+ Dodopayments::SubscriptionCancelledBy::ActorType::TaggedSymbol
78
+ )
79
+ MERCHANT_USER =
80
+ T.let(
81
+ :merchant_user,
82
+ Dodopayments::SubscriptionCancelledBy::ActorType::TaggedSymbol
83
+ )
84
+ API_KEY =
85
+ T.let(
86
+ :api_key,
87
+ Dodopayments::SubscriptionCancelledBy::ActorType::TaggedSymbol
88
+ )
89
+ DODO_TEAM =
90
+ T.let(
91
+ :dodo_team,
92
+ Dodopayments::SubscriptionCancelledBy::ActorType::TaggedSymbol
93
+ )
94
+
95
+ sig do
96
+ override.returns(
97
+ T::Array[
98
+ Dodopayments::SubscriptionCancelledBy::ActorType::TaggedSymbol
99
+ ]
100
+ )
101
+ end
102
+ def self.values
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
@@ -118,6 +118,18 @@ module Dodopayments
118
118
  sig { returns(T.nilable(Time)) }
119
119
  attr_accessor :cancelled_at
120
120
 
121
+ # The caller that cancelled the subscription or scheduled its cancel. `null` when
122
+ # no caller is known, for example when the system cancelled the subscription.
123
+ sig { returns(T.nilable(Dodopayments::SubscriptionCancelledBy)) }
124
+ attr_reader :cancelled_by
125
+
126
+ sig do
127
+ params(
128
+ cancelled_by: T.nilable(Dodopayments::SubscriptionCancelledBy::OrHash)
129
+ ).void
130
+ end
131
+ attr_writer :cancelled_by
132
+
121
133
  # Business / legal name associated with the tax id (B2B). When set this is used on
122
134
  # the invoice in place of the customer's personal name.
123
135
  sig { returns(T.nilable(String)) }
@@ -194,6 +206,8 @@ module Dodopayments
194
206
  tax_inclusive: T::Boolean,
195
207
  trial_period_days: Integer,
196
208
  cancelled_at: T.nilable(Time),
209
+ cancelled_by:
210
+ T.nilable(Dodopayments::SubscriptionCancelledBy::OrHash),
197
211
  customer_business_name: T.nilable(String),
198
212
  discount_cycles_remaining: T.nilable(Integer),
199
213
  discount_id: T.nilable(String),
@@ -256,6 +270,9 @@ module Dodopayments
256
270
  trial_period_days:,
257
271
  # Cancelled timestamp if the subscription is cancelled
258
272
  cancelled_at: nil,
273
+ # The caller that cancelled the subscription or scheduled its cancel. `null` when
274
+ # no caller is known, for example when the system cancelled the subscription.
275
+ cancelled_by: nil,
259
276
  # Business / legal name associated with the tax id (B2B). When set this is used on
260
277
  # the invoice in place of the customer's personal name.
261
278
  customer_business_name: nil,
@@ -312,6 +329,7 @@ module Dodopayments
312
329
  tax_inclusive: T::Boolean,
313
330
  trial_period_days: Integer,
314
331
  cancelled_at: T.nilable(Time),
332
+ cancelled_by: T.nilable(Dodopayments::SubscriptionCancelledBy),
315
333
  customer_business_name: T.nilable(String),
316
334
  discount_cycles_remaining: T.nilable(Integer),
317
335
  discount_id: T.nilable(String),
@@ -477,14 +477,21 @@ module Dodopayments
477
477
  sig { returns(Dodopayments::Currency::TaggedSymbol) }
478
478
  attr_accessor :currency
479
479
 
480
- # Net credit movement in the smallest currency unit (e.g. cents). **Negative** –
481
- # credits were deducted from the customer's balance to offset the charge (typical
482
- # on upgrades). **Positive** – credits were added to the customer's balance,
483
- # either from a downgrade proration refund or from topping-up the wallet to meet a
484
- # gateway minimum-charge threshold. **Zero** – no credit movement occurred.
480
+ # Net credit movement in the smallest unit of `customer_credits_currency` (e.g.
481
+ # cents). Read `customer_credits_currency` for the currency. It can differ from
482
+ # `currency`. **Negative** – credits were deducted from the customer's balance to
483
+ # offset the charge (typical on upgrades). **Positive** – credits were added to
484
+ # the customer's balance, either from a downgrade proration refund or from
485
+ # topping-up the wallet to meet a gateway minimum-charge threshold. **Zero** – no
486
+ # credit movement occurred.
485
487
  sig { returns(Integer) }
486
488
  attr_accessor :customer_credits
487
489
 
490
+ # This field gives the currency of `customer_credits`. The credit wallet uses the
491
+ # subscription currency.
492
+ sig { returns(Dodopayments::Currency::TaggedSymbol) }
493
+ attr_accessor :customer_credits_currency
494
+
488
495
  sig { returns(Integer) }
489
496
  attr_accessor :settlement_amount
490
497
 
@@ -504,6 +511,7 @@ module Dodopayments
504
511
  params(
505
512
  currency: Dodopayments::Currency::OrSymbol,
506
513
  customer_credits: Integer,
514
+ customer_credits_currency: Dodopayments::Currency::OrSymbol,
507
515
  settlement_amount: Integer,
508
516
  settlement_currency: Dodopayments::Currency::OrSymbol,
509
517
  total_amount: Integer,
@@ -513,12 +521,17 @@ module Dodopayments
513
521
  end
514
522
  def self.new(
515
523
  currency:,
516
- # Net credit movement in the smallest currency unit (e.g. cents). **Negative** –
517
- # credits were deducted from the customer's balance to offset the charge (typical
518
- # on upgrades). **Positive** – credits were added to the customer's balance,
519
- # either from a downgrade proration refund or from topping-up the wallet to meet a
520
- # gateway minimum-charge threshold. **Zero** – no credit movement occurred.
524
+ # Net credit movement in the smallest unit of `customer_credits_currency` (e.g.
525
+ # cents). Read `customer_credits_currency` for the currency. It can differ from
526
+ # `currency`. **Negative** – credits were deducted from the customer's balance to
527
+ # offset the charge (typical on upgrades). **Positive** – credits were added to
528
+ # the customer's balance, either from a downgrade proration refund or from
529
+ # topping-up the wallet to meet a gateway minimum-charge threshold. **Zero** – no
530
+ # credit movement occurred.
521
531
  customer_credits:,
532
+ # This field gives the currency of `customer_credits`. The credit wallet uses the
533
+ # subscription currency.
534
+ customer_credits_currency:,
522
535
  settlement_amount:,
523
536
  settlement_currency:,
524
537
  total_amount:,
@@ -532,6 +545,7 @@ module Dodopayments
532
545
  {
533
546
  currency: Dodopayments::Currency::TaggedSymbol,
534
547
  customer_credits: Integer,
548
+ customer_credits_currency: Dodopayments::Currency::TaggedSymbol,
535
549
  settlement_amount: Integer,
536
550
  settlement_currency: Dodopayments::Currency::TaggedSymbol,
537
551
  total_amount: Integer,
@@ -37,6 +37,24 @@ module Dodopayments
37
37
  sig { returns(T.nilable(T::Array[Dodopayments::AttachAddon])) }
38
38
  attr_accessor :addons
39
39
 
40
+ # Cancel the payment link of a pending plan change, so that this change can
41
+ # replace it.
42
+ #
43
+ # The link is cancelled only if the customer has not started to pay. A paid or
44
+ # in-progress payment gives a `409`. A failed cancel gives a `503`, and a retry is
45
+ # safe.
46
+ #
47
+ # The request is validated before the cancel. A later failure, for example an
48
+ # amount below the minimum, leaves the subscription on its current plan with no
49
+ # open link. A retry is safe.
50
+ #
51
+ # The preview route shares this request body and ignores this field.
52
+ sig { returns(T.nilable(T::Boolean)) }
53
+ attr_reader :cancel_older_payment_link
54
+
55
+ sig { params(cancel_older_payment_link: T::Boolean).void }
56
+ attr_writer :cancel_older_payment_link
57
+
40
58
  # Replace a scheduled plan change with this one.
41
59
  #
42
60
  # The scheduled change is cancelled by the transaction that applies this change. A
@@ -127,6 +145,19 @@ module Dodopayments
127
145
  end
128
146
  attr_accessor :on_payment_failure
129
147
 
148
+ # The URL that receives the customer after they pay the payment link. Needs
149
+ # `collect_via_payment_link: true`. Without it, the request gets a `422`. A change
150
+ # that collects no money issues no link and does not use the URL. The preview
151
+ # route validates this field but does not use it.
152
+ #
153
+ # The redirect adds `subscription_id`, `payment_id` and `status`. The `status`
154
+ # value is the status of the plan-change payment. It is not the status of the
155
+ # subscription. When that payment fails, the subscription stays active on its
156
+ # current plan. To try again, call this endpoint again to get a new link. The new
157
+ # plan can apply after the redirect, when the payment webhook arrives.
158
+ sig { returns(T.nilable(String)) }
159
+ attr_accessor :return_url
160
+
130
161
  sig do
131
162
  params(
132
163
  product_id: String,
@@ -135,6 +166,7 @@ module Dodopayments
135
166
  quantity: Integer,
136
167
  adaptive_currency_fees_inclusive: T.nilable(T::Boolean),
137
168
  addons: T.nilable(T::Array[Dodopayments::AttachAddon::OrHash]),
169
+ cancel_older_payment_link: T::Boolean,
138
170
  cancel_scheduled_change_plan: T::Boolean,
139
171
  collect_via_payment_link: T::Boolean,
140
172
  discount_code: T.nilable(String),
@@ -146,7 +178,8 @@ module Dodopayments
146
178
  on_payment_failure:
147
179
  T.nilable(
148
180
  Dodopayments::UpdateSubscriptionPlanReq::OnPaymentFailure::OrSymbol
149
- )
181
+ ),
182
+ return_url: T.nilable(String)
150
183
  ).returns(T.attached_class)
151
184
  end
152
185
  def self.new(
@@ -162,6 +195,19 @@ module Dodopayments
162
195
  # Addons for the new plan. Note : Leaving this empty would remove any existing
163
196
  # addons
164
197
  addons: nil,
198
+ # Cancel the payment link of a pending plan change, so that this change can
199
+ # replace it.
200
+ #
201
+ # The link is cancelled only if the customer has not started to pay. A paid or
202
+ # in-progress payment gives a `409`. A failed cancel gives a `503`, and a retry is
203
+ # safe.
204
+ #
205
+ # The request is validated before the cancel. A later failure, for example an
206
+ # amount below the minimum, leaves the subscription on its current plan with no
207
+ # open link. A retry is safe.
208
+ #
209
+ # The preview route shares this request body and ignores this field.
210
+ cancel_older_payment_link: nil,
165
211
  # Replace a scheduled plan change with this one.
166
212
  #
167
213
  # The scheduled change is cancelled by the transaction that applies this change. A
@@ -207,7 +253,18 @@ module Dodopayments
207
253
  # outcome
208
254
  #
209
255
  # If not specified, uses the business-level default setting.
210
- on_payment_failure: nil
256
+ on_payment_failure: nil,
257
+ # The URL that receives the customer after they pay the payment link. Needs
258
+ # `collect_via_payment_link: true`. Without it, the request gets a `422`. A change
259
+ # that collects no money issues no link and does not use the URL. The preview
260
+ # route validates this field but does not use it.
261
+ #
262
+ # The redirect adds `subscription_id`, `payment_id` and `status`. The `status`
263
+ # value is the status of the plan-change payment. It is not the status of the
264
+ # subscription. When that payment fails, the subscription stays active on its
265
+ # current plan. To try again, call this endpoint again to get a new link. The new
266
+ # plan can apply after the redirect, when the payment webhook arrives.
267
+ return_url: nil
211
268
  )
212
269
  end
213
270
 
@@ -220,6 +277,7 @@ module Dodopayments
220
277
  quantity: Integer,
221
278
  adaptive_currency_fees_inclusive: T.nilable(T::Boolean),
222
279
  addons: T.nilable(T::Array[Dodopayments::AttachAddon]),
280
+ cancel_older_payment_link: T::Boolean,
223
281
  cancel_scheduled_change_plan: T::Boolean,
224
282
  collect_via_payment_link: T::Boolean,
225
283
  discount_code: T.nilable(String),
@@ -231,7 +289,8 @@ module Dodopayments
231
289
  on_payment_failure:
232
290
  T.nilable(
233
291
  Dodopayments::UpdateSubscriptionPlanReq::OnPaymentFailure::OrSymbol
234
- )
292
+ ),
293
+ return_url: T.nilable(String)
235
294
  }
236
295
  )
237
296
  end
@@ -484,6 +484,8 @@ module Dodopayments
484
484
 
485
485
  RefundListParams = Dodopayments::Models::RefundListParams
486
486
 
487
+ RefundNetworkReferenceType = Dodopayments::Models::RefundNetworkReferenceType
488
+
487
489
  RefundRetrieveParams = Dodopayments::Models::RefundRetrieveParams
488
490
 
489
491
  RefundStatus = Dodopayments::Models::RefundStatus
@@ -501,6 +503,8 @@ module Dodopayments
501
503
  SubscriptionCancelChangePlanParams =
502
504
  Dodopayments::Models::SubscriptionCancelChangePlanParams
503
505
 
506
+ SubscriptionCancelledBy = Dodopayments::Models::SubscriptionCancelledBy
507
+
504
508
  SubscriptionCancelledWebhookEvent =
505
509
  Dodopayments::Models::SubscriptionCancelledWebhookEvent
506
510