@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.
Files changed (64) hide show
  1. package/dist/index.d.mts +413 -52
  2. package/dist/index.d.ts +413 -52
  3. package/dist/index.js +39 -12
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +39 -12
  6. package/dist/index.mjs.map +1 -1
  7. package/docs/ai-onboarding/mcp-server.md +1 -1
  8. package/docs/api-reference/customers.md +6 -2
  9. package/docs/api-reference/generated-webhooks.md +2 -2
  10. package/docs/api-reference/index.md +2 -2
  11. package/docs/api-reference/offers.md +2 -2
  12. package/docs/api-reference/plans.md +16 -3
  13. package/docs/api-reference/promo-codes.md +3 -1
  14. package/docs/api-reference/subscriptions.md +84 -9
  15. package/docs/api-reference/usage.md +0 -4
  16. package/docs/documentation/cli.md +60 -49
  17. package/docs/documentation/create-api-key.md +3 -1
  18. package/docs/documentation/customers/customer-portal.md +10 -2
  19. package/docs/documentation/customers/manage-customers.md +2 -1
  20. package/docs/documentation/finance/payouts.md +11 -0
  21. package/docs/documentation/finance/supported-countries.md +5 -5
  22. package/docs/documentation/invoicing/handle-failed-payments.md +9 -9
  23. package/docs/documentation/payments/accept-one-time-payments.md +1 -1
  24. package/docs/documentation/payments/payment-orchestration.md +2 -0
  25. package/docs/documentation/payments/payment-providers.md +46 -0
  26. package/docs/documentation/payments/transactions-refunds-and-retries.md +1 -1
  27. package/docs/documentation/plans/add-ons.md +1 -1
  28. package/docs/documentation/plans/consumption-models.md +44 -9
  29. package/docs/documentation/plans/credit-packs.md +49 -1
  30. package/docs/documentation/plans/one-time-payments.md +3 -3
  31. package/docs/documentation/plans/plan-groups.md +46 -10
  32. package/docs/documentation/platform/dashboard-metrics-and-events.md +40 -9
  33. package/docs/documentation/sales/connect-dub-affiliates.md +52 -0
  34. package/docs/documentation/sales/introductory-offers.md +7 -13
  35. package/docs/documentation/sales/offers.md +10 -6
  36. package/docs/documentation/sales/promo-codes.md +47 -17
  37. package/docs/documentation/sales/promotional-offers.md +6 -7
  38. package/docs/documentation/sales/regional-prices.md +16 -0
  39. package/docs/documentation/sales/trial-periods.md +67 -40
  40. package/docs/documentation/subscriptions/manage-subscriptions.md +65 -2
  41. package/docs/documentation/subscriptions/pay-in-advance.md +4 -7
  42. package/docs/documentation/subscriptions/upgrade-and-downgrade-plans.md +20 -2
  43. package/docs/documentation/testing-sandbox.md +2 -0
  44. package/docs/documentation/usage/track-usage.md +23 -0
  45. package/docs/errors/customer_deleted.md +22 -0
  46. package/docs/errors/index.md +5 -0
  47. package/docs/errors/managed_by_integration.md +22 -0
  48. package/docs/errors/no_scheduled_plan_change.md +22 -0
  49. package/docs/errors/plan_balance_limit_reached.md +22 -0
  50. package/docs/errors/plan_credit_limit_reached.md +22 -0
  51. package/docs/knowledge-base/how-do-credits-credit-packs-and-customer-credits-differ.md +8 -8
  52. package/docs/knowledge-base/how-do-discounts-work.md +7 -5
  53. package/docs/knowledge-base/how-do-free-plans-work-without-payment.md +14 -8
  54. package/docs/knowledge-base/how-do-offers-promo-codes-and-card-promotions-work-together.md +1 -1
  55. package/docs/knowledge-base/how-do-trial-periods-work.md +30 -24
  56. package/docs/knowledge-base/how-does-billing-work.md +1 -0
  57. package/docs/knowledge-base/what-happens-when-a-payment-fails.md +11 -9
  58. package/docs/manifest.json +54 -2
  59. package/docs/platform-documentation.md +1 -0
  60. package/docs/schemas.md +51 -9
  61. package/docs/webhooks/introduction.md +14 -12
  62. package/docs/webhooks.md +53 -17
  63. package/docs/webhooks.openapi.json +857 -745
  64. package/package.json +1 -1
