# Billing

Standard and Enterprise are monthly subscriptions in US dollars, paid through Stripe. The organisation’s owner upgrades, switches plan and cancels; everyone in the organisation can see its plan.

## Upgrade

1. Choose a plan
  As an owner, open **Billing** in the dashboard and choose Standard ($99 a month) or Enterprise ($499 a month).
2. Pay on Stripe
  CLItrail opens Stripe Checkout for that plan’s monthly price. Your card details go to Stripe, never to CLItrail. An organisation that has paid before reuses its Stripe customer.
3. Back in the dashboard
  Stripe returns you to **Billing**. The plan changes as soon as Stripe tells CLItrail the subscription is active, usually within seconds.

## Switch plan, card or cancel

**Manage billing** opens Stripe’s billing portal for your organisation, where the owner can switch between Standard and Enterprise, update the card, download invoices and cancel. Moving from Enterprise to Standard takes effect immediately. Cancelled subscriptions stay active until the end of the period already paid; then the organisation is on Free again and the [downgrade rules](https://clitrail.com/docs/plans#downgrades) apply. Nothing is deleted.

## How the plan follows Stripe

- Stripe sends CLItrail signed webhook events: `checkout.session.completed` and `customer.subscription.created`, `.updated` and `.deleted`.
- Each event’s `Stripe-Signature` is checked against the exact bytes received, and events older than 5 minutes are refused. Each event is applied once, however often Stripe resends it.
- The plan comes from the subscription’s price (`clitrail_standard_monthly` or `clitrail_enterprise_monthly`) and its status: `active` and `trialing` give that plan; any other status, such as `past_due`, `unpaid` or `canceled`, means Free.
- CLItrail keeps the Stripe customer and subscription IDs, the status and the end of the current period. Only owners see the Stripe IDs. Event payloads are never logged.
- Every plan change is recorded in the organisation’s activity.

## Limits and errors

| Code | Status | Meaning |
| --- | --- | --- |
| `forbidden` | 403 | Only owners open Checkout or the billing portal. |
| `rate_limited` | 429 | More than 10 Checkout or portal sessions for one organisation in an hour. |
| `billing_customer_required` | 409 | The portal needs a Stripe customer: upgrade first. |
| `billing_not_configured` | 503 | Billing is not available on this service right now. Nothing was charged. |
| `billing_unavailable` | 503 | Stripe could not be reached. Try again in a minute. |
| `billing_failed` | 502 | Stripe refused the request. The dashboard shows what to do. |
| `subscription_active` | 409 | Cancel the subscription before deleting the organisation or your account. |

Stripe processes payments as CLItrail’s payment processor; see the [privacy notice](https://clitrail.com/privacy).
