dodopayments 2.23.2 → 2.24.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 (142) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/bin/migration-config.json +187 -0
  3. package/client.d.mts +6 -0
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +6 -0
  6. package/client.d.ts.map +1 -1
  7. package/client.js +9 -2
  8. package/client.js.map +1 -1
  9. package/client.mjs +9 -2
  10. package/client.mjs.map +1 -1
  11. package/package.json +12 -1
  12. package/resources/checkout-sessions.d.mts +17 -2
  13. package/resources/checkout-sessions.d.mts.map +1 -1
  14. package/resources/checkout-sessions.d.ts +17 -2
  15. package/resources/checkout-sessions.d.ts.map +1 -1
  16. package/resources/customers/customer-portal.d.mts +5 -0
  17. package/resources/customers/customer-portal.d.mts.map +1 -1
  18. package/resources/customers/customer-portal.d.ts +5 -0
  19. package/resources/customers/customer-portal.d.ts.map +1 -1
  20. package/resources/customers/customer-portal.js +2 -2
  21. package/resources/customers/customer-portal.js.map +1 -1
  22. package/resources/customers/customer-portal.mjs +2 -2
  23. package/resources/customers/customer-portal.mjs.map +1 -1
  24. package/resources/customers/customers.d.mts +5 -0
  25. package/resources/customers/customers.d.mts.map +1 -1
  26. package/resources/customers/customers.d.ts +5 -0
  27. package/resources/customers/customers.d.ts.map +1 -1
  28. package/resources/customers/customers.js.map +1 -1
  29. package/resources/customers/customers.mjs.map +1 -1
  30. package/resources/index.d.mts +2 -0
  31. package/resources/index.d.mts.map +1 -1
  32. package/resources/index.d.ts +2 -0
  33. package/resources/index.d.ts.map +1 -1
  34. package/resources/index.js +5 -1
  35. package/resources/index.js.map +1 -1
  36. package/resources/index.mjs +2 -0
  37. package/resources/index.mjs.map +1 -1
  38. package/resources/invoices/payments.d.mts +1 -0
  39. package/resources/invoices/payments.d.mts.map +1 -1
  40. package/resources/invoices/payments.d.ts +1 -0
  41. package/resources/invoices/payments.d.ts.map +1 -1
  42. package/resources/invoices/payments.js +7 -0
  43. package/resources/invoices/payments.js.map +1 -1
  44. package/resources/invoices/payments.mjs +7 -0
  45. package/resources/invoices/payments.mjs.map +1 -1
  46. package/resources/payments.d.mts +5 -0
  47. package/resources/payments.d.mts.map +1 -1
  48. package/resources/payments.d.ts +5 -0
  49. package/resources/payments.d.ts.map +1 -1
  50. package/resources/product-collections/groups/groups.d.mts +107 -0
  51. package/resources/product-collections/groups/groups.d.mts.map +1 -0
  52. package/resources/product-collections/groups/groups.d.ts +107 -0
  53. package/resources/product-collections/groups/groups.d.ts.map +1 -0
  54. package/resources/product-collections/groups/groups.js +37 -0
  55. package/resources/product-collections/groups/groups.js.map +1 -0
  56. package/resources/product-collections/groups/groups.mjs +32 -0
  57. package/resources/product-collections/groups/groups.mjs.map +1 -0
  58. package/resources/product-collections/groups/index.d.mts +3 -0
  59. package/resources/product-collections/groups/index.d.mts.map +1 -0
  60. package/resources/product-collections/groups/index.d.ts +3 -0
  61. package/resources/product-collections/groups/index.d.ts.map +1 -0
  62. package/resources/product-collections/groups/index.js +9 -0
  63. package/resources/product-collections/groups/index.js.map +1 -0
  64. package/resources/product-collections/groups/index.mjs +4 -0
  65. package/resources/product-collections/groups/index.mjs.map +1 -0
  66. package/resources/product-collections/groups/items.d.mts +91 -0
  67. package/resources/product-collections/groups/items.d.mts.map +1 -0
  68. package/resources/product-collections/groups/items.d.ts +91 -0
  69. package/resources/product-collections/groups/items.d.ts.map +1 -0
  70. package/resources/product-collections/groups/items.js +30 -0
  71. package/resources/product-collections/groups/items.js.map +1 -0
  72. package/resources/product-collections/groups/items.mjs +26 -0
  73. package/resources/product-collections/groups/items.mjs.map +1 -0
  74. package/resources/product-collections/groups.d.mts +2 -0
  75. package/resources/product-collections/groups.d.mts.map +1 -0
  76. package/resources/product-collections/groups.d.ts +2 -0
  77. package/resources/product-collections/groups.d.ts.map +1 -0
  78. package/resources/product-collections/groups.js +6 -0
  79. package/resources/product-collections/groups.js.map +1 -0
  80. package/resources/product-collections/groups.mjs +3 -0
  81. package/resources/product-collections/groups.mjs.map +1 -0
  82. package/resources/product-collections/index.d.mts +3 -0
  83. package/resources/product-collections/index.d.mts.map +1 -0
  84. package/resources/product-collections/index.d.ts +3 -0
  85. package/resources/product-collections/index.d.ts.map +1 -0
  86. package/resources/product-collections/index.js +9 -0
  87. package/resources/product-collections/index.js.map +1 -0
  88. package/resources/product-collections/index.mjs +4 -0
  89. package/resources/product-collections/index.mjs.map +1 -0
  90. package/resources/product-collections/product-collections.d.mts +307 -0
  91. package/resources/product-collections/product-collections.d.mts.map +1 -0
  92. package/resources/product-collections/product-collections.d.ts +307 -0
  93. package/resources/product-collections/product-collections.d.ts.map +1 -0
  94. package/resources/product-collections/product-collections.js +49 -0
  95. package/resources/product-collections/product-collections.js.map +1 -0
  96. package/resources/product-collections/product-collections.mjs +44 -0
  97. package/resources/product-collections/product-collections.mjs.map +1 -0
  98. package/resources/product-collections.d.mts +2 -0
  99. package/resources/product-collections.d.mts.map +1 -0
  100. package/resources/product-collections.d.ts +2 -0
  101. package/resources/product-collections.d.ts.map +1 -0
  102. package/resources/product-collections.js +6 -0
  103. package/resources/product-collections.js.map +1 -0
  104. package/resources/product-collections.mjs +3 -0
  105. package/resources/product-collections.mjs.map +1 -0
  106. package/resources/subscriptions.d.mts +147 -3
  107. package/resources/subscriptions.d.mts.map +1 -1
  108. package/resources/subscriptions.d.ts +147 -3
  109. package/resources/subscriptions.d.ts.map +1 -1
  110. package/resources/subscriptions.js +6 -0
  111. package/resources/subscriptions.js.map +1 -1
  112. package/resources/subscriptions.mjs +6 -0
  113. package/resources/subscriptions.mjs.map +1 -1
  114. package/resources/your-webhook-url.d.mts +85 -0
  115. package/resources/your-webhook-url.d.mts.map +1 -0
  116. package/resources/your-webhook-url.d.ts +85 -0
  117. package/resources/your-webhook-url.d.ts.map +1 -0
  118. package/resources/your-webhook-url.js +26 -0
  119. package/resources/your-webhook-url.js.map +1 -0
  120. package/resources/your-webhook-url.mjs +22 -0
  121. package/resources/your-webhook-url.mjs.map +1 -0
  122. package/src/client.ts +37 -2
  123. package/src/resources/checkout-sessions.ts +20 -2
  124. package/src/resources/customers/customer-portal.ts +8 -2
  125. package/src/resources/customers/customers.ts +5 -0
  126. package/src/resources/index.ts +14 -0
  127. package/src/resources/invoices/payments.ts +8 -0
  128. package/src/resources/payments.ts +5 -0
  129. package/src/resources/product-collections/groups/groups.ts +174 -0
  130. package/src/resources/product-collections/groups/index.ts +16 -0
  131. package/src/resources/product-collections/groups/items.ts +149 -0
  132. package/src/resources/product-collections/groups.ts +3 -0
  133. package/src/resources/product-collections/index.ts +22 -0
  134. package/src/resources/product-collections/product-collections.ts +472 -0
  135. package/src/resources/product-collections.ts +3 -0
  136. package/src/resources/subscriptions.ts +193 -3
  137. package/src/resources/your-webhook-url.ts +138 -0
  138. package/src/version.ts +1 -1
  139. package/version.d.mts +1 -1
  140. package/version.d.ts +1 -1
  141. package/version.js +1 -1
  142. package/version.mjs +1 -1