@@ -9,14 +9,22 @@ Self-service page where customers manage their subscription, view usage, change
9
9
 
10
10
  - View current subscription and billing cycle
11
11
  - See usage across all features
12
- - Upgrade or downgrade plans (requires a [Plan Group](/docs/plan-groups))
13
- - Purchase [Credit Packs](/docs/credit-packs), balance top-ups, and [Add-ons](/docs/add-ons)
12
+ - Upgrade or downgrade plans (requires a [Plan Group](/docs/plan-groups)), and keep the current plan when a change is scheduled (**Keep current plan**)
13
+ - Purchase [Credit Packs](/docs/credit-packs), a chosen quantity of credits, balance top-ups, and [Add-ons](/docs/add-ons)
14
+ - Turn on and edit [auto top-up](/docs/credit-packs#top-up-credits-automatically) for credits
15
+ - Add a card during a [trial without a payment method](/docs/trial-periods#start-a-trial-without-a-payment-method) (**Add card**)
14
16
  - Manage saved payment methods and billing details
15
17
  - View invoice history
16
18
  - Cancel subscription
17
19
 
18
20
  Purchases are available on active, trialing, and free plan subscriptions. Free plan customers are prompted to add a payment method on their first purchase.
19
21
 
22
+ When the plan group has a [default plan](/docs/plan-groups#default-plan-and-signup-trial), canceling a paid plan from the portal moves the customer to that default plan at period end instead of canceling.
23
+
24
+ ## Languages
25
+
26
+ The portal and checkout open in English, Spanish, or Portuguese, following the customer's browser language, and in English otherwise. Customer emails are sent in English or Spanish.
27
+
20
28
  ## Saved payment methods
21
29
 
22
30
  Your customers can save several cards and choose their default payment method. A new card becomes the default unless the customer saves it as an alternative. The first saved card is always the default.
@@ -85,6 +85,7 @@ Use:
85
85
  - `email` for billing communication.
86
86
  - `address` and `taxDocument` for billing and tax context.
87
87
  - `metadata` for application-specific values that do not control billing behavior.
88
+ - `planGroupId` to start the customer at once on the group's signup trial or default plan. See [Plan Groups](/docs/plan-groups#default-plan-and-signup-trial).
88
89
 
89
90
  ## Create customers in batch
90
91
 
@@ -154,7 +155,7 @@ $customerBatch = $commet->customers->createBatch(
154
155
  );
155
156
  ```
156
157
 
157
- A batch accepts up to 100 customers and returns successful and failed items independently.
158
+ A batch accepts up to 100 customers and returns successful and failed items independently. With `planGroupId`, each customer without an open subscription starts on the group's starting plan.
158
159
 
159
160
  ## Retrieve a customer
160
161
 
@@ -17,6 +17,7 @@ Verify your account, then request a payout of $10 or more from your available ba
17
17
 
18
18
  - Minimum payout: **$10**.
19
19
  - Money reaches your bank account in **up to 7 business days**.
20
+ - Receipts and statements are not available in sandbox.
20
21
  - **No payout fee.**
21
22
  - Account verification is required before your first payout.
22
23
 
@@ -26,9 +27,19 @@ Only your **Available** balance can be paid out. See the balance states in [Fina
26
27
 
27
28
  Navigate to **Payouts**. Add your bank accounts, then click **Withdraw funds** to request a payout from your available balance.
28
29
 
30
+ ## Download receipts and monthly statements
31
+
32
+ Live organizations with a Commet payout account get two documents:
33
+
34
+ - **Payout receipt**: a PDF for each paid payout. Open the payout in **Payouts** and click **Download**.
35
+ - **Monthly statement**: a PDF and a CSV with the opening balance, movements, closing balance, and the available, pending, held, and in-transit amounts. Find them in **Settings → Monthly statements**.
36
+
37
+ Statements cover a calendar month in UTC and are issued on the 2nd of the following month. A month with no movements and no balance has no statement. Documents exist from their launch onward; earlier payouts and months have none.
38
+
29
39
  ## Limitations
30
40
 
31
41
  - Minimum payout is **$10**.
32
42
  - Only the **Available** balance can be withdrawn — Pending funds cannot.
33
43
  - Account verification is required before the first payout.
34
44
  - Money reaches your bank account in **up to 7 business days**.
45
+ - Receipts and statements are not available in sandbox.
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  title: Supported Countries
3
- description: Commet supports businesses in 112 countries across the Americas, Europe, Asia and Pacific, and Africa, and your country sets your payout currency.
3
+ description: Commet supports businesses in 88 countries across the Americas, Europe, Asia and Pacific, and Africa, and your country sets your payout currency.
4
4
  ---
5
5
 
6
- Commet supports businesses in 112 countries across all major regions. Your country is set during onboarding and determines your payout currency and compliance requirements.
6
+ Commet supports businesses in 88 countries across all major regions. Your country is set during onboarding and determines your payout currency and compliance requirements.
7
7
 
8
8
  ## Americas
9
9
 
@@ -11,12 +11,12 @@ Argentina, Bolivia, Brazil, Canada, Chile, Colombia, Costa Rica, Dominican Repub
11
11
 
12
12
  ## Europe
13
13
 
14
- Albania, Austria, Belgium, Bosnia & Herzegovina, Bulgaria, Croatia, Cyprus, Czechia, Denmark, Estonia, Finland, France, Germany, Greece, Hungary, Iceland, Ireland, Italy, Latvia, Liechtenstein, Lithuania, Luxembourg, Malta, Moldova, Montenegro, Netherlands, North Macedonia, Norway, Poland, Portugal, Romania, San Marino, Serbia, Slovakia, Slovenia, Spain, Sweden, Switzerland, United Kingdom
14
+ Albania, Austria, Belgium, Bosnia & Herzegovina, Bulgaria, Croatia, Cyprus, Czechia, Denmark, Estonia, Finland, France, Germany, Greece, Iceland, Ireland, Italy, Latvia, Liechtenstein, Lithuania, Luxembourg, Malta, Netherlands, Norway, Poland, Portugal, Romania, San Marino, Serbia, Slovakia, Slovenia, Spain, Sweden, Switzerland, United Kingdom
15
15
 
16
16
  ## Asia & Pacific
17
17
 
18
- Armenia, Australia, Azerbaijan, Bahrain, Bangladesh, Bhutan, Brunei, Cambodia, Hong Kong, India, Indonesia, Israel, Japan, Jordan, Kazakhstan, South Korea, Kuwait, Laos, Malaysia, Mongolia, New Zealand, Oman, Pakistan, Philippines, Qatar, Singapore, Sri Lanka, Taiwan, Thailand, United Arab Emirates, Vietnam
18
+ Armenia, Australia, Azerbaijan, Brunei, Hong Kong, India, Indonesia, Israel, Japan, Kazakhstan, Laos, Mongolia, New Zealand, Philippines, Qatar, Singapore, Sri Lanka, Thailand
19
19
 
20
20
  ## Africa
21
21
 
22
- Algeria, Angola, Benin, Botswana, Côte d’Ivoire, Egypt, Ethiopia, Gabon, Gambia, Ghana, Kenya, Mauritius, Morocco, Mozambique, Namibia, Niger, Nigeria, Rwanda, Senegal, South Africa, Tanzania, Tunisia
22
+ Algeria, Angola, Botswana, Egypt, Ethiopia, Gambia, Ghana, Kenya, Mauritius, Morocco, Mozambique, Namibia, Nigeria, South Africa, Tanzania
@@ -13,24 +13,24 @@ When a renewal payment fails, the subscription moves to `past_due` and enters du
13
13
  4. The customer receives an email notification
14
14
  5. Commet retries the charge on a fixed schedule (dunning)
15
15
 
16
- If a retry succeeds, the subscription returns to `active`. If all retries fail, the subscription is canceled and the invoice is marked as `uncollectible`.
16
+ If a retry succeeds, the subscription returns to `active`. If all retries fail, the invoice is marked as `uncollectible` and the subscription is canceled. When the plan's group has a [default plan](/docs/plan-groups#default-plan-and-signup-trial), the subscription moves to it instead and `subscription.plan_changed` fires.
17
17
 
18
18
  ## Provider error mapping
19
19
 
20
20
  Commet translates provider responses into a common payment outcome and keeps the provider detail alongside it. For recurring failures, the [`payment.failed`](/docs/webhooks/payment-failed) webhook exposes `failureCode`, `failureMessage`, and a `recoveryUrl` when a recovery path is available. The exact `failureCode` depends on the provider, so use the normalized outcome and the recovery URL for customer handling instead of matching only one provider's raw codes.
21
21
 
22
- | Payment outcome | What it means | What to do |
23
- | ------------------------------------ | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
24
- | `requires_action` | The provider needs an additional customer step, such as 3D Secure | Keep the customer in checkout and complete the authentication flow |
25
- | `PAYMENT_FAILED` with a decline code | The provider rejected the charge | Show a retry or alternate payment method and record the provider code for support |
26
- | `payment.failed` | A recurring charge failed and the invoice entered dunning | Keep service during the grace window, communicate the recovery path, and wait for a retry or recovery |
27
- | `payment.retry_failed` | All scheduled dunning retries were exhausted | Revoke access according to your product policy and ask the customer to start a new subscription or contact support |
22
+ | Payment outcome | What it means | What to do |
23
+ | ------------------------------------ | ----------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
24
+ | `requires_action` | The provider needs an additional customer step, such as 3D Secure | Keep the customer in checkout and complete the authentication flow |
25
+ | `PAYMENT_FAILED` with a decline code | The provider rejected the charge | Show a retry or alternate payment method and record the provider code for support |
26
+ | `payment.failed` | A recurring charge failed and the invoice entered dunning | Keep service during the grace window, communicate the recovery path, and wait for a retry or recovery |
27
+ | `payment.retry_failed` | All scheduled dunning retries were exhausted | Revoke paid access according to your product policy and ask the customer to start a new subscription or contact support |
28
28
 
29
29
  Initial checkout card declines do not emit `payment.failed`; the checkout response carries the failure state directly. Recurring failures use the dunning flow below.
30
30
 
31
31
  ## Automatic retries
32
32
 
33
- Retries run on day 1, day 3, day 5, and day 7 after the original failure (4 retries). The calendar is anchored to the failure and never moves. After the last failed retry the subscription is canceled.
33
+ Retries run on day 1, day 3, day 5, and day 7 after the original failure (4 retries). The calendar is anchored to the failure and never moves. After the last failed retry the subscription is canceled, or moves to the plan group's default plan.
34
34
 
35
35
  Manual retries from the Customer Portal or [`reactivate`](#retry-the-charge-server-to-server) use the default payment method and have separate daily limits. They do not consume automatic retry slots or start another charge while an automatic retry is in progress.
36
36
 
@@ -48,7 +48,7 @@ Commet sends a payment-failure notification when a recurring charge enters dunni
48
48
 
49
49
  - [`payment.failed`](/docs/webhooks/payment-failed) — a recurring charge failed; use `failureCode`, `failureMessage`, and `recoveryUrl` to explain the next step.
50
50
  - [`payment.recovered`](/docs/webhooks/payment-recovered) — the outstanding invoice was paid and the subscription returned to `active`.
51
- - [`payment.retry_failed`](/docs/webhooks/payment-retry-failed) — all retries were exhausted and the subscription was canceled.
51
+ - [`payment.retry_failed`](/docs/webhooks/payment-retry-failed) — all retries were exhausted and the subscription was canceled or moved to the default plan.
52
52
 
53
53
  Send your own email, SMS, or in-app message when you need product-specific copy. Do not create a second retry schedule in your app; use Commet's events to close the communication loop.
54
54
 
@@ -9,7 +9,7 @@ Commet calculates tax, generates an invoice, and sends a receipt on every paymen
9
9
 
10
10
  > **Note**
11
11
  >
12
- > For lifetime deals and one-off purchases billed as a **plan** (trials, intro offers, add-ons, consumption models), use [One-Time Plans](/docs/one-time-payments) instead.
12
+ > For lifetime deals and one-off purchases billed as a **plan** (add-ons, consumption models), use [One-Time Plans](/docs/one-time-payments) instead.
13
13
 
14
14
  ## Link vs. charge
15
15
 
@@ -17,6 +17,8 @@ Customers can update their method through the [Customer Portal](/docs/customer-p
17
17
 
18
18
  In **Settings → Payments**, use **Payment routing** to assign countries to connected providers. You can select individual countries or region presets, then save the assignment. The map and routing list show which provider will handle each country.
19
19
 
20
+ Each connected account gets its own countries, including [several Stripe or dLocal accounts](/docs/payment-providers#connect-several-accounts-of-the-same-provider) in one organization. Label them with **Edit alias** to tell them apart.
21
+
20
22
  For a new checkout or other new activity, Commet resolves the customer's billing country as an ISO country code and looks up that country's route. For example, a customer whose billing address has `BR` uses the provider assigned to Brazil. The route is based on the billing address supplied to Commet, not on the customer's IP address.
21
23
 
22
24
  If a subscription already has a saved payment connection, recurring charges continue through that connection. This preserves the location of the vaulted payment method. When there is no saved connection, Commet uses the country route; when no country is available, it uses the organization's default provider.
@@ -19,6 +19,14 @@ To connect your own account:
19
19
 
20
20
  Commet registers and consumes the provider webhooks required to keep payment, refund, dispute, and setup events synchronized. You do not need to create a second billing integration for the connected account.
21
21
 
22
+ ### Connect several accounts of the same provider
23
+
24
+ An organization can connect more than one Stripe or dLocal account, for example one dLocal account for Argentina and another for Brazil and Mexico. Each additional account starts with no countries and is not the default.
25
+
26
+ Give each account a label with **Edit alias** in its menu, then assign its countries in **Payment routing**. When you have several accounts of the same provider, Payment routing shows each connection ID (`pcon_...`) to copy.
27
+
28
+ To pin a subscription's first checkout to one account, pass its connection ID as `provider` when [creating the subscription](/docs/manage-subscriptions#create). `provider: "stripe"` or `"dlocal"` uses the oldest connected account of that provider.
29
+
22
30
  ### Stripe credentials
23
31
 
24
32
  Provide the Stripe **secret key** and **publishable key** for the account you own. In sandbox mode, use `sk_test_...` and `pk_test_...` keys. In live mode, use `sk_live_...` and `pk_live_...` keys. Commet rejects keys from the wrong mode.
@@ -27,6 +35,44 @@ Provide the Stripe **secret key** and **publishable key** for the account you ow
27
35
 
28
36
  Provide the credentials issued for the matching dLocal environment: **X-Login**, **X-Trans-Key**, **Secret Key**, and the **API key (dlocal.js)**. Commet validates the account before saving the connection.
29
37
 
38
+ ## Choose payment methods per connection
39
+
40
+ Stripe and Commet connections accept cards. A dLocal connection can also offer local methods; each one applies only to that connection.
41
+
42
+ Open **Settings → Payments**, open the connection menu, and choose **Payment methods**. Enable a method in your dLocal account before turning it on in Commet.
43
+
44
+ | Method | Where it's offered |
45
+ | ------------ | ------------------------- |
46
+ | Card | All countries |
47
+ | Google Pay | All countries |
48
+ | Mercado Pago | Argentina, in ARS |
49
+ | OXXO | Mexico, as a cash voucher |
50
+ | SmartPix | Brazil, in BRL |
51
+
52
+ A country method appears under **Not available for this connection** until its country is assigned to the connection. Google Pay asks for the **dLocal gateway merchant ID**, the **Google merchant ID** (optional in sandbox), and the **Business name** buyers see.
53
+
54
+ The `paymentMethod` of each [transaction](/docs/transactions-refunds-and-retries) names the method used: `card`, `google_pay`, `mercado_pago`, `oxxo`, or `smartpix`.
55
+
56
+ ### Limit the methods of one checkout
57
+
58
+ To offer only some methods in a subscription's first checkout, pass `paymentMethodTypes` when [creating the subscription](/docs/manage-subscriptions#create), for example `["oxxo"]`. The list only narrows what the checkout already offers for the buyer's country and connection: it never turns on a method or changes which connection the checkout uses. With `["card", "oxxo"]`, a buyer in Mexico sees card and OXXO, and a buyer in Argentina sees only card. Pass `provider` as well to choose the connection.
59
+
60
+ Every method in the list must be turned on in the `provider` connection, or in one of your connections when you don't pass `provider`. Otherwise the request fails with `validation_error` naming that method. A plan that starts with a card trial also rejects methods that can't be saved for renewals, such as OXXO.
61
+
62
+ When no method in the list is available to the buyer, the checkout shows that it can't accept payments and charges nothing. A new checkout for the same invoice, for example after an OXXO voucher expires, keeps the list.
63
+
64
+ ### Mercado Pago
65
+
66
+ The customer authorizes Mercado Pago once in checkout. Commet charges the first payment after the authorization is active, and charges renewals to it automatically.
67
+
68
+ If the customer revokes the authorization in Mercado Pago, Commet removes the saved method and sends the `payment_method.detached` webhook; the subscription does not change. If no other usable method is saved when the next renewal is due, the payment fails and the subscription follows [failed-payment recovery](/docs/what-happens-when-a-payment-fails). The customer can authorize Mercado Pago again from the [Customer Portal](/docs/customer-portal).
69
+
70
+ ### OXXO
71
+
72
+ OXXO is a cash voucher. Checkout shows it inline with the amount, the expiration date, the barcode, and the reference, which the customer can copy or save. The subscription activates when dLocal confirms the payment.
73
+
74
+ Cash can't renew. A subscription paid with OXXO and no other saved payment method [ends after its paid periods](/docs/pay-in-advance#end-oxxo-subscriptions-after-their-paid-periods) unless the customer adds a card. Combine OXXO with [Pay in Advance](/docs/pay-in-advance) to sell several periods with one voucher.
75
+
30
76
  ## Sandbox and live credentials
31
77
 
32
78
  Sandbox and live credentials belong to different payment environments. Keep test credentials in the Commet sandbox organization and live credentials in the live organization. Never copy a live secret into sandbox or a test key into live.
@@ -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 `oxxo`), or is `null` when unknown. It stays tied to the transaction if the customer changes their saved method later.
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
 
@@ -45,7 +45,7 @@ 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 — card was captured during trial checkout |
48
+ | **Trialing** | Yes — with a saved payment method |
49
49
  | **Free plan** | Yes — first purchase prompts for a payment method |
50
50
 
51
51
  ## Manage add-ons
@@ -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 purchase [Credit Packs](/docs/credit-packs) or wait for the next billing cycle.
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 reset each billing period. Credits purchased via Credit Packs **never expire**.
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. Existing subscriptions apply a change from their next reset. 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`. Raising or removing the limit applies at once; lowering it, adding it, or changing its interval applies from the next period.
72
+
73
+ In the dashboard, open **Plans**, select a credits plan, and edit **Credit rollover**, **Credit limit**, or **Credit purchases**.
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 | Balance |
66
- | -------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------ | ----------------------------------------- |
67
- | **When exceeded** | Overage at period end | Blocked or buy packs | Overage at period end |
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 | Top-ups reset at period |
70
- | **Reset frequency** | Weekly plans reset every 7 days. Monthly, quarterly, semiannual, yearly, one-time, and free plans reset monthly | Same | Same |
71
- | **Customer portal** | View usage | Buy credit packs | Add balance (top-up) |
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
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Credit Packs
3
- description: Configure credit packages that customers can purchase from the Commet Customer Portal.
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).
@@ -79,3 +79,51 @@ curl https://commet.co/api/v1/credit-packs \
79
79
  ```
80
80
 
81
81
  The `price` field is in **cents** (1000 = $10.00). Prices are always in USD.
82
+
83
+ ## Buy a chosen quantity of credits
84
+
85
+ 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 **Credit purchases**: **Price per credit** and an optional **Minimum purchase**.
86
+
87
+ ```typescript
88
+ await commet.subscriptions.purchaseCredits({
89
+ id: 'sub_xxx',
90
+ quantity: 500,
91
+ })
92
+ ```
93
+
94
+ Commet charges the saved payment method at the plan's price per credit and adds purchased credits. Send `creditPackId` instead of `quantity` to buy a pack. Both fire [`credits.purchased`](/docs/webhooks/credits-purchased).
95
+
96
+ | Response | Cause |
97
+ | ----------------------- | -------------------------------------------------------------------------- |
98
+ | `400 validation_error` | The quantity is below the plan's minimum, or the plan doesn't sell credits |
99
+ | `402 no_payment_method` | The subscription has no saved payment method Commet can charge |
100
+ | `402 payment_failed` | The charge was declined |
101
+
102
+ The effective minimum is the larger of the configured minimum and the smallest quantity that reaches the currency's minimum charge.
103
+
104
+ ## Top up credits automatically
105
+
106
+ Auto top-up buys credits with the saved payment method when the subscription's credits fall to a threshold.
107
+
108
+ ```typescript
109
+ await commet.subscriptions.updateAutoTopUp({
110
+ id: 'sub_xxx',
111
+ enabled: true,
112
+ threshold: 100,
113
+ quantity: 500,
114
+ maxPerPeriod: 3,
115
+ })
116
+ ```
117
+
118
+ | Parameter | Type | Description |
119
+ | -------------- | --------- | --------------------------------------------------------------- |
120
+ | `enabled` | `boolean` | Turns automatic purchases on or off |
121
+ | `threshold` | `integer` | Plan and purchased credits at or below which a top-up is bought |
122
+ | `quantity` | `integer` | Credits each top-up buys. At least the plan's minimum |
123
+ | `maxPerPeriod` | `integer` | Successful top-ups per credit renewal period. `1` to `100` |
124
+
125
+ 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`.
126
+
127
+ 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.
128
+
129
+ 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 [trials](/docs/trial-periods), [intro offers](/docs/introductory-offers), [add-ons](/docs/add-ons), and all [consumption models](/docs/consumption-models). The only differences are:
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) + any applicable intro offer discount |
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. An explicit trial (`customTrialDays`, a trial Offer, or a trial Promo Code) returns `400`, the plan's automatic introductory trial is skipped, and a trial Promo Code entered at checkout is rejected.
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 together to enable self-service upgrades and downgrades in the Commet Customer Portal.
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
- Plan Groups let customers upgrade or downgrade between plans themselves through the [Customer Portal](/docs/customer-portal). Without a Plan Group, customers won't see upgrade/downgrade options in their portal.
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 | 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 |
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 **Plan Groups** and click **Create Plan 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 with [Regional Prices](/docs/regional-prices) can be added, but all plans in a group must support the same set of currencies so any subscriber can move between them.
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 with [Regional Prices](/docs/regional-prices) can be added, but all plans in a group must support the same set of currencies so any subscriber can move between them.
19
21
 
20
22
  This order defines the upgrade path and display order in the Customer Portal.
21
23
 
22
- ## Learn more
24
+ ## Default plan and signup trial
23
25
 
24
- - [What Happens When a Customer Changes Plans](/docs/what-happens-when-a-customer-changes-plans)
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.
@@ -1,17 +1,48 @@
1
1
  ---
2
2
  title: Dashboard Metrics and Usage Events
3
- description: Understand MRR, revenue, churn, active subscriptions, and the usage-event explorer.
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
- | Metric | Current calculation |
9
- | ------------------------ | ------------------------------------------------------------------------------------------ |
10
- | **MRR** | Latest successful gross payment per active subscription, normalized by billing interval |
11
- | **Total revenue** | Successful gross transactions paid during the current calendar month |
12
- | **Revenue growth** | Percentage change between current and previous monthly recurring revenue |
13
- | **Churn** | Subscriptions canceled in the last 30 days divided by the eligible subscription population |
14
- | **Active subscriptions** | Current subscriptions whose persisted status is `active` |
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`.