dodopayments 2.47.1 → 2.49.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 (154) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/bin/migration-config.json +37 -0
  3. package/client.d.mts +9 -6
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +9 -6
  6. package/client.d.ts.map +1 -1
  7. package/client.js +3 -0
  8. package/client.js.map +1 -1
  9. package/client.mjs +3 -0
  10. package/client.mjs.map +1 -1
  11. package/package.json +1 -1
  12. package/resources/balances.d.mts +1 -0
  13. package/resources/balances.d.mts.map +1 -1
  14. package/resources/balances.d.ts +1 -0
  15. package/resources/balances.d.ts.map +1 -1
  16. package/resources/blocklist/blocklist.d.mts +10 -0
  17. package/resources/blocklist/blocklist.d.mts.map +1 -0
  18. package/resources/blocklist/blocklist.d.ts +10 -0
  19. package/resources/blocklist/blocklist.d.ts.map +1 -0
  20. package/resources/blocklist/blocklist.js +17 -0
  21. package/resources/blocklist/blocklist.js.map +1 -0
  22. package/resources/blocklist/blocklist.mjs +12 -0
  23. package/resources/blocklist/blocklist.mjs.map +1 -0
  24. package/resources/blocklist/customers/customers.d.mts +161 -0
  25. package/resources/blocklist/customers/customers.d.mts.map +1 -0
  26. package/resources/blocklist/customers/customers.d.ts +161 -0
  27. package/resources/blocklist/customers/customers.d.ts.map +1 -0
  28. package/resources/blocklist/customers/customers.js +38 -0
  29. package/resources/blocklist/customers/customers.js.map +1 -0
  30. package/resources/blocklist/customers/customers.mjs +33 -0
  31. package/resources/blocklist/customers/customers.mjs.map +1 -0
  32. package/resources/blocklist/customers/index.d.mts +3 -0
  33. package/resources/blocklist/customers/index.d.mts.map +1 -0
  34. package/resources/blocklist/customers/index.d.ts +3 -0
  35. package/resources/blocklist/customers/index.d.ts.map +1 -0
  36. package/resources/blocklist/customers/index.js +9 -0
  37. package/resources/blocklist/customers/index.js.map +1 -0
  38. package/resources/blocklist/customers/index.mjs +4 -0
  39. package/resources/blocklist/customers/index.mjs.map +1 -0
  40. package/resources/blocklist/customers/notes.d.mts +34 -0
  41. package/resources/blocklist/customers/notes.d.mts.map +1 -0
  42. package/resources/blocklist/customers/notes.d.ts +34 -0
  43. package/resources/blocklist/customers/notes.d.ts.map +1 -0
  44. package/resources/blocklist/customers/notes.js +17 -0
  45. package/resources/blocklist/customers/notes.js.map +1 -0
  46. package/resources/blocklist/customers/notes.mjs +13 -0
  47. package/resources/blocklist/customers/notes.mjs.map +1 -0
  48. package/resources/blocklist/customers.d.mts +2 -0
  49. package/resources/blocklist/customers.d.mts.map +1 -0
  50. package/resources/blocklist/customers.d.ts +2 -0
  51. package/resources/blocklist/customers.d.ts.map +1 -0
  52. package/resources/blocklist/customers.js +6 -0
  53. package/resources/blocklist/customers.js.map +1 -0
  54. package/resources/blocklist/customers.mjs +3 -0
  55. package/resources/blocklist/customers.mjs.map +1 -0
  56. package/resources/blocklist/index.d.mts +3 -0
  57. package/resources/blocklist/index.d.mts.map +1 -0
  58. package/resources/blocklist/index.d.ts +3 -0
  59. package/resources/blocklist/index.d.ts.map +1 -0
  60. package/resources/blocklist/index.js +9 -0
  61. package/resources/blocklist/index.js.map +1 -0
  62. package/resources/blocklist/index.mjs +4 -0
  63. package/resources/blocklist/index.mjs.map +1 -0
  64. package/resources/blocklist.d.mts +2 -0
  65. package/resources/blocklist.d.mts.map +1 -0
  66. package/resources/blocklist.d.ts +2 -0
  67. package/resources/blocklist.d.ts.map +1 -0
  68. package/resources/blocklist.js +6 -0
  69. package/resources/blocklist.js.map +1 -0
  70. package/resources/blocklist.mjs +3 -0
  71. package/resources/blocklist.mjs.map +1 -0
  72. package/resources/customers/customers.d.mts +10 -0
  73. package/resources/customers/customers.d.mts.map +1 -1
  74. package/resources/customers/customers.d.ts +10 -0
  75. package/resources/customers/customers.d.ts.map +1 -1
  76. package/resources/customers/customers.js.map +1 -1
  77. package/resources/customers/customers.mjs.map +1 -1
  78. package/resources/entitlements/grants.d.mts +12 -1
  79. package/resources/entitlements/grants.d.mts.map +1 -1
  80. package/resources/entitlements/grants.d.ts +12 -1
  81. package/resources/entitlements/grants.d.ts.map +1 -1
  82. package/resources/entitlements/grants.js.map +1 -1
  83. package/resources/entitlements/grants.mjs.map +1 -1
  84. package/resources/index.d.mts +4 -3
  85. package/resources/index.d.mts.map +1 -1
  86. package/resources/index.d.ts +4 -3
  87. package/resources/index.d.ts.map +1 -1
  88. package/resources/index.js +3 -1
  89. package/resources/index.js.map +1 -1
  90. package/resources/index.mjs +1 -0
  91. package/resources/index.mjs.map +1 -1
  92. package/resources/payments.d.mts +64 -1
  93. package/resources/payments.d.mts.map +1 -1
  94. package/resources/payments.d.ts +64 -1
  95. package/resources/payments.d.ts.map +1 -1
  96. package/resources/payments.js +21 -0
  97. package/resources/payments.js.map +1 -1
  98. package/resources/payments.mjs +21 -0
  99. package/resources/payments.mjs.map +1 -1
  100. package/resources/products/products.d.mts +19 -16
  101. package/resources/products/products.d.mts.map +1 -1
  102. package/resources/products/products.d.ts +19 -16
  103. package/resources/products/products.d.ts.map +1 -1
  104. package/resources/products/products.js +0 -1
  105. package/resources/products/products.js.map +1 -1
  106. package/resources/products/products.mjs +0 -1
  107. package/resources/products/products.mjs.map +1 -1
  108. package/resources/subscriptions.d.mts +125 -8
  109. package/resources/subscriptions.d.mts.map +1 -1
  110. package/resources/subscriptions.d.ts +125 -8
  111. package/resources/subscriptions.d.ts.map +1 -1
  112. package/resources/subscriptions.js +2 -6
  113. package/resources/subscriptions.js.map +1 -1
  114. package/resources/subscriptions.mjs +2 -6
  115. package/resources/subscriptions.mjs.map +1 -1
  116. package/resources/webhook-events.d.mts +12 -2
  117. package/resources/webhook-events.d.mts.map +1 -1
  118. package/resources/webhook-events.d.ts +12 -2
  119. package/resources/webhook-events.d.ts.map +1 -1
  120. package/resources/webhooks/index.d.mts +1 -1
  121. package/resources/webhooks/index.d.mts.map +1 -1
  122. package/resources/webhooks/index.d.ts +1 -1
  123. package/resources/webhooks/index.d.ts.map +1 -1
  124. package/resources/webhooks/index.js.map +1 -1
  125. package/resources/webhooks/index.mjs.map +1 -1
  126. package/resources/webhooks/webhooks.d.mts +543 -51
  127. package/resources/webhooks/webhooks.d.mts.map +1 -1
  128. package/resources/webhooks/webhooks.d.ts +543 -51
  129. package/resources/webhooks/webhooks.d.ts.map +1 -1
  130. package/resources/webhooks/webhooks.js.map +1 -1
  131. package/resources/webhooks/webhooks.mjs.map +1 -1
  132. package/src/client.ts +13 -0
  133. package/src/resources/balances.ts +2 -0
  134. package/src/resources/blocklist/blocklist.ts +37 -0
  135. package/src/resources/blocklist/customers/customers.ts +254 -0
  136. package/src/resources/blocklist/customers/index.ts +21 -0
  137. package/src/resources/blocklist/customers/notes.ts +62 -0
  138. package/src/resources/blocklist/customers.ts +3 -0
  139. package/src/resources/blocklist/index.ts +15 -0
  140. package/src/resources/blocklist.ts +3 -0
  141. package/src/resources/customers/customers.ts +12 -0
  142. package/src/resources/entitlements/grants.ts +14 -1
  143. package/src/resources/index.ts +5 -0
  144. package/src/resources/payments.ts +84 -0
  145. package/src/resources/products/products.ts +22 -19
  146. package/src/resources/subscriptions.ts +137 -11
  147. package/src/resources/webhook-events.ts +13 -1
  148. package/src/resources/webhooks/index.ts +1 -0
  149. package/src/resources/webhooks/webhooks.ts +575 -48
  150. package/src/version.ts +1 -1
  151. package/version.d.mts +1 -1
  152. package/version.d.ts +1 -1
  153. package/version.js +1 -1
  154. package/version.mjs +1 -1
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export * from './customers/index';
@@ -0,0 +1,15 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export { Blocklist } from './blocklist';
4
+ export {
5
+ Customers,
6
+ type BlockByCustomerID,
7
+ type BlockByEmail,
8
+ type BlockIdentifier,
9
+ type BlockedCustomer,
10
+ type BlockedCustomerSource,
11
+ type CreateBlockedCustomerRequest,
12
+ type CustomerListParams,
13
+ type CustomerCreateParams,
14
+ type BlockedCustomersDefaultPageNumberPagination,
15
+ } from './customers/index';
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export * from './blocklist/index';
@@ -192,6 +192,18 @@ export interface Customer {
192
192
 
193
193
  name: string;
194
194
 
195
+ /**
196
+ * When the merchant blocked this customer. The dashboard shows the "Blocked" badge
197
+ * and the unblock action from it. The list route leaves it empty; only the
198
+ * single-customer route resolves it.
199
+ */
200
+ blocked_at?: string | null;
201
+
202
+ /**
203
+ * Blocklist entry behind `blocked_at`, so the dashboard can link to it.
204
+ */
205
+ blocklist_entry_id?: string | null;
206
+
195
207
  /**
196
208
  * Additional metadata for the customer
197
209
  */
@@ -1,6 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import { APIResource } from '../../core/resource';
4
+ import * as LicenseKeysAPI from '../license-keys';
4
5
  import * as MiscAPI from '../misc';
5
6
  import * as EntitlementsAPI from './entitlements';
6
7
  import * as ProductsAPI from '../products/products';
@@ -210,7 +211,13 @@ export interface EntitlementGrant {
210
211
  */
211
212
  export interface LicenseKeyGrant {
212
213
  /**
213
- * Number of activations consumed so far.
214
+ * Identifier of the issued license key.
215
+ */
216
+ id: string;
217
+
218
+ /**
219
+ * Number of instances currently active. Activation increments it and deactivation
220
+ * decrements it, so it is a live count and not a total.
214
221
  */
215
222
  activations_used: number;
216
223
 
@@ -219,6 +226,12 @@ export interface LicenseKeyGrant {
219
226
  */
220
227
  key: string;
221
228
 
229
+ /**
230
+ * Current status of the license key. Activation fails unless it is `active`, so a
231
+ * client can warn before the customer tries.
232
+ */
233
+ status: LicenseKeysAPI.LicenseKeyStatus;
234
+
222
235
  /**
223
236
  * Maximum activations allowed by the entitlement, when set.
224
237
  */
@@ -15,6 +15,7 @@ export {
15
15
  type BalanceRetrieveLedgerParams,
16
16
  type BalanceLedgerEntriesDefaultPageNumberPagination,
17
17
  } from './balances';
18
+ export { Blocklist } from './blocklist/blocklist';
18
19
  export {
19
20
  Brands,
20
21
  type Brand,
@@ -154,6 +155,8 @@ export {
154
155
  type CustomerLimitedDetails,
155
156
  type CustomerRequest,
156
157
  type IntentStatus,
158
+ type ManualRetry,
159
+ type ManualRetryState,
157
160
  type NewCustomer,
158
161
  type OneTimeProductCartItem,
159
162
  type Payment,
@@ -230,6 +233,7 @@ export {
230
233
  type UpdateSubscriptionPlanReq,
231
234
  type SubscriptionCreateResponse,
232
235
  type SubscriptionListResponse,
236
+ type SubscriptionChangePlanResponse,
233
237
  type SubscriptionChargeResponse,
234
238
  type SubscriptionPreviewChangePlanResponse,
235
239
  type SubscriptionRetrieveCreditUsageResponse,
@@ -301,6 +305,7 @@ export {
301
305
  type SubscriptionExpiredWebhookEvent,
302
306
  type SubscriptionFailedWebhookEvent,
303
307
  type SubscriptionOnHoldWebhookEvent,
308
+ type SubscriptionPastDueWebhookEvent,
304
309
  type SubscriptionPausedWebhookEvent,
305
310
  type SubscriptionPlanChangedWebhookEvent,
306
311
  type SubscriptionRenewedWebhookEvent,
@@ -67,6 +67,29 @@ export class Payments extends APIResource {
67
67
  ): APIPromise<PaymentRetrieveLineItemsResponse> {
68
68
  return this._client.get(path`/payments/${paymentID}/line-items`, options);
69
69
  }
70
+
71
+ /**
72
+ * @example
73
+ * ```ts
74
+ * const manualRetry = await client.payments.retry(
75
+ * 'payment_id',
76
+ * );
77
+ * ```
78
+ */
79
+ retry(paymentID: string, options?: RequestOptions): APIPromise<ManualRetry> {
80
+ return this._client.post(path`/payments/${paymentID}/retry`, options);
81
+ }
82
+
83
+ /**
84
+ * @example
85
+ * ```ts
86
+ * const manualRetryState =
87
+ * await client.payments.retrieveRetryState('payment_id');
88
+ * ```
89
+ */
90
+ retrieveRetryState(paymentID: string, options?: RequestOptions): APIPromise<ManualRetryState> {
91
+ return this._client.get(path`/payments/${paymentID}/retry`, options);
92
+ }
70
93
  }
71
94
 
72
95
  export type PaymentListResponsesDefaultPageNumberPagination =
@@ -177,6 +200,65 @@ export type IntentStatus =
177
200
  | 'partially_captured'
178
201
  | 'partially_captured_and_capturable';
179
202
 
203
+ export interface ManualRetry {
204
+ /**
205
+ * The invoice the send charged.
206
+ */
207
+ invoice_id: string;
208
+
209
+ /**
210
+ * Always true on this route. Tells the row apart from an automatic attempt.
211
+ */
212
+ is_manual_retry: boolean;
213
+
214
+ /**
215
+ * The payment row this send created.
216
+ */
217
+ payment_id: string;
218
+
219
+ /**
220
+ * Which attempt this send is, counting manual sends on the invoice.
221
+ */
222
+ retry_attempt: number;
223
+
224
+ sends_allowed: number;
225
+
226
+ /**
227
+ * Manual sends spent on this invoice, including this one.
228
+ */
229
+ sends_used: number;
230
+
231
+ /**
232
+ * When the next send becomes available. Null when no send is left.
233
+ */
234
+ retry_available_at?: string | null;
235
+
236
+ /**
237
+ * Outcome of the charge. `processing` means the processor has not settled it yet,
238
+ * and the payment webhooks report the result.
239
+ */
240
+ status?: IntentStatus | null;
241
+ }
242
+
243
+ export interface ManualRetryState {
244
+ can_retry: boolean;
245
+
246
+ sends_allowed: number;
247
+
248
+ sends_used: number;
249
+
250
+ /**
251
+ * The code `POST` would fail with. Null when `can_retry` is true.
252
+ */
253
+ reason?: string | null;
254
+
255
+ /**
256
+ * When the next send becomes available. Null when no send is left, or when the
257
+ * block has nothing to do with the cooldown.
258
+ */
259
+ retry_available_at?: string | null;
260
+ }
261
+
180
262
  export interface NewCustomer {
181
263
  /**
182
264
  * Email is required for creating a new customer
@@ -1065,6 +1147,8 @@ export declare namespace Payments {
1065
1147
  type CustomerLimitedDetails as CustomerLimitedDetails,
1066
1148
  type CustomerRequest as CustomerRequest,
1067
1149
  type IntentStatus as IntentStatus,
1150
+ type ManualRetry as ManualRetry,
1151
+ type ManualRetryState as ManualRetryState,
1068
1152
  type NewCustomer as NewCustomer,
1069
1153
  type OneTimeProductCartItem as OneTimeProductCartItem,
1070
1154
  type Payment as Payment,
@@ -71,7 +71,6 @@ export class Products extends APIResource {
71
71
  * currency: 'AED',
72
72
  * discount: 0,
73
73
  * price: 0,
74
- * purchasing_power_parity: true,
75
74
  * type: 'one_time_price',
76
75
  * },
77
76
  * tax_category: 'digital_products',
@@ -501,12 +500,6 @@ export namespace Price {
501
500
  */
502
501
  price: number;
503
502
 
504
- /**
505
- * Indicates if purchasing power parity adjustments are applied to the price.
506
- * Purchasing power parity feature is not available as of now.
507
- */
508
- purchasing_power_parity: boolean;
509
-
510
503
  type: 'one_time_price';
511
504
 
512
505
  /**
@@ -515,6 +508,13 @@ export namespace Price {
515
508
  */
516
509
  pay_what_you_want?: boolean;
517
510
 
511
+ /**
512
+ * Opts this price in to purchasing power parity. The business must also enable
513
+ * purchasing power parity. The discount percentage per country is always
514
+ * business-wide. Defaults to `false`.
515
+ */
516
+ purchasing_power_parity?: boolean;
517
+
518
518
  /**
519
519
  * A suggested price for the user to pay. This value is only considered if
520
520
  * [`pay_what_you_want`](Self::pay_what_you_want) is `true`. Otherwise, it is
@@ -559,12 +559,6 @@ export namespace Price {
559
559
  */
560
560
  price: number;
561
561
 
562
- /**
563
- * Indicates if purchasing power parity adjustments are applied to the price.
564
- * Purchasing power parity feature is not available as of now
565
- */
566
- purchasing_power_parity: boolean;
567
-
568
562
  /**
569
563
  * Number of units for the subscription period. For example, a value of `12` with a
570
564
  * `subscription_period_interval` of `month` represents a one-year subscription.
@@ -578,6 +572,13 @@ export namespace Price {
578
572
 
579
573
  type: 'recurring_price';
580
574
 
575
+ /**
576
+ * Opts this price in to purchasing power parity. The business must also enable
577
+ * purchasing power parity. The discount percentage per country is always
578
+ * business-wide. Defaults to `false`.
579
+ */
580
+ purchasing_power_parity?: boolean;
581
+
581
582
  /**
582
583
  * Indicates if the price is tax inclusive
583
584
  */
@@ -632,12 +633,6 @@ export namespace Price {
632
633
  */
633
634
  payment_frequency_interval: SubscriptionsAPI.TimeInterval;
634
635
 
635
- /**
636
- * Indicates if purchasing power parity adjustments are applied to the price.
637
- * Purchasing power parity feature is not available as of now
638
- */
639
- purchasing_power_parity: boolean;
640
-
641
636
  /**
642
637
  * Number of units for the subscription period. For example, a value of `12` with a
643
638
  * `subscription_period_interval` of `month` represents a one-year subscription.
@@ -653,6 +648,14 @@ export namespace Price {
653
648
 
654
649
  meters?: Array<ProductsAPI.AddMeterToPrice> | null;
655
650
 
651
+ /**
652
+ * Opts this price in to purchasing power parity. The business must also enable
653
+ * purchasing power parity. The discount percentage per country is always
654
+ * business-wide. Applies to the fixed fee only, never to metered usage. Defaults
655
+ * to `false`.
656
+ */
657
+ purchasing_power_parity?: boolean;
658
+
656
659
  /**
657
660
  * Indicates if the price is tax inclusive
658
661
  */
@@ -91,7 +91,7 @@ export class Subscriptions extends APIResource {
91
91
  /**
92
92
  * @example
93
93
  * ```ts
94
- * await client.subscriptions.changePlan(
94
+ * const response = await client.subscriptions.changePlan(
95
95
  * 'sub_Iuaq622bbmmfOGrVTqdXv',
96
96
  * {
97
97
  * product_id: 'product_id',
@@ -105,12 +105,8 @@ export class Subscriptions extends APIResource {
105
105
  subscriptionID: string,
106
106
  body: SubscriptionChangePlanParams,
107
107
  options?: RequestOptions,
108
- ): APIPromise<void> {
109
- return this._client.post(path`/subscriptions/${subscriptionID}/change-plan`, {
110
- body,
111
- ...options,
112
- headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
113
- });
108
+ ): APIPromise<SubscriptionChangePlanResponse> {
109
+ return this._client.post(path`/subscriptions/${subscriptionID}/change-plan`, { body, ...options });
114
110
  }
115
111
 
116
112
  /**
@@ -699,7 +695,8 @@ export type SubscriptionStatus =
699
695
  | 'paused'
700
696
  | 'cancelled'
701
697
  | 'failed'
702
- | 'expired';
698
+ | 'expired'
699
+ | 'past_due';
703
700
 
704
701
  /**
705
702
  * Unit of a duration count (e.g. license-key validity period).
@@ -738,6 +735,34 @@ export interface UpdateSubscriptionPlanReq {
738
735
  */
739
736
  addons?: Array<AttachAddon> | null;
740
737
 
738
+ /**
739
+ * Replace a scheduled plan change with this one.
740
+ *
741
+ * The scheduled change is cancelled by the transaction that applies this change. A
742
+ * change that never applies leaves the schedule in place.
743
+ *
744
+ * `effective_at: next_billing_date` is allowed. The new schedule then replaces the
745
+ * old one in the request transaction.
746
+ *
747
+ * A pending plan change still gets a `409`. This field does not affect it.
748
+ *
749
+ * The preview route shares this request body, so a preview that sets this field
750
+ * also passes the scheduled-change `409`.
751
+ */
752
+ cancel_scheduled_change_plan?: boolean;
753
+
754
+ /**
755
+ * Collect the plan-change amount with a payment link. The customer then pays on a
756
+ * checkout page.
757
+ *
758
+ * The business needs the `allow_plan_change_via_payment_link` capability. The
759
+ * request needs `effective_at: immediately`. The request also needs
760
+ * `on_payment_failure: prevent_change`.
761
+ *
762
+ * The preview route shares this request body and ignores this field.
763
+ */
764
+ collect_via_payment_link?: boolean;
765
+
741
766
  /**
742
767
  * @deprecated Use `discount_id` instead.
743
768
  */
@@ -1039,6 +1064,35 @@ export namespace SubscriptionListResponse {
1039
1064
  }
1040
1065
  }
1041
1066
 
1067
+ /**
1068
+ * Handles for a hosted checkout page that settles a plan change.
1069
+ *
1070
+ * The four fields repeat `UpdatePaymentMethodResponse` and a subset of
1071
+ * `CreateSubscriptionResponse`. A shared type would rename the generated SDK types
1072
+ * for all three routes, so each route keeps its own.
1073
+ */
1074
+ export interface SubscriptionChangePlanResponse {
1075
+ /**
1076
+ * Client secret for an embedded checkout.
1077
+ */
1078
+ client_secret?: string | null;
1079
+
1080
+ /**
1081
+ * When the link stops working.
1082
+ */
1083
+ expires_on?: string | null;
1084
+
1085
+ /**
1086
+ * Id of the payment that settles the plan change.
1087
+ */
1088
+ payment_id?: string | null;
1089
+
1090
+ /**
1091
+ * Checkout page URL. Give this to the customer.
1092
+ */
1093
+ payment_link?: string | null;
1094
+ }
1095
+
1042
1096
  export interface SubscriptionChargeResponse {
1043
1097
  payment_id: string;
1044
1098
  }
@@ -1339,7 +1393,7 @@ export interface SubscriptionListParams extends DefaultPageNumberPaginationParam
1339
1393
  /**
1340
1394
  * Filter by status
1341
1395
  */
1342
- status?: 'pending' | 'active' | 'on_hold' | 'paused' | 'cancelled' | 'failed' | 'expired';
1396
+ status?: 'pending' | 'active' | 'on_hold' | 'paused' | 'cancelled' | 'failed' | 'expired' | 'past_due';
1343
1397
  }
1344
1398
 
1345
1399
  export interface SubscriptionCreateParams {
@@ -1495,6 +1549,7 @@ export interface SubscriptionUpdateParams {
1495
1549
  | 'cancelled_by_customer'
1496
1550
  | 'cancelled_by_merchant'
1497
1551
  | 'cancelled_by_merchant_send_dunning'
1552
+ | 'cancelled_by_merchant_grace_period_expired'
1498
1553
  | 'dodo_team'
1499
1554
  | null;
1500
1555
 
@@ -1535,11 +1590,25 @@ export interface SubscriptionUpdateParams {
1535
1590
  next_billing_date?: string | null;
1536
1591
 
1537
1592
  /**
1538
- * `Some(true)` pauses an active subscription; `Some(false)` unpauses a `Paused`
1539
- * (or abandoned `OnHold`) subscription. Exclusive of every other field.
1593
+ * Removed. Use `status: paused` to pause and `status: active` to resume. This
1594
+ * field always fails with 422, so a caller still on it gets a loud error instead
1595
+ * of a silent no-op.
1540
1596
  */
1541
1597
  pause?: boolean | null;
1542
1598
 
1599
+ /**
1600
+ * Set to `cancelled` to cancel the subscription. See `cancel_reason`,
1601
+ * `cancellation_feedback`, `cancellation_comment`, and
1602
+ * `cancel_at_next_billing_date` for cancellation options.
1603
+ *
1604
+ * Set to `paused` to pause an active subscription. Set to `active` to resume a
1605
+ * `paused` subscription. `active` also resumes an `on_hold` subscription that has
1606
+ * an unpaid pause invoice. This voids that invoice.
1607
+ *
1608
+ * Send `paused` or `active` alone. A request that combines either with any other
1609
+ * field fails with 422. `cancelled` is not exclusive this way — see
1610
+ * `cancel_reason` and friends below.
1611
+ */
1543
1612
  status?: SubscriptionStatus | null;
1544
1613
 
1545
1614
  /**
@@ -1680,6 +1749,34 @@ export interface SubscriptionChangePlanParams {
1680
1749
  */
1681
1750
  addons?: Array<AttachAddon> | null;
1682
1751
 
1752
+ /**
1753
+ * Replace a scheduled plan change with this one.
1754
+ *
1755
+ * The scheduled change is cancelled by the transaction that applies this change. A
1756
+ * change that never applies leaves the schedule in place.
1757
+ *
1758
+ * `effective_at: next_billing_date` is allowed. The new schedule then replaces the
1759
+ * old one in the request transaction.
1760
+ *
1761
+ * A pending plan change still gets a `409`. This field does not affect it.
1762
+ *
1763
+ * The preview route shares this request body, so a preview that sets this field
1764
+ * also passes the scheduled-change `409`.
1765
+ */
1766
+ cancel_scheduled_change_plan?: boolean;
1767
+
1768
+ /**
1769
+ * Collect the plan-change amount with a payment link. The customer then pays on a
1770
+ * checkout page.
1771
+ *
1772
+ * The business needs the `allow_plan_change_via_payment_link` capability. The
1773
+ * request needs `effective_at: immediately`. The request also needs
1774
+ * `on_payment_failure: prevent_change`.
1775
+ *
1776
+ * The preview route shares this request body and ignores this field.
1777
+ */
1778
+ collect_via_payment_link?: boolean;
1779
+
1683
1780
  /**
1684
1781
  * @deprecated Use `discount_id` instead.
1685
1782
  */
@@ -1796,6 +1893,34 @@ export interface SubscriptionPreviewChangePlanParams {
1796
1893
  */
1797
1894
  addons?: Array<AttachAddon> | null;
1798
1895
 
1896
+ /**
1897
+ * Replace a scheduled plan change with this one.
1898
+ *
1899
+ * The scheduled change is cancelled by the transaction that applies this change. A
1900
+ * change that never applies leaves the schedule in place.
1901
+ *
1902
+ * `effective_at: next_billing_date` is allowed. The new schedule then replaces the
1903
+ * old one in the request transaction.
1904
+ *
1905
+ * A pending plan change still gets a `409`. This field does not affect it.
1906
+ *
1907
+ * The preview route shares this request body, so a preview that sets this field
1908
+ * also passes the scheduled-change `409`.
1909
+ */
1910
+ cancel_scheduled_change_plan?: boolean;
1911
+
1912
+ /**
1913
+ * Collect the plan-change amount with a payment link. The customer then pays on a
1914
+ * checkout page.
1915
+ *
1916
+ * The business needs the `allow_plan_change_via_payment_link` capability. The
1917
+ * request needs `effective_at: immediately`. The request also needs
1918
+ * `on_payment_failure: prevent_change`.
1919
+ *
1920
+ * The preview route shares this request body and ignores this field.
1921
+ */
1922
+ collect_via_payment_link?: boolean;
1923
+
1799
1924
  /**
1800
1925
  * @deprecated Use `discount_id` instead.
1801
1926
  */
@@ -1851,6 +1976,7 @@ export declare namespace Subscriptions {
1851
1976
  type UpdateSubscriptionPlanReq as UpdateSubscriptionPlanReq,
1852
1977
  type SubscriptionCreateResponse as SubscriptionCreateResponse,
1853
1978
  type SubscriptionListResponse as SubscriptionListResponse,
1979
+ type SubscriptionChangePlanResponse as SubscriptionChangePlanResponse,
1854
1980
  type SubscriptionChargeResponse as SubscriptionChargeResponse,
1855
1981
  type SubscriptionPreviewChangePlanResponse as SubscriptionPreviewChangePlanResponse,
1856
1982
  type SubscriptionRetrieveCreditUsageResponse as SubscriptionRetrieveCreditUsageResponse,
@@ -32,6 +32,7 @@ export type WebhookEventType =
32
32
  | 'subscription.active'
33
33
  | 'subscription.renewed'
34
34
  | 'subscription.on_hold'
35
+ | 'subscription.past_due'
35
36
  | 'subscription.paused'
36
37
  | 'subscription.unpaused'
37
38
  | 'subscription.cancelled'
@@ -105,6 +106,17 @@ export namespace WebhookPayload {
105
106
  */
106
107
  export interface Subscription extends SubscriptionsAPI.Subscription {
107
108
  payload_type: 'Subscription';
109
+
110
+ /**
111
+ * Time when the grace period ends. The subscription moves to `on_hold` or to
112
+ * `cancelled` at this time.
113
+ *
114
+ * Read in the same query as the rest of the payload, so it always comes from the
115
+ * row snapshot that produced `status`. It is set whenever the subscription sits in
116
+ * a window at that moment. A delayed event of another type therefore carries the
117
+ * deadline too, next to a `past_due` status.
118
+ */
119
+ past_due_ends_at?: string | null;
108
120
  }
109
121
 
110
122
  export interface Refund extends RefundsAPI.Refund {
@@ -270,7 +282,7 @@ export namespace WebhookPayload {
270
282
 
271
283
  subscription_id: string;
272
284
 
273
- trigger_state: 'on_hold' | 'cancelled';
285
+ trigger_state: 'on_hold' | 'cancelled' | 'past_due';
274
286
 
275
287
  payment_id?: string | null;
276
288
  }
@@ -46,6 +46,7 @@ export {
46
46
  type SubscriptionExpiredWebhookEvent,
47
47
  type SubscriptionFailedWebhookEvent,
48
48
  type SubscriptionOnHoldWebhookEvent,
49
+ type SubscriptionPastDueWebhookEvent,
49
50
  type SubscriptionPausedWebhookEvent,
50
51
  type SubscriptionPlanChangedWebhookEvent,
51
52
  type SubscriptionRenewedWebhookEvent,