@commet/node 9.6.0 → 9.8.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 (96) hide show
  1. package/dist/index.d.mts +258 -51
  2. package/dist/index.d.ts +258 -51
  3. package/dist/index.js +47 -11
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +47 -11
  6. package/dist/index.mjs.map +1 -1
  7. package/docs/ai-onboarding/commet-skill.md +1 -1
  8. package/docs/ai-onboarding/mcp-server.md +2 -2
  9. package/docs/api-reference/customers.md +4 -2
  10. package/docs/api-reference/index.md +2 -2
  11. package/docs/api-reference/offers.md +2 -2
  12. package/docs/api-reference/plans.md +9 -1
  13. package/docs/api-reference/promo-codes.md +3 -1
  14. package/docs/api-reference/subscriptions.md +106 -8
  15. package/docs/api-reference/usage.md +0 -4
  16. package/docs/documentation/better-auth.md +1 -8
  17. package/docs/documentation/customers/customer-portal.md +1 -7
  18. package/docs/documentation/customers/manage-customers.md +0 -6
  19. package/docs/documentation/error-handling.md +1 -1
  20. package/docs/documentation/finance/acceptable-use.md +1 -6
  21. package/docs/documentation/finance/finance-overview.md +0 -5
  22. package/docs/documentation/finance/local-currency-taxes.md +0 -6
  23. package/docs/documentation/finance/merchant-of-record.md +0 -7
  24. package/docs/documentation/finance/payouts-verification.md +0 -5
  25. package/docs/documentation/finance/payouts.md +0 -6
  26. package/docs/documentation/finance/supported-countries.md +1 -6
  27. package/docs/documentation/go/integrate-with-encore.md +1 -8
  28. package/docs/documentation/go/integrate-with-go.md +1 -8
  29. package/docs/documentation/invoicing/handle-failed-payments.md +3 -9
  30. package/docs/documentation/invoicing/invoices-and-billing-cycles.md +0 -6
  31. package/docs/documentation/java/integrate-with-java.md +1 -5
  32. package/docs/documentation/nodejs/integrate-with-astro.md +1 -8
  33. package/docs/documentation/nodejs/integrate-with-bun.md +1 -8
  34. package/docs/documentation/nodejs/integrate-with-express.md +1 -8
  35. package/docs/documentation/nodejs/integrate-with-hono.md +1 -8
  36. package/docs/documentation/nodejs/integrate-with-nextjs.md +1 -8
  37. package/docs/documentation/nodejs/integrate-with-nuxt.md +1 -8
  38. package/docs/documentation/nodejs/integrate-with-remix.md +1 -8
  39. package/docs/documentation/nodejs/integrate-with-sveltekit.md +1 -8
  40. package/docs/documentation/payments/accept-one-time-payments.md +0 -8
  41. package/docs/documentation/payments/payment-orchestration.md +0 -6
  42. package/docs/documentation/payments/payment-providers.md +0 -6
  43. package/docs/documentation/php/integrate-with-laravel.md +1 -8
  44. package/docs/documentation/php/integrate-with-php.md +1 -7
  45. package/docs/documentation/php/integrate-with-symfony.md +1 -8
  46. package/docs/documentation/plans/add-ons.md +0 -8
  47. package/docs/documentation/plans/configure-features.md +1 -8
  48. package/docs/documentation/plans/consumption-models.md +0 -7
  49. package/docs/documentation/plans/create-plans.md +0 -9
  50. package/docs/documentation/plans/credit-packs.md +0 -7
  51. package/docs/documentation/plans/one-time-payments.md +36 -7
  52. package/docs/documentation/plans/plan-groups.md +0 -6
  53. package/docs/documentation/python/integrate-with-django.md +1 -8
  54. package/docs/documentation/python/integrate-with-fastapi.md +1 -8
  55. package/docs/documentation/python/integrate-with-flask.md +1 -8
  56. package/docs/documentation/python/integrate-with-python.md +1 -8
  57. package/docs/documentation/sales/introductory-offers.md +1 -9
  58. package/docs/documentation/sales/offers.md +0 -8
  59. package/docs/documentation/sales/promo-codes.md +0 -7
  60. package/docs/documentation/sales/promotional-offers.md +0 -7
  61. package/docs/documentation/sales/regional-prices.md +0 -7
  62. package/docs/documentation/sales/trial-periods.md +0 -8
  63. package/docs/documentation/sdk-reference.md +1 -1
  64. package/docs/documentation/subscriptions/manage-subscriptions.md +2 -9
  65. package/docs/documentation/subscriptions/pay-in-advance.md +161 -0
  66. package/docs/documentation/subscriptions/plan-grants.md +0 -6
  67. package/docs/documentation/subscriptions/upgrade-and-downgrade-plans.md +1 -7
  68. package/docs/documentation/testing-sandbox.md +1 -1
  69. package/docs/documentation/usage/ai-token-billing.md +0 -6
  70. package/docs/documentation/usage/quota-management.md +1 -7
  71. package/docs/documentation/usage/seat-management.md +1 -7
  72. package/docs/documentation/usage/track-usage.md +1 -7
  73. package/docs/errors/customer_deleted.md +22 -0
  74. package/docs/errors/index.md +4 -0
  75. package/docs/errors/managed_by_integration.md +22 -0
  76. package/docs/errors/no_scheduled_plan_change.md +22 -0
  77. package/docs/errors/plan_credit_limit_reached.md +22 -0
  78. package/docs/knowledge-base/how-do-discounts-work.md +0 -8
  79. package/docs/knowledge-base/how-do-free-plans-work-without-payment.md +1 -7
  80. package/docs/knowledge-base/how-do-monthly-quarterly-and-yearly-billing-work.md +0 -6
  81. package/docs/knowledge-base/how-do-trial-periods-work.md +1 -8
  82. package/docs/knowledge-base/how-does-billing-work.md +1 -1
  83. package/docs/knowledge-base/how-does-quota-based-billing-work.md +1 -7
  84. package/docs/knowledge-base/how-does-seat-based-billing-work.md +1 -7
  85. package/docs/knowledge-base/how-is-proration-calculated-when-changing-plans.md +0 -6
  86. package/docs/knowledge-base/what-happens-when-a-customer-changes-plans.md +0 -6
  87. package/docs/knowledge-base/what-happens-when-a-payment-fails.md +1 -7
  88. package/docs/knowledge-base/what-happens-when-you-change-your-prices.md +1 -7
  89. package/docs/knowledge-base/what-invoices-do-customers-receive-and-when.md +1 -7
  90. package/docs/manifest.json +51 -2
  91. package/docs/platform-documentation.md +1 -0
  92. package/docs/schemas.md +46 -8
  93. package/docs/webhooks/introduction.md +3 -3
  94. package/docs/webhooks.md +15 -15
  95. package/docs/webhooks.openapi.json +15 -5
  96. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -189,7 +189,7 @@ var CustomersResource = class {
189
189
  const { id, ...rest } = params;
190
190
  return this.httpClient.patch(`/customers/${id}`, rest, options);
191
191
  }
