@commet/node 9.8.0 → 9.9.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 +216 -23
- package/dist/index.d.ts +216 -23
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/docs/api-reference/customers.md +2 -0
- package/docs/api-reference/generated-webhooks.md +2 -2
- package/docs/api-reference/index.md +1 -1
- package/docs/api-reference/plans.md +8 -3
- package/docs/api-reference/subscriptions.md +7 -5
- package/docs/documentation/cli.md +60 -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 +1 -1
- package/docs/documentation/plans/consumption-models.md +44 -9
- package/docs/documentation/plans/credit-packs.md +49 -1
- package/docs/documentation/plans/one-time-payments.md +3 -3
- package/docs/documentation/plans/plan-groups.md +46 -10
- 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 +16 -0
- package/docs/documentation/sales/trial-periods.md +67 -40
- package/docs/documentation/subscriptions/manage-subscriptions.md +65 -2
- package/docs/documentation/subscriptions/pay-in-advance.md +4 -7
- package/docs/documentation/subscriptions/upgrade-and-downgrade-plans.md +20 -2
- package/docs/documentation/testing-sandbox.md +2 -0
- package/docs/documentation/usage/track-usage.md +23 -0
- package/docs/errors/index.md +1 -0
- package/docs/errors/plan_balance_limit_reached.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 +14 -8
- 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 +30 -24
- package/docs/knowledge-base/how-does-billing-work.md +1 -0
- package/docs/knowledge-base/what-happens-when-a-payment-fails.md +11 -9
- package/docs/manifest.json +12 -2
- package/docs/platform-documentation.md +1 -0
- package/docs/schemas.md +27 -14
- package/docs/webhooks/introduction.md +14 -12
- package/docs/webhooks.md +42 -6
- package/docs/webhooks.openapi.json +857 -745
- package/package.json +1 -1
|
@@ -12,6 +12,22 @@ Commet has two complementary pricing layers:
|
|
|
12
12
|
|
|
13
13
|
Currency Pricing remains the fallback. Add Markets when country segmentation or selectable variants require it.
|
|
14
14
|
|
|
15
|
+
## Set currency pricing
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
await commet.plans.setRegionalPricing({
|
|
19
|
+
id: 'pln_pro',
|
|
20
|
+
currency: 'gbp',
|
|
21
|
+
exchangeRate: 0.79,
|
|
22
|
+
})
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
With only `currency` and `exchangeRate`, Commet derives every price, included balance, and overage from the USD values. Send `prices` or `features` to set exact amounts instead.
|
|
26
|
+
|
|
27
|
+
Supported currencies: USD, ARS, BOB, BRL, CAD, CLP, CNY, COP, EUR, GBP, HKD, INR, JPY, KRW, MXN, PEN, PYG, SGD, THB, TWD, and UYU.
|
|
28
|
+
|
|
29
|
+
A currency applies to the countries that use it. Buyers in the United Kingdom pay in GBP, and EUR covers the euro countries. Buyers in a country without a configured currency pay the USD base price.
|
|
30
|
+
|
|
15
31
|
## Create a Market
|
|
16
32
|
|
|
17
33
|
A Market is a top-level Sales resource. It does not require a plan or price.
|
|
@@ -1,80 +1,107 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Trial Periods
|
|
3
|
-
description:
|
|
3
|
+
description: Set free trial days on a plan price, with or without a payment method, and override them per subscription with customTrialDays or skipTrial.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
A trial is a
|
|
6
|
+
A trial is a number of free days set on a plan price. [Offers](/docs/offers) hold discounts only; a discount starts after the trial.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
## Set trial days on a price
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
| ---------------------- | ------------------------------------------------------------------------------------------ |
|
|
12
|
-
| Introductory placement | Applied automatically to an eligible new subscription |
|
|
13
|
-
| Direct `offerId` | Applied explicitly by your application |
|
|
14
|
-
| Promo Code | Customer enters a code for an Offer that starts with a trial and continues with a discount |
|
|
15
|
-
| `customTrialDays` | Creates customer-specific trial terms without a reusable catalog Offer |
|
|
16
|
-
| `skipTrial: true` | Bypasses the automatic trial |
|
|
17
|
-
|
|
18
|
-
Promo Code trials require at least one discount phase after the trial. A code can be pre-applied at subscription creation or entered in a pending payment checkout, which then changes to a trial setup checkout.
|
|
19
|
-
|
|
20
|
-
## Reusable trial
|
|
21
|
-
|
|
22
|
-
Create one Offer and reuse it:
|
|
10
|
+
In the dashboard, open **Plans**, select the plan, and choose **Edit price**. Enter the **Free trial** days and choose whether to **Require a payment method**.
|
|
23
11
|
|
|
24
12
|
```typescript
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
],
|
|
13
|
+
await commet.plans.updatePrice({
|
|
14
|
+
id: 'pln_xxx',
|
|
15
|
+
priceId: 'pp_xxx',
|
|
16
|
+
trialDays: 14,
|
|
30
17
|
})
|
|
31
18
|
```
|
|
32
19
|
|
|
33
|
-
|
|
20
|
+
| Parameter | Type | Description |
|
|
21
|
+
| ---------------------------- | --------- | ------------------------------------------------------------------------------- |
|
|
22
|
+
| `trialDays` | `integer` | Free days before the first charge. `0` to `730`; `0` removes the trial |
|
|
23
|
+
| `trialRequiresPaymentMethod` | `boolean` | Default `true`. `false` starts the trial without checkout. Requires `trialDays` |
|
|
24
|
+
|
|
25
|
+
Price variants inherit the trial of their base price. One-time prices can't have a trial.
|
|
26
|
+
|
|
27
|
+
A subscription keeps the trial days it accepted. Changing `trialDays` affects only new subscriptions.
|
|
28
|
+
|
|
29
|
+
## Start a trial with a payment method
|
|
34
30
|
|
|
35
31
|
```typescript
|
|
36
|
-
await commet.subscriptions.create({
|
|
32
|
+
const { checkoutUrl } = await commet.subscriptions.create({
|
|
37
33
|
customerId: 'user_123',
|
|
38
34
|
planCode: 'pro',
|
|
39
|
-
offerId: trialOffer.id,
|
|
40
35
|
})
|
|
41
36
|
```
|
|
42
37
|
|
|
43
|
-
|
|
38
|
+
Redirect the customer to `checkoutUrl`. Checkout saves the payment method without charging it, and the subscription becomes `trialing` with `trialEndsAt` set.
|
|
39
|
+
|
|
40
|
+
When the trial ends, Commet charges the current value of the selected price and the subscription becomes `active`. A promo code typed in the trial checkout discounts the first invoice after the trial.
|
|
44
41
|
|
|
45
|
-
##
|
|
42
|
+
## Start a trial without a payment method
|
|
46
43
|
|
|
47
|
-
|
|
44
|
+
> **Warning**
|
|
45
|
+
>
|
|
46
|
+
> A price with `trialRequiresPaymentMethod: false` rejects `offerId`, `promoCode`, `cardPromotionId` and `provider` at creation with `400`. An organization that can't charge yet receives `403`.
|
|
48
47
|
|
|
49
48
|
```typescript
|
|
50
|
-
await commet.subscriptions.create({
|
|
49
|
+
const subscription = await commet.subscriptions.create({
|
|
51
50
|
customerId: 'user_123',
|
|
52
51
|
planCode: 'pro',
|
|
53
|
-
customTrialDays: 21,
|
|
54
52
|
})
|
|
53
|
+
// subscription.status === 'trialing'
|
|
54
|
+
// subscription.checkoutUrl === null
|
|
55
|
+
// subscription.hasPaymentMethod === false
|
|
55
56
|
```
|
|
56
57
|
|
|
57
|
-
|
|
58
|
+
The trial starts immediately, with no checkout and no charge. The customer adds a card from the [Customer Portal](/docs/customer-portal) (**Add card**) or through a link from `subscriptions.updatePaymentMethod`.
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
When the trial ends without a card:
|
|
61
|
+
|
|
62
|
+
- The subscription moves to the [plan group's default plan](/docs/plan-groups#default-plan-and-signup-trial) and `subscription.plan_changed` fires.
|
|
63
|
+
- Without a default plan, the subscription is canceled with `cancelReason: "trial_ended_without_payment_method"`.
|
|
64
|
+
- No invoice is created. `trial.expired` fires in both cases.
|
|
65
|
+
|
|
66
|
+
With a card added, the trial ends like a trial that started with one.
|
|
67
|
+
|
|
68
|
+
During the trial, an immediate plan change returns `409 no_payment_method`. Scheduled changes still apply.
|
|
69
|
+
|
|
70
|
+
## Override the trial per subscription
|
|
71
|
+
|
|
72
|
+
| Field | Effect |
|
|
73
|
+
| ----------------- | ----------------------------------------------------- |
|
|
74
|
+
| `customTrialDays` | Replaces the price's trial days for this subscription |
|
|
75
|
+
| `skipTrial: true` | Starts without a trial |
|
|
76
|
+
|
|
77
|
+
Both combine with `offerId`. The Offer's discount starts after the trial.
|
|
60
78
|
|
|
61
79
|
```typescript
|
|
62
80
|
await commet.subscriptions.create({
|
|
63
81
|
customerId: 'user_123',
|
|
64
82
|
planCode: 'pro',
|
|
65
|
-
|
|
83
|
+
offerId: 'ofr_xxx',
|
|
84
|
+
customTrialDays: 21,
|
|
66
85
|
})
|
|
67
86
|
```
|
|
68
87
|
|
|
69
|
-
|
|
88
|
+
## Eligibility
|
|
89
|
+
|
|
90
|
+
A customer gets one trial per plan. A customer who already had the plan, in a trial or paying, gets no trial and goes through the regular checkout, including with `customTrialDays`.
|
|
91
|
+
|
|
92
|
+
`prepaidPeriods` above `1` and `cancelAtPeriodEnd: true` skip the price's trial; with `customTrialDays` above `0` they return `400`. `cardPromotionId` skips a trial that requires a payment method.
|
|
70
93
|
|
|
71
|
-
##
|
|
94
|
+
## Trial webhooks
|
|
72
95
|
|
|
73
|
-
|
|
96
|
+
- [`trial.checkout_ready`](/docs/webhooks/trial-checkout-ready): the trial checkout link is ready.
|
|
97
|
+
- [`trial.started`](/docs/webhooks/trial-started): the trial began. Grant access.
|
|
98
|
+
- [`trial.will_end`](/docs/webhooks/trial-will-end): the trial ends within 3 days.
|
|
99
|
+
- [`trial.converted`](/docs/webhooks/trial-converted): the customer changed plan before the trial ended.
|
|
100
|
+
- [`trial.expired`](/docs/webhooks/trial-expired): the trial ran out.
|
|
74
101
|
|
|
75
|
-
|
|
76
|
-
2. `trialEndsAt` records the end of the free-trial phase;
|
|
77
|
-
3. Commet charges the current selected price when the trial ends;
|
|
78
|
-
4. any following Offer phase becomes active.
|
|
102
|
+
## Limitations
|
|
79
103
|
|
|
80
|
-
|
|
104
|
+
- `trialDays` accepts `0` to `730`. The dashboard accepts whole days from `1` to `730`; leave it empty for no trial.
|
|
105
|
+
- One trial per customer per plan.
|
|
106
|
+
- Trials don't combine with `prepaidPeriods` above `1` or `cancelAtPeriodEnd: true`.
|
|
107
|
+
- A trial without a payment method can't start with an Offer, promo code, card promotion or provider override.
|
|
@@ -97,7 +97,7 @@ $createdSubscription = $commet->subscriptions->create(
|
|
|
97
97
|
);
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
-
For a paid plan, redirect the customer to `checkoutUrl`. Free plans
|
|
100
|
+
For a paid plan, redirect the customer to `checkoutUrl`. Free plans and [trials without a payment method](/docs/trial-periods#start-a-trial-without-a-payment-method) start without checkout and return `checkoutUrl: null`; `hasPaymentMethod` tells whether Commet can charge the subscription on its own.
|
|
101
101
|
|
|
102
102
|
The normal path needs only `customerId` and either `planCode` or `planId`. Optional selection fields are:
|
|
103
103
|
|
|
@@ -108,7 +108,7 @@ The normal path needs only `customerId` and either `planCode` or `planId`. Optio
|
|
|
108
108
|
| `offerId` | Your application selected an Offer directly; it overrides automatic introductory selection |
|
|
109
109
|
| `promoCode` | The customer entered a Promo Code |
|
|
110
110
|
| `initialSeats` | You know the initial seat quantities at creation |
|
|
111
|
-
| `skipTrial` or `customTrialDays` | You intentionally override the
|
|
111
|
+
| `skipTrial` or `customTrialDays` | You intentionally override the price's [trial](/docs/trial-periods) |
|
|
112
112
|
|
|
113
113
|
Omitting `priceId` preserves default price and Market resolution. Omitting `offerId` preserves automatic Introductory Offer selection.
|
|
114
114
|
|
|
@@ -402,6 +402,8 @@ $subscription = $commet->subscriptions->cancel(id: 'sub_xxx');
|
|
|
402
402
|
|
|
403
403
|
A normal paid active subscription schedules cancellation at period end unless `immediate: true` is sent. Free, pending-payment, and past-due relationships cancel immediately. Cancellation does not erase the stored subscription balance.
|
|
404
404
|
|
|
405
|
+
The API cancels even when the plan group has a [default plan](/docs/plan-groups#default-plan-and-signup-trial). A paid plan canceled from the Customer Portal moves to that default plan at period end instead.
|
|
406
|
+
|
|
405
407
|
Canceling a paused subscription is immediate and discards its preserved time. Pending usage, overage, or seat adjustments may still produce a final invoice. To cancel while a future pause is scheduled, revoke that pause first.
|
|
406
408
|
|
|
407
409
|
## Reverse a scheduled cancellation
|
|
@@ -467,6 +469,67 @@ $subscription = $commet->subscriptions->uncancel(id: 'sub_xxx');
|
|
|
467
469
|
|
|
468
470
|
`uncancel` works only before an end-of-period cancellation takes effect. It keeps the same subscription and current period.
|
|
469
471
|
|
|
472
|
+
## Revoke a scheduled plan change
|
|
473
|
+
|
|
474
|
+
Keep the current plan when a downgrade or interval change is scheduled for the end of the period:
|
|
475
|
+
|
|
476
|
+
**TypeScript**
|
|
477
|
+
|
|
478
|
+
```typescript
|
|
479
|
+
import { Commet } from "@commet/node";
|
|
480
|
+
|
|
481
|
+
const commet = new Commet({ apiKey: "ck_xxx" });
|
|
482
|
+
|
|
483
|
+
const subscription = await commet.subscriptions.revokeScheduledPlanChange({ id: "sub_xxx" });
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
**Python**
|
|
487
|
+
|
|
488
|
+
```python
|
|
489
|
+
from commet import Commet
|
|
490
|
+
|
|
491
|
+
commet = Commet("ck_xxx")
|
|
492
|
+
|
|
493
|
+
subscription = commet.subscriptions.revoke_scheduled_plan_change("sub_xxx")
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
**Go**
|
|
497
|
+
|
|
498
|
+
```go
|
|
499
|
+
client, err := commet.New("ck_xxx")
|
|
500
|
+
if err != nil {
|
|
501
|
+
log.Fatal(err)
|
|
502
|
+
}
|
|
503
|
+
ctx := context.Background()
|
|
504
|
+
|
|
505
|
+
subscription, err := client.Subscriptions.RevokeScheduledPlanChange(ctx, "sub_xxx")
|
|
506
|
+
if err != nil {
|
|
507
|
+
log.Fatal(err)
|
|
508
|
+
}
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
**Java**
|
|
512
|
+
|
|
513
|
+
```java
|
|
514
|
+
import co.commet.Commet;
|
|
515
|
+
|
|
516
|
+
var commet = Commet.builder().apiKey("ck_xxx").build();
|
|
517
|
+
|
|
518
|
+
var subscription = commet.subscriptions().revokeScheduledPlanChange("sub_xxx");
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
**PHP**
|
|
522
|
+
|
|
523
|
+
```php
|
|
524
|
+
use Commet\Commet;
|
|
525
|
+
|
|
526
|
+
$commet = new Commet('ck_xxx');
|
|
527
|
+
|
|
528
|
+
$subscription = $commet->subscriptions->revokeScheduledPlanChange(id: 'sub_xxx');
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
This also revokes a scheduled move to the plan group's default plan. A subscription with nothing scheduled returns `409 no_scheduled_plan_change`.
|
|
532
|
+
|
|
470
533
|
## Recover a past-due subscription
|
|
471
534
|
|
|
472
535
|
Reactivate retries the outstanding renewal charge and keeps the original billing relationship:
|
|
@@ -13,7 +13,7 @@ Paying in advance doesn't decide whether the subscription renews afterward. To s
|
|
|
13
13
|
|
|
14
14
|
> **Warning**
|
|
15
15
|
>
|
|
16
|
-
> **Free trials don't combine with paying in advance.** With `prepaidPeriods` above `1` or `cancelAtPeriodEnd: true`,
|
|
16
|
+
> **Free trials don't combine with paying in advance.** With `prepaidPeriods` above `1` or `cancelAtPeriodEnd: true`, `customTrialDays` above `0` returns `400` and the price's trial is skipped.
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
19
|
curl -X POST https://commet.co/api/v1/subscriptions \
|
|
@@ -66,10 +66,10 @@ Commet voids an unpaid link and emits [`invoice.voided`](/docs/webhooks/invoice-
|
|
|
66
66
|
| Response | Cause |
|
|
67
67
|
| --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
68
68
|
| `400 validation_error` | The price is one-time or the plan is free |
|
|
69
|
-
| `400 validation_error` | `offerId`
|
|
69
|
+
| `400 validation_error` | `offerId` is unavailable or was sent for a `pending_payment` subscription. `param` is `offerId` |
|
|
70
70
|
| `400 validation_error` | An Offer bills on another interval. See [Offers billed on another interval](#offers-billed-on-another-interval) |
|
|
71
71
|
| `400 validation_error` | The total is below the minimum charge, such as with a 100% Offer. `param` is `offerId` when you sent one, `periods` otherwise. The previous unpaid link stays payable |
|
|
72
|
-
| `409 invalid_subscription_status` | The subscription isn't `active` or awaiting its first payment, it
|
|
72
|
+
| `409 invalid_subscription_status` | The subscription isn't `active` or awaiting its first payment, it starts with a free trial, or a pause is scheduled |
|
|
73
73
|
| `409 charge_in_progress` | A payment for the link being replaced couldn't be canceled, such as a generated OXXO voucher |
|
|
74
74
|
|
|
75
75
|
## How each period is priced
|
|
@@ -89,10 +89,7 @@ Payment → $20
|
|
|
89
89
|
|
|
90
90
|
For the first payment, the currency and country price are resolved at checkout, as for any subscription. Offers run for their full configured duration starting at the first paid period. An Offer assigned with `PUT /v1/subscriptions/{id}/offer` to a subscription with paid periods left starts at the first renewal that charges, after the last paid period.
|
|
91
91
|
|
|
92
|
-
[Card Promotions](/docs/card-promotions) behave as on any subscription. [Promo Codes](/docs/promo-codes) do too, with
|
|
93
|
-
|
|
94
|
-
- A link that adds periods to an active subscription keeps the price it was created with, so a Promo Code entered there is rejected with "Promo codes can't be used on a link that adds billing periods".
|
|
95
|
-
- A trial Promo Code entered on a checkout that pays several periods or on a one-time purchase is rejected with "Trial codes can't be used when paying in advance".
|
|
92
|
+
[Card Promotions](/docs/card-promotions) behave as on any subscription. [Promo Codes](/docs/promo-codes) do too, with one exception: a link that adds periods to an active subscription keeps the price it was created with, so a Promo Code entered there is rejected with "Promo codes can't be used on a link that adds billing periods".
|
|
96
93
|
|
|
97
94
|
### Offers billed on another interval
|
|
98
95
|
|
|
@@ -14,15 +14,33 @@ Customers change plans through the [Customer Portal](/docs/customer-portal) or f
|
|
|
14
14
|
| **Interval change (up)** | Applied immediately | Monthly → Yearly |
|
|
15
15
|
| **Interval change (down)** | Takes effect at next renewal | Yearly → Monthly |
|
|
16
16
|
|
|
17
|
-
Both plans must be in the same [Plan Group](/docs/plan-groups) for customers to change plans themselves through the portal. Free-to-paid changes
|
|
17
|
+
Both plans must be in the same [Plan Group](/docs/plan-groups) for customers to change plans themselves through the portal. Free-to-paid changes open a checkout for the customer to pay. When the new price has a [trial without a payment method](/docs/trial-periods#start-a-trial-without-a-payment-method) and the customer never had that plan, the trial starts at once instead.
|
|
18
|
+
|
|
19
|
+
Immediate changes accept an `offerId` or a [`promoCode`](/docs/promo-codes#apply-a-code-on-a-plan-change). Scheduled changes accept neither.
|
|
18
20
|
|
|
19
21
|
An immediate upgrade is rejected with a seat-limit error when the customer's current seats exceed the target plan's included seats for a seat feature that is not unlimited and has overage disabled. Reduce seats first, or pick a plan with enough included seats. Interval-only changes and scheduled downgrades are not affected.
|
|
20
22
|
|
|
23
|
+
During a trial without a payment method, an immediate change returns `409 no_payment_method`. Scheduled changes still apply.
|
|
24
|
+
|
|
21
25
|
If you need to expand features or limits temporarily without changing the subscription's plan, price, or billing cycle, use a [Plan Grant](/docs/plan-grants) instead.
|
|
22
26
|
|
|
27
|
+
## Revoke a scheduled plan change
|
|
28
|
+
|
|
29
|
+
A scheduled downgrade or interval change can be revoked before it takes effect, so the subscription stays on its current plan:
|
|
30
|
+
|
|
31
|
+
- Customers choose **Keep current plan** in the portal.
|
|
32
|
+
- In the dashboard, open the subscription and choose **Revert plan change**.
|
|
33
|
+
- Through the API, call `DELETE /subscriptions/{id}/scheduled-plan-change`.
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
await commet.subscriptions.revokeScheduledPlanChange({ id: 'sub_xxx' })
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
A subscription with nothing scheduled returns `409 no_scheduled_plan_change`. One whose payment authorization must be renewed first returns `409 no_payment_method`.
|
|
40
|
+
|
|
23
41
|
## Dashboard
|
|
24
42
|
|
|
25
|
-
From a customer's subscription detail page, click **Change
|
|
43
|
+
From a customer's subscription detail page, click **Change plan** and select the new plan. The same upgrade/downgrade rules apply.
|
|
26
44
|
|
|
27
45
|
## Learn more
|
|
28
46
|
|
|
@@ -30,6 +30,8 @@ await commet.usage.track({
|
|
|
30
30
|
})
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
Commet doesn't send emails whose recipients are all on reserved domains: `example.com`, `example.net`, `example.org` and their subdomains, and the `.example`, `.test`, `.invalid`, and `.localhost` domains. They still show as sent. Use a real inbox to check customer emails.
|
|
34
|
+
|
|
33
35
|
## Dev Tools Panel
|
|
34
36
|
|
|
35
37
|
A floating widget that appears on all sandbox pages. The [**Test Clock**](#test-clock) tab is available everywhere. The [**Test Data**](#test-data) tab (address and card presets) only appears on checkout pages.
|
|
@@ -273,3 +273,26 @@ $usageCheck = $commet->usage->check(
|
|
|
273
273
|
featureCode: 'api_calls',
|
|
274
274
|
);
|
|
275
275
|
```
|
|
276
|
+
|
|
277
|
+
## Limit plan credit spending
|
|
278
|
+
|
|
279
|
+
When a credits plan has a [plan credit limit](/docs/consumption-models#limit-plan-credit-spending), an event that would spend more plan credits than the current day or week allows, and that purchased credits can't cover, is rejected with `402 plan_credit_limit_reached`. Nothing is deducted.
|
|
280
|
+
|
|
281
|
+
Usage Check reports the same case before you consume:
|
|
282
|
+
|
|
283
|
+
```json
|
|
284
|
+
{
|
|
285
|
+
"allowed": false,
|
|
286
|
+
"reason": "plan_credit_limit_reached",
|
|
287
|
+
"consumptionModel": "credits",
|
|
288
|
+
"planCreditLimit": {
|
|
289
|
+
"credits": 100,
|
|
290
|
+
"interval": "day",
|
|
291
|
+
"spent": 100,
|
|
292
|
+
"remaining": 0,
|
|
293
|
+
"resetsAt": "2026-11-03T14:00:00.000Z"
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Only plan credits count toward the limit. Accepted events return the updated limit in `consumption.planCreditLimit`. Show `remaining` and `resetsAt` to the customer, or let them [buy credits](/docs/credit-packs#buy-a-chosen-quantity-of-credits), which the limit never caps.
|
package/docs/errors/index.md
CHANGED
|
@@ -33,6 +33,7 @@ Use the response `code` to open the matching local reference. Preserve `x-reques
|
|
|
33
33
|
- [`insufficient_seats`](./insufficient_seats.md) — The requested seat removal exceeds the subscription's available seat balance.
|
|
34
34
|
- [`included_limit_reached`](./included_limit_reached.md) — The requested usage exceeds the plan's included usage limit.
|
|
35
35
|
- [`plan_credit_limit_reached`](./plan_credit_limit_reached.md) — The usage event would spend more plan credits than the plan's credit limit allows in the current day or week, and purchased credits do not cover the rest.
|
|
36
|
+
- [`plan_balance_limit_reached`](./plan_balance_limit_reached.md) — The usage event would spend more plan balance than the plan's balance limit allows in the current day or week, and purchased balance does not cover the rest.
|
|
36
37
|
- [`missing_regional_price`](./missing_regional_price.md) — The plan has no price for the subscription's currency or resolved market.
|
|
37
38
|
- [`payment_failed`](./payment_failed.md) — The operation could not complete its payment or required tax calculation.
|
|
38
39
|
- [`payment_not_found`](./payment_not_found.md) — The requested payment does not exist in this organization.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# plan_balance_limit_reached
|
|
2
|
+
|
|
3
|
+
The usage event would spend more plan balance than the plan's balance limit allows in the current day or week, and purchased balance does not cover the rest.
|
|
4
|
+
|
|
5
|
+
- **Error type:** `billing_error`
|
|
6
|
+
- **`code`:** `plan_balance_limit_reached`
|
|
7
|
+
- **API version:** `2026-08-27`
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## What to do
|
|
11
|
+
|
|
12
|
+
Use the planBalanceLimit details to show what remains and when the window resets, or let the customer top up, which the limit never caps.
|
|
13
|
+
|
|
14
|
+
The response `message`, `param`, and `details` fields describe the condition observed by the specific operation.
|
|
15
|
+
|
|
16
|
+
## Retry behavior
|
|
17
|
+
|
|
18
|
+
Retry after planBalanceLimit.resetsAt or once purchased balance covers the usage.
|
|
19
|
+
|
|
20
|
+
## Correlate the request
|
|
21
|
+
|
|
22
|
+
Keep the `x-request-id` response header when reporting or investigating this error. Platform records the same identifier in its request event, so Commet can locate the exact execution without customer data or credentials.
|
|
@@ -5,15 +5,15 @@ description: Choose the correct credit mechanism based on what the customer rece
|
|
|
5
5
|
|
|
6
6
|
These mechanisms share a name but affect different ledgers.
|
|
7
7
|
|
|
8
|
-
| Mechanism
|
|
9
|
-
|
|
|
10
|
-
| **Plan credits**
|
|
11
|
-
| **
|
|
12
|
-
| **Customer credit**
|
|
13
|
-
| **Plan grant**
|
|
8
|
+
| Mechanism | Represents | Reset or expiry | Used by |
|
|
9
|
+
| --------------------- | ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
|
|
10
|
+
| **Plan credits** | Recurring product units included in a Credits plan | Expire at each reset, or [roll over](/docs/consumption-models#roll-over-unused-plan-credits) up to a cap | Usage events, within an optional daily or weekly limit |
|
|
11
|
+
| **Purchased credits** | Product units the customer buys as a pack, a chosen quantity, or an automatic top-up | Persist across plan resets | Usage events after plan credits, never limited |
|
|
12
|
+
| **Customer credit** | Money that reduces eligible recurring invoices in one currency | Optional expiration; consumed FIFO | Invoice calculation before tax |
|
|
13
|
+
| **Plan grant** | Temporary access beyond the subscribed plan | Ends when revoked or expired | Feature access, not a credit ledger |
|
|
14
14
|
|
|
15
|
-
Use plan
|
|
15
|
+
Use plan and purchased credits when the customer thinks in actions such as generations or exports. Use customer credit when the adjustment is monetary, such as USD 25 after a service incident. Use a plan grant when no invoice should exist at all.
|
|
16
16
|
|
|
17
|
-
Revoking unused customer credit does not rewrite invoices that already consumed it. Purchased
|
|
17
|
+
Revoking unused customer credit does not rewrite invoices that already consumed it. Purchased credits do not disappear at the next plan reset.
|
|
18
18
|
|
|
19
19
|
See [Credit Packs](/docs/credit-packs), [Customer Credits](/docs/customer-credits), and [Plan Grants](/docs/plan-grants) for implementation.
|
|
@@ -17,13 +17,13 @@ A direct Offer does not need a prior association with the selected plan or price
|
|
|
17
17
|
|
|
18
18
|
## Eligibility and exclusivity
|
|
19
19
|
|
|
20
|
-
Automatic introductory selection
|
|
20
|
+
Automatic introductory selection excludes customers with an `active`, `past_due`, or `paused` subscription in the organization. Other historical statuses do not create a lifetime ban.
|
|
21
21
|
|
|
22
|
-
An explicit `offerId` overrides automatic introductory selection. A Promo Code is rejected with `intro_offer_active` while an eligible introductory placement applies. `offerId`, `promoCode`, `customTrialDays
|
|
22
|
+
An explicit `offerId` overrides automatic introductory selection. A Promo Code is rejected with `intro_offer_active` while an eligible introductory placement applies. `offerId`, `promoCode`, and `cardPromotionId` are mutually exclusive. `customTrialDays` and `skipTrial` combine with `offerId` and `promoCode`, not with `cardPromotionId`. A trial without a payment method starts with none of the three.
|
|
23
23
|
|
|
24
24
|
## Duration and phases
|
|
25
25
|
|
|
26
|
-
An Offer
|
|
26
|
+
An Offer combines ordered discount or fixed-price phases. A finite `durationCycles` counts billing periods, not calendar months. A yearly Offer phase with `durationCycles: 2` lasts two yearly billing cycles.
|
|
27
27
|
|
|
28
28
|
```
|
|
29
29
|
Pro costs $99/month with 50% off for 3 cycles:
|
|
@@ -34,11 +34,13 @@ Cycle 3: $49.50
|
|
|
34
34
|
Cycle 4: $99.00
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
The final discount phase may use `durationCycles: null` to remain active until the accepted application ends. Promo Codes
|
|
37
|
+
The final discount phase may use `durationCycles: null` to remain active until the accepted application ends. Promo Codes can reference the same Offers. Introductory placement is narrower: exactly one finite `percentage` or `amount_off` phase.
|
|
38
|
+
|
|
39
|
+
Trials are not Offer phases. When the price has a [trial](/docs/trial-periods), the discount starts with the first invoice after it.
|
|
38
40
|
|
|
39
41
|
## Plan changes
|
|
40
42
|
|
|
41
|
-
The Offer Application belongs to the price target accepted by the subscription. An immediate plan change ends that application. The change may pass a new `offerId`; otherwise the new plan begins at its normal price. Scheduled plan changes
|
|
43
|
+
The Offer Application belongs to the price target accepted by the subscription. An immediate plan change ends that application. The change may pass a new `offerId` or a `promoCode`; otherwise the new plan begins at its normal price. Scheduled plan changes accept neither.
|
|
42
44
|
|
|
43
45
|
## What gets discounted
|
|
44
46
|
|
|
@@ -7,14 +7,14 @@ A free plan has no price and no checkout. When you assign a customer to a free p
|
|
|
7
7
|
|
|
8
8
|
## How Free Plans Differ from Paid Plans
|
|
9
9
|
|
|
10
|
-
| | Paid plan
|
|
11
|
-
| -------------- |
|
|
12
|
-
| Price | Has a price
|
|
13
|
-
| Billing | Monthly, quarterly, semiannual, or yearly
|
|
14
|
-
| How they start | Checkout + payment
|
|
15
|
-
| Invoices | Yes
|
|
16
|
-
| Overage | Configurable per feature
|
|
17
|
-
| Usage resets | Every month
|
|
10
|
+
| | Paid plan | Free plan |
|
|
11
|
+
| -------------- | --------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
|
|
12
|
+
| Price | Has a price | $0 |
|
|
13
|
+
| Billing | Monthly, quarterly, semiannual, or yearly | No charges — usage resets monthly |
|
|
14
|
+
| How they start | Checkout + payment, or a [trial without a payment method](/docs/trial-periods#start-a-trial-without-a-payment-method) | **Activated immediately** |
|
|
15
|
+
| Invoices | Yes | Only for purchases (credits, balance, add-ons) |
|
|
16
|
+
| Overage | Configurable per feature | **Never allowed** — usage is blocked at the included limit |
|
|
17
|
+
| Usage resets | Every month | Every month |
|
|
18
18
|
|
|
19
19
|
## Monthly Usage Resets
|
|
20
20
|
|
|
@@ -79,3 +79,9 @@ Credit from free plan: $0 (it's free)
|
|
|
79
79
|
They pay: $99 (full month)
|
|
80
80
|
Invoices, payment method, and billing info appear in their portal.
|
|
81
81
|
```
|
|
82
|
+
|
|
83
|
+
When the Pro price has a trial without a payment method and the customer never had Pro, the trial starts at once with no checkout and no charge. Without a card at the end of the trial, the subscription moves to the plan group's default plan, or is canceled when the group has none.
|
|
84
|
+
|
|
85
|
+
## Use a Free Plan as the Default Plan
|
|
86
|
+
|
|
87
|
+
Mark a free plan as its [plan group's default plan](/docs/plan-groups#default-plan-and-signup-trial) to keep customers on it instead of canceling. A paid plan of the group that ends from the Customer Portal, a revoked payment authorization, exhausted payment retries, or a trial without a card moves to it.
|
|
@@ -3,7 +3,7 @@ title: Offers, Promo Codes, and Card Promotions
|
|
|
3
3
|
description: Understand where commercial terms live and how each distribution channel selects them.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
An Offer owns the economic terms:
|
|
6
|
+
An Offer owns the economic terms: percentage discount, amount off, or temporary fixed price. Trials belong to the plan price. Introductory Offers, direct Promotional Offers, Promo Codes, and Card Promotions decide how those terms reach a customer.
|
|
7
7
|
|
|
8
8
|
| Channel | Who selects it | Additional rule |
|
|
9
9
|
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
|
|
@@ -1,46 +1,52 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Trials
|
|
3
|
-
description: "
|
|
3
|
+
description: "How a plan price trial works: checkout saves a card without charging it, or the trial starts at once without one and the first charge waits until it ends."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
A trial is a
|
|
6
|
+
A trial is a number of free days set on a plan price. Each price chooses whether its trial requires a payment method.
|
|
7
7
|
|
|
8
8
|
## What the customer experiences
|
|
9
9
|
|
|
10
|
-
| |
|
|
11
|
-
| -------------- |
|
|
12
|
-
|
|
|
13
|
-
| Primary action |
|
|
14
|
-
|
|
|
10
|
+
| | Trial with a payment method | Trial without a payment method |
|
|
11
|
+
| -------------- | -------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
|
12
|
+
| Start | Checkout saves the payment method, no charge | Starts at once, no checkout |
|
|
13
|
+
| Primary action | Start free trial | None until the customer adds a card |
|
|
14
|
+
| `checkoutUrl` | Checkout link | `null` |
|
|
15
|
+
| Trial ends | First charge, subscription becomes `active` | With a card, the same. Without one, moves to the plan group's default plan or is canceled |
|
|
15
16
|
|
|
16
|
-
The trial
|
|
17
|
+
The trial with a payment method starts after setup succeeds. If the card requires 3D Secure, the customer completes verification before the trial begins.
|
|
17
18
|
|
|
18
19
|
## How it works
|
|
19
20
|
|
|
20
21
|
```
|
|
21
|
-
1. Commet
|
|
22
|
-
2.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
1. Commet reads the trial days of the selected price.
|
|
23
|
+
2. With a payment method required, checkout saves it without charging.
|
|
24
|
+
Without one, the subscription starts trialing at once.
|
|
25
|
+
3. The subscription is trialing and records trialEndsAt.
|
|
26
|
+
4. At the end, Commet charges the current value of the selected price.
|
|
27
|
+
Without a card, it moves to the default plan or is canceled, with no invoice.
|
|
28
|
+
5. A discount from an Offer starts with the first invoice after the trial.
|
|
26
29
|
```
|
|
27
30
|
|
|
28
31
|
> **Warning**
|
|
29
32
|
>
|
|
30
|
-
> The
|
|
33
|
+
> The subscription keeps its accepted trial days, but the selected catalog price can change. A price change during the trial changes the first paid charge.
|
|
31
34
|
|
|
32
|
-
##
|
|
35
|
+
## Customer-specific trials
|
|
33
36
|
|
|
34
|
-
Use
|
|
37
|
+
Use `customTrialDays` to replace the price's trial days for one subscription, or `skipTrial: true` to start without a trial. Both combine with `offerId`.
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
A customer gets one trial per plan. A customer who already had the plan, in a trial or paying, starts with the regular checkout.
|
|
37
40
|
|
|
38
41
|
## During the trial
|
|
39
42
|
|
|
40
|
-
| Behavior | During trial
|
|
41
|
-
| ------------------------------------- |
|
|
42
|
-
| Plan features | Available
|
|
43
|
-
| Overage | Blocked at included limits
|
|
44
|
-
| Credit, balance, and add-on purchases | Available
|
|
45
|
-
|
|
|
46
|
-
|
|
|
43
|
+
| Behavior | During trial |
|
|
44
|
+
| ------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
45
|
+
| Plan features | Available |
|
|
46
|
+
| Overage | Blocked at included limits |
|
|
47
|
+
| Credit, balance, and add-on purchases | Available with a saved payment method |
|
|
48
|
+
| Immediate plan changes | End the trial and charge the new plan; without a payment method, `409 no_payment_method` |
|
|
49
|
+
| Metered usage reset | Monthly on the billing day for trials longer than a month |
|
|
50
|
+
| Included balance and credits | Granted once when the trial starts |
|
|
51
|
+
|
|
52
|
+
See [Trial Periods](/docs/trial-periods) to configure trials.
|
|
@@ -47,6 +47,7 @@ Those layers change at different times. Commet separates catalog changes, subscr
|
|
|
47
47
|
| ------------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
|
|
48
48
|
| Trial starts | They use the product, no charge. **Overage is blocked** — usage stops at included limits |
|
|
49
49
|
| Trial ends | They're charged the current price, overage activates normally |
|
|
50
|
+
| Trial without a payment method ends without a card | No charge; the subscription moves to the plan group's default plan or is canceled |
|
|
50
51
|
| Renewal or retryable first-trial charge fails | Subscription becomes `past_due`; usage continues while retries run and purchases are blocked |
|
|
51
52
|
| First-trial charge needs a payment method or customer action | Subscription remains `pending_payment` so checkout can complete |
|
|
52
53
|
| Canceled subscription | Can be reactivated — fresh invoice at the current price, new billing period starts that day |
|