@@ -45,6 +45,13 @@ export class Subscriptions extends APIResource {
45
45
  });
46
46
  }
47
47
 
48
+ cancelChangePlan(subscriptionID: string, options?: RequestOptions): APIPromise<void> {
49
+ return this._client.delete(path`/subscriptions/${subscriptionID}/change-plan/scheduled`, {
50
+ ...options,
51
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
52
+ });
53
+ }
54
+
48
55
  changePlan(
49
56
  subscriptionID: string,
50
57
  body: SubscriptionChangePlanParams,
@@ -458,12 +465,83 @@ export interface Subscription {
458
465
  */
459
466
  payment_method_id?: string | null;
460
467
 
468
+ /**
469
+ * Scheduled plan change details, if any
470
+ */
471
+ scheduled_change?: Subscription.ScheduledChange | null;
472
+
461
473
  /**
462
474
  * Tax identifier provided for this subscription (if applicable)
463
475
  */
464
476
  tax_id?: string | null;
465
477
  }
466
478
 
479
+ export namespace Subscription {
480
+ /**
481
+ * Scheduled plan change details, if any
482
+ */
483
+ export interface ScheduledChange {
484
+ /**
485
+ * The scheduled plan change ID
486
+ */
487
+ id: string;
488
+
489
+ /**
490
+ * Addons included in the scheduled change
491
+ */
492
+ addons: Array<ScheduledChange.Addon>;
493
+
494
+ /**
495
+ * When this scheduled change was created
496
+ */
497
+ created_at: string;
498
+
499
+ /**
500
+ * When the change will be applied
501
+ */
502
+ effective_at: string;
503
+
504
+ /**
505
+ * The product ID the subscription will change to
506
+ */
507
+ product_id: string;
508
+
509
+ /**
510
+ * Quantity for the new plan
511
+ */
512
+ quantity: number;
513
+
514
+ /**
515
+ * Description of the product being changed to
516
+ */
517
+ product_description?: string | null;
518
+
519
+ /**
520
+ * Name of the product being changed to
521
+ */
522
+ product_name?: string | null;
523
+ }
524
+
525
+ export namespace ScheduledChange {
526
+ export interface Addon {
527
+ /**
528
+ * The addon ID
529
+ */
530
+ addon_id: string;
531
+
532
+ /**
533
+ * Name of the addon
534
+ */
535
+ name: string;
536
+
537
+ /**
538
+ * Quantity of the addon
539
+ */
540
+ quantity: number;
541
+ }
542
+ }
543
+ }
544
+
467
545
  export type SubscriptionStatus = 'pending' | 'active' | 'on_hold' | 'cancelled' | 'failed' | 'expired';
468
546
 
469
547
  export type TimeInterval = 'Day' | 'Week' | 'Month' | 'Year';
@@ -477,7 +555,11 @@ export interface UpdateSubscriptionPlanReq {
477
555
  /**
478
556
  * Proration Billing Mode
479
557
  */
480
- proration_billing_mode: 'prorated_immediately' | 'full_immediately' | 'difference_immediately';
558
+ proration_billing_mode:
559
+ | 'prorated_immediately'
560
+ | 'full_immediately'
561
+ | 'difference_immediately'
562
+ | 'do_not_bill';
481
563
 
482
564
  /**
483
565
  * Number of units to subscribe for. Must be at least 1.
@@ -498,6 +580,14 @@ export interface UpdateSubscriptionPlanReq {
498
580
  */
499
581
  discount_code?: string | null;
500
582
 
583
+ /**
584
+ * When to apply the plan change.
585
+ *
586
+ * - `immediately` (default): Apply the plan change right away
587
+ * - `next_billing_date`: Schedule the change for the next billing date
588
+ */
589
+ effective_at?: 'immediately' | 'next_billing_date';
590
+
501
591
  /**
502
592
  * Metadata for the payment. If not passed, the metadata of the subscription will
503
593
  * be taken
@@ -706,12 +796,83 @@ export interface SubscriptionListResponse {
706
796
  */
707
797
  product_name?: string | null;
708
798
 
799
+ /**
800
+ * Scheduled plan change details, if any
801
+ */
802
+ scheduled_change?: SubscriptionListResponse.ScheduledChange | null;
803
+
709
804
  /**
710
805
  * Tax identifier provided for this subscription (if applicable)
711
806
  */
712
807
  tax_id?: string | null;
713
808
  }
714
809
 
810
+ export namespace SubscriptionListResponse {
811
+ /**
812
+ * Scheduled plan change details, if any
813
+ */
814
+ export interface ScheduledChange {
815
+ /**
816
+ * The scheduled plan change ID
817
+ */
818
+ id: string;
819
+
820
+ /**
821
+ * Addons included in the scheduled change
822
+ */
823
+ addons: Array<ScheduledChange.Addon>;
824
+
825
+ /**
826
+ * When this scheduled change was created
827
+ */
828
+ created_at: string;
829
+
830
+ /**
831
+ * When the change will be applied
832
+ */
833
+ effective_at: string;
834
+
835
+ /**
836
+ * The product ID the subscription will change to
837
+ */
838
+ product_id: string;
839
+
840
+ /**
841
+ * Quantity for the new plan
842
+ */
843
+ quantity: number;
844
+
845
+ /**
846
+ * Description of the product being changed to
847
+ */
848
+ product_description?: string | null;
849
+
850
+ /**
851
+ * Name of the product being changed to
852
+ */
853
+ product_name?: string | null;
854
+ }
855
+
856
+ export namespace ScheduledChange {
857
+ export interface Addon {
858
+ /**
859
+ * The addon ID
860
+ */
861
+ addon_id: string;
862
+
863
+ /**
864
+ * Name of the addon
865
+ */
866
+ name: string;
867
+
868
+ /**
869
+ * Quantity of the addon
870
+ */
871
+ quantity: number;
872
+ }
873
+ }
874
+ }
875
+
715
876
  export interface SubscriptionChargeResponse {
716
877
  payment_id: string;
717
878
  }
@@ -727,6 +888,11 @@ export interface SubscriptionPreviewChangePlanResponse {
727
888
 
728
889
  export namespace SubscriptionPreviewChangePlanResponse {
729
890
  export interface ImmediateCharge {
891
+ /**
892
+ * When the plan change will be effective
893
+ */
894
+ effective_at: string;
895
+
730
896
  line_items: Array<ImmediateCharge.Subscription | ImmediateCharge.Addon | ImmediateCharge.Meter>;
731
897
 
732
898
  summary: ImmediateCharge.Summary;
@@ -1188,7 +1354,11 @@ export interface SubscriptionChangePlanParams {
1188
1354
  /**
1189
1355
  * Proration Billing Mode
1190
1356
  */
1191
- proration_billing_mode: 'prorated_immediately' | 'full_immediately' | 'difference_immediately';
1357
+ proration_billing_mode:
1358
+ | 'prorated_immediately'
1359
+ | 'full_immediately'
1360
+ | 'difference_immediately'
1361
+ | 'do_not_bill';
1192
1362
 
1193
1363
  /**
1194
1364
  * Number of units to subscribe for. Must be at least 1.
@@ -1209,6 +1379,14 @@ export interface SubscriptionChangePlanParams {
1209
1379
  */
1210
1380
  discount_code?: string | null;
1211
1381
 
1382
+ /**
1383
+ * When to apply the plan change.
1384
+ *
1385
+ * - `immediately` (default): Apply the plan change right away
1386
+ * - `next_billing_date`: Schedule the change for the next billing date
1387
+ */
1388
+ effective_at?: 'immediately' | 'next_billing_date';
1389
+
1212
1390
  /**
1213
1391
  * Metadata for the payment. If not passed, the metadata of the subscription will
1214
1392
  * be taken
@@ -1291,7 +1469,11 @@ export interface SubscriptionPreviewChangePlanParams {
1291
1469
  /**
1292
1470
  * Proration Billing Mode
1293
1471
  */
1294
- proration_billing_mode: 'prorated_immediately' | 'full_immediately' | 'difference_immediately';
1472
+ proration_billing_mode:
1473
+ | 'prorated_immediately'
1474
+ | 'full_immediately'
1475
+ | 'difference_immediately'
1476
+ | 'do_not_bill';
1295
1477
 
1296
1478
  /**
1297
1479
  * Number of units to subscribe for. Must be at least 1.
@@ -1312,6 +1494,14 @@ export interface SubscriptionPreviewChangePlanParams {
1312
1494
  */
1313
1495
  discount_code?: string | null;
1314
1496
 
1497
+ /**
1498
+ * When to apply the plan change.
1499
+ *
1500
+ * - `immediately` (default): Apply the plan change right away
1501
+ * - `next_billing_date`: Schedule the change for the next billing date
1502
+ */
1503
+ effective_at?: 'immediately' | 'next_billing_date';
1504
+
1315
1505
  /**
1316
1506
  * Metadata for the payment. If not passed, the metadata of the subscription will
1317
1507
  * be taken
@@ -0,0 +1,138 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as DisputesAPI from './disputes';
5
+ import * as LicenseKeysAPI from './license-keys';
6
+ import * as PaymentsAPI from './payments';
7
+ import * as RefundsAPI from './refunds';
8
+ import * as SubscriptionsAPI from './subscriptions';
9
+ import * as WebhookEventsAPI from './webhook-events';
10
+ import * as BalancesAPI from './credit-entitlements/balances';
11
+ import { APIPromise } from '../core/api-promise';
12
+ import { buildHeaders } from '../internal/headers';
13
+ import { RequestOptions } from '../internal/request-options';
14
+
15
+ export class YourWebhookURL extends APIResource {
16
+ create(params: YourWebhookURLCreateParams, options?: RequestOptions): APIPromise<void> {
17
+ const {
18
+ 'webhook-id': webhookID,
19
+ 'webhook-signature': webhookSignature,
20
+ 'webhook-timestamp': webhookTimestamp,
21
+ ...body
22
+ } = params;
23
+ return this._client.post('/your-webhook-url', {
24
+ body,
25
+ ...options,
26
+ headers: buildHeaders([
27
+ {
28
+ Accept: '*/*',
29
+ 'webhook-id': webhookID,
30
+ 'webhook-signature': webhookSignature,
31
+ 'webhook-timestamp': webhookTimestamp,
32
+ },
33
+ options?.headers,
34
+ ]),
35
+ });
36
+ }
37
+ }
38
+
39
+ export interface YourWebhookURLCreateParams {
40
+ /**
41
+ * Body param
42
+ */
43
+ business_id: string;
44
+
45
+ /**
46
+ * Body param: The latest data at the time of delivery attempt
47
+ */
48
+ data:
49
+ | YourWebhookURLCreateParams.Payment
50
+ | YourWebhookURLCreateParams.Subscription
51
+ | YourWebhookURLCreateParams.Refund
52
+ | YourWebhookURLCreateParams.Dispute
53
+ | YourWebhookURLCreateParams.LicenseKey
54
+ | YourWebhookURLCreateParams.CreditLedgerEntry
55
+ | YourWebhookURLCreateParams.CreditBalanceLow;
56
+
57
+ /**
58
+ * Body param: The timestamp of when the event occurred (not necessarily the same
59
+ * of when it was delivered)
60
+ */
61
+ timestamp: string;
62
+
63
+ /**
64
+ * Body param: Event types for Dodo events
65
+ */
66
+ type: WebhookEventsAPI.WebhookEventType;
67
+
68
+ /**
69
+ * Header param: Unique identifier for the webhook
70
+ */
71
+ 'webhook-id': string;
72
+
73
+ /**
74
+ * Header param: Signature of the Webhook
75
+ */
76
+ 'webhook-signature': string;
77
+
78
+ /**
79
+ * Header param: Unix timestamp when the webhook was sent
80
+ */
81
+ 'webhook-timestamp': string;
82
+ }
83
+
84
+ export namespace YourWebhookURLCreateParams {
85
+ export interface Payment extends PaymentsAPI.Payment {
86
+ payload_type: 'Payment';
87
+ }
88
+
89
+ /**
90
+ * Response struct representing subscription details
91
+ */
92
+ export interface Subscription extends SubscriptionsAPI.Subscription {
93
+ payload_type: 'Subscription';
94
+ }
95
+
96
+ export interface Refund extends RefundsAPI.Refund {
97
+ payload_type: 'Refund';
98
+ }
99
+
100
+ export interface Dispute extends DisputesAPI.GetDispute {
101
+ payload_type: 'Dispute';
102
+ }
103
+
104
+ export interface LicenseKey extends LicenseKeysAPI.LicenseKey {
105
+ payload_type: 'LicenseKey';
106
+ }
107
+
108
+ /**
109
+ * Response for a ledger entry
110
+ */
111
+ export interface CreditLedgerEntry extends BalancesAPI.CreditLedgerEntry {
112
+ payload_type: 'CreditLedgerEntry';
113
+ }
114
+
115
+ export interface CreditBalanceLow {
116
+ available_balance: string;
117
+
118
+ credit_entitlement_id: string;
119
+
120
+ credit_entitlement_name: string;
121
+
122
+ customer_id: string;
123
+
124
+ payload_type: 'CreditBalanceLow';
125
+
126
+ subscription_credits_amount: string;
127
+
128
+ subscription_id: string;
129
+
130
+ threshold_amount: string;
131
+
132
+ threshold_percent: number;
133
+ }
134
+ }
135
+
136
+ export declare namespace YourWebhookURL {
137
+ export { type YourWebhookURLCreateParams as YourWebhookURLCreateParams };
138
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '2.23.2'; // x-release-please-version
1
+ export const VERSION = '2.24.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.23.2";
1
+ export declare const VERSION = "2.24.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.23.2";
1
+ export declare const VERSION = "2.24.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '2.23.2'; // x-release-please-version
4
+ exports.VERSION = '2.24.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.23.2'; // x-release-please-version
1
+ export const VERSION = '2.24.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map