@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
|
@@ -67,7 +67,7 @@ $transactionsListResult = $commet->transactions->list();
|
|
|
67
67
|
|
|
68
68
|
One invoice can have multiple transactions when a renewal is retried. The original failed transaction remains immutable; a retry creates a new attempt.
|
|
69
69
|
|
|
70
|
-
`provider` names the processor. `paymentMethod` names the method used for that attempt (`card`, `mercado_pago`, or `
|
|
70
|
+
`provider` names the processor. `paymentMethod` names the method used for that attempt (`card`, `google_pay`, `mercado_pago`, `oxxo`, or `smartpix`), or is `null` when unknown. It stays tied to the transaction if the customer changes their saved method later.
|
|
71
71
|
|
|
72
72
|
`subPaymentMethod` describes how a Mercado Pago charge was funded when dLocal reports it: `credit_card`, `debit_card`, `prepaid_card`, `bank_transfer`, or `account_money`. It is `null` when unavailable or unknown. The dashboard also shows the card brand and last four digits when dLocal provides them for that charge.
|
|
73
73
|
|
|
@@ -36,7 +36,7 @@ Add-ons declare their own consumption model. Boolean add-ons are compatible with
|
|
|
36
36
|
|
|
37
37
|
Go to **Add-ons** and click **Create Add-on**. Configure the name, base price, feature, and consumption model. For metered add-ons, set included units and overage rate. For credits, set the credit cost per unit.
|
|
38
38
|
|
|
39
|
-
The feature dropdown only shows features not already assigned to another add-on. Once created, the add-on is
|
|
39
|
+
The feature dropdown only shows features not already assigned to another add-on. Once created, the add-on is sold on the current version of every compatible plan, or of the plans you choose in `planIds`.
|
|
40
40
|
|
|
41
41
|
## Availability by subscription status
|
|
42
42
|
|
|
@@ -45,9 +45,20 @@ Add-ons can be activated on any subscription with a payment method:
|
|
|
45
45
|
| Status | Can activate add-ons |
|
|
46
46
|
| ------------- | ------------------------------------------------- |
|
|
47
47
|
| **Active** | Yes |
|
|
48
|
-
| **Trialing** | Yes —
|
|
48
|
+
| **Trialing** | Yes — with a saved payment method |
|
|
49
49
|
| **Free plan** | Yes — first purchase prompts for a payment method |
|
|
50
50
|
|
|
51
|
+
## Add-ons and plan versions
|
|
52
|
+
|
|
53
|
+
Each [plan version](/docs/plan-versions) lists the add-ons it sells, with their prices. Creating or editing an add-on publishes a new version of each plan that sells it:
|
|
54
|
+
|
|
55
|
+
- New customers get the add-on and its price on the plan's current version.
|
|
56
|
+
- Existing subscribers keep the add-ons and prices of their version. Activating an add-on their version doesn't sell returns `409 addon_unavailable` until you [move them](/docs/plan-versions#move-subscribers) to a version that sells it.
|
|
57
|
+
- A subscription with an active add-on can't move to a version that doesn't sell it until the add-on is removed. A plan move can remove it at renewal with `removeAddonIds`.
|
|
58
|
+
- A canceled subscription that is [reactivated](/docs/plan-versions#reactivate-a-canceled-subscription) returns on the latest version of what was bought, and the add-ons that version doesn't sell are deactivated.
|
|
59
|
+
|
|
60
|
+
Send `planIds` when you create or update an add-on to choose the plans that sell it. Left out on create, or empty, every plan sells it, including plans created later. Removing a plan returns `409 addon_has_activations` while a subscription of that plan has the add-on active.
|
|
61
|
+
|
|
51
62
|
## Manage add-ons
|
|
52
63
|
|
|
53
64
|
Add-ons are managed through the dashboard, the customer portal, or the API.
|
|
@@ -228,13 +239,13 @@ Subtotal $213.00
|
|
|
228
239
|
|
|
229
240
|
### Multi-currency
|
|
230
241
|
|
|
231
|
-
Add-on prices are defined in USD. For non-USD subscriptions, the price is converted using the plan's exchange rate — the same mechanism used for plan base prices.
|
|
242
|
+
Add-on prices are defined in USD. For non-USD subscriptions, the price is converted using the plan's exchange rate — the same mechanism used for plan base prices. A plan version can also set an add-on's price by hand for a country in the [Regional prices](/docs/regional-prices#set-prices-by-country) tab.
|
|
232
243
|
|
|
233
244
|
## Customer portal
|
|
234
245
|
|
|
235
246
|
Customers can self-service add-ons from the portal:
|
|
236
247
|
|
|
237
|
-
- **Available add-ons** — see compatible add-ons with pricing
|
|
248
|
+
- **Available add-ons** — see the compatible add-ons their plan version sells, with pricing
|
|
238
249
|
- **Activate** — confirmation dialog with prorated charge preview
|
|
239
250
|
- **Active add-ons** — manage active add-ons
|
|
240
251
|
- **Deactivate** — instant, no refund
|
|
@@ -25,7 +25,7 @@ Customers pay a base price and get included usage. Overage beyond the included a
|
|
|
25
25
|
|
|
26
26
|
## Credits
|
|
27
27
|
|
|
28
|
-
Customers receive credits with their subscription. Feature usage consumes credits. When credits run out, customers can
|
|
28
|
+
Customers receive credits with their subscription. Feature usage consumes credits. When credits run out, customers can buy [Credit Packs or a chosen quantity](/docs/credit-packs), turn on [auto top-up](/docs/credit-packs#top-up-credits-automatically), or wait for the next billing cycle.
|
|
29
29
|
|
|
30
30
|
| Feature | Credits per Use |
|
|
31
31
|
| ------------------- | --------------- |
|
|
@@ -35,7 +35,42 @@ Customers receive credits with their subscription. Feature usage consumes credit
|
|
|
35
35
|
|
|
36
36
|
> **Note**
|
|
37
37
|
>
|
|
38
|
-
> Plan credits
|
|
38
|
+
> Plan credits expire at each reset unless the plan rolls them over. Purchased credits **never expire**.
|
|
39
|
+
|
|
40
|
+
### Roll over unused plan credits
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
await commet.plans.update({
|
|
44
|
+
id: 'pln_xxx',
|
|
45
|
+
unusedPlanCredits: { type: 'roll_over', maxPlanCredits: 2500 },
|
|
46
|
+
})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
At each reset, the new allocation is added to the unused plan credits instead of replacing them. `maxPlanCredits` caps the total after the reset, including the new allocation; credits above it expire. It must be at least the included credits of every price. `null` means no cap other than 2,147,483,647 credits.
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
Plan grants 1,000 credits per month. maxPlanCredits: 2,500.
|
|
53
|
+
|
|
54
|
+
Month 1: 800 unused → 800 + 1,000 = 1,800
|
|
55
|
+
Month 2: 1,800 unused → 2,800, capped at 2,500. 300 expire.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`{ type: 'expire' }` restores the default. Changing it publishes a new [plan version](/docs/plan-versions); each subscription keeps its version's setting until you move it. A plan change applies the new plan's setting.
|
|
59
|
+
|
|
60
|
+
### Limit plan credit spending
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
await commet.plans.update({
|
|
64
|
+
id: 'pln_xxx',
|
|
65
|
+
planCreditLimit: { credits: 100, interval: 'day' },
|
|
66
|
+
})
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`planCreditLimit` caps the plan credits a subscription spends per window: `day` is 24 hours and `week` is 7 days, starting at the time of day of the subscription's billing anchor. Purchased credits are never limited.
|
|
70
|
+
|
|
71
|
+
An event past the limit uses purchased credits. Without enough, [Track Usage](/docs/track-usage#limit-plan-credit-spending) rejects it with `402 plan_credit_limit_reached`. Changing the limit publishes a new plan version; each subscription keeps its version's limit until you move it.
|
|
72
|
+
|
|
73
|
+
In the dashboard, open **Plans**, select a credits plan, and edit **Carry-over**, **Credit limit**, or **Buying credits** under **Credit rules**. The changes go into a draft until you publish it.
|
|
39
74
|
|
|
40
75
|
## Balance
|
|
41
76
|
|
|
@@ -62,13 +97,13 @@ Set a margin percentage instead of a fixed price. Commet looks up the model's to
|
|
|
62
97
|
|
|
63
98
|
## Comparison
|
|
64
99
|
|
|
65
|
-
| Aspect | Metered | Credits
|
|
66
|
-
| -------------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
67
|
-
| **When exceeded** | Overage at period end | Blocked or buy
|
|
68
|
-
| **Reset behavior** | Usage resets to 0 each period | Plan credits reset each period | Balance resets to plan amount each period |
|
|
69
|
-
| **Purchased extras** | N/A | Credits persist forever
|
|
70
|
-
| **Reset frequency** | Weekly plans reset every 7 days. Monthly, quarterly, semiannual, yearly, one-time, and free plans reset monthly | Same
|
|
71
|
-
| **Customer portal** | View usage | Buy
|
|
100
|
+
| Aspect | Metered | Credits | Balance |
|
|
101
|
+
| -------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------- | ----------------------------------------- |
|
|
102
|
+
| **When exceeded** | Overage at period end | Blocked or buy credits | Overage at period end |
|
|
103
|
+
| **Reset behavior** | Usage resets to 0 each period | Plan credits reset or roll over each period | Balance resets to plan amount each period |
|
|
104
|
+
| **Purchased extras** | N/A | Credits persist forever | Top-ups reset at period |
|
|
105
|
+
| **Reset frequency** | Weekly plans reset every 7 days. Monthly, quarterly, semiannual, yearly, one-time, and free plans reset monthly | Same | Same |
|
|
106
|
+
| **Customer portal** | View usage | Buy credits, set auto top-up | Add balance (top-up) |
|
|
72
107
|
|
|
73
108
|
## Overage restrictions by plan type
|
|
74
109
|
|
|
@@ -24,6 +24,10 @@ A free plan has a price of $0 and no billing cycle. Customers are activated imme
|
|
|
24
24
|
|
|
25
25
|
Go to **Plans** and click **Create Plan**. Fill in each component from the table above, then save. For detailed feature configuration, see [Configure Features](/docs/configure-features).
|
|
26
26
|
|
|
27
|
+
## Edit a plan
|
|
28
|
+
|
|
29
|
+
Editing a plan's prices, trials, features, rules, add-ons, credit packs, or country prices publishes a new [plan version](/docs/plan-versions). New customers get it; existing subscribers keep their version until you move them. In the dashboard, edits go into a draft that you publish when ready. The name, description, and visibility are not versioned and change at once with **Edit details**.
|
|
30
|
+
|
|
27
31
|
## Retrieve plans via SDK
|
|
28
32
|
|
|
29
33
|
### TypeScript
|
|
@@ -107,7 +111,7 @@ curl "https://commet.co/api/v1/plans?includePrivate=true" \
|
|
|
107
111
|
-H "x-api-key: $COMMET_API_KEY"
|
|
108
112
|
```
|
|
109
113
|
|
|
110
|
-
Get a specific plan
|
|
114
|
+
Get a specific plan. Plan reads return the terms of the current version; list a plan's versions with `GET /plans/{id}/versions`.
|
|
111
115
|
|
|
112
116
|
### TypeScript
|
|
113
117
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Credit Packs
|
|
3
|
-
description:
|
|
3
|
+
description: Sell credit packs, let customers buy a chosen quantity of credits at the plan price, and top up credits automatically at a threshold.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
Credit Packs are additional credit packages customers can purchase when they run out of included plan credits. Only available for plans using the **Credits** [consumption model](/docs/consumption-models).
|
|
@@ -19,7 +19,16 @@ Credit packs can be purchased on any subscription with a payment method — incl
|
|
|
19
19
|
|
|
20
20
|
## Create credit packs in the dashboard
|
|
21
21
|
|
|
22
|
-
Go to **Credit Packs** and click **Create Credit Pack**. Pack names must be unique within your organization.
|
|
22
|
+
Go to **Credit Packs** and click **Create Credit Pack**. Pack names must be unique within your organization. A new pack is sold on the current version of every credits plan, or of the plans you choose in `planIds`.
|
|
23
|
+
|
|
24
|
+
## Credit packs and plan versions
|
|
25
|
+
|
|
26
|
+
Each [plan version](/docs/plan-versions) lists the credit packs it sells, with their prices. Creating or editing a pack publishes a new version of each plan that sells it:
|
|
27
|
+
|
|
28
|
+
- New customers can buy the pack at its price on the plan's current version.
|
|
29
|
+
- Existing subscribers keep the packs and prices of their version. Buying a pack their version doesn't sell returns `409 credit_pack_unavailable` until you [move them](/docs/plan-versions#move-subscribers) to a version that sells it.
|
|
30
|
+
|
|
31
|
+
Send `planIds` when you create or update a pack to choose the plans that sell it. Left out on create, or empty, every plan sells it, including plans created later.
|
|
23
32
|
|
|
24
33
|
## List credit packs via SDK
|
|
25
34
|
|
|
@@ -78,4 +87,53 @@ curl https://commet.co/api/v1/credit-packs \
|
|
|
78
87
|
}
|
|
79
88
|
```
|
|
80
89
|
|
|
81
|
-
The `price` field is in **cents** (1000 = $10.00).
|
|
90
|
+
The `price` field is the USD price in **cents** (1000 = $10.00). For other currencies, Commet converts it with the plan's exchange rate, unless the plan version sets the pack's price by hand for the buyer's country in the [Regional prices](/docs/regional-prices#set-prices-by-country) tab.
|
|
91
|
+
|
|
92
|
+
## Buy a chosen quantity of credits
|
|
93
|
+
|
|
94
|
+
Set a price per credit on the plan to let customers buy any whole quantity instead of a fixed pack. Open **Plans**, select a credits plan, and edit **Buying credits** under **Credit rules**: the **Price per credit** and an optional minimum. The change goes into a draft until you [publish it](/docs/plan-versions#edit-in-the-dashboard).
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
await commet.subscriptions.purchaseCredits({
|
|
98
|
+
id: 'sub_xxx',
|
|
99
|
+
quantity: 500,
|
|
100
|
+
})
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Commet charges the saved payment method at the price per credit of the subscription's plan version and adds purchased credits. Send `creditPackId` instead of `quantity` to buy a pack. Both fire [`credits.purchased`](/docs/webhooks/credits-purchased).
|
|
104
|
+
|
|
105
|
+
| Response | Cause |
|
|
106
|
+
| ----------------------------- | -------------------------------------------------------------------------- |
|
|
107
|
+
| `400 validation_error` | The quantity is below the plan's minimum, or the plan doesn't sell credits |
|
|
108
|
+
| `402 no_payment_method` | The subscription has no saved payment method Commet can charge |
|
|
109
|
+
| `402 payment_failed` | The charge was declined |
|
|
110
|
+
| `409 credit_pack_unavailable` | The subscription's plan version doesn't sell the pack |
|
|
111
|
+
|
|
112
|
+
The effective minimum is the larger of the configured minimum and the smallest quantity that reaches the currency's minimum charge.
|
|
113
|
+
|
|
114
|
+
## Top up credits automatically
|
|
115
|
+
|
|
116
|
+
Auto top-up buys credits with the saved payment method when the subscription's credits fall to a threshold.
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
await commet.subscriptions.updateAutoTopUp({
|
|
120
|
+
id: 'sub_xxx',
|
|
121
|
+
enabled: true,
|
|
122
|
+
threshold: 100,
|
|
123
|
+
quantity: 500,
|
|
124
|
+
maxPerPeriod: 3,
|
|
125
|
+
})
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
| Parameter | Type | Description |
|
|
129
|
+
| -------------- | --------- | --------------------------------------------------------------- |
|
|
130
|
+
| `enabled` | `boolean` | Turns automatic purchases on or off |
|
|
131
|
+
| `threshold` | `integer` | Plan and purchased credits at or below which a top-up is bought |
|
|
132
|
+
| `quantity` | `integer` | Credits each top-up buys. At least the plan's minimum |
|
|
133
|
+
| `maxPerPeriod` | `integer` | Successful top-ups per credit renewal period. `1` to `100` |
|
|
134
|
+
|
|
135
|
+
Send only the fields that change. Enabling requires a plan with a price per credit. Read the current settings, `status`, `topUpsThisPeriod`, and `lastFailure` with `getAutoTopUp`.
|
|
136
|
+
|
|
137
|
+
Auto top-up pauses after 3 consecutive failed top-ups, or after one whose charge couldn't be refunded. It resumes when the payment method changes, a credit purchase succeeds, or you save it enabled again.
|
|
138
|
+
|
|
139
|
+
Customers turn it on and edit it in the [Customer Portal](/docs/customer-portal) under **Auto top-up**. In the dashboard, it appears on the subscription detail.
|
|
@@ -16,7 +16,7 @@ A one-time price charges the customer once at checkout and never bills again for
|
|
|
16
16
|
>
|
|
17
17
|
> This page covers one-time charges billed as a **plan**. To charge a customer once with **no subscription or plan** — a standalone invoice with tax and receipt — use [Accept One-Time Payments](/docs/accept-one-time-payments) instead.
|
|
18
18
|
|
|
19
|
-
One-time plans behave like any other plan — they support [
|
|
19
|
+
One-time plans behave like any other plan — they support [add-ons](/docs/add-ons) and all [consumption models](/docs/consumption-models). One-time prices can't have a [trial](/docs/trial-periods) or an [intro offer](/docs/introductory-offers). The other differences are:
|
|
20
20
|
|
|
21
21
|
| Aspect | Behavior |
|
|
22
22
|
| -------------------- | ------------------------------------------------------------------------- |
|
|
@@ -131,7 +131,7 @@ The initial invoice includes the plan base price as a one-time charge. After tha
|
|
|
131
131
|
|
|
132
132
|
| Invoice | What's included |
|
|
133
133
|
| --------------------- | ------------------------------------------------------------------------ |
|
|
134
|
-
| **Initial** | `plan_base` (once)
|
|
134
|
+
| **Initial** | `plan_base` (once) |
|
|
135
135
|
| **Subsequent cycles** | `feature_overage`, `feature_seats`, `addon_base` — only if charges exist |
|
|
136
136
|
|
|
137
137
|
If there's no overage or additional charges at a billing cycle, no invoice is generated.
|
|
@@ -164,7 +164,7 @@ curl -X POST https://commet.co/api/v1/subscriptions \
|
|
|
164
164
|
|
|
165
165
|
- The cancellation is scheduled from creation: the response already shows `cancelAtPeriodEnd: true` and `cancellation` before the customer pays.
|
|
166
166
|
- The purchase keeps ending even if the customer saves a card through a payment method update link, and the Customer Portal doesn't offer **Keep subscription** for it.
|
|
167
|
-
- Free trials don't combine with it
|
|
167
|
+
- Free trials don't combine with it: `customTrialDays` above `0` returns `400` and the price's trial is skipped.
|
|
168
168
|
- When the purchase ends, Commet emits [`subscription.canceled`](/docs/webhooks/subscription-canceled).
|
|
169
169
|
|
|
170
170
|
To make it renew, [reverse the scheduled cancellation](/docs/manage-subscriptions#reverse-a-scheduled-cancellation) through the API with `POST /v1/subscriptions/{id}/uncancel`. If the customer paid with a method Commet can't charge again, such as OXXO, and has no saved card, the request returns `409 subscription_uncancel_failed`.
|
|
@@ -1,24 +1,60 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Plan Groups
|
|
3
|
-
description: Group plans
|
|
3
|
+
description: Group plans for self-service upgrades and downgrades, and choose the default free plan and signup trial that new and departing customers land on.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
A plan group is the [upgrade and downgrade path](/docs/what-happens-when-a-customer-changes-plans) between plans. Without a plan group, customers won't see upgrade or downgrade options in the [Customer Portal](/docs/customer-portal).
|
|
7
7
|
|
|
8
8
|
## Plan group components
|
|
9
9
|
|
|
10
|
-
| Component
|
|
11
|
-
|
|
|
12
|
-
| **Group Name**
|
|
13
|
-
| **Plans**
|
|
14
|
-
| **Hierarchy**
|
|
10
|
+
| Component | Description | Example |
|
|
11
|
+
| ---------------- | ----------------------------------------------------------- | ------------------ |
|
|
12
|
+
| **Group Name** | Name for the collection | "Standard Plans" |
|
|
13
|
+
| **Plans** | Plans in the group, ordered low to high | Free, Starter, Pro |
|
|
14
|
+
| **Hierarchy** | Drag-and-drop order defining upgrade path | Lowest tier first |
|
|
15
|
+
| **Default plan** | Free plan customers land on when a paid plan or trial ends | Free |
|
|
16
|
+
| **Signup trial** | Paid plan new customers start on, as a trial without a card | Pro |
|
|
15
17
|
|
|
16
18
|
## Create a plan group in the dashboard
|
|
17
19
|
|
|
18
|
-
Go to **
|
|
20
|
+
Go to **Plans** → **Groups** and click **Create Group**. Name the group, add your plans, then drag and drop to arrange them from lowest to highest tier. Each plan can only belong to one group. Plans in a group can sell different currencies and countries with [Regional Prices](/docs/regional-prices). A subscriber can switch only to group plans that sell its currency in its country: the Customer Portal shows only those, and the API rejects the others with `422 missing_regional_price`.
|
|
19
21
|
|
|
20
22
|
This order defines the upgrade path and display order in the Customer Portal.
|
|
21
23
|
|
|
22
|
-
##
|
|
24
|
+
## Default plan and signup trial
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
Open the group and choose **Set as default** on a free plan, or **Set as signup trial** on a paid plan whose default price has a [trial without a payment method](/docs/trial-periods#start-a-trial-without-a-payment-method). A group has at most one of each.
|
|
27
|
+
|
|
28
|
+
A customer created with `planGroupId` starts at once on:
|
|
29
|
+
|
|
30
|
+
- the signup trial, when the group has one and the customer never had that plan;
|
|
31
|
+
- otherwise the default plan;
|
|
32
|
+
- otherwise no plan.
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
await commet.customers.create({
|
|
36
|
+
email: 'user@example.com',
|
|
37
|
+
planGroupId: 'plg_xxx',
|
|
38
|
+
})
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`customers.createBatch` accepts the same `planGroupId` for every customer in the batch. A customer that already has an open subscription keeps it.
|
|
42
|
+
|
|
43
|
+
A paid plan of the group moves to the default plan instead of being canceled when:
|
|
44
|
+
|
|
45
|
+
- the customer cancels it from the Customer Portal, at period end;
|
|
46
|
+
- its payment authorization is revoked;
|
|
47
|
+
- every payment retry fails;
|
|
48
|
+
- a trial without a payment method ends without a card.
|
|
49
|
+
|
|
50
|
+
Canceling through the API still cancels. A scheduled move to the default plan can be revoked like any [scheduled plan change](/docs/upgrade-and-downgrade-plans#revoke-a-scheduled-plan-change).
|
|
51
|
+
|
|
52
|
+
Removing the default plan makes later endings regular cancellations. Moves already scheduled keep their target.
|
|
53
|
+
|
|
54
|
+
## Limitations
|
|
55
|
+
|
|
56
|
+
- The default plan must be a free plan in the group.
|
|
57
|
+
- A signup trial plan can't remove the trial without a payment method from its default price.
|
|
58
|
+
- A customer gets the signup trial once per plan.
|
|
59
|
+
- `planGroupId` for a group with neither a default plan nor a signup trial returns `400`.
|
|
60
|
+
- `planGroupId` for a group with a signup trial returns `403` while the organization can't charge yet.
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Plan Versions
|
|
3
|
+
description: "Edit a plan without changing what existing subscribers pay: publish a new version or an experiment, then move subscribers when you choose."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Every subscription is pinned to one version of its plan. A version holds the complete terms: prices, trials, features, credit and balance rules, add-ons, credit packs, and country prices. The plan points at its current version, which every new buyer gets.
|
|
7
|
+
|
|
8
|
+
Editing a plan publishes a new version and moves nobody. Existing subscribers keep the prices, features, and rules of their version, at renewal too, until you move them.
|
|
9
|
+
|
|
10
|
+
## What a version holds
|
|
11
|
+
|
|
12
|
+
| Versioned | Not versioned |
|
|
13
|
+
| ------------------------------------------------------------------------------------ | ------------------------------------------------------ |
|
|
14
|
+
| Prices per billing interval, trial days, and the interval shown first | Name and description |
|
|
15
|
+
| The Introductory Offer of each price | Visibility |
|
|
16
|
+
| Features, included amounts, overage prices, and limits | [Market](/docs/regional-prices#create-a-market) prices |
|
|
17
|
+
| Credit and balance rules: carry-over, spending limits, credit purchases, and top-ups | |
|
|
18
|
+
| The add-ons and credit packs the plan sells, with their prices | |
|
|
19
|
+
| Countries with their currency and prices | |
|
|
20
|
+
|
|
21
|
+
**Edit details** changes the name, description, and visibility at once, for everyone. Market prices apply to every version: an edit to a Market price reaches the subscribers who pay it at their next renewal.
|
|
22
|
+
|
|
23
|
+
The plan's versions are numbered 1, 2, 3. An experiment's own versions carry its code, such as `price-test 2`.
|
|
24
|
+
|
|
25
|
+
## Edit in the dashboard
|
|
26
|
+
|
|
27
|
+
Open a plan from **Plans**. The version menu opens the current version, drafts, experiments, and older versions. The plan page has six tabs:
|
|
28
|
+
|
|
29
|
+
| Tab | What it shows |
|
|
30
|
+
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
|
|
31
|
+
| **Plan** | The prices, features, rules, add-ons, and credit packs of the version you opened |
|
|
32
|
+
| **Regional prices** | The version's countries, with their currency and prices |
|
|
33
|
+
| **Subscribers** | The plan's subscribers with their version and any move pending, with its date, plus **Needs a change** |
|
|
34
|
+
| **Versions** | The published versions with what changed in each, and the plan's drafts |
|
|
35
|
+
| **Experiments** | Each experiment with its status, the version it sells, and its subscribers |
|
|
36
|
+
| **Moves** | Every move with how many subscribers moved, are on track, need a change, or were left out. A move not yet finished can be canceled here |
|
|
37
|
+
|
|
38
|
+
1. Edit any version. The first change starts a draft from it. A draft is saved as you edit, and nobody sees it until you publish it. A removed price, feature, add-on, or credit pack stays in place, struck through, with **Undo**. Disabling a feature appears in the changes as **Disabled**; only removing it appears as removed.
|
|
39
|
+
2. The plan header shows the draft's number of changes. Open it to review **Changes in this draft** and undo any of them, or choose **Discard draft**.
|
|
40
|
+
3. Choose **Review and publish** in the header, then publish it as:
|
|
41
|
+
- **The current version**, which new buyers get.
|
|
42
|
+
- **A new experiment**, sold only through its own code. Only for drafts started from the current version.
|
|
43
|
+
- **Next version of an experiment**, for drafts started from an experiment's latest version.
|
|
44
|
+
4. Choose what happens to subscribers of earlier versions: **Keep them on their version**, **Move them at their next renewal**, or **Move them now**. When some of them don't fit the new version, the dialog lists each one with what would make it fit.
|
|
45
|
+
|
|
46
|
+
A draft publishes exactly its content. A draft started from an older version undoes what later versions changed, and the review lists those changes.
|
|
47
|
+
|
|
48
|
+
Publishing stops while a country is missing a price, or when the current version would drop the trial without a payment method of the plan group's [signup trial](/docs/plan-groups#default-plan-and-signup-trial).
|
|
49
|
+
|
|
50
|
+
To move subscribers later, open **Subscribers**, select them, and choose **Move to another version**.
|
|
51
|
+
|
|
52
|
+
## Edit through the API
|
|
53
|
+
|
|
54
|
+
Every plan edit made through the API, MCP, or the CLI publishes a new current version at once and moves nobody. That includes adding, changing, or removing prices and features, regional pricing, and the credit and balance rules of `PATCH /plans/{id}`. New buyers get the new version; existing subscribers stay on theirs until you [move them](#move-subscribers).
|
|
55
|
+
|
|
56
|
+
To prepare several changes and publish them together, start a draft:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
curl -X POST https://commet.co/api/v1/plans/pln_xxx/drafts \
|
|
60
|
+
-H "x-api-key: $COMMET_API_KEY" \
|
|
61
|
+
-H "commet-version: 2026-08-27" \
|
|
62
|
+
-H "Content-Type: application/json" \
|
|
63
|
+
-d '{}'
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The draft starts from the current version unless you send `fromVersionId`. Change it with `PATCH /plans/{id}/drafts/{draftId}` and the blocks `prices`, `countries`, `rules`, and `undo`. Each block you send replaces that block, so `prices` lists every interval the draft sells:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
curl -X PATCH https://commet.co/api/v1/plans/pln_xxx/drafts/plr_draft \
|
|
70
|
+
-H "x-api-key: $COMMET_API_KEY" \
|
|
71
|
+
-H "commet-version: 2026-08-27" \
|
|
72
|
+
-H "Content-Type: application/json" \
|
|
73
|
+
-d '{"prices":[{"billingInterval":"monthly","price":5900,"isDefault":true},{"billingInterval":"yearly","price":59000}]}'
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Publish it with `"preview": true` first to check everything without publishing:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
curl -X POST https://commet.co/api/v1/plans/pln_xxx/drafts/plr_draft/publish \
|
|
80
|
+
-H "x-api-key: $COMMET_API_KEY" \
|
|
81
|
+
-H "commet-version: 2026-08-27" \
|
|
82
|
+
-H "Content-Type: application/json" \
|
|
83
|
+
-d '{"publishAs":"current","move":"period_end","preview":true}'
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
| Field | Values |
|
|
87
|
+
| ----------- | ------------------------------------------------------------------------------------------------------------ |
|
|
88
|
+
| `publishAs` | `current`, `experiment` with `experimentCode`, or `experiment_version` |
|
|
89
|
+
| `move` | `keep` (default), `period_end`, or `now`, for subscribers of earlier versions. An experiment takes no `move` |
|
|
90
|
+
| `changes` | Per-subscriber changes that make each one fit. See [Resolve conflicts](#resolve-conflicts) |
|
|
91
|
+
|
|
92
|
+
Features and the add-ons and credit packs a plan sells are not part of an API draft: their own endpoints publish a new version at once. Introductory Offers are set in a dashboard draft.
|
|
93
|
+
|
|
94
|
+
`POST /plans/{id}/versions` publishes a new current version without a draft. It changes only money terms: prices, included credits or balance, per-currency amounts, and the carry-over cap.
|
|
95
|
+
|
|
96
|
+
## Move subscribers
|
|
97
|
+
|
|
98
|
+
Only you move subscribers, and a move changes a subscription's version, never its plan. Move one subscription with `change-version`:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
curl -X POST https://commet.co/api/v1/subscriptions/sub_xxx/change-version \
|
|
102
|
+
-H "x-api-key: $COMMET_API_KEY" \
|
|
103
|
+
-H "commet-version: 2026-08-27" \
|
|
104
|
+
-H "Content-Type: application/json" \
|
|
105
|
+
-d '{"planVersionId":"plr_new","effective":"period_end"}'
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Repeating the same request changes nothing, and a new one replaces the pending move. Move many at once with `POST /plans/{id}/moves`, sending `subscriptionIds` (up to 10,000) or `fromVersionId` to move every subscription of that version:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
curl -X POST https://commet.co/api/v1/plans/pln_xxx/moves \
|
|
112
|
+
-H "x-api-key: $COMMET_API_KEY" \
|
|
113
|
+
-H "commet-version: 2026-08-27" \
|
|
114
|
+
-H "Content-Type: application/json" \
|
|
115
|
+
-d '{"fromVersionId":"plr_old","toVersionId":"plr_new","effective":"period_end","preview":true}'
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
| `effective` | What changes |
|
|
119
|
+
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
120
|
+
| `now` | Features, limits, and included credits or balance change today, without resetting usage. The new price is charged from the next renewal |
|
|
121
|
+
| `period_end` | Everything changes at the next renewal. Until then nothing in the current period changes: balance, usage checks, features, and access stay as they are |
|
|
122
|
+
|
|
123
|
+
A move never prorates or refunds. With `now`, a larger included amount first pays any plan credit or balance debt, a smaller one never creates new debt, and purchased credits and balance are untouched.
|
|
124
|
+
|
|
125
|
+
### What a move keeps
|
|
126
|
+
|
|
127
|
+
- **Currency, country, interval, and price.** A move never changes a subscription's currency. A version that doesn't sell its currency returns `422 missing_regional_price`, and one that doesn't sell the price it pays returns `404 price_not_found`.
|
|
128
|
+
- **Market prices.** A subscription that pays a Market price keeps paying it.
|
|
129
|
+
- **Free or paid.** A free version moves only to a free version, and a paid one only to a paid one (`400 validation_error`).
|
|
130
|
+
|
|
131
|
+
### Who can move
|
|
132
|
+
|
|
133
|
+
- Subscriptions move only to a newer version (`422 version_not_newer`). One on a running experiment moves only to a later version of that experiment.
|
|
134
|
+
- Only `active`, `trialing`, and `past_due` subscriptions move; `change-version` rejects the others with `409 invalid_subscription_status`. A plan move leaves out the others, such as paused ones, and listed subscriptions already on the destination; they stay on their version. A scheduled cancellation, pause, downgrade, or interval change doesn't leave a subscription out.
|
|
135
|
+
- A one-time subscription never renews, so it moves only now. `change-version` with `period_end` returns `409 invalid_subscription_status`, and a plan move at renewal leaves it out.
|
|
136
|
+
- An active add-on the version doesn't sell (`409 addon_unavailable`), or more seats than the version allows (`400 seat_limit_exceeded`), keeps a subscription from moving until you resolve it.
|
|
137
|
+
|
|
138
|
+
### Resolve conflicts
|
|
139
|
+
|
|
140
|
+
A plan move, a publish with `move`, and an experiment archive check every subscriber first. If any of them doesn't fit, nobody moves and the response is `409 subscribers_do_not_fit`, listing each one with the reasons. Send a change for each one in `changes`:
|
|
141
|
+
|
|
142
|
+
| Change | Effect at the subscriber's renewal |
|
|
143
|
+
| --------------------- | ---------------------------------------------- |
|
|
144
|
+
| `billingInterval` | Moves it to another interval the version sells |
|
|
145
|
+
| `seatLimit: true` | Lowers its seats to the version's limit |
|
|
146
|
+
| `removeAddonIds` | Stops charging the listed add-ons |
|
|
147
|
+
| `keepOnVersion: true` | Leaves it on its version |
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"fromVersionId": "plr_old",
|
|
152
|
+
"toVersionId": "plr_new",
|
|
153
|
+
"effective": "now",
|
|
154
|
+
"changes": [{ "subscriptionId": "sub_xxx", "removeAddonIds": ["adn_xxx"] }]
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
A subscriber with a change always moves at its renewal, even in a move made now.
|
|
159
|
+
|
|
160
|
+
### When a move at renewal applies
|
|
161
|
+
|
|
162
|
+
A move at renewal waits for the subscription's next renewal, the date `scheduledVersionChange.effectiveAt` shows. The renewal invoices the new period on the new version and sends one `subscription.version_changed`.
|
|
163
|
+
|
|
164
|
+
| Subscription | When it moves |
|
|
165
|
+
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
166
|
+
| `active` | At the end of its current period |
|
|
167
|
+
| `trialing` | When the trial ends. Its first charge is already on the new version |
|
|
168
|
+
| `past_due` | It keeps its version while Commet collects the overdue renewal. Once that's paid, it moves at the end of the period it paid for; `effectiveAt` shows that date meanwhile |
|
|
169
|
+
| Paused and resumed, or changing interval | At its next renewal after that, with that date |
|
|
170
|
+
|
|
171
|
+
A subscription that ends instead of renewing ends on its version, whether by a cancellation at the end of its period or trial, exhausted dunning, the suspension of the organization, or an immediate cancellation. It sends no version webhook, `scheduledVersionChange` becomes `null`, and its plan move stops waiting for it. A change to another plan, now or at that renewal, such as a scheduled downgrade or the plan group's default plan, lands on the other plan's current version, also without a version webhook.
|
|
172
|
+
|
|
173
|
+
While a cancellation or a downgrade is scheduled, the API and the Subscribers tab still show the move with its date. If the cancellation or downgrade is revoked, the subscription moves at its renewal.
|
|
174
|
+
|
|
175
|
+
### Track and cancel moves
|
|
176
|
+
|
|
177
|
+
- `GET /plans/{id}/moves` lists the plan's moves, and `GET /plans/{id}/moves/{moveId}` reports each subscriber as `moving`, `moved`, `needs_a_change`, `left_out`, `canceled`, or `kept_on_version`.
|
|
178
|
+
- A change of one subscription with `change-version` is recorded as a move of that one subscriber. It appears in `GET /plans/{id}/moves` and the **Moves** tab like any other move.
|
|
179
|
+
- `POST /plans/{id}/moves/{moveId}/cancel` cancels the move for everyone who hasn't moved yet. `POST /plans/{id}/moves/{moveId}/subscriptions/{subscriptionId}/cancel` cancels it for one.
|
|
180
|
+
- `DELETE /subscriptions/{id}/scheduled-version-change` revokes one subscription's pending move.
|
|
181
|
+
|
|
182
|
+
Canceling or revoking a pending move sends `subscription.version_change_canceled` with `reason: "canceled_by_merchant"` for each subscriber it cancels, and records them as `canceled`.
|
|
183
|
+
|
|
184
|
+
A move scheduled for renewal is checked again at the renewal. If the subscription no longer fits, it renews on its version and appears in `GET /plans/{id}/needs-a-change` and under **Needs a change** on the Subscribers tab. Each entry carries the `moveId` of the move it couldn't complete. Move it again with a change, or leave it with `POST /plans/{id}/needs-a-change/{subscriptionId}/keep`.
|
|
185
|
+
|
|
186
|
+
## Run an experiment
|
|
187
|
+
|
|
188
|
+
An experiment sells a version only to the buyers you send to it; everyone else keeps buying the current version. Publish a draft started from the current version as **A new experiment**, or create one with `POST /plans/{id}/experiments`. Its code uses lowercase letters, numbers, hyphens, and underscores, and is never reused in the plan.
|
|
189
|
+
|
|
190
|
+
Sell it by sending the experiment code after the plan code:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
curl -X POST https://commet.co/api/v1/subscriptions \
|
|
194
|
+
-H "x-api-key: $COMMET_API_KEY" \
|
|
195
|
+
-H "commet-version: 2026-08-27" \
|
|
196
|
+
-H "Content-Type: application/json" \
|
|
197
|
+
-d '{"customerId":"user_123","planCode":"pro:price-test"}'
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
An unknown experiment code returns `404 plan_experiment_not_found`.
|
|
201
|
+
|
|
202
|
+
| Action | Endpoint | Result |
|
|
203
|
+
| ------------------------ | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
204
|
+
| Publish its next version | `POST /plans/{id}/experiments/{code}/versions` | Its code sells the new version; earlier subscribers of the experiment stay on theirs |
|
|
205
|
+
| Make it current | `POST /plans/{id}/experiments/{code}/make-current` | Its latest version becomes the plan's current version with the next number. Its subscribers are already on it, and its code sells the current version from then on |
|
|
206
|
+
| Archive it | `POST /plans/{id}/experiments/{code}/archive` | Its code sells the current version, so links already shared keep working. `subscribers` chooses `keep`, `period_end`, or `now` for its subscribers |
|
|
207
|
+
|
|
208
|
+
Making an experiment current through the API moves nobody else. The dashboard also asks what happens to subscribers of earlier versions.
|
|
209
|
+
|
|
210
|
+
## Sell a specific version
|
|
211
|
+
|
|
212
|
+
Send `planVersionId` on `POST /subscriptions` to create the subscription on any published version, current or not, including an experiment's versions. Checkout charges that version's price, and activation grants its credits, add-ons, and credit packs. Sending `planVersionId` with an experiment code returns `400`.
|
|
213
|
+
|
|
214
|
+
## Unpaid checkouts
|
|
215
|
+
|
|
216
|
+
A checkout that hasn't been paid isn't a subscriber yet, so it follows the latest version of what was requested:
|
|
217
|
+
|
|
218
|
+
| Requested with | The checkout charges |
|
|
219
|
+
| -------------------------------------------- | ------------------------------------------------------------- |
|
|
220
|
+
| The plan code, such as `pro` | The plan's current version |
|
|
221
|
+
| An experiment code, such as `pro:price-test` | The experiment's latest version, never the plan's current one |
|
|
222
|
+
| `planVersionId` | That version |
|
|
223
|
+
|
|
224
|
+
Its link charges that version without a new request. Repeating the same `POST /subscriptions` after you edit the plan reuses the checkout: the response is `200` with the same subscription ID and `checkoutUrl`.
|
|
225
|
+
|
|
226
|
+
A different request replaces it: another plan, experiment, version, interval, or price, the plan code after an experiment code, or `planVersionId` instead of a code or the other way round. The old subscription is canceled, its invoice is voided, and its link stops working.
|
|
227
|
+
|
|
228
|
+
## Reactivate a canceled subscription
|
|
229
|
+
|
|
230
|
+
Reactivating a canceled subscription returns it on the latest version of what was bought:
|
|
231
|
+
|
|
232
|
+
- the plan's current version, when it was bought with the plan code;
|
|
233
|
+
- the experiment's latest version, when it was bought with an experiment code, or the plan's current version once the experiment is no longer running;
|
|
234
|
+
- the same version, when it was bought with `planVersionId`.
|
|
235
|
+
|
|
236
|
+
Add-ons that version doesn't sell are deactivated. A version that doesn't sell the subscription's currency returns `422 missing_regional_price`. Reactivating a `past_due` subscription keeps its version.
|
|
237
|
+
|
|
238
|
+
## Add-ons, credit packs, and countries
|
|
239
|
+
|
|
240
|
+
Each version lists the add-ons and credit packs it sells, with their prices. Creating or editing an add-on or credit pack publishes a new version of each plan that sells it. A subscriber buys only what its version sells: an add-on or pack added in a newer version returns `409 addon_unavailable` or `409 credit_pack_unavailable` until you move the subscriber. See [Add-ons](/docs/add-ons#add-ons-and-plan-versions) and [Credit Packs](/docs/credit-packs#credit-packs-and-plan-versions).
|
|
241
|
+
|
|
242
|
+
Each version also sets countries with their own currency and prices. See [Set prices by country](/docs/regional-prices#set-prices-by-country).
|
|
243
|
+
|
|
244
|
+
## Read versions
|
|
245
|
+
|
|
246
|
+
| Request | Returns |
|
|
247
|
+
| ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
248
|
+
| `GET /plans/{id}/versions` | The plan's published versions, newest first, with their prices and subscription counts |
|
|
249
|
+
| `GET /plans/{id}/versions/{versionId}` | One version |
|
|
250
|
+
| `GET /plans/{id}/versions/{versionId}/changes?against={otherVersionId}` | Every term that differs between two versions. A disabled feature reads `Disabled`; a removed term has `after: null` |
|
|
251
|
+
|
|
252
|
+
Versions published before Commet recorded every term are not listed, and reading one by ID returns `404 plan_version_not_found`.
|
|
253
|
+
|
|
254
|
+
Every subscription includes `planVersion`, with its `id` and `label`, and `scheduledVersionChange`, with the `planVersionId`, `label`, and `effectiveAt` of the move pending for its next renewal, or `null`. See [When a move at renewal applies](#when-a-move-at-renewal-applies). Filter `GET /subscriptions` by version with `planVersionId`.
|
|
255
|
+
|
|
256
|
+
## Webhooks
|
|
257
|
+
|
|
258
|
+
| Event | When it fires |
|
|
259
|
+
| --------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
260
|
+
| [`subscription.version_changed`](/docs/webhooks/subscription-version-changed) | A subscription changed version: a move made now or a scheduled move at renewal. Making an experiment current moves nobody, so it sends none |
|
|
261
|
+
| [`subscription.version_change_canceled`](/docs/webhooks/subscription-version-change-canceled) | A pending move will not happen. `reason` is `canceled_by_merchant` when you canceled or revoked it, `version_change_failed`, or the code of what the subscription no longer fits |
|
|
262
|
+
|
|
263
|
+
Neither is sent when the subscription ends or changes to another plan before the move applies, or when a new move replaces the pending one.
|
|
264
|
+
|
|
265
|
+
Both reach only the webhook endpoints that list them. Add them to your endpoint's events to receive them.
|