192
- /** Create up to 100 customers in a single request. */
192
+ /** Create up to 100 customers in a single request. With planGroupId, each customer without an open subscription starts on that group's starting plan (see planGroupId), and the entry of a deleted customer fails with customer_deleted. */
193
193
  async createBatch(params, options) {
194
194
  return this.httpClient.post("/customers/batch", params, options);
195
195
  }
@@ -197,7 +197,7 @@ var CustomersResource = class {
197
197
  async list(params, options) {
198
198
  return this.httpClient.get("/customers", params, options);
199
199
  }
200
- /** Create a new customer. Idempotent when customerId is provided. */
200
+ /** Create a new customer. Idempotent when customerId is provided. With planGroupId, a customer without an open subscription starts on that group's starting plan (see planGroupId), and the externalId of a deleted customer is rejected. */
201
201
  async create(params, options) {
202
202
  return this.httpClient.post("/customers", params, options);
203
203
  }
@@ -536,7 +536,7 @@ var PlansResource = class {
536
536
  const { id } = params;
537
537
  return this.httpClient.get(`/plans/${id}`, void 0, options);
538
538
  }
539
- /** Update a plan's name, description, visibility, or metadata. */
539
+ /** Update a plan's name, description, visibility, default status, metadata, what happens to its unused plan credits, or its plan credit limit. */
540
540
  async update(params, options) {
541
541
  const { id, ...rest } = params;
542
542
  return this.httpClient.patch(`/plans/${id}`, rest, options);
@@ -591,7 +591,7 @@ var PromoCodesResource = class {
591
591
  async list(params, options) {
592
592
  return this.httpClient.get("/promo-codes", params, options);
593
593
  }
594
- /** Create a distribution code for an existing Offer with one or more sequential discount phases and an optional leading trial. The code owns redemption restrictions. */
594
+ /** Create a distribution code for an existing Offer with one or more sequential discount phases. The code owns redemption restrictions. */
595
595
  async create(params, options) {
596
596
  return this.httpClient.post("/promo-codes", params, options);
597
597
  }
@@ -685,6 +685,24 @@ var SubscriptionsResource = class {
685
685
  const { id, ...rest } = params;
686
686
  return this.httpClient.post(`/subscriptions/${id}/addons`, rest, options);
687
687
  }
688
+ /** Read whether the subscription buys credits automatically with its saved payment method when credits reach a threshold, with the top-ups used this period and the last failure. */
689
+ async getAutoTopUp(params, options) {
690
+ const { id } = params;
691
+ return this.httpClient.get(
692
+ `/subscriptions/${id}/auto-top-up`,
693
+ void 0,
694
+ options
695
+ );
696
+ }
697
+ /** Turn automatic credit purchases on or off and set the threshold, the credits each top-up buys and the maximum top-ups per period. Send only the fields that change. Enabling requires a plan that sells credits. The quantity must be at least the plan's purchase minimum when auto top-up is enabled or when the quantity changes, so turning it off keeps working after the minimum rises. Saving it enabled resumes a paused auto top-up. */
698
+ async updateAutoTopUp(params, options) {
699
+ const { id, ...rest } = params;
700
+ return this.httpClient.patch(
701
+ `/subscriptions/${id}/auto-top-up`,
702
+ rest,
703
+ options
704
+ );
705
+ }
688
706
  /** Adjust a subscription's balance or credits by a signed amount. Positive adds, negative subtracts. */
689
707
  async adjustBalance(params, options) {
690
708
  const { id, ...rest } = params;
@@ -708,7 +726,7 @@ var SubscriptionsResource = class {
708
726
  const { id, ...rest } = params;
709
727
  return this.httpClient.post(`/subscriptions/${id}/cancel`, rest, options);
710
728
  }
711
- /** Upgrade or change billing interval immediately, optionally applying an Offer. Scheduled changes do not accept offers. */
729
+ /** Upgrade or change billing interval immediately, optionally applying an Offer by offerId or the Offer of a promoCode. Scheduled changes accept neither offerId nor promoCode. From a free plan, a promoCode opens the checkout with the code applied and counts its use when the checkout is paid; without offerId or promoCode, a destination price whose free trial requires no payment method starts that trial right away without checkout. During a trial without a payment method, an immediate change returns 409 no_payment_method; scheduled changes still apply. */
712
730
  async changePlan(params, options) {
713
731
  const { id, ...rest } = params;
714
732
  return this.httpClient.post(
@@ -717,12 +735,12 @@ var SubscriptionsResource = class {
717
735
  options
718
736
  );
719
737
  }
720
- /** Purchase a credit pack for a subscription. Charges the customer and adds credits to their balance. */
738
+ /** Purchase a fixed credit pack or choose a whole credit quantity at the subscription plan price and minimum. Charges the saved payment method and adds purchased credits. */
721
739
  async purchaseCredits(params, options) {
722
740
  const { id, ...rest } = params;
723
741
  return this.httpClient.post(`/subscriptions/${id}/credits`, rest, options);
724
742
  }
725
- /** Apply a direct Offer to a subscription. On a pending payment checkout it quotes or replaces the checkout discount and the existing checkout URL remains unchanged. On an active subscription it applies the Offer immediately with its discount phases starting at the next billing cycle; the call is rejected while another applied Offer still has active or upcoming discount phases. Offers with a free trial phase cannot be applied after checkout creation. */
743
+ /** Apply a direct Offer to a subscription. On a pending checkout it quotes or replaces the checkout discount, which starts after the plan price trial when there is one, and the existing checkout URL remains unchanged. On an active subscription it applies the Offer immediately with its discount phases starting at the next billing cycle; the call is rejected while another applied Offer still has active or upcoming discount phases. */
726
744
  async applyOffer(params, options) {
727
745
  const { id, ...rest } = params;
728
746
  return this.httpClient.put(`/subscriptions/${id}/offer`, rest, options);
@@ -755,7 +773,7 @@ var SubscriptionsResource = class {
755
773
  options
756
774
  );
757
775
  }
758
- /** Creates a hosted checkout session for the customer to update the subscription's default payment method. */
776
+ /** Creates a hosted checkout to update the payment method of an active, trialing or past_due subscription. Pending-payment subscriptions must use their payment checkout. */
759
777
  async updatePaymentMethod(params, options) {
760
778
  const { id, ...rest } = params;
761
779
  return this.httpClient.post(
@@ -764,7 +782,16 @@ var SubscriptionsResource = class {
764
782
  options
765
783
  );
766
784
  }
767
- /** Preview proration details for an immediate plan change without applying it. Free-to-paid changes are never scheduled and the change-plan endpoint always returns hosted checkout for them. For paid plans, interval direction takes precedence: a longer interval is immediate and a shorter interval is scheduled. When the interval is unchanged, a higher-sort-order plan is immediate and a lower-sort-order plan is scheduled. A paid-to-free change is always scheduled. Returns credit, charge, and net amount. The target plan must belong to the same plan group as the current plan, otherwise a 400 with code `plans_not_in_same_group` is returned. A change between two free plans has nothing to prorate and returns a zero-amount estimate. Scheduled changes return a 400 with code `plan_change_scheduled`; apply those via the change-plan endpoint. Pass offerId to quote the destination plan with an Offer. */
785
+ /** Creates a hosted checkout to pay billing periods of a recurring subscription in advance with any payment method. On an active subscription the paid periods start after the last paid period and replace any open prepaid-periods checkout. On a pending-payment subscription the first payment covers the requested periods and replaces its pending checkout. The billing interval does not change. */
786
+ async createPrepaidPeriodsCheckout(params, options) {
787
+ const { id, ...rest } = params;
788
+ return this.httpClient.post(
789
+ `/subscriptions/${id}/prepaid-periods`,
790
+ rest,
791
+ options
792
+ );
793
+ }
794
+ /** Preview proration details for an immediate plan change without applying it. Free-to-paid changes are never scheduled and the change-plan endpoint returns hosted checkout for them, except a change without offerId or promoCode to a price whose free trial needs no payment method, for a customer who never had that plan: it starts the trial at once, so the preview reports nothing due today. For paid plans, interval direction takes precedence: a longer interval is immediate and a shorter interval is scheduled. When the interval is unchanged, a higher-sort-order plan is immediate and a lower-sort-order plan is scheduled. A paid-to-free change is always scheduled. Returns credit, charge, and net amount. The target plan must belong to the same plan group as the current plan, otherwise a 400 with code `plans_not_in_same_group` is returned. A change between two free plans has nothing to prorate and returns a zero-amount estimate. Scheduled changes return a 400 with code `plan_change_scheduled`; apply those via the change-plan endpoint. Pass offerId to quote the destination plan with an Offer, or promoCode to quote it with the Offer of a promo code validated with the checkout's rules. */
768
795
  async previewChange(params, options) {
769
796
  const { id, ...rest } = params;
770
797
  return this.httpClient.post(
@@ -801,6 +828,15 @@ var SubscriptionsResource = class {
801
828
  const { id } = params;
802
829
  return this.httpClient.get(`/subscriptions/${id}`, void 0, options);
803
830
  }
831
+ /** Revoke the plan or interval change scheduled for the end of the period, so the subscription stays on its current plan. Returns the updated subscription. */
832
+ async revokeScheduledPlanChange(params, options) {
833
+ const { id } = params;
834
+ return this.httpClient.delete(
835
+ `/subscriptions/${id}/scheduled-plan-change`,
836
+ void 0,
837
+ options
838
+ );
839
+ }
804
840
  /** Revert a scheduled cancellation and return the updated subscription. Only works before cancellation takes effect. */
805
841
  async uncancel(params, options) {
806
842
  const { id } = params;
@@ -814,7 +850,7 @@ var SubscriptionsResource = class {
814
850
  async list(params, options) {
815
851
  return this.httpClient.get("/subscriptions", params, options);
816
852
  }
817
- /** Create a subscription for a customer. Commet selects the default price when priceId is omitted. The subscription starts at the base USD price; market and currency are resolved from the buyer's request country when the checkout opens. Without an offer override, Commet applies the price's automatic introductory Offer. Pass offerId to apply an active compatible Offer directly, or cardPromotionId to preselect a card-eligible Promotional Offer for the initial checkout when card promotions are enabled for the organization. For the initial checkout, provider accepts either a processor name or an exact payment connection ID. */
853
+ /** Create a subscription for a customer. Commet selects the default price when priceId is omitted. The subscription starts at the base USD price; market and currency are resolved from the buyer's request country when the checkout opens. Without an offer override, Commet applies the price's automatic introductory Offer. Pass offerId to apply an active compatible Offer directly, or cardPromotionId to preselect a card-eligible Promotional Offer for the initial checkout when card promotions are enabled for the organization. For the initial checkout, provider accepts either a processor name or an exact payment connection ID. When the price's free trial requires no payment method, the subscription starts trialing right away with no checkout (checkoutUrl null, hasPaymentMethod false); it cannot be combined with offerId, promoCode, cardPromotionId or provider, and an organization that cannot charge yet receives 403. */
818
854
  async create(params, options) {
819
855
  return this.httpClient.post("/subscriptions", params, options);
820
856
  }
@@ -1061,7 +1097,7 @@ var CommetValidationError = class extends CommetAPIError {
1061
1097
 
1062
1098
  // src/version.ts
1063
1099
  var API_VERSION = "2026-08-27";
1064
- var SDK_VERSION = "9.6.0";
1100
+ var SDK_VERSION = "9.8.0";
1065
1101
 
1066
1102
  // src/utils/telemetry.ts
1067
1103
  var registeredIntegrations = /* @__PURE__ */ new Set();