@commet/node 8.0.1 → 9.1.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/README.md +4 -4
- package/dist/index.d.mts +514 -206
- package/dist/index.d.ts +514 -206
- package/dist/index.js +202 -88
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +202 -88
- package/dist/index.mjs.map +1 -1
- package/docs/README.md +20 -0
- package/docs/ai-onboarding/ai-onboarding.md +90 -0
- package/docs/ai-onboarding/billing-best-practices-skill.md +29 -0
- package/docs/ai-onboarding/commet-skill.md +58 -0
- package/docs/ai-onboarding/mcp-server.md +207 -0
- package/docs/ai-onboarding/meta.json +17 -0
- package/docs/ai-onboarding/pricing-models-skill.md +29 -0
- package/docs/ai-onboarding/subscription-patterns-skill.md +29 -0
- package/docs/api-reference/addons.md +127 -0
- package/docs/api-reference/api-keys.md +57 -0
- package/docs/api-reference/credit-packs.md +80 -0
- package/docs/api-reference/customers.md +274 -0
- package/docs/api-reference/feature-access.md +36 -0
- package/docs/api-reference/features.md +94 -0
- package/docs/api-reference/generated-webhooks.md +120 -0
- package/docs/api-reference/index.md +31 -0
- package/docs/api-reference/invoices.md +123 -0
- package/docs/api-reference/markets.md +92 -0
- package/docs/api-reference/meta.json +7 -0
- package/docs/api-reference/offers.md +104 -0
- package/docs/api-reference/payments.md +106 -0
- package/docs/api-reference/payouts.md +66 -0
- package/docs/api-reference/plan-groups.md +157 -0
- package/docs/api-reference/plans.md +358 -0
- package/docs/api-reference/portal.md +30 -0
- package/docs/api-reference/promo-codes.md +86 -0
- package/docs/api-reference/provisioning.md +19 -0
- package/docs/api-reference/quota.md +120 -0
- package/docs/api-reference/seats.md +123 -0
- package/docs/api-reference/subscriptions.md +387 -0
- package/docs/api-reference/test-clock.md +59 -0
- package/docs/api-reference/transactions.md +78 -0
- package/docs/api-reference/usage.md +83 -0
- package/docs/documentation/api-versioning.md +100 -0
- package/docs/documentation/better-auth.md +361 -0
- package/docs/documentation/choose-a-billing-model.md +38 -0
- package/docs/documentation/cli.md +1024 -0
- package/docs/documentation/create-api-key.md +47 -0
- package/docs/documentation/customers/customer-credits.md +48 -0
- package/docs/documentation/customers/customer-portal.md +107 -0
- package/docs/documentation/customers/manage-customers.md +346 -0
- package/docs/documentation/customers/meta.json +5 -0
- package/docs/documentation/error-handling.md +239 -0
- package/docs/documentation/examples.md +37 -0
- package/docs/documentation/finance/acceptable-use.md +145 -0
- package/docs/documentation/finance/finance-overview.md +32 -0
- package/docs/documentation/finance/local-currency-taxes.md +40 -0
- package/docs/documentation/finance/merchant-of-record.md +48 -0
- package/docs/documentation/finance/meta.json +13 -0
- package/docs/documentation/finance/payouts-verification.md +186 -0
- package/docs/documentation/finance/payouts.md +41 -0
- package/docs/documentation/finance/supported-countries.md +28 -0
- package/docs/documentation/go/integrate-with-encore.md +229 -0
- package/docs/documentation/go/integrate-with-go.md +258 -0
- package/docs/documentation/go/meta.json +5 -0
- package/docs/documentation/introduction.md +58 -0
- package/docs/documentation/invoicing/handle-failed-payments.md +283 -0
- package/docs/documentation/invoicing/invoices-and-billing-cycles.md +73 -0
- package/docs/documentation/invoicing/manage-invoices.md +340 -0
- package/docs/documentation/invoicing/meta.json +9 -0
- package/docs/documentation/java/integrate-with-java.md +117 -0
- package/docs/documentation/java/meta.json +5 -0
- package/docs/documentation/meta.json +36 -0
- package/docs/documentation/nodejs/integrate-with-astro.md +129 -0
- package/docs/documentation/nodejs/integrate-with-bun.md +113 -0
- package/docs/documentation/nodejs/integrate-with-express.md +127 -0
- package/docs/documentation/nodejs/integrate-with-hono.md +141 -0
- package/docs/documentation/nodejs/integrate-with-nextjs.md +118 -0
- package/docs/documentation/nodejs/integrate-with-nuxt.md +125 -0
- package/docs/documentation/nodejs/integrate-with-remix.md +136 -0
- package/docs/documentation/nodejs/integrate-with-sveltekit.md +127 -0
- package/docs/documentation/nodejs/meta.json +14 -0
- package/docs/documentation/payments/accept-one-time-payments.md +314 -0
- package/docs/documentation/payments/meta.json +10 -0
- package/docs/documentation/payments/payment-orchestration.md +43 -0
- package/docs/documentation/payments/payment-providers.md +59 -0
- package/docs/documentation/payments/transactions-refunds-and-retries.md +199 -0
- package/docs/documentation/php/integrate-with-laravel.md +222 -0
- package/docs/documentation/php/integrate-with-php.md +103 -0
- package/docs/documentation/php/integrate-with-symfony.md +214 -0
- package/docs/documentation/php/meta.json +9 -0
- package/docs/documentation/plans/add-ons.md +257 -0
- package/docs/documentation/plans/balance-and-top-ups.md +169 -0
- package/docs/documentation/plans/configure-features.md +335 -0
- package/docs/documentation/plans/consumption-models.md +93 -0
- package/docs/documentation/plans/create-plans.md +162 -0
- package/docs/documentation/plans/credit-packs.md +89 -0
- package/docs/documentation/plans/meta.json +14 -0
- package/docs/documentation/plans/one-time-payments.md +142 -0
- package/docs/documentation/plans/plan-groups.md +31 -0
- package/docs/documentation/platform/custom-domains.md +27 -0
- package/docs/documentation/platform/dashboard-metrics-and-events.md +25 -0
- package/docs/documentation/platform/members-and-permissions.md +21 -0
- package/docs/documentation/platform/meta.json +10 -0
- package/docs/documentation/platform/organization-settings.md +29 -0
- package/docs/documentation/python/integrate-with-django.md +161 -0
- package/docs/documentation/python/integrate-with-fastapi.md +164 -0
- package/docs/documentation/python/integrate-with-flask.md +153 -0
- package/docs/documentation/python/integrate-with-python.md +90 -0
- package/docs/documentation/python/meta.json +10 -0
- package/docs/documentation/sales/card-promotions.md +41 -0
- package/docs/documentation/sales/introductory-offers.md +64 -0
- package/docs/documentation/sales/meta.json +13 -0
- package/docs/documentation/sales/offers.md +65 -0
- package/docs/documentation/sales/promo-codes.md +65 -0
- package/docs/documentation/sales/promotional-offers.md +58 -0
- package/docs/documentation/sales/regional-prices.md +100 -0
- package/docs/documentation/sales/trial-periods.md +88 -0
- package/docs/documentation/sdk-reference.md +68 -0
- package/docs/documentation/subscriptions/manage-subscriptions.md +505 -0
- package/docs/documentation/subscriptions/meta.json +9 -0
- package/docs/documentation/subscriptions/plan-grants.md +132 -0
- package/docs/documentation/subscriptions/upgrade-and-downgrade-plans.md +35 -0
- package/docs/documentation/testing-sandbox.md +251 -0
- package/docs/documentation/usage/ai-token-billing.md +294 -0
- package/docs/documentation/usage/meta.json +10 -0
- package/docs/documentation/usage/quota-management.md +341 -0
- package/docs/documentation/usage/seat-management.md +377 -0
- package/docs/documentation/usage/track-usage.md +282 -0
- package/docs/errors/addon_already_active.md +22 -0
- package/docs/errors/addon_has_activations.md +22 -0
- package/docs/errors/addon_not_active.md +22 -0
- package/docs/errors/addon_not_found.md +22 -0
- package/docs/errors/already_has_active_subscription.md +22 -0
- package/docs/errors/already_scheduled.md +22 -0
- package/docs/errors/api_key_not_found.md +22 -0
- package/docs/errors/card_promotions_not_available.md +22 -0
- package/docs/errors/charge_failed.md +22 -0
- package/docs/errors/charge_in_progress.md +22 -0
- package/docs/errors/claim_not_pending.md +22 -0
- package/docs/errors/credit_pack_not_found.md +22 -0
- package/docs/errors/customer_not_found.md +22 -0
- package/docs/errors/duplicate.md +22 -0
- package/docs/errors/endpoint_deprecated.md +22 -0
- package/docs/errors/endpoint_not_available.md +22 -0
- package/docs/errors/feature_already_exists.md +22 -0
- package/docs/errors/feature_disabled.md +22 -0
- package/docs/errors/feature_in_use.md +22 -0
- package/docs/errors/feature_not_found.md +22 -0
- package/docs/errors/feature_not_in_plan.md +22 -0
- package/docs/errors/forbidden.md +22 -0
- package/docs/errors/free_plan_change_not_supported.md +22 -0
- package/docs/errors/idempotency_in_progress.md +22 -0
- package/docs/errors/idempotency_key_mismatch.md +22 -0
- package/docs/errors/idempotency_unavailable.md +22 -0
- package/docs/errors/included_limit_reached.md +22 -0
- package/docs/errors/index.md +89 -0
- package/docs/errors/insufficient_balance.md +22 -0
- package/docs/errors/insufficient_credits.md +22 -0
- package/docs/errors/insufficient_seats.md +22 -0
- package/docs/errors/internal_error.md +22 -0
- package/docs/errors/invalid_json.md +22 -0
- package/docs/errors/invalid_subscription_status.md +22 -0
- package/docs/errors/invoice_not_found.md +22 -0
- package/docs/errors/market_group_in_use.md +22 -0
- package/docs/errors/market_group_not_found.md +22 -0
- package/docs/errors/market_in_use.md +22 -0
- package/docs/errors/market_not_found.md +22 -0
- package/docs/errors/missing_regional_price.md +22 -0
- package/docs/errors/model_not_found.md +22 -0
- package/docs/errors/no_active_subscription.md +22 -0
- package/docs/errors/no_change_requested.md +22 -0
- package/docs/errors/no_outstanding_invoice.md +22 -0
- package/docs/errors/no_payment_method.md +22 -0
- package/docs/errors/no_prices_configured.md +22 -0
- package/docs/errors/not_found.md +22 -0
- package/docs/errors/not_scheduled_for_cancellation.md +22 -0
- package/docs/errors/offer_not_applicable.md +22 -0
- package/docs/errors/offer_not_found.md +22 -0
- package/docs/errors/one_time_subscription_not_cancelable.md +22 -0
- package/docs/errors/organization_already_claimed.md +22 -0
- package/docs/errors/payment_failed.md +22 -0
- package/docs/errors/payment_method_not_found.md +22 -0
- package/docs/errors/payment_not_cancelable.md +22 -0
- package/docs/errors/payment_not_found.md +22 -0
- package/docs/errors/payouts_not_available_in_sandbox.md +22 -0
- package/docs/errors/plan_change_scheduled.md +22 -0
- package/docs/errors/plan_group_not_found.md +22 -0
- package/docs/errors/plan_not_found.md +22 -0
- package/docs/errors/plan_unavailable.md +22 -0
- package/docs/errors/plans_not_in_same_group.md +22 -0
- package/docs/errors/price_in_use.md +22 -0
- package/docs/errors/price_not_found.md +22 -0
- package/docs/errors/pricing_mode_mismatch.md +22 -0
- package/docs/errors/promo_code_expired.md +22 -0
- package/docs/errors/promo_code_not_found.md +22 -0
- package/docs/errors/provider_unsupported.md +22 -0
- package/docs/errors/rate_limited.md +22 -0
- package/docs/errors/sandbox_only.md +22 -0
- package/docs/errors/seat_limit_exceeded.md +22 -0
- package/docs/errors/subscription_activation_failed.md +22 -0
- package/docs/errors/subscription_already_canceled.md +22 -0
- package/docs/errors/subscription_cancel_failed.md +22 -0
- package/docs/errors/subscription_creation_failed.md +22 -0
- package/docs/errors/subscription_has_open_dispute.md +22 -0
- package/docs/errors/subscription_not_active.md +22 -0
- package/docs/errors/subscription_not_found.md +22 -0
- package/docs/errors/subscription_required.md +22 -0
- package/docs/errors/subscription_uncancel_failed.md +22 -0
- package/docs/errors/transaction_not_found.md +22 -0
- package/docs/errors/unauthorized.md +22 -0
- package/docs/errors/validation_error.md +22 -0
- package/docs/errors/webhook_not_found.md +22 -0
- package/docs/errors.md +34 -0
- package/docs/getting-started.md +35 -0
- package/docs/knowledge-base/how-do-balance-and-top-ups-work.md +22 -0
- package/docs/knowledge-base/how-do-credits-credit-packs-and-customer-credits-differ.md +20 -0
- package/docs/knowledge-base/how-do-discounts-work.md +65 -0
- package/docs/knowledge-base/how-do-free-plans-work-without-payment.md +88 -0
- package/docs/knowledge-base/how-do-monthly-quarterly-and-yearly-billing-work.md +77 -0
- package/docs/knowledge-base/how-do-offers-promo-codes-and-card-promotions-work-together.md +20 -0
- package/docs/knowledge-base/how-do-trial-periods-work.md +54 -0
- package/docs/knowledge-base/how-does-billing-work.md +73 -0
- package/docs/knowledge-base/how-does-payment-routing-work.md +17 -0
- package/docs/knowledge-base/how-does-quota-based-billing-work.md +106 -0
- package/docs/knowledge-base/how-does-seat-based-billing-work.md +88 -0
- package/docs/knowledge-base/how-is-proration-calculated-when-changing-plans.md +89 -0
- package/docs/knowledge-base/meta.json +29 -0
- package/docs/knowledge-base/what-happens-when-a-customer-changes-plans.md +110 -0
- package/docs/knowledge-base/what-happens-when-a-payment-fails.md +40 -0
- package/docs/knowledge-base/what-happens-when-you-change-your-prices.md +74 -0
- package/docs/knowledge-base/what-happens-when-you-refund-or-retry-a-transaction.md +21 -0
- package/docs/knowledge-base/what-invoices-do-customers-receive-and-when.md +101 -0
- package/docs/manifest.json +1677 -0
- package/docs/meta.json +11 -0
- package/docs/platform-documentation.md +175 -0
- package/docs/schemas.md +995 -0
- package/docs/webhooks/addon-activated.md +44 -0
- package/docs/webhooks/addon-deactivated.md +40 -0
- package/docs/webhooks/balance-depleted.md +37 -0
- package/docs/webhooks/balance-low.md +39 -0
- package/docs/webhooks/balance-topped-up.md +41 -0
- package/docs/webhooks/checkout-ready.md +43 -0
- package/docs/webhooks/credits-depleted.md +35 -0
- package/docs/webhooks/credits-expired.md +35 -0
- package/docs/webhooks/credits-granted.md +37 -0
- package/docs/webhooks/credits-low.md +39 -0
- package/docs/webhooks/credits-purchased.md +41 -0
- package/docs/webhooks/customer-created.md +49 -0
- package/docs/webhooks/customer-state-changed.md +134 -0
- package/docs/webhooks/customer-updated.md +49 -0
- package/docs/webhooks/introduction.md +499 -0
- package/docs/webhooks/invoice-created.md +45 -0
- package/docs/webhooks/invoice-overdue.md +53 -0
- package/docs/webhooks/invoice-upcoming.md +43 -0
- package/docs/webhooks/invoice-voided.md +53 -0
- package/docs/webhooks/meta.json +78 -0
- package/docs/webhooks/payment-dispute-resolved.md +52 -0
- package/docs/webhooks/payment-disputed.md +49 -0
- package/docs/webhooks/payment-failed.md +37 -0
- package/docs/webhooks/payment-link-canceled.md +41 -0
- package/docs/webhooks/payment-link-completed.md +47 -0
- package/docs/webhooks/payment-link-created.md +41 -0
- package/docs/webhooks/payment-link-failed.md +45 -0
- package/docs/webhooks/payment-method-attached.md +40 -0
- package/docs/webhooks/payment-method-updated.md +38 -0
- package/docs/webhooks/payment-received.md +45 -0
- package/docs/webhooks/payment-recovered.md +39 -0
- package/docs/webhooks/payment-refunded.md +47 -0
- package/docs/webhooks/payment-retry-failed.md +39 -0
- package/docs/webhooks/payout-available.md +33 -0
- package/docs/webhooks/payout-created.md +48 -0
- package/docs/webhooks/payout-failed.md +52 -0
- package/docs/webhooks/payout-paid.md +48 -0
- package/docs/webhooks/quota-exceeded.md +44 -0
- package/docs/webhooks/quota-threshold-reached.md +41 -0
- package/docs/webhooks/seats-limit-reached.md +39 -0
- package/docs/webhooks/seats-updated.md +39 -0
- package/docs/webhooks/subscription-activated.md +43 -0
- package/docs/webhooks/subscription-canceled.md +57 -0
- package/docs/webhooks/subscription-cancellation-revoked.md +37 -0
- package/docs/webhooks/subscription-cancellation-scheduled.md +45 -0
- package/docs/webhooks/subscription-created.md +35 -0
- package/docs/webhooks/subscription-past-due.md +43 -0
- package/docs/webhooks/subscription-plan-change-revoked.md +50 -0
- package/docs/webhooks/subscription-plan-change-scheduled.md +55 -0
- package/docs/webhooks/subscription-plan-changed.md +43 -0
- package/docs/webhooks/subscription-reactivated.md +53 -0
- package/docs/webhooks/subscription-updated.md +39 -0
- package/docs/webhooks/trial-checkout-ready.md +39 -0
- package/docs/webhooks/trial-converted.md +39 -0
- package/docs/webhooks/trial-expired.md +39 -0
- package/docs/webhooks/trial-started.md +46 -0
- package/docs/webhooks/trial-will-end.md +41 -0
- package/docs/webhooks/usage-recorded.md +41 -0
- package/docs/webhooks.md +782 -0
- package/package.json +2 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-07-28
|
|
3
|
+
title: Integrate with Flask
|
|
4
|
+
description: Add billing and payments to your Flask application.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Install the Commet Skill so your coding agent can integrate the current SDK and verify its work against the live API contract.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx skills add commet-labs/skills --skill commet
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
1. ## Install
|
|
14
|
+
### pip
|
|
15
|
+
```bash
|
|
16
|
+
pip install commet-sdk flask
|
|
17
|
+
```
|
|
18
|
+
### uv
|
|
19
|
+
```bash
|
|
20
|
+
uv add commet-sdk flask
|
|
21
|
+
```
|
|
22
|
+
### poetry
|
|
23
|
+
```bash
|
|
24
|
+
poetry add commet-sdk flask
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
2. ## Configure
|
|
28
|
+
```bash title=".env"
|
|
29
|
+
COMMET_API_KEY=ck_sandbox_xxx
|
|
30
|
+
```
|
|
31
|
+
```python title="commet_client.py"
|
|
32
|
+
import os
|
|
33
|
+
from commet import Commet
|
|
34
|
+
|
|
35
|
+
commet = Commet(
|
|
36
|
+
api_key=os.environ["COMMET_API_KEY"],
|
|
37
|
+
)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
3. ## Subscribe
|
|
41
|
+
```python title="routes/billing.py"
|
|
42
|
+
from flask import Blueprint, request, jsonify, redirect
|
|
43
|
+
from commet_client import commet
|
|
44
|
+
|
|
45
|
+
billing = Blueprint("billing", __name__)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@billing.route("/subscribe", methods=["POST"])
|
|
49
|
+
def subscribe():
|
|
50
|
+
data = request.get_json()
|
|
51
|
+
|
|
52
|
+
commet.customers.create(
|
|
53
|
+
email=data["email"],
|
|
54
|
+
id=data["customer_id"],
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
subscription = commet.subscriptions.create(
|
|
58
|
+
customer_id=data["customer_id"],
|
|
59
|
+
plan_code="pro",
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
return jsonify({"checkout_url": subscription.checkout_url})
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
4. ## Check Access
|
|
66
|
+
```python title="routes/billing.py"
|
|
67
|
+
@billing.route("/subscription/<customer_id>")
|
|
68
|
+
def get_subscription(customer_id):
|
|
69
|
+
sub = commet.subscriptions.get_active(customer_id=customer_id)
|
|
70
|
+
if sub is None:
|
|
71
|
+
return jsonify({"error": "no_active_subscription"}), 404
|
|
72
|
+
return jsonify({"status": sub.status})
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@billing.route("/features/<feature>/<customer_id>")
|
|
76
|
+
def check_feature(feature, customer_id):
|
|
77
|
+
result = commet.feature_access.get(code=feature, customer_id=customer_id)
|
|
78
|
+
return jsonify({"allowed": result.allowed})
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
5. ## Track Usage
|
|
82
|
+
```python title="routes/billing.py"
|
|
83
|
+
@billing.route("/usage", methods=["POST"])
|
|
84
|
+
def track_usage():
|
|
85
|
+
data = request.get_json()
|
|
86
|
+
|
|
87
|
+
commet.usage.track(
|
|
88
|
+
customer_id=data["customer_id"],
|
|
89
|
+
feature_code="api_calls",
|
|
90
|
+
value=1,
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
return jsonify({"tracked": True})
|
|
94
|
+
```
|
|
95
|
+
Usage is aggregated and billed at end of period.
|
|
96
|
+
|
|
97
|
+
6. ## Customer Portal
|
|
98
|
+
```python title="routes/billing.py"
|
|
99
|
+
@billing.route("/portal")
|
|
100
|
+
def portal():
|
|
101
|
+
result = commet.portal.get_url(customer_id="user_123")
|
|
102
|
+
return redirect(result.portal_url)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
7. ## Webhooks
|
|
106
|
+
```python title="routes/webhooks.py"
|
|
107
|
+
import os
|
|
108
|
+
|
|
109
|
+
from flask import Blueprint, request
|
|
110
|
+
from commet import Webhooks
|
|
111
|
+
|
|
112
|
+
webhooks_bp = Blueprint("webhooks", __name__)
|
|
113
|
+
webhooks = Webhooks()
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@webhooks_bp.route("/webhooks/commet", methods=["POST"])
|
|
117
|
+
def handle_webhook():
|
|
118
|
+
payload = webhooks.verify_and_parse(
|
|
119
|
+
raw_body=request.get_data(as_text=True),
|
|
120
|
+
signature=request.headers.get("x-commet-signature"),
|
|
121
|
+
secret=os.environ["COMMET_WEBHOOK_SECRET"],
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
if payload is None:
|
|
125
|
+
return "Invalid signature", 401
|
|
126
|
+
|
|
127
|
+
if payload["event"] == "subscription.activated":
|
|
128
|
+
# handle activation
|
|
129
|
+
pass
|
|
130
|
+
|
|
131
|
+
return "", 200
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
8. ## Start Server
|
|
135
|
+
```python title="app.py"
|
|
136
|
+
from flask import Flask
|
|
137
|
+
from routes.billing import billing
|
|
138
|
+
from routes.webhooks import webhooks_bp
|
|
139
|
+
|
|
140
|
+
app = Flask(__name__)
|
|
141
|
+
app.register_blueprint(billing, url_prefix="/billing")
|
|
142
|
+
app.register_blueprint(webhooks_bp)
|
|
143
|
+
|
|
144
|
+
if __name__ == "__main__":
|
|
145
|
+
app.run(port=3000)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Related
|
|
149
|
+
|
|
150
|
+
- [Subscriptions](/docs/manage-subscriptions)
|
|
151
|
+
- [Track Usage](/docs/track-usage)
|
|
152
|
+
- [Customer Portal](/docs/customer-portal)
|
|
153
|
+
- [SDK Reference](/docs/sdk-reference)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-07-28
|
|
3
|
+
title: Integrate with Python
|
|
4
|
+
description: Install and configure the Commet Python SDK.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Install the Commet Skill so your coding agent can integrate the current SDK and verify its work against the live API contract.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx skills add commet-labs/skills --skill commet
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
1. ## Install
|
|
14
|
+
### pip
|
|
15
|
+
```bash
|
|
16
|
+
pip install commet-sdk
|
|
17
|
+
```
|
|
18
|
+
### uv
|
|
19
|
+
```bash
|
|
20
|
+
uv add commet-sdk
|
|
21
|
+
```
|
|
22
|
+
### poetry
|
|
23
|
+
```bash
|
|
24
|
+
poetry add commet-sdk
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
2. ## Configure
|
|
28
|
+
```bash title=".env"
|
|
29
|
+
COMMET_API_KEY=ck_sandbox_xxx
|
|
30
|
+
```
|
|
31
|
+
```python title="commet_client.py"
|
|
32
|
+
import os
|
|
33
|
+
|
|
34
|
+
from commet import Commet
|
|
35
|
+
|
|
36
|
+
commet = Commet(
|
|
37
|
+
api_key=os.environ["COMMET_API_KEY"],
|
|
38
|
+
)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
3. ## Create Customer and Subscribe
|
|
42
|
+
`customers.create` is idempotent — if a customer with the same `id` already exists, it returns the existing record.
|
|
43
|
+
```python
|
|
44
|
+
response = commet.customers.create(
|
|
45
|
+
email="user@example.com",
|
|
46
|
+
id="user_123",
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
subscription = commet.subscriptions.create(
|
|
50
|
+
customer_id="user_123",
|
|
51
|
+
plan_code="pro",
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
checkout_url = subscription.checkout_url
|
|
55
|
+
```
|
|
56
|
+
The customer is redirected to checkout to complete payment.
|
|
57
|
+
|
|
58
|
+
4. ## Check Access
|
|
59
|
+
```python
|
|
60
|
+
sub = commet.subscriptions.get_active(customer_id="user_123")
|
|
61
|
+
status = sub.status if sub else None
|
|
62
|
+
|
|
63
|
+
access = commet.feature_access.get(code="custom_branding", customer_id="user_123")
|
|
64
|
+
allowed = access.allowed
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
5. ## Track Usage
|
|
68
|
+
```python
|
|
69
|
+
commet.usage.track(
|
|
70
|
+
customer_id="user_123",
|
|
71
|
+
feature_code="api_calls",
|
|
72
|
+
value=1,
|
|
73
|
+
)
|
|
74
|
+
```
|
|
75
|
+
Usage is aggregated and billed at end of period.
|
|
76
|
+
|
|
77
|
+
6. ## Multiple Operations
|
|
78
|
+
Call each resource directly with `customer_id`:
|
|
79
|
+
```python
|
|
80
|
+
commet.usage.track(customer_id="user_123", feature_code="api_calls", value=1)
|
|
81
|
+
commet.feature_access.get(code="custom_branding", customer_id="user_123")
|
|
82
|
+
commet.seats.add(customer_id="user_123", feature_code="editor", count=3)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Related
|
|
86
|
+
|
|
87
|
+
- [Flask](/docs/integrate-with-flask)
|
|
88
|
+
- [FastAPI](/docs/integrate-with-fastapi)
|
|
89
|
+
- [Django](/docs/integrate-with-django)
|
|
90
|
+
- [SDK Reference](/docs/sdk-reference)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-08-16
|
|
3
|
+
title: Card Promotions
|
|
4
|
+
description: Distribute a Promotional Offer to eligible card BINs and revalidate eligibility at checkout.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Card Promotions connect an existing Promotional Offer to one or more card BINs. The Offer owns the discount and duration; the Card Promotion controls who can receive it.
|
|
8
|
+
|
|
9
|
+
This feature appears only for organizations with Card Promotions enabled.
|
|
10
|
+
|
|
11
|
+
## Configure the promotion
|
|
12
|
+
|
|
13
|
+
1. Create a [Promotional Offer](/docs/promotional-offers) whose first phase is a discount.
|
|
14
|
+
2. Open **Card Promotions** and choose that Offer.
|
|
15
|
+
3. Add the eligible 6- or 8-digit BINs.
|
|
16
|
+
4. Choose whether it applies to every billing interval or one specific interval.
|
|
17
|
+
5. Choose automatic discovery or require your application to preselect it.
|
|
18
|
+
6. Activate it when the commercial campaign begins.
|
|
19
|
+
|
|
20
|
+
A BIN can belong to only one Card Promotion. Eight-digit matches take precedence over their six-digit fallback.
|
|
21
|
+
|
|
22
|
+
## Preselect it in checkout
|
|
23
|
+
|
|
24
|
+
Pass the public `cardPromotionId` when creating the subscription:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
const subscription = await commet.subscriptions.create(
|
|
28
|
+
{
|
|
29
|
+
customerId: 'cus_01J...',
|
|
30
|
+
planId: 'pln_01J...',
|
|
31
|
+
cardPromotionId: 'cpr_01J...',
|
|
32
|
+
},
|
|
33
|
+
{ idempotencyKey: 'checkout-acme-2026-08-16' },
|
|
34
|
+
)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The checkout can show the benefit immediately, but it remains conditional. Commet reads the entered card and verifies its BIN, the configured billing interval, and the Offer's compatibility with the selected price. It removes the promotion before confirmation if those checks fail.
|
|
38
|
+
|
|
39
|
+
Do not pass the underlying `offerId` to simulate a card promotion. A direct Offer is unconditional; `cardPromotionId` preserves the eligibility check and records the application source correctly.
|
|
40
|
+
|
|
41
|
+
Use sandbox cards that match your configured BINs and verify both eligible and ineligible confirmation paths.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-07-31
|
|
3
|
+
title: Introductory Offers
|
|
4
|
+
description: Apply an existing Offer automatically to eligible new subscriptions.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
An Introductory Offer is not a separate Offer type. It is an existing Offer attached to one base plan price with introductory placement.
|
|
8
|
+
|
|
9
|
+
That placement adds two behaviors:
|
|
10
|
+
|
|
11
|
+
- Commet selects the Offer automatically when no explicit override is supplied.
|
|
12
|
+
- Commet checks introductory eligibility before applying it.
|
|
13
|
+
|
|
14
|
+
Selectable price variants inherit the introductory placement from their base price.
|
|
15
|
+
|
|
16
|
+
## Compatible phases
|
|
17
|
+
|
|
18
|
+
An Offer used as introductory may contain:
|
|
19
|
+
|
|
20
|
+
1. One optional `free_trial` phase at the beginning.
|
|
21
|
+
2. At most one finite `percentage` or `amount_off` phase.
|
|
22
|
+
|
|
23
|
+
It cannot use `fixed_price`, multiple discount phases, or an open-ended discount.
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
const onboarding = await commet.offers.create({
|
|
27
|
+
name: 'Starter onboarding',
|
|
28
|
+
phases: [
|
|
29
|
+
{ type: 'free_trial', durationDays: 14 },
|
|
30
|
+
{ type: 'percentage', durationCycles: 3, percentage: 3000 },
|
|
31
|
+
],
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
In the Dashboard, open the plan price and choose **Add intro offer** to attach the existing Offer. A base price can have only one introductory placement at a time.
|
|
36
|
+
|
|
37
|
+
## Eligibility
|
|
38
|
+
|
|
39
|
+
Current automatic eligibility excludes a customer who already has an `active` or `past_due` subscription in the organization. Other historical statuses do not create a lifetime ban.
|
|
40
|
+
|
|
41
|
+
## Selection at subscription creation
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
await commet.subscriptions.create({
|
|
45
|
+
customerId: 'user_123',
|
|
46
|
+
planCode: 'starter',
|
|
47
|
+
})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
When `offerId` is omitted, Commet resolves the selected price and applies its introductory Offer if the customer is eligible.
|
|
51
|
+
|
|
52
|
+
An explicit `offerId` applies that Offer directly instead. It cannot be combined with `promoCode`, `customTrialDays`, or `skipTrial: true`.
|
|
53
|
+
|
|
54
|
+
## Trials and compatibility fields
|
|
55
|
+
|
|
56
|
+
`trialDays`, `customTrialDays`, and `skipTrial` remain supported API shortcuts. Internally, an accepted trial is recorded as a `free_trial` phase in the Offer Application. Prefer catalog Offers when the same terms should be named, reused, inspected, or distributed consistently.
|
|
57
|
+
|
|
58
|
+
## Related
|
|
59
|
+
|
|
60
|
+
- [Offers](/docs/offers)
|
|
61
|
+
- [Promotional Offers](/docs/promotional-offers)
|
|
62
|
+
- [Promo Codes](/docs/promo-codes)
|
|
63
|
+
- [Trial Periods](/docs/trial-periods)
|
|
64
|
+
- [Manage Subscriptions](/docs/manage-subscriptions)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Sales",
|
|
3
|
+
"description": "Create Offers, Promo Codes, Markets, and customer acquisition strategies",
|
|
4
|
+
"pages": [
|
|
5
|
+
"offers",
|
|
6
|
+
"introductory-offers",
|
|
7
|
+
"promotional-offers",
|
|
8
|
+
"card-promotions",
|
|
9
|
+
"promo-codes",
|
|
10
|
+
"regional-prices",
|
|
11
|
+
"trial-periods"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-07-31
|
|
3
|
+
title: Offers
|
|
4
|
+
description: Define reusable trials and temporary pricing terms independently from plans and distribution.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
An Offer is a reusable sequence of benefits. It defines **what changes**—a trial, a discount, or a temporary fixed price—without deciding which plan uses it or how a customer receives it.
|
|
8
|
+
|
|
9
|
+
## Offer phases
|
|
10
|
+
|
|
11
|
+
An Offer contains between 1 and 10 ordered phases:
|
|
12
|
+
|
|
13
|
+
| Phase | Effect |
|
|
14
|
+
| ------------- | --------------------------------------------------------------------------------- |
|
|
15
|
+
| `free_trial` | Delays the first charge for a fixed number of days |
|
|
16
|
+
| `percentage` | Reduces the plan base price by basis points |
|
|
17
|
+
| `amount_off` | Subtracts an explicit amount for each configured currency |
|
|
18
|
+
| `fixed_price` | Replaces the plan base price with an explicit amount for each configured currency |
|
|
19
|
+
|
|
20
|
+
A free trial can appear only as the first phase. A discount phase may have a finite `durationCycles`, or `null` when it is the final open-ended phase.
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
const launchOffer = await commet.offers.create({
|
|
24
|
+
name: 'Launch sequence',
|
|
25
|
+
phases: [
|
|
26
|
+
{ type: 'free_trial', durationDays: 14 },
|
|
27
|
+
{ type: 'percentage', durationCycles: 3, percentage: 5000 },
|
|
28
|
+
{ type: 'percentage', durationCycles: null, percentage: 2000 },
|
|
29
|
+
],
|
|
30
|
+
metadata: { campaign: 'launch-2026' },
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The Offer does not contain `purpose`, `planPriceIds`, eligibility, or redemption rules.
|
|
35
|
+
|
|
36
|
+
## Apply the same Offer in different ways
|
|
37
|
+
|
|
38
|
+
| Channel | How the Offer is selected | What the channel adds |
|
|
39
|
+
| ---------------- | --------------------------------- | ------------------------------------------------------ |
|
|
40
|
+
| **Introductory** | Attached to one base plan price | Automatic selection and new-customer eligibility |
|
|
41
|
+
| **Promotional** | Your integration passes `offerId` | Explicit campaign, retention, or experiment assignment |
|
|
42
|
+
| **Promo Code** | The customer enters a code | Redemption limits, plan restrictions, and expiration |
|
|
43
|
+
|
|
44
|
+
The channel does not create another copy of the Offer. It only decides how the reusable terms reach a customer.
|
|
45
|
+
|
|
46
|
+
## Accepted terms
|
|
47
|
+
|
|
48
|
+
When Commet quotes or applies an Offer, it records an immutable Offer Application. The application includes:
|
|
49
|
+
|
|
50
|
+
- the Offer and selection source;
|
|
51
|
+
- the target under `appliesTo`;
|
|
52
|
+
- the resolved currency and amounts when available;
|
|
53
|
+
- the exact accepted phases and dates.
|
|
54
|
+
|
|
55
|
+
Editing, deactivating, or archiving the catalog Offer affects future applications only. Existing applications remain available for billing and audit.
|
|
56
|
+
|
|
57
|
+
The v9 response is target-aware (`plan_price`, `addon`, or `credit_pack`) so new purchase surfaces do not require another breaking response change. Current public subscription, Introductory, direct, and Promo Code flows create `plan_price` applications.
|
|
58
|
+
|
|
59
|
+
## Related
|
|
60
|
+
|
|
61
|
+
- [Introductory Offers](/docs/introductory-offers)
|
|
62
|
+
- [Promotional Offers](/docs/promotional-offers)
|
|
63
|
+
- [Promo Codes](/docs/promo-codes)
|
|
64
|
+
- [Trial Periods](/docs/trial-periods)
|
|
65
|
+
- [Offers API reference](/docs/api-reference/offers/list-offers)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-07-31
|
|
3
|
+
title: Promo Codes
|
|
4
|
+
description: Distribute an existing Offer through a customer-entered checkout code.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
A Promo Code is a distribution channel. The referenced Offer owns the economic terms; the code owns who can redeem them and when.
|
|
8
|
+
|
|
9
|
+
## Create a compatible Offer
|
|
10
|
+
|
|
11
|
+
A Promo Code can reference an Offer with exactly one `percentage` or `amount_off` phase.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
const launchOffer = await commet.offers.create({
|
|
15
|
+
name: 'Launch 50',
|
|
16
|
+
phases: [
|
|
17
|
+
{ type: 'percentage', durationCycles: 2, percentage: 5000 },
|
|
18
|
+
],
|
|
19
|
+
})
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Trial, multi-phase, and `fixed_price` Offers can still be applied directly with `offerId`, but cannot be distributed through a Promo Code.
|
|
23
|
+
|
|
24
|
+
## Create the code
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
const promoCode = await commet.promoCodes.create({
|
|
28
|
+
code: 'LAUNCH50',
|
|
29
|
+
offerId: launchOffer.id,
|
|
30
|
+
billingInterval: 'monthly',
|
|
31
|
+
maxRedemptions: 100,
|
|
32
|
+
expiresAt: '2026-12-31T23:59:59.000Z',
|
|
33
|
+
planIds: ['pln_pro'],
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The Promo Code owns:
|
|
38
|
+
|
|
39
|
+
- the customer-facing code;
|
|
40
|
+
- optional plan and billing-interval restrictions;
|
|
41
|
+
- the redemption limit;
|
|
42
|
+
- expiration and active state.
|
|
43
|
+
|
|
44
|
+
Updating the Offer changes future redemptions. Existing Offer Applications keep their accepted terms.
|
|
45
|
+
|
|
46
|
+
## Checkout behavior
|
|
47
|
+
|
|
48
|
+
The customer enters the code during checkout. Commet validates the code, resolves the referenced Offer in the checkout currency, and records an Offer Application with source `promo_code`.
|
|
49
|
+
|
|
50
|
+
If an eligible automatic Introductory Offer applies, the code is rejected with `intro_offer_active`. A Promo Code also cannot be combined with an explicit `offerId`.
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
await commet.subscriptions.create({
|
|
54
|
+
customerId: 'user_123',
|
|
55
|
+
planCode: 'pro',
|
|
56
|
+
promoCode: 'LAUNCH50',
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Related
|
|
61
|
+
|
|
62
|
+
- [Offers](/docs/offers)
|
|
63
|
+
- [Promotional Offers](/docs/promotional-offers)
|
|
64
|
+
- [Introductory Offers](/docs/introductory-offers)
|
|
65
|
+
- [Manage Subscriptions](/docs/manage-subscriptions)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-07-31
|
|
3
|
+
title: Promotional Offers
|
|
4
|
+
description: Apply any compatible Offer directly for campaigns, retention, and experiments.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
A Promotional Offer is an Offer applied directly with `offerId`. Promotional describes the application channel, not a different catalog resource or `purpose`.
|
|
8
|
+
|
|
9
|
+
The Offer stays independent from plans and prices until your integration selects it.
|
|
10
|
+
|
|
11
|
+
## Create the terms
|
|
12
|
+
|
|
13
|
+
Direct Offers may combine a free trial with ordered discount or fixed-price phases:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
const retentionOffer = await commet.offers.create({
|
|
17
|
+
name: 'Return to Pro',
|
|
18
|
+
phases: [
|
|
19
|
+
{ type: 'free_trial', durationDays: 7 },
|
|
20
|
+
{ type: 'fixed_price', durationCycles: 2, prices: [
|
|
21
|
+
{ currency: 'usd', amount: 2900 },
|
|
22
|
+
{ currency: 'ars', amount: 3990000 },
|
|
23
|
+
] },
|
|
24
|
+
{ type: 'percentage', durationCycles: null, percentage: 2000 },
|
|
25
|
+
],
|
|
26
|
+
})
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Currency-specific phases require an explicit value for the checkout currency. Commet does not reuse a USD amount silently in another currency.
|
|
30
|
+
|
|
31
|
+
## Apply it directly
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
await commet.subscriptions.create({
|
|
35
|
+
customerId: 'user_123',
|
|
36
|
+
planCode: 'pro',
|
|
37
|
+
offerId: retentionOffer.id,
|
|
38
|
+
})
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The Offer must be active, inside its availability window, and resolvable in the selected currency. It does not need a prior association with the plan or price.
|
|
42
|
+
|
|
43
|
+
An explicit `offerId` overrides automatic introductory selection. It cannot be combined with `promoCode`, `customTrialDays`, or `skipTrial: true`.
|
|
44
|
+
|
|
45
|
+
Immediate plan changes, plan-change previews, and supported reactivation flows also accept `offerId`. Scheduled plan changes do not accept an Offer.
|
|
46
|
+
|
|
47
|
+
## Direct application or Promo Code?
|
|
48
|
+
|
|
49
|
+
Use direct `offerId` when your application decides who receives the terms. Use a Promo Code when the customer should enter a code and the campaign needs redemption restrictions.
|
|
50
|
+
|
|
51
|
+
A Promo Code can reference only an Offer with one `percentage` or `amount_off` phase. Multi-phase, trial, and `fixed_price` Offers remain available for direct application.
|
|
52
|
+
|
|
53
|
+
## Related
|
|
54
|
+
|
|
55
|
+
- [Offers](/docs/offers)
|
|
56
|
+
- [Introductory Offers](/docs/introductory-offers)
|
|
57
|
+
- [Promo Codes](/docs/promo-codes)
|
|
58
|
+
- [Manage Subscriptions](/docs/manage-subscriptions)
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-07-31
|
|
3
|
+
title: Markets and Regional Pricing
|
|
4
|
+
description: Combine currency pricing, reusable country Markets, and selectable price variants.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Commet has two complementary pricing layers:
|
|
8
|
+
|
|
9
|
+
| Layer | Use it for |
|
|
10
|
+
| -------------------- | ------------------------------------------------------------------------- |
|
|
11
|
+
| **Currency Pricing** | Define plan, balance, and overage values in one presentment currency |
|
|
12
|
+
| **Markets** | Group countries that should resolve explicit price and currency overrides |
|
|
13
|
+
|
|
14
|
+
Currency Pricing remains the fallback. Add Markets when country segmentation or selectable variants require it.
|
|
15
|
+
|
|
16
|
+
## Create a Market
|
|
17
|
+
|
|
18
|
+
A Market is a top-level Sales resource. It does not require a plan or price.
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
const argentina = await commet.markets.create({
|
|
22
|
+
name: 'Argentina',
|
|
23
|
+
countryCodes: ['AR'],
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const southernCone = await commet.markets.create({
|
|
27
|
+
name: 'Southern Cone',
|
|
28
|
+
countryCodes: ['BO', 'PY', 'UY'],
|
|
29
|
+
})
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Countries can belong to only one active Market. The v9 REST paths are `/markets` and `/markets/{id}`.
|
|
33
|
+
|
|
34
|
+
## Add Market prices
|
|
35
|
+
|
|
36
|
+
The base amount remains the fallback for every country without a Market override.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
const basePrice = await commet.plans.addPrice({
|
|
40
|
+
id: 'pln_pro',
|
|
41
|
+
billingInterval: 'monthly',
|
|
42
|
+
price: 4900,
|
|
43
|
+
isDefault: true,
|
|
44
|
+
marketPrices: [
|
|
45
|
+
{ marketGroupId: argentina.id, currency: 'ars', price: 6490000 },
|
|
46
|
+
{ marketGroupId: southernCone.id, currency: 'usd', price: 3900 },
|
|
47
|
+
],
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
At checkout, Commet resolves the Market from the request country. Sandbox checkout lets you change **Country** to test another Market; live checkout ignores that override.
|
|
52
|
+
|
|
53
|
+
## Selectable variants
|
|
54
|
+
|
|
55
|
+
A variant inherits one base price and overrides only Markets already configured on that base:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
const foundingCustomers = await commet.plans.addPrice({
|
|
59
|
+
id: 'pln_pro',
|
|
60
|
+
billingInterval: 'monthly',
|
|
61
|
+
inheritsFromPriceId: basePrice.id,
|
|
62
|
+
metadata: { name: 'Founding customers' },
|
|
63
|
+
marketPrices: [
|
|
64
|
+
{ marketGroupId: argentina.id, currency: 'ars', price: 3990000 },
|
|
65
|
+
],
|
|
66
|
+
})
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Pass `priceId` only when the customer deliberately selects that variant:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
await commet.subscriptions.create({
|
|
73
|
+
customerId: 'user_123',
|
|
74
|
+
planCode: 'pro',
|
|
75
|
+
priceId: foundingCustomers.id,
|
|
76
|
+
})
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Omitting `priceId` keeps normal default-price and Market resolution.
|
|
80
|
+
|
|
81
|
+
## Renewal and archival
|
|
82
|
+
|
|
83
|
+
- A subscription stores the selected price identity.
|
|
84
|
+
- Renewals use that price row's current catalog value.
|
|
85
|
+
- A variant inherits every Market it does not override.
|
|
86
|
+
- Archiving hides a price from new selection without breaking existing subscriptions.
|
|
87
|
+
- A referenced Market cannot be deleted.
|
|
88
|
+
|
|
89
|
+
Accepted Offer phases are a separate immutable snapshot; the selected catalog price remains editable.
|
|
90
|
+
|
|
91
|
+
## v8 compatibility
|
|
92
|
+
|
|
93
|
+
API `2026-07-24` and SDK v8 keep `/pricing/market-groups` and `commet.pricing.*`. API `2026-07-31` and SDK v9 use the top-level Market surface.
|
|
94
|
+
|
|
95
|
+
## Related
|
|
96
|
+
|
|
97
|
+
- [Offers](/docs/offers)
|
|
98
|
+
- [Create Plans](/docs/create-plans)
|
|
99
|
+
- [Manage Subscriptions](/docs/manage-subscriptions)
|
|
100
|
+
- [Markets API reference](/docs/api-reference/markets/list-markets)
|