@commet/node 9.11.0 → 9.13.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 +329 -507
- package/dist/index.d.ts +329 -507
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -12
- package/dist/index.mjs.map +1 -1
- package/docs/api-reference/addons.md +8 -15
- package/docs/api-reference/api-keys.md +1 -1
- package/docs/api-reference/credit-packs.md +2 -2
- package/docs/api-reference/customers.md +7 -19
- package/docs/api-reference/features.md +1 -1
- package/docs/api-reference/offers.md +9 -5
- package/docs/api-reference/payments.md +1 -1
- package/docs/api-reference/plan-groups.md +2 -2
- package/docs/api-reference/plans.md +28 -44
- package/docs/api-reference/portal.md +3 -8
- package/docs/api-reference/promo-codes.md +3 -3
- package/docs/api-reference/quota.md +6 -21
- package/docs/api-reference/subscriptions.md +38 -52
- package/docs/api-reference/test-clock.md +3 -8
- package/docs/api-reference/usage.md +6 -11
- package/docs/documentation/create-api-key.md +4 -2
- package/docs/documentation/error-handling.md +11 -0
- package/docs/documentation/invoicing/handle-failed-payments.md +12 -3
- package/docs/documentation/plans/add-ons.md +2 -0
- package/docs/documentation/plans/balance-and-top-ups.md +2 -0
- package/docs/documentation/plans/consumption-models.md +9 -1
- package/docs/documentation/plans/credit-packs.md +24 -6
- package/docs/documentation/plans/one-time-payments.md +1 -0
- package/docs/documentation/sales/offers.md +21 -3
- package/docs/documentation/sales/promo-codes.md +2 -2
- package/docs/documentation/sales/promotional-offers.md +2 -2
- package/docs/documentation/subscriptions/manage-subscriptions.md +3 -3
- package/docs/documentation/subscriptions/pay-in-advance.md +6 -4
- package/docs/documentation/subscriptions/plan-grants.md +22 -6
- package/docs/errors/already_has_active_subscription.md +1 -1
- package/docs/errors/charge_failed.md +1 -1
- package/docs/errors/no_payment_method.md +1 -1
- package/docs/errors/payment_failed.md +1 -1
- package/docs/errors/subscription_not_active.md +1 -1
- package/docs/errors/validation_error.md +1 -1
- package/docs/knowledge-base/how-do-discounts-work.md +20 -2
- package/docs/knowledge-base/what-happens-when-a-payment-fails.md +6 -6
- package/docs/schemas.md +13 -5
- package/docs/webhooks.md +16 -14
- package/docs/webhooks.openapi.json +85 -41
- package/package.json +1 -1
|
@@ -25,12 +25,13 @@ Deactivate an add-on from a subscription.
|
|
|
25
25
|
|
|
26
26
|
`POST /subscriptions/{id}/addons` · operation `activate-addon`
|
|
27
27
|
|
|
28
|
-
Activate an add-on on a subscription. Creates the activation invoice and charges a prorated amount for the current billing period; the add-on is active once the payment is confirmed. Rejected with 409 while the add-on is active or an activation of it is still processing. An add-on that the subscription's plan version does not sell is rejected with addon_unavailable.
|
|
28
|
+
Activate an add-on on a subscription. Creates the activation invoice and charges a prorated amount for the current billing period; the add-on is active once the payment is confirmed. Send successUrl to receive, when there is no saved payment method or it is declined, a checkout that charges the activation and saves the method. Rejected with 409 while the add-on is active or an activation of it is still processing. An add-on that the subscription's plan version does not sell is rejected with addon_unavailable.
|
|
29
29
|
|
|
30
30
|
### Parameters
|
|
31
31
|
|
|
32
32
|
- `id` (`string`, required)
|
|
33
33
|
- `addonId` (`string`, required)
|
|
34
|
+
- `successUrl` (`string`, optional) — Where the customer returns after paying. When it is set and the subscription has no saved payment method, or the saved method is declined or asks for authentication, the response has status `requires_checkout` and a `checkoutUrl` where the customer pays this purchase and saves the method in one step. Without it, the request is rejected in both cases. A saved method is always charged directly first, and a payment that fails for any other reason is rejected either way.
|
|
34
35
|
|
|
35
36
|
### Request options
|
|
36
37
|
|
|
@@ -110,12 +111,13 @@ Adjust a subscription's balance or credits by a signed amount. Positive adds, ne
|
|
|
110
111
|
|
|
111
112
|
`POST /subscriptions/{id}/balance/topup` · operation `topup-balance`
|
|
112
113
|
|
|
113
|
-
Top up a balance subscription. Creates the top-up invoice and charges the customer's payment method for the amount plus tax. Once the payment is confirmed, adds the amount to the subscription's purchased balance (after paying back any overage owed on the plan balance), marks the invoice paid and emits `balance.topped_up`. Purchased balance is spent after the plan balance and is kept until the subscription ends. Rejected with 400 when the subscription is not on a balance plan, its plan has top-ups turned off, or the amount is below the effective minimum: the plan's minimum top-up in the subscription currency, raised to the currency's minimum charge.
|
|
114
|
+
Top up a balance subscription. Creates the top-up invoice and charges the customer's payment method for the amount plus tax. Once the payment is confirmed, adds the amount to the subscription's purchased balance (after paying back any overage owed on the plan balance), marks the invoice paid and emits `balance.topped_up`. Purchased balance is spent after the plan balance and is kept until the subscription ends. Send successUrl to receive, when there is no saved payment method or it is declined, a checkout that charges the top-up and saves the method. Rejected with 400 when the subscription is not on a balance plan, its plan has top-ups turned off, or the amount is below the effective minimum: the plan's minimum top-up in the subscription currency, raised to the currency's minimum charge.
|
|
114
115
|
|
|
115
116
|
### Parameters
|
|
116
117
|
|
|
117
118
|
- `id` (`string`, required)
|
|
118
119
|
- `amount` (`number`, required) — The amount to add, in minor units of the subscription currency (cents; whole units for zero-decimal currencies).
|
|
120
|
+
- `successUrl` (`string`, optional) — Where the customer returns after paying. When it is set and the subscription has no saved payment method, or the saved method is declined or asks for authentication, the response has status `requires_checkout` and a `checkoutUrl` where the customer pays this purchase and saves the method in one step. Without it, the request is rejected in both cases. A saved method is always charged directly first, and a payment that fails for any other reason is rejected either way.
|
|
119
121
|
|
|
120
122
|
### Request options
|
|
121
123
|
|
|
@@ -131,7 +133,7 @@ Top up a balance subscription. Creates the top-up invoice and charges the custom
|
|
|
131
133
|
|
|
132
134
|
`POST /subscriptions/{id}/cancel` · operation `cancel-subscription`
|
|
133
135
|
|
|
134
|
-
Cancel immediately or at period end and return the updated subscription.
|
|
136
|
+
Cancel immediately or at period end and return the updated subscription. When the plan's group has a default free plan, a paid subscription moves to that plan instead of ending: now when `immediate` is true, otherwise at the end of the period or trial as a scheduled plan change that `POST /subscriptions/{id}/uncancel` undoes. The move sends `subscription.plan_change_scheduled` and `subscription.plan_changed` with the `reason` as `cancelReason`, never `subscription.canceled`. Cancelling the default plan itself ends the subscription.
|
|
135
137
|
|
|
136
138
|
### Parameters
|
|
137
139
|
|
|
@@ -158,15 +160,13 @@ Upgrade or change billing interval immediately, optionally applying an Offer by
|
|
|
158
160
|
### Parameters
|
|
159
161
|
|
|
160
162
|
- `id` (`string`, required)
|
|
161
|
-
- `newPlanId` (`string`, optional)
|
|
162
163
|
- `newBillingInterval` (`"weekly" | "monthly" | "quarterly" | "semiannual" | "yearly"`, optional)
|
|
163
164
|
- `successUrl` (`string`, optional)
|
|
164
|
-
- `offerId` (`string`, optional)
|
|
165
|
-
- `promoCode` (`string`, optional)
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
- `promoCode`
|
|
165
|
+
- `offerId` (`string`, optional) — Cannot be combined with `promoCode`.
|
|
166
|
+
- `promoCode` (`string`, optional) — Promo code whose Offer prices the change, validated with the checkout's rules: a code the checkout would refuse returns 400 validation_error with the checkout's reason in details.reason. Cannot be combined with `offerId`.
|
|
167
|
+
- `newPlanId` (`string`, optional) — The plan's ID (`pln_…`) or its code. Cannot be combined with `planCode`.
|
|
168
|
+
- `planCode` (`string`, optional) — Code of the destination plan, or `<plan code>:<experiment code>` to change to the experiment's latest version while it runs (the plan's current version once the experiment is won or archived). Same rules as planCode on subscription creation. Cannot be combined with `newPlanId`.
|
|
169
|
+
- `planVersionId` (`string`, optional) — Public ID of a published version of the destination plan, current or not, including a running experiment's versions. The change is priced, checked out and activated on that version. Only for an immediate change to another paid plan, and not with an experiment code. When omitted, the change lands on the plan's current version, or the version its experiment code sells. Requires `newPlanId` or `planCode`.
|
|
170
170
|
|
|
171
171
|
### Request options
|
|
172
172
|
|
|
@@ -205,18 +205,14 @@ Move a subscription to a newer published version of its plan, now or at the end
|
|
|
205
205
|
|
|
206
206
|
`POST /subscriptions/{id}/credits` · operation `purchase-credits`
|
|
207
207
|
|
|
208
|
-
Purchase a fixed credit pack or choose a whole credit quantity at the subscription plan price and minimum. Creates the purchase invoice, charges the saved payment method and adds the purchased credits once the payment is confirmed. A credit pack that the subscription's plan version does not sell is rejected with credit_pack_unavailable.
|
|
208
|
+
Purchase a fixed credit pack or choose a whole credit quantity at the subscription plan price and minimum. Creates the purchase invoice, charges the saved payment method and adds the purchased credits once the payment is confirmed. Send successUrl to receive, when there is no saved payment method or it is declined, a checkout that charges the purchase and saves the method. A credit pack that the subscription's plan version does not sell is rejected with credit_pack_unavailable.
|
|
209
209
|
|
|
210
210
|
### Parameters
|
|
211
211
|
|
|
212
212
|
- `id` (`string`, required)
|
|
213
|
-
- `creditPackId` (`string`, optional)
|
|
214
|
-
- `quantity` (`number`, optional)
|
|
215
|
-
|
|
216
|
-
### Valid parameter combinations
|
|
217
|
-
|
|
218
|
-
- `creditPackId`
|
|
219
|
-
- `quantity`
|
|
213
|
+
- `creditPackId` (`string`, optional) — Required unless `quantity` is sent. Cannot be combined with `quantity`.
|
|
214
|
+
- `quantity` (`number`, optional) — Required unless `creditPackId` is sent. Cannot be combined with `creditPackId`.
|
|
215
|
+
- `successUrl` (`string`, optional) — Where the customer returns after paying. When it is set and the subscription has no saved payment method, or the saved method is declined or asks for authentication, the response has status `requires_checkout` and a `checkoutUrl` where the customer pays this purchase and saves the method in one step. Without it, the request is rejected in both cases. A saved method is always charged directly first, and a payment that fails for any other reason is rejected either way.
|
|
220
216
|
|
|
221
217
|
### Request options
|
|
222
218
|
|
|
@@ -238,7 +234,7 @@ Apply a direct Offer to a subscription. On a pending checkout it quotes or repla
|
|
|
238
234
|
|
|
239
235
|
- `id` (`string`, required)
|
|
240
236
|
- `offerId` (`string`, required)
|
|
241
|
-
- `expiresAt` (`string`, optional)
|
|
237
|
+
- `expiresAt` (`string`, optional) — Only for a pending payment checkout, and later than the current time.
|
|
242
238
|
|
|
243
239
|
### Request options
|
|
244
240
|
|
|
@@ -378,15 +374,12 @@ Preview proration details for an immediate plan change without applying it. Free
|
|
|
378
374
|
### Parameters
|
|
379
375
|
|
|
380
376
|
- `id` (`string`, required)
|
|
381
|
-
- `planId` (`string`, required)
|
|
382
377
|
- `billingInterval` (`"weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time"`, optional)
|
|
383
|
-
- `offerId` (`string`, optional)
|
|
384
|
-
- `promoCode` (`string`, optional)
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
- `planId`
|
|
389
|
-
- `planId` + `promoCode`
|
|
378
|
+
- `offerId` (`string`, optional) — Cannot be combined with `promoCode`.
|
|
379
|
+
- `promoCode` (`string`, optional) — Promo code whose Offer prices the change, validated with the checkout's rules: a code the checkout would refuse returns 400 validation_error with the checkout's reason in details.reason. Cannot be combined with `offerId`.
|
|
380
|
+
- `planId` (`string`, optional) — The plan's ID (`pln_…`) or its code. Required unless `planCode` is sent. Cannot be combined with `planCode`.
|
|
381
|
+
- `planCode` (`string`, optional) — Code of the destination plan, or `<plan code>:<experiment code>` to change to the experiment's latest version while it runs (the plan's current version once the experiment is won or archived). Same rules as planCode on subscription creation. Required unless `planId` is sent. Cannot be combined with `planId`.
|
|
382
|
+
- `planVersionId` (`string`, optional) — Public ID of a published version of the destination plan, current or not, including a running experiment's versions. The change is priced, checked out and activated on that version. Only for an immediate change to another paid plan, and not with an experiment code. When omitted, the change lands on the plan's current version, or the version its experiment code sells.
|
|
390
383
|
|
|
391
384
|
### Request options
|
|
392
385
|
|
|
@@ -402,7 +395,7 @@ Preview proration details for an immediate plan change without applying it. Free
|
|
|
402
395
|
|
|
403
396
|
`POST /subscriptions/{id}/reactivate` · operation `reactivate-subscription`
|
|
404
397
|
|
|
405
|
-
Reactivates a subscription. A past_due subscription retries its outstanding renewal charge (recovering to active on success). A canceled subscription generates a fresh invoice, charges the saved card, and resets the billing period. On a successful charge the subscription becomes active; a declined charge returns an error with a recoveryUrl in the error details that can be sent to the customer to update their card. A canceled subscription may apply an Offer by offerId; past-due recovery cannot.
|
|
398
|
+
Reactivates a subscription. A past_due subscription retries its outstanding renewal charge (recovering to active on success). A canceled subscription generates a fresh invoice, charges the saved card, and resets the billing period; when that invoice totals zero, for example under an Offer, it is marked paid without a charge and the subscription becomes active at once, still requiring a saved payment method. On a successful charge the subscription becomes active; a declined charge returns an error with a recoveryUrl in the error details that can be sent to the customer to update their card. A past_due subscription without a payment method returns no_payment_method with the same recoveryUrl. A canceled subscription may apply an Offer by offerId; past-due recovery cannot.
|
|
406
399
|
|
|
407
400
|
### Parameters
|
|
408
401
|
|
|
@@ -511,7 +504,7 @@ Cancel the move to another plan version pending for the next renewal, so the sub
|
|
|
511
504
|
|
|
512
505
|
`POST /subscriptions/{id}/uncancel` · operation `uncancel-subscription`
|
|
513
506
|
|
|
514
|
-
Revert a scheduled cancellation and return the updated subscription. Only works before cancellation takes effect.
|
|
507
|
+
Revert a scheduled cancellation and return the updated subscription. Only works before cancellation takes effect. When the cancellation scheduled a move to the group's default plan instead, it reverts that move: the subscription keeps its plan and renews normally.
|
|
515
508
|
|
|
516
509
|
### Parameters
|
|
517
510
|
|
|
@@ -547,10 +540,12 @@ Get the active subscription for a customer. Returns null if none.
|
|
|
547
540
|
|
|
548
541
|
`GET /subscriptions` · operation `list-subscriptions`
|
|
549
542
|
|
|
550
|
-
List
|
|
543
|
+
List subscriptions, newest first. Filter by customer ID, status or plan version. Send `limit` or `cursor` to receive them in pages and follow `nextCursor` while `hasMore` is true; without them the response holds every matching subscription, up to 80,000.
|
|
551
544
|
|
|
552
545
|
### Parameters
|
|
553
546
|
|
|
547
|
+
- `cursor` (`string`, optional)
|
|
548
|
+
- `limit` (`number`, optional)
|
|
554
549
|
- `customerId` (`string`, optional)
|
|
555
550
|
- `status` (`SubscriptionStatus`, optional)
|
|
556
551
|
- `planVersionId` (`string`, optional)
|
|
@@ -565,7 +560,7 @@ List all subscriptions. Filter by customer ID or status.
|
|
|
565
560
|
|
|
566
561
|
`POST /subscriptions` · operation `create-subscription`
|
|
567
562
|
|
|
568
|
-
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
|
|
563
|
+
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, provider or paymentMethodTypes, and an organization that cannot charge yet receives 403. When the customer already has a past_due subscription, the 409 error details carry its subscriptionId, its status and, while its renewal is unpaid, a recoveryUrl where the customer can pay it.
|
|
569
564
|
|
|
570
565
|
### Parameters
|
|
571
566
|
|
|
@@ -573,30 +568,21 @@ Create a subscription for a customer. Commet selects the default price when pric
|
|
|
573
568
|
- `billingInterval` (`"weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time" | null`, optional)
|
|
574
569
|
- `priceId` (`string`, optional) — Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing.
|
|
575
570
|
- `initialSeats` (`Record<string, number>`, optional)
|
|
576
|
-
- `provider` (`"stripe" | "commet" | "dlocal" | string`, optional) — Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present.
|
|
577
|
-
- `paymentMethodTypes` (`Array<"card" | "
|
|
571
|
+
- `provider` (`"stripe" | "commet" | "dlocal" | string`, optional) — Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. Not available on free plans or with a free trial that requires no payment method.
|
|
572
|
+
- `paymentMethodTypes` (`Array<"card" | "mercado_pago" | "oxxo" | "google_pay" | "smartpix" | "apple_pay" | "link">`, optional) — Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. Not available on free plans or with a free trial that requires no payment method.
|
|
578
573
|
- `name` (`string`, optional)
|
|
579
574
|
- `startDate` (`string`, optional)
|
|
580
575
|
- `successUrl` (`string`, optional)
|
|
581
|
-
- `prepaidPeriods` (`number`, optional) — Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true.
|
|
582
|
-
- `cancelAtPeriodEnd` (`boolean`, optional) — Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method.
|
|
583
|
-
- `planVersionId` (`string`, optional) — Public ID of a published version of the plan, current or not, including an experiment's versions. The subscription is created on that version and stays on it: checkout charges its price and activation grants its credits, add-ons and credit packs. When omitted, the subscription gets the current version, or the version an experiment code (planCode `<plan code>:<experiment code>`) sells.
|
|
584
|
-
- `offerId` (`string`, optional)
|
|
585
|
-
- `promoCode` (`string`, optional)
|
|
586
|
-
- `customTrialDays` (`number`, optional) — Trial length in days, replacing the price's trial. A customer who already had this plan, in a trial or paying, gets no trial and goes through the regular checkout.
|
|
587
|
-
- `skipTrial` (`boolean`, optional)
|
|
588
|
-
- `
|
|
589
|
-
- `
|
|
590
|
-
- `
|
|
591
|
-
|
|
592
|
-
### Valid parameter combinations
|
|
593
|
-
|
|
594
|
-
- `customerId` + `planId`
|
|
595
|
-
- `customerId` + `planCode`
|
|
596
|
-
- `customerId` + `offerId` + `planId`
|
|
597
|
-
- `customerId` + `offerId` + `planCode`
|
|
598
|
-
- `customerId` + `cardPromotionId` + `planId`
|
|
599
|
-
- `customerId` + `cardPromotionId` + `planCode`
|
|
576
|
+
- `prepaidPeriods` (`number`, optional) — Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. Above 1, needs a paid recurring price, cannot take an Offer whose phases bill on another interval and cannot be combined with `customTrialDays` above 0.
|
|
577
|
+
- `cancelAtPeriodEnd` (`boolean`, optional) — Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. When the plan's group has a default free plan, it moves to that plan then instead of ending. When true, needs a paid recurring price and cannot be combined with `customTrialDays` above 0.
|
|
578
|
+
- `planVersionId` (`string`, optional) — Public ID of a published version of the plan, current or not, including an experiment's versions. The subscription is created on that version and stays on it: checkout charges its price and activation grants its credits, add-ons and credit packs. When omitted, the subscription gets the current version, or the version an experiment code (planCode `<plan code>:<experiment code>`) sells. Cannot be combined with an experiment code in `planCode`.
|
|
579
|
+
- `offerId` (`string`, optional) — Cannot be combined with `promoCode`. Cannot be combined with `cardPromotionId`.
|
|
580
|
+
- `promoCode` (`string`, optional) — Cannot be combined with `offerId`. Cannot be combined with `cardPromotionId`.
|
|
581
|
+
- `customTrialDays` (`number`, optional) — Trial length in days, replacing the price's trial. A customer who already had this plan, in a trial or paying, gets no trial and goes through the regular checkout. Above 0, cannot be combined with `prepaidPeriods` above 1 or with `cancelAtPeriodEnd` true. Cannot be combined with `cardPromotionId`.
|
|
582
|
+
- `skipTrial` (`boolean`, optional) — Cannot be `true` with `cardPromotionId`.
|
|
583
|
+
- `cardPromotionId` (`string`, optional) — Public card promotion ID. The offer is shown immediately and remains conditional on card eligibility until checkout confirmation. Cannot be combined with `offerId`. Cannot be combined with `promoCode`. Cannot be combined with `customTrialDays`. Cannot be used when `skipTrial` is `true`.
|
|
584
|
+
- `planId` (`string`, optional) — Required unless `planCode` is sent. Cannot be combined with `planCode`.
|
|
585
|
+
- `planCode` (`string`, optional) — The plan code, or an experiment code as `<plan code>:<experiment code>` to sell the version the experiment sells. Required unless `planId` is sent. Cannot be combined with `planId`.
|
|
600
586
|
|
|
601
587
|
### Request options
|
|
602
588
|
|
|
@@ -34,7 +34,7 @@ Returns the organization's current test clock state and latest durable run. Sand
|
|
|
34
34
|
|
|
35
35
|
## advance
|
|
36
36
|
|
|
37
|
-
`commet.testClock.advance(params
|
|
37
|
+
`commet.testClock.advance(params?, options?)`
|
|
38
38
|
|
|
39
39
|
`POST /test-clock` · operation `advance-test-clock`
|
|
40
40
|
|
|
@@ -42,13 +42,8 @@ Starts a durable run that moves the test clock forward and processes every billi
|
|
|
42
42
|
|
|
43
43
|
### Parameters
|
|
44
44
|
|
|
45
|
-
- `advanceDays` (`number`, optional)
|
|
46
|
-
- `frozenTime` (`string`, optional)
|
|
47
|
-
|
|
48
|
-
### Valid parameter combinations
|
|
49
|
-
|
|
50
|
-
- `advanceDays`
|
|
51
|
-
- `frozenTime`
|
|
45
|
+
- `advanceDays` (`number`, optional) — Required unless `frozenTime` is sent. Cannot be combined with `frozenTime`.
|
|
46
|
+
- `frozenTime` (`string`, optional) — Required unless `advanceDays` is sent. Cannot be combined with `advanceDays`.
|
|
52
47
|
|
|
53
48
|
### Request options
|
|
54
49
|
|
|
@@ -35,17 +35,12 @@ Track a usage event for a metered feature. Deducts from balance/credits if appli
|
|
|
35
35
|
- `eventId` (`string`, optional)
|
|
36
36
|
- `timestamp` (`string`, optional)
|
|
37
37
|
- `properties` (`Array<{ property: string; value: string }>`, optional)
|
|
38
|
-
- `model` (`string`, optional)
|
|
39
|
-
- `inputTokens` (`number`, optional)
|
|
40
|
-
- `outputTokens` (`number`, optional)
|
|
41
|
-
- `value` (`number`, optional)
|
|
42
|
-
- `cacheReadTokens` (`number`, optional)
|
|
43
|
-
- `cacheWriteTokens` (`number`, optional)
|
|
44
|
-
|
|
45
|
-
### Valid parameter combinations
|
|
46
|
-
|
|
47
|
-
- `featureCode` + `customerId` + `model` + `inputTokens` + `outputTokens`
|
|
48
|
-
- `featureCode` + `customerId`
|
|
38
|
+
- `model` (`string`, optional) — Required when `inputTokens`, `outputTokens`, `cacheReadTokens` or `cacheWriteTokens` is sent. Cannot be combined with `value`.
|
|
39
|
+
- `inputTokens` (`number`, optional) — Required when `model`, `outputTokens`, `cacheReadTokens` or `cacheWriteTokens` is sent. Cannot be combined with `value`.
|
|
40
|
+
- `outputTokens` (`number`, optional) — Required when `model`, `inputTokens`, `cacheReadTokens` or `cacheWriteTokens` is sent. Cannot be combined with `value`.
|
|
41
|
+
- `value` (`number`, optional) — Defaults to `1` unless `model` is sent. Cannot be combined with `model`, `inputTokens`, `outputTokens`, `cacheReadTokens` or `cacheWriteTokens`.
|
|
42
|
+
- `cacheReadTokens` (`number`, optional) — Requires `model`, `inputTokens` and `outputTokens`. Cannot be combined with `value`.
|
|
43
|
+
- `cacheWriteTokens` (`number`, optional) — Requires `model`, `inputTokens` and `outputTokens`. Cannot be combined with `value`.
|
|
49
44
|
|
|
50
45
|
### Request options
|
|
51
46
|
|
|
@@ -16,7 +16,7 @@ Choose the path that fits where you are working. You only need one to get starte
|
|
|
16
16
|
1. Select your **sandbox organization** in the dashboard.
|
|
17
17
|
2. Go to **Settings → API Keys** and click **Create API Key**.
|
|
18
18
|
3. Choose **Full Access** for a backend or **AI Agents** to select resource permissions.
|
|
19
|
-
4. Enter a descriptive name of up to 32 characters, such as `Local development
|
|
19
|
+
4. Enter a descriptive name of up to 32 characters, such as `Local development`. A key created from the dashboard does not expire.
|
|
20
20
|
5. Create the key and copy it before closing the dialog. The full secret is shown only once.
|
|
21
21
|
|
|
22
22
|
### CLI
|
|
@@ -110,7 +110,9 @@ For other languages, follow the [Python](/docs/integrate-with-python), [Go](/doc
|
|
|
110
110
|
|
|
111
111
|
## Rotate and promote to live
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
Keys created from the dashboard or by linking the CLI do not expire. Keys created through the API, `commet api-keys create` or MCP expire after `expiresInDays`, 365 when omitted; **Expires** in the dashboard and `expiresAt` in [List API keys](/docs/api-reference/api-keys/list-api-keys) show the date. An expired key stops authenticating and cannot be extended.
|
|
114
|
+
|
|
115
|
+
Use a separate key for each application or deployment that needs independent rotation. To replace a key:
|
|
114
116
|
|
|
115
117
|
1. Create a replacement in the **same organization**.
|
|
116
118
|
2. Update the secret in every process using the old key and deploy or restart those processes.
|
|
@@ -109,6 +109,17 @@ Every current API error includes a stable `code` and a version-matched `doc_url`
|
|
|
109
109
|
|
|
110
110
|
Keep the `x-request-id` response header when logging or reporting an error. Commet records the same identifier in Platform, allowing the request to be correlated without including credentials or customer data.
|
|
111
111
|
|
|
112
|
+
## Rate Limits
|
|
113
|
+
|
|
114
|
+
Each API key, and each person connected through OAuth, has two limits over a sliding 10-second window. Every request counts toward exactly one of them, so a burst of usage checks never uses up the room your other calls need.
|
|
115
|
+
|
|
116
|
+
| Limit | Routes |
|
|
117
|
+
| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
118
|
+
| 1,000 requests per 10 seconds | `POST /v1/usage/events`, `POST /v1/usage/check`, `GET /v1/feature-access`, `GET /v1/feature-access/{code}`, `GET /v1/features/{code}`, `GET /v1/active-addons`, `GET /v1/addons/active`, `GET /v1/seats/balance`, `GET /v1/seats/balances`, `GET /v1/subscriptions/active`, `GET /v1/subscriptions/{id}` |
|
|
119
|
+
| 300 requests per 10 seconds | Every other route |
|
|
120
|
+
|
|
121
|
+
Every authenticated response carries `RateLimit-Limit`, the limit of the route you called, and `RateLimit-Remaining`. Above the limit the API answers `429` with the code [`rate_limited`](/docs/api-reference/errors/rate_limited.md), plus `RateLimit-Reset` and `Retry-After` in seconds.
|
|
122
|
+
|
|
112
123
|
## Automatic Retries
|
|
113
124
|
|
|
114
125
|
Failed requests retry with exponential backoff (1s → 2s → 4s, max 8s).
|
|
@@ -11,7 +11,7 @@ When a renewal payment fails, the subscription moves to `past_due` and enters du
|
|
|
11
11
|
2. The failed invoice is marked as `outstanding`
|
|
12
12
|
3. The customer keeps service: usage events and seat events still work (usage accrues as debt)
|
|
13
13
|
4. The customer receives an email notification
|
|
14
|
-
5. Commet retries the charge on
|
|
14
|
+
5. Commet retries the charge on the calendar of your retry window (dunning)
|
|
15
15
|
|
|
16
16
|
If a retry succeeds, the subscription returns to `active`. If all retries fail, the invoice is marked as `uncollectible` and the subscription is canceled. When the plan's group has a [default plan](/docs/plan-groups#default-plan-and-signup-trial), the subscription moves to it instead and `subscription.plan_changed` fires.
|
|
17
17
|
|
|
@@ -30,7 +30,16 @@ Initial checkout card declines do not emit `payment.failed`; the checkout respon
|
|
|
30
30
|
|
|
31
31
|
## Automatic retries
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
You choose how long Commet retries in **Settings → Revenue recovery**: 7, 14, 21 or 30 days. Each window has a fixed calendar counted from the original failure, and 7 days is the default:
|
|
34
|
+
|
|
35
|
+
| Window | Retries | Days after the failure |
|
|
36
|
+
| ---------------- | ------- | ----------------------------- |
|
|
37
|
+
| 7 days (default) | 4 | 1, 3, 5 and 7 |
|
|
38
|
+
| 14 days | 6 | 1, 3, 5, 7, 10 and 13 |
|
|
39
|
+
| 21 days | 8 | 1, 3, 5, 9, 11, 13, 15 and 20 |
|
|
40
|
+
| 30 days | 8 | 1, 3, 5, 9, 14, 19, 24 and 29 |
|
|
41
|
+
|
|
42
|
+
A subscription never retries for longer than its billing period: weekly subscriptions always use the 7-day calendar, and monthly subscriptions use the 21-day calendar when the window is 30 days. A subscription keeps the window it had when its payment failed, even if you change the setting later. The calendar is anchored to the failure and never moves. After the last failed retry the subscription is canceled, or moves to the plan group's default plan.
|
|
34
43
|
|
|
35
44
|
Manual retries from the Customer Portal or [`reactivate`](#retry-the-charge-server-to-server) use the default payment method and have separate daily limits. They do not consume automatic retry slots or start another charge while an automatic retry is in progress.
|
|
36
45
|
|
|
@@ -179,7 +188,7 @@ The SDK exposes three server-side recovery primitives. For `past_due` subscripti
|
|
|
179
188
|
`reactivate` charges the subscription's saved payment method. It works on both `past_due` and `canceled` subscriptions, with different effects:
|
|
180
189
|
|
|
181
190
|
- `past_due`: retries the same outstanding renewal invoice. The billing anchor stays fixed. On success the subscription returns to `active` and `payment.recovered` fires.
|
|
182
|
-
- `canceled`: generates a fresh invoice, resets the billing period anchor to now, and charges the saved card. On success the subscription returns to `active` and `subscription.reactivated` fires. Requires the plan to still be available in the subscription's currency, otherwise it returns `PLAN_UNAVAILABLE` (422).
|
|
191
|
+
- `canceled`: generates a fresh invoice, resets the billing period anchor to now, and charges the saved card. On success the subscription returns to `active` and `subscription.reactivated` fires. When the fresh invoice totals zero, for example under an Offer with a fixed price of 0, it is marked paid without a charge, the subscription returns to `active` at once, and `subscription.reactivated` fires with `invoiceTotal: 0`; a saved payment method is still required. Requires the plan to still be available in the subscription's currency, otherwise it returns `PLAN_UNAVAILABLE` (422).
|
|
183
192
|
|
|
184
193
|
```typescript
|
|
185
194
|
const result = await commet.subscriptions.reactivate({ id: 'sub_123' })
|
|
@@ -83,6 +83,8 @@ await commet.subscriptions.deactivateAddon({
|
|
|
83
83
|
})
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
+
Without a saved payment method, activation returns `400`. Send `successUrl` to receive a `status` of `requires_checkout` and a `checkoutUrl` instead: the customer pays the activation there and saves the payment method in one step, and the add-on is active when the payment is confirmed. An activation with nothing to charge opens no checkout.
|
|
87
|
+
|
|
86
88
|
REST equivalents: `POST /api/v1/subscriptions/{id}/addons` and `DELETE /api/v1/subscriptions/{id}/addons/{addonId}`. Add-ons themselves support full CRUD through the `addons` resource: `commet.addons.list`, `get`, `create`, `update`, and `delete`.
|
|
87
89
|
|
|
88
90
|
## Feature access
|
|
@@ -161,6 +161,8 @@ $balanceTopup = $commet->subscriptions->topupBalance(
|
|
|
161
161
|
|
|
162
162
|
A top-up creates its invoice and charges the payment method attached to the subscription. The balance is added once the payment is confirmed: the response's `status` is `succeeded`, or `processing` when the payment method confirms later, such as Pix. A declined payment adds nothing and voids the invoice. Customers can also buy balance from the [Customer Portal](/docs/customer-portal).
|
|
163
163
|
|
|
164
|
+
Without a saved payment method, the request returns `402`. Send `successUrl` to receive a `status` of `requires_checkout` and a `checkoutUrl` instead: the customer pays the top-up there and saves the payment method in one step, and the balance is added when the payment is confirmed. Don't send the top-up again after the customer returns.
|
|
165
|
+
|
|
164
166
|
## Enforce before spending
|
|
165
167
|
|
|
166
168
|
Check usage before work that should not run with insufficient balance, then track only completed work. Use a stable idempotency key so a retry does not deduct twice.
|
|
@@ -55,7 +55,15 @@ Month 1: 800 unused → 800 + 1,000 = 1,800
|
|
|
55
55
|
Month 2: 1,800 unused → 2,800, capped at 2,500. 300 expire.
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
`{ type: 'expire' }` restores the default. Changing it publishes a new [plan version](/docs/plan-versions); each subscription keeps its version's setting until you move it.
|
|
58
|
+
`{ type: 'expire' }` restores the default. Changing it publishes a new [plan version](/docs/plan-versions); each subscription keeps its version's setting until you move it.
|
|
59
|
+
|
|
60
|
+
A plan change applies the new plan's setting to the credits the customer holds. An immediate change cuts the current period short, so the credits the previous plan gave for that period do not pass: only what the customer holds above that allocation carries over, and the new plan adds its own. A change applied at the end of the period carries every unused plan credit.
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
Pro grants 240 credits per month. The customer holds 400 and upgrades today to Studio, which grants 1,000 and rolls over.
|
|
64
|
+
|
|
65
|
+
400 − 240 = 160 carried → 160 + 1,000 = 1,160
|
|
66
|
+
```
|
|
59
67
|
|
|
60
68
|
### Limit plan credit spending
|
|
61
69
|
|
|
@@ -102,12 +102,30 @@ await commet.subscriptions.purchaseCredits({
|
|
|
102
102
|
|
|
103
103
|
Commet creates the purchase invoice, charges the saved payment method at the price per credit of the subscription's plan version and adds the purchased credits once the payment is confirmed. Send `creditPackId` instead of `quantity` to buy a pack. The response's `status` is `succeeded` when the credits were added, or `processing` when the payment method confirms later, such as Pix: the credits are added and [`credits.purchased`](/docs/webhooks/credits-purchased) fires when the payment is confirmed. A declined payment adds nothing and voids the invoice.
|
|
104
104
|
|
|
105
|
-
| Response | Cause
|
|
106
|
-
| ----------------------------- |
|
|
107
|
-
| `400 validation_error` | The quantity is below the plan's minimum, or the plan doesn't sell credits
|
|
108
|
-
| `402 no_payment_method` | The subscription has no saved payment method Commet can charge
|
|
109
|
-
| `402 payment_failed` | The charge was declined
|
|
110
|
-
| `409 credit_pack_unavailable` | The subscription's plan version doesn't sell the pack
|
|
105
|
+
| Response | Cause |
|
|
106
|
+
| ----------------------------- | --------------------------------------------------------------------------------------------------- |
|
|
107
|
+
| `400 validation_error` | The quantity is below the plan's minimum, or the plan doesn't sell credits |
|
|
108
|
+
| `402 no_payment_method` | The subscription has no saved payment method Commet can charge, and the request has no `successUrl` |
|
|
109
|
+
| `402 payment_failed` | The charge was declined |
|
|
110
|
+
| `409 credit_pack_unavailable` | The subscription's plan version doesn't sell the pack |
|
|
111
|
+
|
|
112
|
+
### Customers without a saved payment method
|
|
113
|
+
|
|
114
|
+
Send `successUrl` to let a customer without a saved payment method buy a quantity or a pack. The response's `status` is `requires_checkout`, with a `checkoutUrl` where the customer pays the purchase and saves the payment method in one step:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
const purchase = await commet.subscriptions.purchaseCredits({
|
|
118
|
+
id: 'sub_xxx',
|
|
119
|
+
quantity: 500,
|
|
120
|
+
successUrl: 'https://your-app.com/credits',
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
if (purchase.status === 'requires_checkout') {
|
|
124
|
+
redirect(purchase.checkoutUrl)
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Nothing is charged until the customer pays. The credits are added and [`credits.purchased`](/docs/webhooks/credits-purchased) fires when the payment is confirmed, so don't send the purchase again after the customer returns. An unpaid checkout expires after 24 hours and leaves nothing owed. A subscription with a saved payment method is charged directly, and a declined charge returns `402` with or without `successUrl`.
|
|
111
129
|
|
|
112
130
|
The effective minimum is the larger of the configured minimum and the smallest quantity that reaches the currency's minimum charge.
|
|
113
131
|
|
|
@@ -163,6 +163,7 @@ curl -X POST https://commet.co/api/v1/subscriptions \
|
|
|
163
163
|
```
|
|
164
164
|
|
|
165
165
|
- The cancellation is scheduled from creation: the response already shows `cancelAtPeriodEnd: true` and `cancellation` before the customer pays.
|
|
166
|
+
- The checkout shows `1 month · one-time payment, doesn't renew`, or the periods paid, and no charges after them.
|
|
166
167
|
- The purchase keeps ending even if the customer saves a card through a payment method update link, and the Customer Portal doesn't offer **Keep subscription** for it.
|
|
167
168
|
- Free trials don't combine with it: `customTrialDays` above `0` returns `400` and the price's trial is skipped.
|
|
168
169
|
- When the purchase ends, Commet emits [`subscription.canceled`](/docs/webhooks/subscription-canceled).
|
|
@@ -30,7 +30,25 @@ const launchOffer = await commet.offers.create({
|
|
|
30
30
|
})
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
The Offer does not contain `purpose`, `planPriceIds`, eligibility, or redemption rules.
|
|
33
|
+
The Offer does not contain `purpose`, `planPriceIds`, eligibility, or redemption rules. It can carry two optional limits: the plans and the billing interval it applies to.
|
|
34
|
+
|
|
35
|
+
## Limit an Offer to plans or a billing interval
|
|
36
|
+
|
|
37
|
+
An Offer applies to any plan and any billing interval, and it stays with the subscription when the customer changes either one. Two optional limits narrow that:
|
|
38
|
+
|
|
39
|
+
| Field | Limit |
|
|
40
|
+
| ----------------- | --------------------------------------------------------------------------------------------- |
|
|
41
|
+
| `planIds` | The Offer applies only to subscriptions on these plans. An empty list means every plan. |
|
|
42
|
+
| `billingInterval` | The Offer applies only to subscriptions billed on this interval. `null` means every interval. |
|
|
43
|
+
|
|
44
|
+
In the dashboard, open **Limits (optional)** in the Offer form and choose **Subscription billing interval** and **Applicable plans**. The Offer page shows them as **Applies to** and **Billing interval**. Through the API, send `planIds` and `billingInterval` when you create or update the Offer. An update that omits a limit keeps it; `planIds: []` and `billingInterval: null` remove it.
|
|
45
|
+
|
|
46
|
+
A limit acts at two moments:
|
|
47
|
+
|
|
48
|
+
- **When the Offer is applied.** A limited Offer cannot be applied to a subscription on another plan or interval. With `offerId`, creating the subscription returns `400 validation_error` on `offerId`, an immediate plan change and `PUT /subscriptions/{id}/offer` return `400 offer_not_applicable`, and a plan-change preview returns `404 offer_not_found`. A [Promo Code](/docs/promo-codes) of the Offer is rejected with `plan_not_eligible` or `billing_interval_not_eligible`, and a [Card Promotion](/docs/card-promotions) of the Offer does not apply.
|
|
49
|
+
- **When the customer changes plan or billing interval.** The applied Offer ends with the change when the new plan or interval is outside the limit. Inside the limit, it continues as [any discount does](/docs/how-do-discounts-work#plan-changes).
|
|
50
|
+
|
|
51
|
+
Limits are read when the change happens. A limit you add later also reaches customers who already have the Offer, the next time they change plan or billing interval.
|
|
34
52
|
|
|
35
53
|
## Apply the same Offer in different ways
|
|
36
54
|
|
|
@@ -51,10 +69,10 @@ When Commet quotes or applies an Offer, it records an immutable Offer Applicatio
|
|
|
51
69
|
- the resolved currency and amounts when available;
|
|
52
70
|
- the exact accepted phases and dates.
|
|
53
71
|
|
|
54
|
-
Editing, deactivating, or archiving the catalog Offer affects future applications only. Existing applications remain available for billing and audit.
|
|
72
|
+
Editing, deactivating, or archiving the catalog Offer affects future applications only. Existing applications remain available for billing and audit. The plan and interval limits are the exception: they are read each time the customer changes plan or billing interval.
|
|
55
73
|
|
|
56
74
|
The v9 response is target-aware (`plan_price`, `addon`, or `credit_pack`) so new purchase surfaces do not require another breaking response change. Current public subscription, Introductory, direct, and Promo Code flows create `plan_price` applications.
|
|
57
75
|
|
|
58
76
|
## Offers managed by an integration
|
|
59
77
|
|
|
60
|
-
An Offer created by an integration, such as [Dub](/docs/connect-dub-affiliates), has `managedBy` set to that integration. Its terms change only there: editing them returns `409 managed_by_integration`. Renaming it still
|
|
78
|
+
An Offer created by an integration, such as [Dub](/docs/connect-dub-affiliates), has `managedBy` set to that integration. Its terms change only there: editing them returns `409 managed_by_integration`. Renaming it and changing its plan and interval limits still work.
|
|
@@ -91,8 +91,8 @@ A rejected code returns `400 validation_error` with `param: "promoCode"` and the
|
|
|
91
91
|
- `max_redemptions_reached`: the redemption limit was reached.
|
|
92
92
|
- `first_purchase_only`: the customer already paid or has a paid subscription.
|
|
93
93
|
- `already_redeemed`: the customer already redeemed the code.
|
|
94
|
-
- `plan_not_eligible`: the code is
|
|
95
|
-
- `billing_interval_not_eligible`: the code is
|
|
94
|
+
- `plan_not_eligible`: the code, or its Offer, is limited to other plans.
|
|
95
|
+
- `billing_interval_not_eligible`: the code, or its Offer, is limited to another billing interval.
|
|
96
96
|
- `intro_offer_active`: an Introductory Offer applies.
|
|
97
97
|
|
|
98
98
|
Checkout also rejects a positive total below the currency's minimum charge.
|
|
@@ -36,7 +36,7 @@ await commet.subscriptions.create({
|
|
|
36
36
|
})
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
The Offer must be active, inside its availability window, and resolvable in the selected currency. It does not need a prior association with the plan or price.
|
|
39
|
+
The Offer must be active, inside its availability window, and resolvable in the selected currency. It does not need a prior association with the plan or price, but an Offer [limited to other plans or another billing interval](/docs/offers#limit-an-offer-to-plans-or-a-billing-interval) is rejected.
|
|
40
40
|
|
|
41
41
|
An explicit `offerId` overrides automatic introductory selection. It cannot be combined with `promoCode`. It combines with `customTrialDays` and `skipTrial`; when the price has a trial, the discount starts after it.
|
|
42
42
|
|
|
@@ -55,7 +55,7 @@ await commet.subscriptions.applyOffer({
|
|
|
55
55
|
|
|
56
56
|
Only one Offer applies at a time: while an accepted Offer still has active or upcoming discount phases, a new application is rejected. Once its phases are exhausted, the subscription accepts a new Offer. The discount applies to the plan base price only.
|
|
57
57
|
|
|
58
|
-
The applied Offer belongs to that subscription
|
|
58
|
+
The applied Offer belongs to that subscription: it ends with a cancellation, and it [keeps going through a plan change](/docs/how-do-discounts-work#plan-changes) with the cycles it had left.
|
|
59
59
|
|
|
60
60
|
The same operation on a subscription with a pending checkout quotes or replaces the checkout discount instead; there it accepts an optional `expiresAt` for the quote. When the price has a trial, the discount starts after it.
|
|
61
61
|
|
|
@@ -329,7 +329,7 @@ The response includes `subscriptionId`, `invoiceId`, and `status`. An immediate
|
|
|
329
329
|
| `422`, `no_payment_method` | A period-end resume needs a saved payment method. |
|
|
330
330
|
| `500`, `internal_error` | An internal failure prevented completion; this is distinct from a declined payment. |
|
|
331
331
|
|
|
332
|
-
A declined resume keeps its invoice outstanding. Automatic payment retries follow
|
|
332
|
+
A declined resume keeps its invoice outstanding. Automatic payment retries follow the calendar of your [retry window](/docs/handle-failed-payments#automatic-retries) from the original failure and reuse that invoice. The subscription stays paused during retries. If all retries fail, it is canceled and the resume invoice becomes uncollectible. Manual resume attempts do not consume automatic retry slots.
|
|
333
333
|
|
|
334
334
|
A period-end resume uses the base price of the subscription's plan version when its new invoice is created. An outstanding resume invoice keeps its original amounts and included credits or balance on retry, even if the catalog changes again. Accepted Introductory Offers and discounts preserve their unconsumed terms; resume does not grant a new Introductory Offer or redeem a promo code again.
|
|
335
335
|
|
|
@@ -689,11 +689,11 @@ $commet = new Commet('ck_xxx');
|
|
|
689
689
|
$recoveryLink = $commet->subscriptions->createRecoveryLink(id: 'sub_xxx');
|
|
690
690
|
```
|
|
691
691
|
|
|
692
|
-
Automatic dunning retries are anchored to the original decline
|
|
692
|
+
Automatic dunning retries are anchored to the original decline and follow the calendar of your [retry window](/docs/handle-failed-payments#automatic-retries). A successful retry returns the subscription to `active`.
|
|
693
693
|
|
|
694
694
|
## Reactivate a canceled subscription
|
|
695
695
|
|
|
696
|
-
The same `reactivate` operation charges the saved payment method, reuses the subscription record, and starts a fresh period anchored to the reactivation date. You may pass an `offerId`; accepted phases are persisted as an immutable Offer Application.
|
|
696
|
+
The same `reactivate` operation charges the saved payment method, reuses the subscription record, and starts a fresh period anchored to the reactivation date. You may pass an `offerId`; accepted phases are persisted as an immutable Offer Application. When the reactivation invoice totals zero, for example under an Offer with a fixed price of 0, it is marked paid without a charge and the subscription becomes active at once; a saved payment method is still required.
|
|
697
697
|
|
|
698
698
|
The subscription returns on the latest version of what was bought: the plan's current version for a plan code, the experiment's latest version for an experiment code (the plan's current version once the experiment is no longer running), and the same version for `planVersionId`. Add-ons that version doesn't sell are deactivated. If it doesn't sell the subscription's currency, reactivation returns `422 missing_regional_price`.
|
|
699
699
|
|
|
@@ -105,10 +105,12 @@ A Promo Code for that Offer entered on a prepaid checkout is rejected with "This
|
|
|
105
105
|
|
|
106
106
|
## What the customer sees at checkout
|
|
107
107
|
|
|
108
|
-
| Purchase | Checkout shows
|
|
109
|
-
| ------------------------------------------------------------------------------------------------------------ |
|
|
110
|
-
| Renews after the paid periods | `3 months · then $10.00/mo` or `2 quarters · then $30.00/qtr`
|
|
111
|
-
| One-time purchase, a subscription scheduled to end, or a first payment with a method that can't renew (OXXO) | `3 months · one-time payment, doesn't renew`
|
|
108
|
+
| Purchase | Checkout shows |
|
|
109
|
+
| ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- |
|
|
110
|
+
| Renews after the paid periods | `3 months · then $10.00/mo` or `2 quarters · then $30.00/qtr` |
|
|
111
|
+
| One-time purchase, a subscription scheduled to end, or a first payment with a method that can't renew (OXXO) | `3 months · one-time payment, doesn't renew`, or `1 month · one-time payment, doesn't renew` for a single period |
|
|
112
|
+
|
|
113
|
+
A single period that renews keeps the plan interval, such as `per month`. A purchase that doesn't renew shows no charges after its paid periods, even with a discount. The pending payment page and an unavailable checkout show the same label.
|
|
112
114
|
|
|
113
115
|
On a link that adds periods to an active subscription, the label follows whether the subscription renews, not the method chosen in that checkout. An OXXO payment on a card subscription shows `then …`.
|
|
114
116
|
|
|
@@ -18,18 +18,30 @@ The subscription keeps its immutable base-plan contract. The grant pins an immut
|
|
|
18
18
|
|
|
19
19
|
When the grant ends, Commet immediately evaluates access against the base subscription again. Existing seats and recorded usage are not deleted. If the customer is already above a base-plan hard limit, further use is blocked until usage resets, capacity falls below the limit, or the subscription is upgraded normally.
|
|
20
20
|
|
|
21
|
+
## Credits and Balance plans
|
|
22
|
+
|
|
23
|
+
On a Credits or Balance plan, the target plan's terms for plan credits or plan balance apply while the grant lasts: the amount included each period, unused credits or balance carried over and their cap, the daily or weekly limit, and unlimited plan credits or balance. What each unit consumes stays the base plan's: credits per unit, the balance price per unit and AI model margins. A feature only the target plan has uses the target plan's.
|
|
24
|
+
|
|
25
|
+
- When the grant starts, the plan credits or plan balance grow at once by the difference between both included amounts. A Free subscription with 50 of its 93 monthly credits left that is granted Pro, which includes 240, holds 197.
|
|
26
|
+
- Each renewal while the grant is active adds the target plan's included amount with the target plan's carry-over rules.
|
|
27
|
+
- When the grant is revoked or expires mid-period, the plan part goes down by the same difference, without going below zero or removing debt, and the base plan's limit applies again. The next renewal gives the base plan's amount. A grant that ends exactly at a renewal leaves that renewal on the base plan's amount.
|
|
28
|
+
- Purchased credits and balance top-ups keep being sold and charged by the base subscription's plan.
|
|
29
|
+
|
|
30
|
+
A subscription on a plan without a consumption model can be granted a Credits or Balance plan. It consumes the target plan's credits or balance while the grant lasts, and when the grant ends it can no longer use those features.
|
|
31
|
+
|
|
21
32
|
## Eligibility
|
|
22
33
|
|
|
23
34
|
The base subscription must be active and recurring. The target plan must belong to the same Plan Group and have a higher `sortOrder` than the base plan.
|
|
24
35
|
|
|
25
|
-
|
|
36
|
+
Grants work on Metered, Credits and Balance plans. Both plans must use the same consumption model, with two exceptions: a plan without a consumption model can be granted a plan of any model, and a Metered plan and a plan without a consumption model can be combined either way. Commet rejects a grant when:
|
|
26
37
|
|
|
27
|
-
-
|
|
28
|
-
- paid overage;
|
|
29
|
-
-
|
|
30
|
-
-
|
|
38
|
+
- the base and target plans use different consumption models other than those exceptions;
|
|
39
|
+
- either plan bills paid overage: Metered overage or AI model pricing on a Metered plan, or Credits or Balance that can go negative;
|
|
40
|
+
- the subscription has active add-ons;
|
|
41
|
+
- a Credits or Balance target plan does not sell the subscription's billing interval; or
|
|
42
|
+
- a Balance target plan does not sell the subscription's country and currency, or does not price in that country a usage feature the base plan lacks.
|
|
31
43
|
|
|
32
|
-
The target plan may itself be free or paid.
|
|
44
|
+
The target plan may itself be free or paid. It never charges anything: on a Credits or Balance plan, Commet only reads the amount included by its price for the subscription's billing interval.
|
|
33
45
|
|
|
34
46
|
## Choose a duration
|
|
35
47
|
|
|
@@ -93,6 +105,10 @@ curl -X POST https://commet.co/api/v1/customers/cus_xxx/plan-grants/grt_xxx/revo
|
|
|
93
105
|
|
|
94
106
|
Revocation does not create a full-price obligation, re-anchor the subscription, or move it to `pending_payment`.
|
|
95
107
|
|
|
108
|
+
## Change plan during a grant
|
|
109
|
+
|
|
110
|
+
A subscription with an active grant can change plan or billing interval. When the change applies, Commet revokes the grant with source `system` and sends `plan_grant.revoked`. On a Credits or Balance plan, the plan part first goes down by the grant's difference, as on any revocation, and then the change gives the new plan's amounts with its carry-over rules.
|
|
111
|
+
|
|
96
112
|
## Plan Grants, Offers, trials, and Invoice Credit
|
|
97
113
|
|
|
98
114
|
| Need | Use |
|