@commet/node 9.8.0 → 9.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1021 -30
- package/dist/index.d.ts +1021 -30
- package/dist/index.js +204 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +204 -11
- package/dist/index.mjs.map +1 -1
- package/docs/ai-onboarding/mcp-server.md +2 -0
- package/docs/api-reference/addons.md +3 -1
- package/docs/api-reference/credit-packs.md +3 -1
- package/docs/api-reference/customers.md +2 -0
- package/docs/api-reference/generated-webhooks.md +2 -2
- package/docs/api-reference/index.md +3 -3
- package/docs/api-reference/plans.md +488 -6
- package/docs/api-reference/subscriptions.md +50 -8
- package/docs/documentation/api-versioning.md +8 -2
- package/docs/documentation/cli.md +64 -49
- package/docs/documentation/create-api-key.md +3 -1
- package/docs/documentation/customers/customer-portal.md +10 -2
- package/docs/documentation/customers/manage-customers.md +2 -1
- package/docs/documentation/finance/payouts.md +11 -0
- package/docs/documentation/finance/supported-countries.md +5 -5
- package/docs/documentation/invoicing/handle-failed-payments.md +9 -9
- package/docs/documentation/payments/accept-one-time-payments.md +1 -1
- package/docs/documentation/payments/payment-orchestration.md +2 -0
- package/docs/documentation/payments/payment-providers.md +46 -0
- package/docs/documentation/payments/transactions-refunds-and-retries.md +1 -1
- package/docs/documentation/plans/add-ons.md +15 -4
- package/docs/documentation/plans/consumption-models.md +44 -9
- package/docs/documentation/plans/create-plans.md +5 -1
- package/docs/documentation/plans/credit-packs.md +61 -3
- package/docs/documentation/plans/one-time-payments.md +3 -3
- package/docs/documentation/plans/plan-groups.md +46 -10
- package/docs/documentation/plans/plan-versions.md +265 -0
- package/docs/documentation/platform/dashboard-metrics-and-events.md +40 -9
- package/docs/documentation/sales/connect-dub-affiliates.md +52 -0
- package/docs/documentation/sales/introductory-offers.md +7 -13
- package/docs/documentation/sales/offers.md +10 -6
- package/docs/documentation/sales/promo-codes.md +47 -17
- package/docs/documentation/sales/promotional-offers.md +6 -7
- package/docs/documentation/sales/regional-prices.md +38 -8
- package/docs/documentation/sales/trial-periods.md +67 -40
- package/docs/documentation/subscriptions/manage-subscriptions.md +114 -14
- package/docs/documentation/subscriptions/pay-in-advance.md +4 -7
- package/docs/documentation/subscriptions/upgrade-and-downgrade-plans.md +22 -2
- package/docs/documentation/testing-sandbox.md +2 -0
- package/docs/documentation/usage/track-usage.md +23 -0
- package/docs/errors/addon_has_activations.md +2 -2
- package/docs/errors/addon_unavailable.md +22 -0
- package/docs/errors/credit_pack_unavailable.md +22 -0
- package/docs/errors/index.md +9 -2
- package/docs/errors/missing_regional_price.md +3 -3
- package/docs/errors/plan_balance_limit_reached.md +22 -0
- package/docs/errors/plan_experiment_not_found.md +22 -0
- package/docs/errors/plan_version_not_found.md +22 -0
- package/docs/errors/subscribers_do_not_fit.md +22 -0
- package/docs/errors/version_not_newer.md +22 -0
- package/docs/knowledge-base/how-do-credits-credit-packs-and-customer-credits-differ.md +8 -8
- package/docs/knowledge-base/how-do-discounts-work.md +7 -5
- package/docs/knowledge-base/how-do-free-plans-work-without-payment.md +18 -11
- package/docs/knowledge-base/how-do-offers-promo-codes-and-card-promotions-work-together.md +1 -1
- package/docs/knowledge-base/how-do-trial-periods-work.md +31 -25
- package/docs/knowledge-base/how-does-billing-work.md +26 -27
- package/docs/knowledge-base/how-does-quota-based-billing-work.md +12 -22
- package/docs/knowledge-base/how-does-seat-based-billing-work.md +12 -22
- package/docs/knowledge-base/what-happens-when-a-customer-changes-plans.md +11 -8
- package/docs/knowledge-base/what-happens-when-a-payment-fails.md +11 -9
- package/docs/knowledge-base/what-happens-when-you-change-your-prices.md +34 -29
- package/docs/knowledge-base/what-invoices-do-customers-receive-and-when.md +1 -1
- package/docs/manifest.json +201 -2
- package/docs/platform-documentation.md +2 -0
- package/docs/schemas.md +134 -14
- package/docs/webhooks/introduction.md +17 -13
- package/docs/webhooks.md +66 -6
- package/docs/webhooks.openapi.json +1218 -876
- package/package.json +1 -1
|
@@ -1,17 +1,48 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Dashboard Metrics and Usage Events
|
|
3
|
-
description:
|
|
3
|
+
description: Customize the dashboard home, filter it by period, plan and currency, and see how MRR, revenue, churn and the usage-event explorer work.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
The dashboard summarizes confirmed billing records. Use it for operational review, not as a replacement for your accounting ledger or product analytics.
|
|
6
|
+
The dashboard home summarizes confirmed billing records. Use it for operational review, not as a replacement for your accounting ledger or product analytics.
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
## Customize the dashboard
|
|
9
|
+
|
|
10
|
+
Click **Customize** on the dashboard home. Drag widgets to reorder them, drag a widget to the hidden area to hide it, or click **Add widget** to show a hidden one. Click **Save** to keep the layout, or **Reset** to restore the default.
|
|
11
|
+
|
|
12
|
+
The layout is saved for you and this organization in your browser. By default the home shows Revenue, Successful Payments, Active Subscriptions, New Customers, New Paid Subscriptions, and MRR, plus Revenue by Plan when you have more than one plan. Provider Volume is available with more than one payment provider.
|
|
13
|
+
|
|
14
|
+
Hover the info icon next to a widget title to see how it is calculated. Most widgets open a detail page when clicked.
|
|
15
|
+
|
|
16
|
+
## Filter by period, plan, and currency
|
|
17
|
+
|
|
18
|
+
The period, comparison, plan, and currency filters live in the URL, so a shared link opens the same view. Periods range from **Today** to **All time** or a **Custom range**, and their boundaries are in UTC.
|
|
19
|
+
|
|
20
|
+
The currency selector lists **All currencies**, USD, and every currency your organization has received:
|
|
21
|
+
|
|
22
|
+
- **All currencies** sums every payment in USD. A non-USD payment is converted at the previous UTC day's rate when it was made.
|
|
23
|
+
- A specific currency shows only the payments made in that currency, in that currency. Nothing is converted.
|
|
24
|
+
|
|
25
|
+
## Metric definitions
|
|
26
|
+
|
|
27
|
+
| Widget | Calculation |
|
|
28
|
+
| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
29
|
+
| **Revenue** | Successful payments excluding tax. Fully refunded or disputed payments are excluded; partial refunds keep the original amount |
|
|
30
|
+
| **Successful Payments** | Successful transactions, including payments later refunded or disputed |
|
|
31
|
+
| **MRR** | Effective recurring prices net of recurring discounts at period end, normalized to a month. Excludes tax, usage overage, one-time charges, and proration |
|
|
32
|
+
| **MRR after scheduled churn** | MRR of subscriptions still in service at period end, leaving out subscriptions scheduled to cancel before then. Hidden by default |
|
|
33
|
+
| **ARR** | MRR at period end × 12. A run rate, not cash collected |
|
|
34
|
+
| **Active Subscriptions** | Subscriptions entitled to service at period end: active, past due, or scheduled to cancel after the cutoff |
|
|
35
|
+
| **New Customers** | Customers created in the period. The currency filter does not apply |
|
|
36
|
+
| **New Paid Subscriptions** | Subscriptions whose first successful payment happened in the period, even if later refunded or disputed |
|
|
37
|
+
| **Churned Subscriptions** | Subscriptions that reached `canceled` in the period. **User Churned** and **Dunning Churned** split them by whether exhausted payment retries caused the cancellation |
|
|
38
|
+
| **Churned MRR** | Effective recurring price, net of recurring discounts and normalized to a month, at each cancellation |
|
|
39
|
+
| **Dunning Amount Recovered** | Recurring invoice totals recovered by a payment retry or manual recovery |
|
|
40
|
+
| **Dunning Payments Recovered** | Payment retries or manual recoveries that settled a recurring invoice |
|
|
41
|
+
| **Revenue by Plan** | Revenue grouped by plan, top three |
|
|
42
|
+
| **Provider Volume** | Successful payments by payment provider, with the comparison period dotted |
|
|
43
|
+
| **Seats** | Each customer's latest seat count per seat feature at period end. The currency filter does not apply |
|
|
44
|
+
|
|
45
|
+
Churn widgets count from June 4, 2026. A paused subscription is out of MRR and is not churn.
|
|
15
46
|
|
|
16
47
|
Metrics are cached and can lag recent writes briefly. Investigate an exact payment in **Transactions** and its accounting result in **Invoices**.
|
|
17
48
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Connect Dub Affiliates
|
|
3
|
+
description: Connect Dub so partners earn commission on every sale Commet charges, and sync Dub partner discounts and codes as Offers and promo codes.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Dub is an affiliate platform. Connected to Commet, it receives every sale Commet charges so partners earn their commission, and its partner discounts and codes become [Offers](/docs/offers) and [promo codes](/docs/promo-codes).
|
|
7
|
+
|
|
8
|
+
## 1. Connect Dub
|
|
9
|
+
|
|
10
|
+
Open **Settings → Integrations**, and on the Dub card choose **Connect**. Paste an API key from your Dub workspace.
|
|
11
|
+
|
|
12
|
+
- Live organizations need a Dub workspace on the Business plan or higher and an API key with All permissions.
|
|
13
|
+
- Sandbox organizations use a Dub staging workspace. Partner emails still go out, and no payouts are made.
|
|
14
|
+
|
|
15
|
+
Commet validates the key by reading your Dub catalog and stores it encrypted. Only owners and admins can connect or manage Dub.
|
|
16
|
+
|
|
17
|
+
## 2. Sync partner codes
|
|
18
|
+
|
|
19
|
+
On the Dub card, choose **Manage** and copy the **Code sync** URL. In Dub, go to **Settings → Webhooks** and create a webhook with that URL and the `discount_code.created` and `discount_code.deleted` events.
|
|
20
|
+
|
|
21
|
+
Each event makes Commet read the Dub catalog again. Without the webhook, new codes don't reach Commet.
|
|
22
|
+
|
|
23
|
+
## How Dub records appear in Commet
|
|
24
|
+
|
|
25
|
+
| In Dub | In Commet |
|
|
26
|
+
| ---------------- | ---------------------------------------------------------------- |
|
|
27
|
+
| Partner discount | Offer with `managedBy: "dub"` |
|
|
28
|
+
| Partner code | Promo code with `firstPurchaseOnly: true` and `managedBy: "dub"` |
|
|
29
|
+
|
|
30
|
+
Their terms change only in Dub. Editing them in Commet returns `409 managed_by_integration`. Renaming an Offer and activating or deactivating a code still work.
|
|
31
|
+
|
|
32
|
+
A Dub code whose text already exists as a Commet promo code is not imported. **Manage** lists it under **Codes not imported**.
|
|
33
|
+
|
|
34
|
+
## What Commet sends to Dub
|
|
35
|
+
|
|
36
|
+
Sales match Dub customers by the customer's `externalId`, the same ID you track leads with in Dub.
|
|
37
|
+
|
|
38
|
+
- Every invoice Commet charges is sent as a sale.
|
|
39
|
+
- Refunds mark the sale refunded.
|
|
40
|
+
- Cancellations, trial starts, customer updates, and code deletions are sent too.
|
|
41
|
+
|
|
42
|
+
Commet retries a failed send for up to 3 days. Billing is never affected. Sends that still fail appear under **Not reaching Dub** in **Manage**, with **Resend**.
|
|
43
|
+
|
|
44
|
+
## Disconnect Dub
|
|
45
|
+
|
|
46
|
+
Choose **Disconnect** in **Manage**. Commet stops sending sales, refunds, and subscription changes to Dub, and stops following its discounts and codes. Their Offers and promo codes keep working as regular ones.
|
|
47
|
+
|
|
48
|
+
## Limitations
|
|
49
|
+
|
|
50
|
+
- Invoices first charged before Dub was connected are not sent.
|
|
51
|
+
- Term changes in Dub reach Commet on the next code sync event.
|
|
52
|
+
- Dub codes are first-purchase only: customers who already paid are refused with `first_purchase_only`.
|
|
@@ -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`.
|
|
@@ -1,17 +1,46 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Markets and Regional Pricing
|
|
3
|
-
description:
|
|
3
|
+
description: Set plan prices per currency or per country, group countries into reusable Markets, and offer selectable price variants.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
Commet has
|
|
6
|
+
Commet has these complementary pricing layers:
|
|
7
7
|
|
|
8
|
-
| Layer | Use it for
|
|
9
|
-
| -------------------- |
|
|
10
|
-
| **Currency Pricing** | Define plan, balance, and overage values in one presentment currency
|
|
11
|
-
| **
|
|
8
|
+
| Layer | Use it for |
|
|
9
|
+
| -------------------- | ----------------------------------------------------------------------------------- |
|
|
10
|
+
| **Currency Pricing** | Define plan, balance, and overage values in one presentment currency |
|
|
11
|
+
| **Country prices** | Give a country its own currency and prices in a [plan version](/docs/plan-versions) |
|
|
12
|
+
| **Markets** | Group countries that should resolve explicit price and currency overrides |
|
|
12
13
|
|
|
13
14
|
Currency Pricing remains the fallback. Add Markets when country segmentation or selectable variants require it.
|
|
14
15
|
|
|
16
|
+
## Set currency pricing
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
await commet.plans.setRegionalPricing({
|
|
20
|
+
id: 'pln_pro',
|
|
21
|
+
currency: 'gbp',
|
|
22
|
+
exchangeRate: 0.79,
|
|
23
|
+
})
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
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. Each change publishes a new [plan version](/docs/plan-versions); existing subscribers keep theirs until you move them.
|
|
27
|
+
|
|
28
|
+
Supported currencies: USD, ARS, BOB, BRL, CAD, CLP, CNY, COP, EUR, GBP, HKD, INR, JPY, KRW, MXN, PEN, PYG, SGD, THB, TWD, and UYU.
|
|
29
|
+
|
|
30
|
+
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.
|
|
31
|
+
|
|
32
|
+
## Set prices by country
|
|
33
|
+
|
|
34
|
+
In the dashboard, the plan's **Regional prices** tab sets prices country by country in a draft:
|
|
35
|
+
|
|
36
|
+
1. Choose **Add a country** and the currency it pays in, USD included.
|
|
37
|
+
2. Set each price **By hand**, or follow the USD base at an exchange rate.
|
|
38
|
+
3. Set the country's prices for the add-ons and credit packs the plan sells, the same way.
|
|
39
|
+
|
|
40
|
+
Publishing the draft publishes every country together in one plan version. A country missing a price blocks publishing. Through the API, the `countries` block of `PATCH /plans/{id}/drafts/{draftId}` sets the same terms.
|
|
41
|
+
|
|
42
|
+
A subscriber pays the prices of its own country in its version; a buyer from a country the version doesn't list pays the USD base price. A move to another version never changes a subscription's currency, and a version that doesn't sell it can't receive the subscription. The same applies when a canceled subscription is reactivated on the latest version of what was bought: if that version doesn't sell its currency, reactivation returns `422 missing_regional_price`.
|
|
43
|
+
|
|
15
44
|
## Create a Market
|
|
16
45
|
|
|
17
46
|
A Market is a top-level Sales resource. It does not require a plan or price.
|
|
@@ -79,8 +108,9 @@ Omitting `priceId` keeps normal default-price and Market resolution.
|
|
|
79
108
|
|
|
80
109
|
## Renewal and archival
|
|
81
110
|
|
|
82
|
-
- A subscription stores the selected price identity.
|
|
83
|
-
- Renewals use
|
|
111
|
+
- A subscription stores the selected price identity and its plan version.
|
|
112
|
+
- Renewals use the price of the subscription's plan version. Market prices are not versioned: renewals use the Market price's current value.
|
|
113
|
+
- A version move keeps a subscriber's Market price, and a draft can't drop a currency that a Market price uses.
|
|
84
114
|
- A variant inherits every Market it does not override.
|
|
85
115
|
- Archiving hides a price from new selection without breaking existing subscriptions.
|
|
86
116
|
- A referenced Market cannot be deleted.
|
|
@@ -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 open the price. Enter the **Free trial** days, choose whether to **Require a payment method**, and choose **Save to draft**. The trial applies to new subscriptions once you [publish the draft](/docs/plan-versions#edit-in-the-dashboard).
|
|
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` publishes a new plan version and 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 selected price of the subscription's plan version 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.
|