@commet/node 9.7.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 +413 -52
- package/dist/index.d.ts +413 -52
- package/dist/index.js +39 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -12
- package/dist/index.mjs.map +1 -1
- package/docs/ai-onboarding/mcp-server.md +1 -1
- package/docs/api-reference/customers.md +6 -2
- package/docs/api-reference/generated-webhooks.md +2 -2
- package/docs/api-reference/index.md +2 -2
- package/docs/api-reference/offers.md +2 -2
- package/docs/api-reference/plans.md +16 -3
- package/docs/api-reference/promo-codes.md +3 -1
- package/docs/api-reference/subscriptions.md +84 -9
- package/docs/api-reference/usage.md +0 -4
- 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/customer_deleted.md +22 -0
- package/docs/errors/index.md +5 -0
- package/docs/errors/managed_by_integration.md +22 -0
- package/docs/errors/no_scheduled_plan_change.md +22 -0
- package/docs/errors/plan_balance_limit_reached.md +22 -0
- package/docs/errors/plan_credit_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 +54 -2
- package/docs/platform-documentation.md +1 -0
- package/docs/schemas.md +51 -9
- package/docs/webhooks/introduction.md +14 -12
- package/docs/webhooks.md +53 -17
- package/docs/webhooks.openapi.json +857 -745
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Introductory Offers
|
|
3
|
-
description: Attach an existing Offer to a base plan price so Commet applies
|
|
3
|
+
description: Attach an existing Offer to a base plan price so Commet applies its discount automatically to eligible new subscriptions.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
An Introductory Offer is not a separate Offer type. It is an existing Offer attached to one base plan price with introductory placement.
|
|
@@ -10,22 +10,16 @@ That placement adds two behaviors:
|
|
|
10
10
|
- Commet selects the Offer automatically when no explicit override is supplied.
|
|
11
11
|
- Commet checks introductory eligibility before applying it.
|
|
12
12
|
|
|
13
|
-
Selectable price variants inherit the introductory placement from their base price.
|
|
13
|
+
Selectable price variants inherit the introductory placement from their base price. One-time prices can't have an Introductory Offer.
|
|
14
14
|
|
|
15
15
|
## Compatible phases
|
|
16
16
|
|
|
17
|
-
An Offer used as introductory
|
|
18
|
-
|
|
19
|
-
1. One optional `free_trial` phase at the beginning.
|
|
20
|
-
2. At most one finite `percentage` or `amount_off` phase.
|
|
21
|
-
|
|
22
|
-
It cannot use `fixed_price`, multiple discount phases, or an open-ended discount.
|
|
17
|
+
An Offer used as introductory contains exactly one finite `percentage` or `amount_off` phase. It cannot use `fixed_price` or an open-ended discount.
|
|
23
18
|
|
|
24
19
|
```typescript
|
|
25
20
|
const onboarding = await commet.offers.create({
|
|
26
21
|
name: 'Starter onboarding',
|
|
27
22
|
phases: [
|
|
28
|
-
{ type: 'free_trial', durationDays: 14 },
|
|
29
23
|
{ type: 'percentage', durationCycles: 3, percentage: 3000 },
|
|
30
24
|
],
|
|
31
25
|
})
|
|
@@ -35,7 +29,7 @@ In the Dashboard, open the plan price and choose **Add intro offer** to attach t
|
|
|
35
29
|
|
|
36
30
|
## Eligibility
|
|
37
31
|
|
|
38
|
-
|
|
32
|
+
Automatic eligibility excludes a customer who already has an `active`, `past_due`, or `paused` subscription in the organization. Other historical statuses do not create a lifetime ban.
|
|
39
33
|
|
|
40
34
|
## Selection at subscription creation
|
|
41
35
|
|
|
@@ -48,8 +42,8 @@ await commet.subscriptions.create({
|
|
|
48
42
|
|
|
49
43
|
When `offerId` is omitted, Commet resolves the selected price and applies its introductory Offer if the customer is eligible.
|
|
50
44
|
|
|
51
|
-
An explicit `offerId` applies that Offer directly instead. It cannot be combined with `promoCode
|
|
45
|
+
An explicit `offerId` applies that Offer directly instead. It cannot be combined with `promoCode` or `cardPromotionId`.
|
|
52
46
|
|
|
53
|
-
## Trials
|
|
47
|
+
## Trials
|
|
54
48
|
|
|
55
|
-
|
|
49
|
+
Trial days belong to the plan price, not to the Offer. When the price has a trial, the introductory discount starts with the first invoice after it. See [Trial Periods](/docs/trial-periods).
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Offers
|
|
3
|
-
description: Define reusable
|
|
3
|
+
description: Define reusable discount phases independently from plans and distribution, then apply them automatically, directly, or through promo codes.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
An Offer is a reusable sequence of
|
|
6
|
+
An Offer is a reusable sequence of discount phases. It defines **what changes**—a discount or a temporary fixed price—without deciding which plan uses it or how a customer receives it.
|
|
7
|
+
|
|
8
|
+
Trials are not Offers. Set trial days on the plan price; see [Trial Periods](/docs/trial-periods).
|
|
7
9
|
|
|
8
10
|
## Offer phases
|
|
9
11
|
|
|
@@ -11,18 +13,16 @@ An Offer contains between 1 and 10 ordered phases:
|
|
|
11
13
|
|
|
12
14
|
| Phase | Effect |
|
|
13
15
|
| ------------- | --------------------------------------------------------------------------------- |
|
|
14
|
-
| `free_trial` | Delays the first charge for a fixed number of days |
|
|
15
16
|
| `percentage` | Reduces the plan base price by basis points |
|
|
16
17
|
| `amount_off` | Subtracts an explicit amount for each configured currency |
|
|
17
18
|
| `fixed_price` | Replaces the plan base price with an explicit amount for each configured currency |
|
|
18
19
|
|
|
19
|
-
A
|
|
20
|
+
A phase has a finite `durationCycles`, or `null` when it is the final open-ended phase. A `fixed_price` phase of `0` gives free billing cycles; the dashboard calls it **Free cycles**.
|
|
20
21
|
|
|
21
22
|
```typescript
|
|
22
23
|
const launchOffer = await commet.offers.create({
|
|
23
24
|
name: 'Launch sequence',
|
|
24
25
|
phases: [
|
|
25
|
-
{ type: 'free_trial', durationDays: 14 },
|
|
26
26
|
{ type: 'percentage', durationCycles: 3, percentage: 5000 },
|
|
27
27
|
{ type: 'percentage', durationCycles: null, percentage: 2000 },
|
|
28
28
|
],
|
|
@@ -40,7 +40,7 @@ The Offer does not contain `purpose`, `planPriceIds`, eligibility, or redemption
|
|
|
40
40
|
| **Promotional** | Your integration passes `offerId` | Explicit campaign, retention, or experiment assignment |
|
|
41
41
|
| **Promo Code** | The customer enters a code | Redemption limits, plan restrictions, and expiration |
|
|
42
42
|
|
|
43
|
-
The channel does not create another copy of the Offer. It only decides how the reusable terms reach a customer.
|
|
43
|
+
The channel does not create another copy of the Offer. It only decides how the reusable terms reach a customer. When the price has a trial, the discount starts with the first invoice after it.
|
|
44
44
|
|
|
45
45
|
## Accepted terms
|
|
46
46
|
|
|
@@ -54,3 +54,7 @@ When Commet quotes or applies an Offer, it records an immutable Offer Applicatio
|
|
|
54
54
|
Editing, deactivating, or archiving the catalog Offer affects future applications only. Existing applications remain available for billing and audit.
|
|
55
55
|
|
|
56
56
|
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
|
+
|
|
58
|
+
## Offers managed by an integration
|
|
59
|
+
|
|
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 works.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Promo Codes
|
|
3
|
-
description: Distribute an existing Offer through a customer-entered checkout code.
|
|
3
|
+
description: Distribute an existing Offer through a customer-entered checkout code, limited to first purchases or applied on plan changes.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
A Promo Code is a distribution channel. The referenced Offer owns the
|
|
6
|
+
A Promo Code is a distribution channel. The referenced Offer owns the discount; the code owns who can redeem it and when.
|
|
7
7
|
|
|
8
8
|
## Create a compatible Offer
|
|
9
9
|
|
|
10
|
-
A Promo Code can reference
|
|
10
|
+
A Promo Code can reference any Offer: ordered `percentage`, `amount_off`, or `fixed_price` phases where only the last phase may be open-ended.
|
|
11
11
|
|
|
12
12
|
```typescript
|
|
13
13
|
const launchOffer = await commet.offers.create({
|
|
@@ -19,17 +19,7 @@ const launchOffer = await commet.offers.create({
|
|
|
19
19
|
})
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
const trialOffer = await commet.offers.create({
|
|
26
|
-
name: 'Early access',
|
|
27
|
-
phases: [
|
|
28
|
-
{ type: 'free_trial', durationDays: 14 },
|
|
29
|
-
{ type: 'percentage', durationCycles: 3, percentage: 2000 },
|
|
30
|
-
],
|
|
31
|
-
})
|
|
32
|
-
```
|
|
22
|
+
A `fixed_price` phase of `0`, **Free cycles** in the dashboard, makes a code that gives free billing cycles. Checkout saves the card and settles the invoice at $0 without a charge.
|
|
33
23
|
|
|
34
24
|
## Create the code
|
|
35
25
|
|
|
@@ -41,6 +31,7 @@ const promoCode = await commet.promoCodes.create({
|
|
|
41
31
|
maxRedemptions: 100,
|
|
42
32
|
expiresAt: '2026-12-31T23:59:59.000Z',
|
|
43
33
|
planIds: ['pln_pro'],
|
|
34
|
+
firstPurchaseOnly: true,
|
|
44
35
|
})
|
|
45
36
|
```
|
|
46
37
|
|
|
@@ -49,17 +40,20 @@ The Promo Code owns:
|
|
|
49
40
|
- the customer-facing code;
|
|
50
41
|
- optional plan and billing-interval restrictions;
|
|
51
42
|
- the redemption limit;
|
|
52
|
-
- expiration and active state
|
|
43
|
+
- expiration and active state;
|
|
44
|
+
- `firstPurchaseOnly`, which limits the code to a customer's first purchase. Default `false`.
|
|
45
|
+
|
|
46
|
+
A customer qualifies for a first-purchase code while they have no paid invoice above $0 and no `active` or `past_due` subscription on a paid plan. A customer in a trial qualifies.
|
|
53
47
|
|
|
54
48
|
Updating the Offer changes future redemptions of codes that reference it. Each completed checkout counts one redemption and keeps an immutable Offer Application with the phases accepted at that checkout. Editing the Offer does not change earlier redemptions or their renewals.
|
|
55
49
|
|
|
56
|
-
Clients pinned before `2026-07-24` receive only the first phase in the legacy Promo Code discount fields when that phase is `percentage` or `amount_off`. Codes starting with `
|
|
50
|
+
Clients pinned before `2026-07-24` receive only the first phase in the legacy Promo Code discount fields when that phase is `percentage` or `amount_off`. Codes starting with `fixed_price` cannot be represented and are absent from those older Promo Code endpoints. Use the current Offer API to inspect the complete sequence.
|
|
57
51
|
|
|
58
52
|
## Checkout behavior
|
|
59
53
|
|
|
60
54
|
The customer enters the code during checkout. Commet validates the code, resolves the referenced Offer in the checkout currency, and records an Offer Application with source `promo_code`.
|
|
61
55
|
|
|
62
|
-
When the
|
|
56
|
+
When the price has a [trial](/docs/trial-periods) that requires a payment method, the customer can enter the code in the trial checkout. The trial starts without a charge and the discount starts with the first invoice after it. One redemption is recorded when the checkout completes. Renewals do not count as new redemptions.
|
|
63
57
|
|
|
64
58
|
If an eligible automatic Introductory Offer applies, the code is rejected with `intro_offer_active`. A Promo Code also cannot be combined with an explicit `offerId`.
|
|
65
59
|
|
|
@@ -70,3 +64,39 @@ await commet.subscriptions.create({
|
|
|
70
64
|
promoCode: 'LAUNCH50',
|
|
71
65
|
})
|
|
72
66
|
```
|
|
67
|
+
|
|
68
|
+
A trial without a payment method has no checkout, so it can't start with a promo code.
|
|
69
|
+
|
|
70
|
+
## Apply a code on a plan change
|
|
71
|
+
|
|
72
|
+
`changePlan` and `previewChange` accept `promoCode` for immediate changes. The preview quotes what the change charges.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
await commet.subscriptions.changePlan({
|
|
76
|
+
id: 'sub_xxx',
|
|
77
|
+
newPlanId: 'pln_pro',
|
|
78
|
+
promoCode: 'LAUNCH50',
|
|
79
|
+
})
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
From a free plan, the code opens the checkout with the discount applied and counts its use when the checkout is paid. Scheduled changes reject a promo code with `offer_not_applicable`.
|
|
83
|
+
|
|
84
|
+
## Rejection reasons
|
|
85
|
+
|
|
86
|
+
A rejected code returns `400 validation_error` with `param: "promoCode"` and the reason in `details.reason`:
|
|
87
|
+
|
|
88
|
+
- `not_found`: no code with that text exists.
|
|
89
|
+
- `inactive`: the code is deactivated.
|
|
90
|
+
- `expired`: the expiration date passed.
|
|
91
|
+
- `max_redemptions_reached`: the redemption limit was reached.
|
|
92
|
+
- `first_purchase_only`: the customer already paid or has a paid subscription.
|
|
93
|
+
- `already_redeemed`: the customer already redeemed the code.
|
|
94
|
+
- `plan_not_eligible`: the code is restricted to other plans.
|
|
95
|
+
- `billing_interval_not_eligible`: the code is restricted to another billing interval.
|
|
96
|
+
- `intro_offer_active`: an Introductory Offer applies.
|
|
97
|
+
|
|
98
|
+
Checkout also rejects a positive total below the currency's minimum charge.
|
|
99
|
+
|
|
100
|
+
## Codes managed by an integration
|
|
101
|
+
|
|
102
|
+
Codes created by an integration, such as [Dub](/docs/connect-dub-affiliates), have `managedBy` set. Changing their restrictions returns `409 managed_by_integration`; activating and deactivating them still works.
|
|
@@ -9,13 +9,12 @@ The Offer stays independent from plans and prices until your integration selects
|
|
|
9
9
|
|
|
10
10
|
## Create the terms
|
|
11
11
|
|
|
12
|
-
Direct Offers may combine
|
|
12
|
+
Direct Offers may combine ordered discount and fixed-price phases:
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
const retentionOffer = await commet.offers.create({
|
|
16
16
|
name: 'Return to Pro',
|
|
17
17
|
phases: [
|
|
18
|
-
{ type: 'free_trial', durationDays: 7 },
|
|
19
18
|
{ type: 'fixed_price', durationCycles: 2, prices: [
|
|
20
19
|
{ currency: 'usd', amount: 2900 },
|
|
21
20
|
{ currency: 'ars', amount: 3990000 },
|
|
@@ -39,9 +38,9 @@ await commet.subscriptions.create({
|
|
|
39
38
|
|
|
40
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.
|
|
41
40
|
|
|
42
|
-
An explicit `offerId` overrides automatic introductory selection. It cannot be combined with `promoCode
|
|
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.
|
|
43
42
|
|
|
44
|
-
Immediate plan changes, plan-change previews, and supported reactivation flows also accept `offerId`. Scheduled plan changes do not accept an Offer.
|
|
43
|
+
Immediate plan changes, plan-change previews, and supported reactivation flows also accept `offerId`. Scheduled plan changes do not accept an Offer or a promo code.
|
|
45
44
|
|
|
46
45
|
## Apply it to an active subscription
|
|
47
46
|
|
|
@@ -54,14 +53,14 @@ await commet.subscriptions.applyOffer({
|
|
|
54
53
|
})
|
|
55
54
|
```
|
|
56
55
|
|
|
57
|
-
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.
|
|
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.
|
|
58
57
|
|
|
59
58
|
The applied Offer belongs to that subscription and plan: it ends with a cancellation and a plan change removes it.
|
|
60
59
|
|
|
61
|
-
The same operation on a subscription with a pending
|
|
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.
|
|
62
61
|
|
|
63
62
|
## Direct application or Promo Code?
|
|
64
63
|
|
|
65
64
|
Use direct `offerId` when your application decides who receives the terms. Use a Promo Code when the customer should enter a code and the campaign needs redemption restrictions.
|
|
66
65
|
|
|
67
|
-
A Promo Code can distribute
|
|
66
|
+
A Promo Code can distribute the same Offers, including multiple phases and `fixed_price`.
|
|
@@ -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.
|