@commet/node 9.8.0 → 9.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1021 -30
- package/dist/index.d.ts +1021 -30
- package/dist/index.js +204 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +204 -11
- package/dist/index.mjs.map +1 -1
- package/docs/ai-onboarding/mcp-server.md +2 -0
- package/docs/api-reference/addons.md +3 -1
- package/docs/api-reference/credit-packs.md +3 -1
- package/docs/api-reference/customers.md +2 -0
- package/docs/api-reference/generated-webhooks.md +2 -2
- package/docs/api-reference/index.md +3 -3
- package/docs/api-reference/plans.md +488 -6
- package/docs/api-reference/subscriptions.md +50 -8
- package/docs/documentation/api-versioning.md +8 -2
- package/docs/documentation/cli.md +64 -49
- package/docs/documentation/create-api-key.md +3 -1
- package/docs/documentation/customers/customer-portal.md +10 -2
- package/docs/documentation/customers/manage-customers.md +2 -1
- package/docs/documentation/finance/payouts.md +11 -0
- package/docs/documentation/finance/supported-countries.md +5 -5
- package/docs/documentation/invoicing/handle-failed-payments.md +9 -9
- package/docs/documentation/payments/accept-one-time-payments.md +1 -1
- package/docs/documentation/payments/payment-orchestration.md +2 -0
- package/docs/documentation/payments/payment-providers.md +46 -0
- package/docs/documentation/payments/transactions-refunds-and-retries.md +1 -1
- package/docs/documentation/plans/add-ons.md +15 -4
- package/docs/documentation/plans/consumption-models.md +44 -9
- package/docs/documentation/plans/create-plans.md +5 -1
- package/docs/documentation/plans/credit-packs.md +61 -3
- package/docs/documentation/plans/one-time-payments.md +3 -3
- package/docs/documentation/plans/plan-groups.md +46 -10
- package/docs/documentation/plans/plan-versions.md +265 -0
- package/docs/documentation/platform/dashboard-metrics-and-events.md +40 -9
- package/docs/documentation/sales/connect-dub-affiliates.md +52 -0
- package/docs/documentation/sales/introductory-offers.md +7 -13
- package/docs/documentation/sales/offers.md +10 -6
- package/docs/documentation/sales/promo-codes.md +47 -17
- package/docs/documentation/sales/promotional-offers.md +6 -7
- package/docs/documentation/sales/regional-prices.md +38 -8
- package/docs/documentation/sales/trial-periods.md +67 -40
- package/docs/documentation/subscriptions/manage-subscriptions.md +114 -14
- package/docs/documentation/subscriptions/pay-in-advance.md +4 -7
- package/docs/documentation/subscriptions/upgrade-and-downgrade-plans.md +22 -2
- package/docs/documentation/testing-sandbox.md +2 -0
- package/docs/documentation/usage/track-usage.md +23 -0
- package/docs/errors/addon_has_activations.md +2 -2
- package/docs/errors/addon_unavailable.md +22 -0
- package/docs/errors/credit_pack_unavailable.md +22 -0
- package/docs/errors/index.md +9 -2
- package/docs/errors/missing_regional_price.md +3 -3
- package/docs/errors/plan_balance_limit_reached.md +22 -0
- package/docs/errors/plan_experiment_not_found.md +22 -0
- package/docs/errors/plan_version_not_found.md +22 -0
- package/docs/errors/subscribers_do_not_fit.md +22 -0
- package/docs/errors/version_not_newer.md +22 -0
- package/docs/knowledge-base/how-do-credits-credit-packs-and-customer-credits-differ.md +8 -8
- package/docs/knowledge-base/how-do-discounts-work.md +7 -5
- package/docs/knowledge-base/how-do-free-plans-work-without-payment.md +18 -11
- package/docs/knowledge-base/how-do-offers-promo-codes-and-card-promotions-work-together.md +1 -1
- package/docs/knowledge-base/how-do-trial-periods-work.md +31 -25
- package/docs/knowledge-base/how-does-billing-work.md +26 -27
- package/docs/knowledge-base/how-does-quota-based-billing-work.md +12 -22
- package/docs/knowledge-base/how-does-seat-based-billing-work.md +12 -22
- package/docs/knowledge-base/what-happens-when-a-customer-changes-plans.md +11 -8
- package/docs/knowledge-base/what-happens-when-a-payment-fails.md +11 -9
- package/docs/knowledge-base/what-happens-when-you-change-your-prices.md +34 -29
- package/docs/knowledge-base/what-invoices-do-customers-receive-and-when.md +1 -1
- package/docs/manifest.json +201 -2
- package/docs/platform-documentation.md +2 -0
- package/docs/schemas.md +134 -14
- package/docs/webhooks/introduction.md +17 -13
- package/docs/webhooks.md +66 -6
- package/docs/webhooks.openapi.json +1218 -876
- package/package.json +1 -1
|
@@ -11,6 +11,8 @@ Webhooks let your application receive real-time HTTP notifications when events h
|
|
|
11
11
|
2. You select which events you want to receive
|
|
12
12
|
3. When an event occurs, Commet sends a `POST` request to your URL with the event data
|
|
13
13
|
|
|
14
|
+
An endpoint receives only the events it lists. New event types are not added to existing endpoints: when Commet adds one, such as `subscription.version_changed`, edit the endpoint to receive it.
|
|
15
|
+
|
|
14
16
|
## Local development
|
|
15
17
|
|
|
16
18
|
Use the Commet CLI to forward webhook events to your local server in real time — no tunneling tools needed:
|
|
@@ -462,24 +464,26 @@ After 8 failed attempts (the initial delivery plus 7 retries), the delivery is m
|
|
|
462
464
|
|
|
463
465
|
## Auto-disable for broken endpoints
|
|
464
466
|
|
|
465
|
-
|
|
467
|
+
Commet disables an endpoint when its three most recent deliveries with a final outcome all failed after their 8 attempts, even if newer deliveries are still retrying. A successful delivery among those three, including a test event, keeps the endpoint active. You get one email when the endpoint is disabled, with a link to it.
|
|
468
|
+
|
|
469
|
+
Deliveries still retrying when the endpoint is disabled are stopped: Commet doesn't call your receiver again for them or send their failure emails.
|
|
466
470
|
|
|
467
|
-
Once you've fixed the issue on your receiver, re-enable the endpoint
|
|
471
|
+
Once you've fixed the issue on your receiver, re-enable the endpoint in **Settings → Webhooks**: choose **Re-enable** in the endpoint's menu, or **Re-enable endpoint** in its detail. The next delivery that fails all its attempts disables it again unless a success lands first. Events that arrived while the endpoint was disabled are not replayed automatically — contact support if you need to backfill any missed events.
|
|
468
472
|
|
|
469
473
|
You can monitor delivery status, inspect payloads, and retry individual deliveries from the dashboard at any time.
|
|
470
474
|
|
|
471
475
|
## Subscription status lifecycle
|
|
472
476
|
|
|
473
|
-
|
|
477
|
+
Most `subscription.*` webhooks include a `status` field. These are the valid values and which ones grant access to your product:
|
|
474
478
|
|
|
475
|
-
| Status | Grants access? | Meaning
|
|
476
|
-
| ----------------- | ------------------ |
|
|
477
|
-
| `draft` | No | Internal setup state before any event is fired
|
|
478
|
-
| `pending_payment` | **No** | Subscription created, waiting for the first charge to confirm
|
|
479
|
-
| `trialing` | **Yes** | Trial active
|
|
480
|
-
| `active` | **Yes** | Paid and current
|
|
481
|
-
| `past_due` | Yes (grace period) | A renewal charge failed; dunning retries in progress — usage and seats keep working, new purchases are blocked
|
|
482
|
-
| `canceled` | No | Terminal — the cancellation executed at period end,
|
|
479
|
+
| Status | Grants access? | Meaning |
|
|
480
|
+
| ----------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
481
|
+
| `draft` | No | Internal setup state before any event is fired |
|
|
482
|
+
| `pending_payment` | **No** | Subscription created, waiting for the first charge to confirm |
|
|
483
|
+
| `trialing` | **Yes** | Trial active, with or without a payment method; no charge yet |
|
|
484
|
+
| `active` | **Yes** | Paid and current |
|
|
485
|
+
| `past_due` | Yes (grace period) | A renewal charge failed; dunning retries in progress — usage and seats keep working, new purchases are blocked |
|
|
486
|
+
| `canceled` | No | Terminal — the cancellation executed at period end, dunning exhausted its retries, or a trial without a payment method ended without a card |
|
|
483
487
|
|
|
484
488
|
Typical flow:
|
|
485
489
|
|
|
@@ -490,8 +494,8 @@ draft → pending_payment → trialing → active ⇄ past_due
|
|
|
490
494
|
canceled
|
|
491
495
|
```
|
|
492
496
|
|
|
493
|
-
- Without a trial, `pending_payment` goes straight to `active` when the first charge confirms; with one, it goes to `trialing`.
|
|
494
|
-
- `trialing → active` happens when the trial converts — and also when it expires: trial expiry activates the subscription and regular billing begins.
|
|
497
|
+
- Without a trial, `pending_payment` goes straight to `active` when the first charge confirms; with one, it goes to `trialing`. A [trial without a payment method](/docs/trial-periods#start-a-trial-without-a-payment-method) starts in `trialing` with no checkout.
|
|
498
|
+
- `trialing → active` happens when the trial converts — and also when it expires: trial expiry activates the subscription and regular billing begins. A trial without a payment method that ends without a card moves to the plan group's default plan (`subscription.plan_changed`) or is canceled.
|
|
495
499
|
- `active ⇄ past_due`: a failed renewal starts dunning; a recovered payment returns the subscription to `active`.
|
|
496
500
|
- `canceled` is terminal, reached when a scheduled cancellation executes at period end or when dunning exhausts its retries.
|
|
497
501
|
|
package/docs/webhooks.md
CHANGED
|
@@ -221,6 +221,30 @@ Fired when a scheduled plan change will no longer take effect: it was revoked th
|
|
|
221
221
|
- `billingInterval` (`string | null`, required) — The current billing interval.
|
|
222
222
|
- `revokedBillingInterval` (`string | null`, required) — The previously scheduled billing interval, if the revoked change included one.
|
|
223
223
|
|
|
224
|
+
## subscription.version_changed
|
|
225
|
+
|
|
226
|
+
Fired when a subscription moves to another version of its plan: a move applied now or a scheduled move that took effect at renewal. Making an experiment current moves nobody, so it sends none. The plan stays the same; the version's prices and features apply from now on.
|
|
227
|
+
|
|
228
|
+
### Data
|
|
229
|
+
|
|
230
|
+
- `subscriptionId` (`string`, required) — The subscription ID.
|
|
231
|
+
- `customerId` (`string`, required) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
232
|
+
- `fromVersionId` (`string`, required) — The version the subscription left.
|
|
233
|
+
- `toVersionId` (`string`, required) — The version the subscription is on now.
|
|
234
|
+
- `currency` (`string`, required) — The currency the subscription pays in.
|
|
235
|
+
- `billingInterval` (`string`, required) — The billing interval the subscription pays.
|
|
236
|
+
|
|
237
|
+
## subscription.version_change_canceled
|
|
238
|
+
|
|
239
|
+
Fired when a scheduled move to another plan version will no longer take effect because the subscription no longer fit the version at its renewal, or because the merchant revoked the scheduled version change or canceled the plan move. A new move that replaces it, a move made now, a plan change or an immediate cancellation sends none. The subscription stays on its version; reason says why.
|
|
240
|
+
|
|
241
|
+
### Data
|
|
242
|
+
|
|
243
|
+
- `subscriptionId` (`string`, required) — The subscription ID.
|
|
244
|
+
- `customerId` (`string`, required) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
245
|
+
- `toVersionId` (`string`, required) — The version the subscription was going to move to.
|
|
246
|
+
- `reason` (`string`, required) — Why the move was canceled: canceled_by_merchant, version_change_failed when the move could not be applied at renewal, or the code of what the subscription no longer fits (addon_unavailable, seat_limit_exceeded, price_not_found, missing_regional_price).
|
|
247
|
+
|
|
224
248
|
## subscription.past_due
|
|
225
249
|
|
|
226
250
|
Fired when a recurring payment fails on a previously paid subscription and its status becomes past_due. past_due is a grace window, not a cutoff: usage and seats keep working while new purchases are blocked, and dunning retries the charge — use this to notify the customer and recover the payment.
|
|
@@ -584,6 +608,17 @@ Fired when a customer replaces their default payment method through the customer
|
|
|
584
608
|
- `paymentMethod` (`PaymentMethod | null`, required) — The payment method: card, oxxo, or mercado_pago. Null when unknown.
|
|
585
609
|
- `card` (`WebhookCardInfo | null`, required) — Card display metadata for the new method: brand, last4, expMonth, expYear. Null when the method is not a card or its details cannot be retrieved.
|
|
586
610
|
|
|
611
|
+
## payment_method.detached
|
|
612
|
+
|
|
613
|
+
Fired when a saved payment method is removed from a customer: the customer unlinked it at the payment provider (for example, revoking a Mercado Pago authorization), or removed it through the customer portal. Removing a method never changes the customer's subscriptions; a renewal that finds no usable method follows the usual failed-payment recovery.
|
|
614
|
+
|
|
615
|
+
### Data
|
|
616
|
+
|
|
617
|
+
- `customerId` (`string`, required) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
618
|
+
- `paymentMethod` (`PaymentMethod | null`, required) — The payment method: card, oxxo, or mercado_pago. Null when unknown.
|
|
619
|
+
- `card` (`WebhookCardInfo | null`, required) — Card display metadata of the removed method: brand, last4, expMonth, expYear. Null when the method is not a card or its details cannot be retrieved.
|
|
620
|
+
- `reason` (`"unlinked_at_provider" | "removed_by_customer"`, required) — Why the method was removed: `unlinked_at_provider` when the customer revoked it at the payment provider, `removed_by_customer` when the customer removed it through the customer portal.
|
|
621
|
+
|
|
587
622
|
## customer.created
|
|
588
623
|
|
|
589
624
|
Fired when a customer is created, via the API (including batch create), SDK, or dashboard. The payload is the customer resource exactly as GET /customers returns it.
|
|
@@ -596,6 +631,7 @@ Fired when a customer is created, via the API (including batch create), SDK, or
|
|
|
596
631
|
- `email` (`string`, required) — The customer's email.
|
|
597
632
|
- `taxDocument` (`string | null`, required) — The customer's tax identification number, if provided.
|
|
598
633
|
- `documentType` (`string | null`, required) — The local tax document type label inferred from the customer's country (e.g. CUIT, RFC, RUT), or null when no tax document was provided.
|
|
634
|
+
- `businessTaxId` (`{ country: string; type: string; value: string } | null`, required) — The business tax ID saved for the customer (EU VAT number, Peruvian RUC), or null when the customer has none.
|
|
599
635
|
- `timezone` (`string | null`, required) — The customer's timezone.
|
|
600
636
|
- `metadata` (`Record<string, unknown> | null`, required) — Custom key-value metadata you attached to the customer.
|
|
601
637
|
- `createdAt` (`string`, required) — ISO 8601 datetime when the customer was created.
|
|
@@ -613,6 +649,7 @@ Fired when a customer's details change (email, name, timezone, externalId, or me
|
|
|
613
649
|
- `email` (`string`, required) — The customer's email.
|
|
614
650
|
- `taxDocument` (`string | null`, required) — The customer's tax identification number, if provided.
|
|
615
651
|
- `documentType` (`string | null`, required) — The local tax document type label inferred from the customer's country (e.g. CUIT, RFC, RUT), or null when no tax document was provided.
|
|
652
|
+
- `businessTaxId` (`{ country: string; type: string; value: string } | null`, required) — The business tax ID saved for the customer (EU VAT number, Peruvian RUC), or null when the customer has none.
|
|
616
653
|
- `timezone` (`string | null`, required) — The customer's timezone.
|
|
617
654
|
- `metadata` (`Record<string, unknown> | null`, required) — Custom key-value metadata you attached to the customer.
|
|
618
655
|
- `createdAt` (`string`, required) — ISO 8601 datetime when the customer was created.
|
|
@@ -634,7 +671,7 @@ Aggregate entitlement event answering one question: what can this customer acces
|
|
|
634
671
|
- `features` (`Array<{ code: string; name: string; unitName: string | null; allowed: boolean; type: "boolean"; enabled: boolean } | { code: string; name: string; unitName: string | null; allowed: boolean; type: "usage"; consumption: { model: "metered"; period: { start: string; end: string }; unitsUsed: number; includedUnits: number; remainingUnits?: number; unlimited: boolean; overage: { enabled: boolean; units: number; unitPrice?: { amount: number; currency: string; scale: 10000 } } } | { model: "credits"; period: { start: string; end: string }; unitsUsed: number; creditsPerUnit: number; creditsConsumed: number; availableUnits: number } | { model: "balance"; period: { start: string; end: string }; unitsUsed: number; spent: { amount: number; currency: string }; availableUnits?: number; unitPrice?: { amount: number; currency: string; scale: 10000 } } } | { code: string; name: string; unitName: string | null; allowed: boolean; type: "seats"; usage: { period: { start: string; end: string }; unitsUsed: number; includedUnits: number; remainingUnits?: number; unlimited: boolean; overage: { enabled: boolean; units: number; unitPrice?: { amount: number; currency: string; scale: 10000 } } } } | { code: string; name: string; unitName: string | null; allowed: boolean; type: "quota"; usage: { period: { start: string; end: string }; unitsUsed: number; includedUnits: number; remainingUnits?: number; unlimited: boolean; overage: { enabled: boolean; units: number; unitPrice?: { amount: number; currency: string; scale: 10000 } }; billedUnits: number } }>`, required) — Current feature access, discriminated by type. Boolean features expose enabled; usage features expose model-specific consumption; seats and quota expose usage allowances.
|
|
635
672
|
- `seats` (`Array<WebhookSeatSummary>`, required) — Summary of seats-type features: code, current, included, remaining, unlimited.
|
|
636
673
|
- `credits` (`WebhookCreditsBalance | null`, required) — For credits plans: planCredits, purchasedCredits, totalCredits. Null otherwise.
|
|
637
|
-
- `balance` (`WebhookBalance | null`, required) — For balance plans
|
|
674
|
+
- `balance` (`WebhookBalance | null`, required) — For balance plans, in rate scale (10000 = 1.00 of the subscription currency): currentBalance (the available total), planBalance, purchasedBalance and totalBalance. Null otherwise.
|
|
638
675
|
|
|
639
676
|
## plan_grant.created
|
|
640
677
|
|
|
@@ -758,19 +795,19 @@ Fired when a customer buys a credit pack or a chosen quantity of credits through
|
|
|
758
795
|
|
|
759
796
|
## credits.low
|
|
760
797
|
|
|
761
|
-
Fired when a subscription's
|
|
798
|
+
Fired when a subscription's available credits (plan plus purchased) cross below 10% of their last refill: a period reset, a purchase or a manual adjustment. Emitted once per crossing, the same rule as balance.low.
|
|
762
799
|
|
|
763
800
|
### Data
|
|
764
801
|
|
|
765
802
|
- `subscriptionId` (`string`, required) — The subscription ID.
|
|
766
803
|
- `customerId` (`string`, required) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
767
804
|
- `remainingCredits` (`number`, required) — Total credits remaining (plan plus purchased).
|
|
768
|
-
- `thresholdCredits` (`number`, required) — The low-credit threshold that was crossed: 10% of the
|
|
769
|
-
- `periodCredits` (`number`, required) — The
|
|
805
|
+
- `thresholdCredits` (`number`, required) — The low-credit threshold that was crossed: 10% of the last refill.
|
|
806
|
+
- `periodCredits` (`number`, required) — The credits added by the last refill: a period reset, a purchase or a manual adjustment.
|
|
770
807
|
|
|
771
808
|
## credits.depleted
|
|
772
809
|
|
|
773
|
-
Fired
|
|
810
|
+
Fired each time a subscription's available credits cross to zero or below. Usage that needs more credits than remain is rejected from this point, unless the plan allows overage, which is billed at its price per credit at the next renewal. Also fires customer.state_changed with trigger credits_depleted.
|
|
774
811
|
|
|
775
812
|
### Data
|
|
776
813
|
|
|
@@ -788,9 +825,21 @@ Fired at a reset when unused plan credits are discarded. On a plan whose unused
|
|
|
788
825
|
- `customerId` (`string`, required) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
789
826
|
- `expiredCredits` (`number`, required) — The plan credits that were discarded.
|
|
790
827
|
|
|
828
|
+
## balance.granted
|
|
829
|
+
|
|
830
|
+
Fired when non-purchase balance is granted to a subscription: the plan balance at the start of each billing period, or a manual adjustment from the dashboard or the API, which goes to the purchased balance. Balance top-ups fire balance.topped_up instead.
|
|
831
|
+
|
|
832
|
+
### Data
|
|
833
|
+
|
|
834
|
+
- `subscriptionId` (`string`, required) — The subscription ID.
|
|
835
|
+
- `customerId` (`string`, required) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
836
|
+
- `amount` (`number`, required) — The balance granted in rate scale (10000 = 1.00 of the subscription currency).
|
|
837
|
+
- `currency` (`string`, required) — The subscription currency.
|
|
838
|
+
- `reason` (`string`, required) — Why the balance was granted: period_reset or manual_adjustment.
|
|
839
|
+
|
|
791
840
|
## balance.topped_up
|
|
792
841
|
|
|
793
|
-
Fired when a
|
|
842
|
+
Fired when a balance top-up succeeds: through the API, an automatic top-up or the customer portal. The amount goes to the purchased balance, which is spent after the plan balance and kept until the subscription ends.
|
|
794
843
|
|
|
795
844
|
### Data
|
|
796
845
|
|
|
@@ -824,6 +873,17 @@ Fired when a subscription's prepaid balance crosses to zero or below. With block
|
|
|
824
873
|
- `currentBalance` (`number`, required) — The balance after depletion in rate scale. Zero, or negative when overage is allowed.
|
|
825
874
|
- `currency` (`string`, required) — The subscription currency.
|
|
826
875
|
|
|
876
|
+
## balance.expired
|
|
877
|
+
|
|
878
|
+
Fired at a reset when unused plan balance is discarded. On a plan whose unused plan balance expires, all of it expires at each reset. On a plan that rolls it over, a reset keeps it, up to the plan's maxPlanBalance when it has one, and only the excess expires. An overage debt invoiced at the renewal counts as nothing left over. Purchased balance never expires and is not affected.
|
|
879
|
+
|
|
880
|
+
### Data
|
|
881
|
+
|
|
882
|
+
- `subscriptionId` (`string`, required) — The subscription ID.
|
|
883
|
+
- `customerId` (`string`, required) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
884
|
+
- `expiredAmount` (`number`, required) — The plan balance that was discarded, in rate scale (10000 = 1.00 of the subscription currency).
|
|
885
|
+
- `currency` (`string`, required) — The subscription currency.
|
|
886
|
+
|
|
827
887
|
## quota.threshold_reached
|
|
828
888
|
|
|
829
889
|
Fired when a metered feature's usage crosses 80% of its included quantity for the current period. Emitted once per feature per billing period, when the crossing happens.
|