Billing (cloud mode)
Billing is for hosted deployments only. With BILLING_ENABLED unset (the self-host default), reviews have no quota, the Stripe webhook endpoint returns 404, and the billing page says billing is off.
Plans
Use left and right arrow keys to scroll columns. Home shows the first column; End shows the last.
| Feature | Free | Starter | Pro |
|---|---|---|---|
| Price | $0, no card (existing workspaces only) | BILLING_SEAT_PRICE_LABEL per seat (we sell $12/month) | BILLING_PRO_PRICE_LABEL per seat (we sell $24/month) |
| Included model usage per month | BILLING_FREE_USAGE_USD per workspace (default $3) | BILLING_USAGE_PER_SEAT_USD per seat (default $6), pooled | BILLING_PRO_USAGE_PER_SEAT_USD per seat (default $12), pooled |
| Extra usage | none | up to the admin cap | up to the admin cap |
| Fix prompts, the local bridge, your own cloud agents and Devin | ✓ | ✓ | ✓ |
| OpenReview agent fixes (fix pull requests) per month | BILLING_STARTER_FIXES_PER_SEAT per seat (default 5), pooled | BILLING_PRO_FIXES_PER_SEAT per seat (default 20), pooled | |
| Your own model key (its calls are not metered) | ✓ | ✓ | |
| Deep reviews (deep tier, agentic and hypothesis engines, agent budgets, model overrides), generated reproduction tests | ✓ | ||
| Requirements from Linear, Jira, Confluence and Notion; learning conventions | ✓ | ||
| API keys, analytics older than 30 days, SSO, the audit log | ✓ |
The plan catalog is src/plans.ts. Security checks, every provider, and the CLI and MCP signed in through the browser are on every plan. With billing off every feature is unlocked.
- Choosing a plan (new workspaces): a workspace created while the deployment bills workspaces (
BILLING_ENABLED=trueand a Stripe secret;organizations.planRequired) needs a plan before anything else: setup goes workspace → Choose your plan → connect. Self-hosted installs with billing unset, or with no Stripe secret, skip the plan step and never gate reviews (billsWorkspacesinsrc/billing.ts).- Starter starts a
BILLING_TRIAL_DAYS(default 14) day trial with no card (billing.startTrial). Dates are set on the server (billingAccounts.trialStartedAt); the client cannot set them, and a workspace gets one trial. After it ends without a card, reviews pause (Billing:reason) and nothing is deleted; adding a card in Billing & Usage resumes them. - Pro opens Stripe Checkout with a card always collected (
payment_method_collection: always). The paid choice is recorded when Stripe confirms it:checkout.session.completedwith a subscription, or a subscription that is trialing, active or past due. - The choice is stored in
organizations.planSelectedAtandplan, and audited asbilling.plan_selected(orbilling.trial_started). Until then the dashboard sends everyone to the plan step (Billing, Account and Referrals settings stay open), and the server refuses indexing, reviews, advancing and finishing setup.
- Starter starts a
- Existing subscriptions (grandfathered): subscriptions from before Pro existed keep every Pro feature while they stay on Starter (
billingAccounts.legacy). Run once right after deploying plans:npx convex run billing:grandfatherSubscriptions '{"confirm":"grandfather-pre-plan-subscriptions"}' --prod. - Free (existing workspaces only): a workspace keeps Free if it was created before plans were required (no
planRequired) or started on Free (plan: "free"); seekeepsFreeinsrc/billing.ts. The rule reads those fields, with no cut-off date and no migration. Without a paying subscription such a workspace is on Free, which never expires; its allowance resets each month.BILLING_TRIAL_USAGE_USDis no longer read: a generous trial allowance must not become a monthly gift.- Every other workspace without a paying subscription (a new one, or one whose subscription ended) has no allowance: a $0 limit with a
Billing:reason to choose Starter or Pro.billing.chooseFreePlanrefuses it. - A workspace that started on Free, then subscribes and later cancels, has its
planoverwritten by the subscription, so it does not fall back to Free. One from before plans does.
- Every other workspace without a paying subscription (a new one, or one whose subscription ended) has no allowance: a $0 limit with a
- One Free workspace per owner still holds among the workspaces that keep Free: one that started on Free gets no allowance (a $0 limit, with a
Billing:reason naming the owner's Free workspace) while any of its owners owns another Free workspace created before it. A Free workspace is one that keeps Free and has no paying subscription. Paid workspaces, workspaces from before plans were required, and billing off are unaffected. When the owner's Free workspace subscribes, the next-oldest one gets Free. A workspace that is pending deletion still counts until it is purged. - Which paid plan: the subscription's seat price decides it (
billingAccounts.plan):STRIPE_SEAT_PRICE_ID/STRIPE_SEAT_ANNUAL_PRICE_IDis Starter, andSTRIPE_PRO_PRICE_ID/STRIPE_PRO_ANNUAL_PRICE_IDis Pro. An unknown price keeps the recorded plan, and a subscription with none recorded is Starter. Checkout uses the monthly prices. Admins switch between Starter and Pro in Organization Settings → Billing & Usage (billingJobs.changePlan): it swaps the seat price on the subscription item with prorations and auditsbilling.plan_change_requested, and the webhook then records the new plan. The Customer Portal can't do this, because it doesn't update subscriptions that carry a metered price. Switching to Starter leaveslegacyas it is. - Gated features: each one is skipped, never failed.
- A deep review runs at standard, with a coverage note. So does a repository set to the agentic or hypothesis engine: it runs the standard pipeline, its agent budgets are ignored, and team, repository and agent-authored model overrides give way to the workspace model.
- Saving your own model key needs Starter or Pro. A key saved earlier is kept but not used on Free (calls are metered on the operator's model), and works again after upgrading.
- Generated reproduction tests are not drafted.
- A fix pull request request on Free replies that fix pull requests are on Starter and Pro, and one past the month's agent fixes replies with the reset date. The validated suggestion is still posted. Each run counts once it makes a model call (
billingUsage.fixes); a run that stops before that gives it back. Its model calls also use the included usage. - Linked requirements are not fetched, with a coverage note. Connecting a new Linear, Atlassian or Notion workspace needs Pro; existing connections stay and work again after upgrading.
- Convention learning is skipped (the sweep marks the repository synced without moving its cursor, so an upgrade later learns from the comments it skipped). Approved conventions keep applying.
- Creating API keys needs Pro. Existing keys are kept but answer
402with an upgrade message. The Perforce watcher and trigger are exempt: they are a code provider, not the public API. - Analytics periods may start at most 30 days back (the start of the UTC day 30 days ago).
- Setting up SSO needs Pro. A connection configured before keeps working and stays editable on any plan.
- The audit log page needs Pro. Events are still recorded, so they appear after upgrading.
- In the dashboard, each locked setting stays visible but disabled (
<Locked>,app/dashboard/locked.tsx) with a link to Organization Settings → Billing & Usage.billing.lockedlists what the workspace's plan lacks.
- Seats: owners, admins and members are seats; viewers are free. Accepting an invitation or changing a member's role resyncs the subscription quantity, with prorations.
- Past due: reviews continue for
BILLING_GRACE_DAYS(default 7) after the first failed payment, then pause until an invoice is paid.
Stripe setup:
- Create a Product "OpenReview Pro" with a $24 monthly price and a $240 yearly price.
- Add a $120 yearly price to the Starter product.
- Set
STRIPE_PRO_PRICE_ID,STRIPE_PRO_ANNUAL_PRICE_IDandSTRIPE_SEAT_ANNUAL_PRICE_IDon Convex. - Set
BILLING_PRO_PRICE_LABELon the web app. - In the Customer Portal configuration, turn off quantity changes. Plan switching happens in the app, not the portal.
Usage
Usage is the inference cost of the workspace's model calls (reviews, chat, Slack answers, fixes, knowledge, indexing embeddings), priced by INFERENCE_PRICES or the built-in prices, so pricier models use it faster. Workspaces that bring their own model key are not metered.
- Enforcement: every model call reserves its worst-case cost before it is sent (
inferenceBudget.reserve, which also checks the deployment-wide cap) and settles the real cost after (billingUsage.usedMicros). A call that would pass the allowance is refused before anything is sent, with aBilling:reason that says when usage resets (the first of the next UTC month). New reviews are blocked once the allowance is used. - Extra usage: on Starter and Pro an admin sets a monthly cap in Organization Settings → Billing & Usage (0 = off, audited as
billing.spending_cap). Usage past the included amount, up to the cap, is recorded inbillingUsage.overageMicrosand reported to Stripe as meter events (billingMeterEvents, retried with backoff, the row id as the idempotent identifier). Extra usage starts after the trial: Stripe does not bill metered usage recorded during a trial, so a trialing subscription stops at its included usage whatever the cap. - Meter: Organization Settings → Billing & Usage shows the percentage used and the reset date; admins also see dollars.
- Alerts: when settled usage crosses 80% and then 100% of the included usage, the workspace owners and admins with a verified notification email (Organization Settings → Notifications) get one email per threshold per month; members and viewers never do.
settleUsagerecords the thresholds inbillingUsage.alertsSent, so the next month starts over, andnotificationJobs.usageAlertsends them (skipped without email configured). On Free the 100% email says reviews are paused until the reset date and points to upgrading; on Starter and Pro it says extra usage is off, or how much of the cap is left. Organization Settings → Billing & Usage shows a banner from 80%. - Stripe setup: create a Meter (event name
STRIPE_METER_EVENT, sum ofvalue) and a metered price on it with the markup inunit_amount_decimal(the value is micro-dollars of cost: $1.25 per $1 of cost is 0.000125 cents per unit). SetSTRIPE_USAGE_PRICE_ID; Checkout then adds it next to the seat price. Existing subscriptions need the price added (Customer Portal or Dashboard) before their extra usage is invoiced.
Operators
OPERATOR_GITHUB_IDS on Convex lists the operators (super admins) by numeric GitHub user id, comma-separated; look one up with gh api users/<login> --jq .id. Only this setting grants it: nothing a user can edit does, and a GitHub login (which can be renamed and reused) never does.
- Their own workspaces: a workspace an operator owns (owner role, not admin) bills like a self-hosted install: no plan to choose, unlimited usage and agent fixes, every feature, and nothing reported to Stripe. Its usage and fix runs are still counted in
billingUsage, and the deployment-wide inference budget still caps it. Its Billing page says it is an operator workspace. - Operator page:
/dashboard/operator(Operator in the account menu) shows every workspace's plan, seats, spend, billed usage, reviews, blocked reviews and agent fixes this month, and last activity; the users, with sign-in method and last sign-in; a 30-day spend chart; and recent sign-ins, reviews, agent fixes and plan changes. It shows names, counts and times, never code, pull request titles, findings, chat or email addresses. Anyone else gets a 404. - Checks and audit:
convex/operator.tschecks the caller in every operator function and requires a browser session, so a server-minted API-key token never qualifies. Each visit is recorded inoperatorAuditand listed at the bottom of the page.
Model choice
Workspace and team defaults and repository settings pick the review model from the operator's priced list: the INFERENCE_PRICES entries for LLM_PROVIDER (for example openrouter:anthropic/claude-sonnet-5-5). Chat, Slack answers, fixes and knowledge use the workspace default. A saved model that leaves the list falls back to the operator's LLM_MODEL. Only list models that support tool calls and response_format JSON.
Choosing a plan during setup
When the deployment bills workspaces, guided setup adds a Choose your plan step right after the workspace. Every step uses the same total (wizardProgress in src/onboarding-steps.ts): 10 with the plan step, 9 without it. The step shows the Starter and Pro cards and the seat count:
- Start 14-day Starter trial: no card. Setup continues at connect once Convex records the trial.
- Choose Pro: opens Stripe Checkout and returns to the step.
- A workspace that keeps Free and opens the step gets Continue, with both plans as upgrades.
- The referral code field on this step is optional.
The no-card Starter trial clock starts when an admin chooses Start 14-day trial; each workspace gets one, and it cannot be restarted. Checkout for Pro (or to add a card) carries any remaining trial into the subscription (subscription_data.trial_end), so the card is not charged until the trial ends. Stripe requires a trial end at least 48 hours away, so a trial with less time left is charged at Checkout. Without billing, or without a Stripe secret, the step does not exist and setup has one step fewer.
The dashboard's trial banner (days left, Add Payment Method) shows for the no-card Starter trial the whole time it is running, and for a Stripe trialing subscription with no default payment method on file: neither the subscription's default_payment_method (from customer.subscription.*) nor the customer's invoice_settings.default_payment_method (from customer.updated, sent when a card is added in the Customer Portal). A subscription from before these were recorded counts as having one, because Checkout always collects a card. With a card on file the banner returns for the last 3 days of the trial, saying when the card will be charged, with Manage billing. Also turn on Stripe's own trial-ending reminder email (Stripe Dashboard → Settings → Billing → Subscriptions and emails), in test and live mode.
From 80% of the included usage, or when reviews are blocked, every dashboard page shows a usage banner with an estimate of the reviews left (this workspace's average review cost over the last 30 days, at least five reviews, else $0.065). Admins get Upgrade (Free) or Manage usage; members get Ask an admin, which emails owners and admins with a verified notification address, at most once a day per member.
Pricing-page buttons for Starter and Pro send sign-up to /dashboard/onboarding/plan?intent=<plan>; the intent survives workspace creation, so the plan step opens with that plan's Checkout as the main action.
Conversion events (conversionEvents, see convex/conversions.ts) add checkout_started, first_paid (the first invoice.paid with money in it; subscribed includes trials), paywall:<feature> (a deep review or agentic engine capped, repro tests or linked tickets skipped, a fix PR asked for on Free) and upgrade_requested. Operators see them, for the last 30 days, on /dashboard/operator.
Setup can't be skipped. Until a workspace finishes it, opening the dashboard takes owners and admins back to setup, and every dashboard page shows a Setup isn't finished bar (members see that an admin is completing it). Setup finishes only from its last step (onboarding.complete), which needs the plan and a selected repository that has started indexing. Workspaces that used the former Exit setup before any repository was indexing are reopened once per deployment with npx convex run onboarding:reopenSkippedSetups '{"confirm":"reopen-skipped-setups"}' --prod.
When a review is blocked, it is recorded as failed with a Billing: reason, visible on the pull request's review page. Blocked reviews are also counted on Organization Settings → Billing & Usage.
Enterprise contracts
Enterprise is sold by contract, not through Checkout. It bills active contributors: the distinct authors of pull requests that got a completed review in a UTC month. Bots and the logins a contract lists as non-billable never count. A customer commits to a number of contributors for a year and is invoiced.
What the customer receives:
- Day one: one invoice for the year's commitment (committed contributors × monthly price × 12), due after the contract's net days.
- Each month after: an invoice for contributors above the commitment and, on Managed, model usage past the included amount. It can be $0.
- End of term: the subscription cancels. A contract never renews by itself.
Two modes:
- Managed: reviews run on the operator's model. Each billed contributor adds included usage to a shared monthly pool; usage past it is billed at cost times the contract's multiplier, up to the admin's spending cap.
- Own key: reviews run on the customer's saved model key and nothing is metered. A call that would fall back to the operator's model is refused.
Stripe objects (one Product per tier, prices per contract):
- Product "OpenReview Enterprise":
STRIPE_ENTERPRISE_PRODUCT_ID. - Meter for contributors above the commitment, aggregation Sum: its event name is
STRIPE_CONTRIBUTOR_METER_EVENT(defaultopenreview_contributors_over) and its ID isSTRIPE_CONTRIBUTOR_METER_ID. One event is sent per contract per month, at 00:10 UTC on the 1st, for the month that just closed. - Shared overage price on the existing usage meter with the Enterprise markup:
STRIPE_ENTERPRISE_USAGE_PRICE_ID. A contract with another multiplier gets its own price on the same meter, entered on the form. - Per contract, created by the app and never by hand: a yearly licensed price (the commitment) and a monthly metered price on the contributors meter (the true-up).
- Subscription schedule: one phase of one year with those items,
collection_method: send_invoice,days_until_duefrom the contract,billing_mode: flexible(mixed yearly and monthly items need it) andend_behavior: cancel. Its metadata carriesorganizationIdandcontractId.
Creating a contract: an operator opens Operator → Enterprise contracts, enters the terms, checks Preview and chooses Create contract. The preview is computed by the app before tax; it does not call Stripe. The workspace moves to Enterprise when the customer.subscription.created webhook arrives on the contract's first day, and a live Pro subscription is replaced then. Every step is recorded in the operator log and the workspace audit log (billing.contract_draft, billing.contract_created).
Moving from Starter or Pro: choose the workspace and Preview: the form shows its current subscription and its billable contributors for the last three months, so the commitment comes from data rather than seats. Creating a contract that starts next month sets the old subscription's cancel_at to the contract's first day with no proration, so it bills normally until then. A contract that starts on the 1st of the current month ends the old subscription at once and credits its unused time. The audit log records billing.migrated_from_pro. Features never drop in between: Enterprise holds every Pro feature, and if the old subscription ends a moment before the new one starts, the contract takes over at once (billing.contract_takeover in the logs).
Renewal and end of term: 60 and 30 days before a contract ends, the workspace's owners and the operators get one email each, unless a renewal is signed. To renew, use the same form for that workspace: it creates the next year's contract, which must start the day the term ends, with its own prices. Without a renewal the subscription cancels at the end of the term and the workspace is left as after a cancelled Pro subscription. The term's last month of contributors is reported at 23:30 UTC on its last day, before the subscription ends.
What customers see: Organization Settings → Billing & Usage shows the contract term, this month's active contributors against the commitment, and the included usage (or "Your own model key, nothing metered"). Admins also see the price and the list of contributors, with bots marked not billed. There is no Checkout, plan switch or seat count. The billing portal opens with STRIPE_ENTERPRISE_PORTAL_CONFIGURATION_ID when it is set: create that portal configuration in Stripe with invoices and payment details on, and cancellation and plan switching off.
Pricing page: the Enterprise card shows only when BILLING_ENTERPRISE_CONTACT_URL is set on the web app (a mailto: or https: link). BILLING_ENTERPRISE_PRICE_LABEL is its price text, for example "From $22 per active contributor".
Enterprise-only features:
- SCIM provisioning (
auth.scim): see SSO → SCIM provisioning. - Audit log export (
audit.export): Organization Settings → Audit has an export of any date range as CSV or JSON. Audit events are kept forever unless the contract sets a retention period. - Retention terms: a contract can set the shortest and longest review and transcript retention a workspace may choose, and how long audit events are kept. The settings form follows those bounds, and the daily sweep applies them even to a setting saved earlier.
- Support tier: a line of text on the contract, shown to the customer in Billing & Usage. See support and service levels.
- One contract across several workspaces: on the Operator page, a workspace without its own subscription can be billed under another workspace's contract. A person active in several of them counts once, included usage is one pool, and extra usage is billed to the workspace that holds the contract. Taking a workspace out returns it to its own plan.
Own cloud account (Own-key mode, and any plan with its own model key): besides Anthropic, OpenAI and OpenRouter keys, a workspace can run on its own AWS Bedrock, Azure OpenAI or Google Vertex AI account (Organization Settings → API Keys → Model provider key). All three are called in the OpenAI Chat Completions format, and none of those calls is metered.
- AWS Bedrock: a Bedrock API key and a region. Calls go to
https://bedrock-runtime.<region>.amazonaws.com/openai/v1. Only models whose model card lists the OpenAI Chat Completions API work there; AWS's docs do not say that Anthropic models do. (AWS docs) - Azure OpenAI: the resource's key and name, with the deployment name as the model. Calls go to
https://<resource>.openai.azure.com/openai/v1with anapi-keyheader. (Microsoft docs) - Google Vertex AI: a service account key file (JSON), a project ID and a location (default
global), with a model such asgoogle/gemini-3.5-flash. OpenReview exchanges the key for a one-hour access token for each job. (Google docs) - These three have been tested against recorded request shapes only, never against a real cloud account. Structured JSON output is not requested from them, so replies are checked by the app as for any OpenAI-compatible endpoint.
Stripe setup (once):
- Create the product, the contributors meter and the shared overage price, and set the four settings above on Convex.
- In Billing settings, leave a past-due invoiced subscription past due. The contract's grace days decide when reviews pause.
- In Invoice settings, give subscription-cycle invoices with a metered price at least 24 hours before they finalize (Stripe allows up to 72), so the monthly contributor report always lands first.
- Turn on invoice reminder emails.
Stripe customers
Every workspace becomes a Stripe customer when it is created, so the Stripe Dashboard lists all of them. The customer is named after the workspace and carries its first owner's verified email (if there is one) and metadata.organizationId. The workspace keeps the ID in organizations.stripeCustomerId. Checkout reuses it, and linking it there (billingAccounts.customerId) is still what starts the trial and shows the billing portal. Operators' workspaces get no customer.
Creating the customer is a scheduled job (billingJobs.createCustomer), so signup never waits on Stripe. If Stripe is down, the job logs billing.customer_failed and does not retry: Checkout still creates a customer, and the backfill below picks the workspace up.
To give existing workspaces a customer, count them first, then create them. Rerunning is safe:
npx convex run billing:backfillCustomers '{}' --prod
npx convex run billing:backfillCustomers '{"confirm":"create-stripe-customers"}' --prod
Deleting a workspace leaves its Stripe customer in place.
Discounts and free months
Checkout shows an Add promotion code box. To give a prospect a free month:
- Coupon: create one in Stripe (Product catalog → Coupons): 100% off, duration Multiple months = 1, limited to the Starter product.
- Promotion code: give the coupon a single-use code (limit 1 redemption, with an expiry date) and send that code to the prospect. Reuse the coupon and create one code per prospect.
The prospect enters the code at Checkout, from the setup plan step or Organization Settings → Billing & Usage. Their first billed month is free for every seat. Any remaining trial still comes first, so the first charge falls one month after the trial ends, or one month after Checkout if the trial is over.
Referred workspaces: while the referral discount applies (a referred workspace that has not paid yet), Checkout carries the referral coupon instead and shows no promotion-code box, because Stripe takes only one of the two. Don't send such a prospect a code: after they subscribe, add the free-month coupon to the subscription as below and check that the referral coupon is still on it.
Existing subscriptions: in the Stripe Dashboard, open the subscription and choose Actions → Update subscription → Add coupon. The discount applies from the next invoice.
Deactivating: archive a promotion code to stop new redemptions. Deleting a coupon also stops them, and keeps the discounts already applied.
Setup (operator)
-
Sandbox: use a Stripe sandbox (or test mode) for setup and testing.
-
Product and price: create the Product "OpenReview Starter" with a recurring, per-unit monthly price. Set its ID as
STRIPE_SEAT_PRICE_ID. Each future tier gets its own Product. -
Webhook: add the endpoint
https://<convex-site>/stripe/webhookon API version2026-08-26.dahlia(STRIPE_API_VERSIONinsrc/billing.ts) for these events:checkout.session.completedcustomer.subscription.created,customer.subscription.updatedandcustomer.subscription.deletedcustomer.updated(a card added in the Customer Portal). An endpoint created before this event was added must be edited in the Stripe Dashboard to subscribe to it too, in test and live mode.invoice.payment_failedandinvoice.paid- with the referral program:
charge.refunded,charge.dispute.createdandcharge.dispute.closed
Set its signing secret as
STRIPE_WEBHOOK_SECRET. -
API key: create a restricted key (
rk_test_…) with write access to Customers (every new workspace becomes one), Checkout Sessions, Customer portal and Subscriptions. Set it asSTRIPE_SECRET_KEYon Convex (ask_test_…key also works).- With the referral program, also give it read access to Charges, Disputes, Invoices and Invoice payments. Customers write already covers customer balance transactions (referral credit). Permission names vary in the Dashboard: make one credit and one refund in the sandbox and check the key's request log for denied calls.
-
Turn on billing: set
BILLING_ENABLED=trueon Convex, and on the web app so the landing page shows pricing and the setup step count is right. Live keys (rk_live_…/sk_live_…) are refused unlessBILLING_ALLOW_LIVE=true. -
Customer Portal: turn it on in Stripe so admins can manage their payment method, invoices and cancellation. Turn off quantity changes, because seats follow workspace membership.
-
Tax: turn on Stripe Tax only after you have an active tax registration; until then Stripe collects no tax.
On Vercel, Stripe can also be provisioned from the Vercel Marketplace. The keys still belong in the Convex environment, because Convex runs Checkout, the portal and webhook handling.
Switching from test to live
- Activate payments on the Stripe account (business details and bank account) and fill in Settings → Public details: business name, support email and statement descriptor. Then, in live mode, create the same Product and Price, webhook endpoint (same events and API version) and portal configuration as in test mode, with the site's
/privacyand/termslinks in the portal. - Live keys: create a live restricted key (
rk_live_…) with the same permissions. Set it asSTRIPE_SECRET_KEY, and the live endpoint's signing secret asSTRIPE_WEBHOOK_SECRET. - Convex settings: set
STRIPE_SEAT_PRICE_IDto the live price andBILLING_ALLOW_LIVE=true. - Drop test links: test customers and subscriptions do not exist in live mode, so every workspace must drop its Stripe links. Run this once:
A workspace that keeps Free returns to it; any other has no allowance until its next Checkout, which creates a live customer with a fresh trial. Then give every workspace a live customer with the backfill under Stripe customers.npx convex run billing:forgetStripeLinks '{"confirm":"switch-stripe-mode"}' --prod - Old webhook: cancel the test subscriptions and disable the test-mode webhook endpoint, so the sandbox stops sending events (and retries) that would now fail signature checks.
- Referrals: commissions, credits and payout accounts don't record the Stripe mode. Keep
REFERRALS_ENABLEDoff on a deployment until it is live. A deployment where any test invoice earned a commission (anyreferralCommissionsrow) must not be switched to live, even after voiding them: its referrals stay marked as paid, so live Checkout gives no coupon, the commission window counts from the test invoice and the conversion email is not sent again. Use a separate deployment. If referrals were on but no commission was ever earned, only delete itsreferralPayoutAccountsrows (testacct_…IDs don't exist in live mode). Add the three charge events to the live webhook endpoint too, and enable Connect in live mode.
Referral program
Off unless REFERRALS_ENABLED=true and BILLING_ENABLED=true, on both Convex and the web app. Every signed-in user gets a link (/r/<code>) under Personal Settings → Referrals. A new account created through it is credited to the link's owner, and so is the first workspace it creates.
- Discount: a referred workspace that has not paid yet gets the Stripe coupon
STRIPE_REFERRAL_COUPON_IDat Checkout (discounts), and the subscription carriesmetadata.referralId. Promotion codes are never offered. - Commission: each paid subscription invoice of a referred workspace earns the referrer
REFERRAL_RATE_BPS(default 2000 = 20%) of the cash collected, excluding tax pro rata. Credits and overpayments don't count (an invoice they pay in full earns nothing but still counts as the workspace's first payment), $0 invoices and invoices in another currency than USD earn nothing, and one-off invoices without a subscription are skipped.- It lasts
REFERRAL_MONTHS(default 12), counted from the earliest paid invoice. An invoice created after that ends the referral. - Each commission is held
REFERRAL_HOLD_DAYS(default 30) after the payment before it counts toward the referrer's balance. - Commissions are computed in a job scheduled from the
invoice.paidwebhook, never in the webhook itself, so a referral problem cannot block billing. - The referrer gets one email when the workspace first pays, if they have a verified email (an email, Google, GitLab or SSO sign-in, or a verified address in Organization Settings → Notifications).
- It lasts
- Self-referral: you can't use your own code. Checkout gives no coupon to a workspace the referrer is or ever was a member of, and the referral is voided at its next paid invoice, with its commissions still on hold.
- Codes in Organization Settings → Billing & Usage: owners and admins can add a referral code to a workspace that has none, within its first 30 days and before it has subscribed. The code's owner must not be, or ever have been, a member of the workspace, nor someone the caller referred, and a caller who was already referred can only bring that same referral. Five attempts per person per hour.
- Refunds and disputes:
charge.refunded,charge.dispute.createdandcharge.dispute.closedtake a commission back in proportion to the cash its invoice lost. The webhook only queues a job; the job reads the charge (and its dispute) from Stripe, then every invoice the charge's PaymentIntent paid (/v1/invoice_payments), so out-of-order events cannot leave a stale state. An open or lost dispute counts as lost; a won,warning_closedorpreventedone gives the commission back. Clawbacks followBILLING_ENABLED, notREFERRALS_ENABLED, so they continue after the program is switched off. A refund of a deleted workspace still counts. A failed Stripe read is retried at 1, 4, 16 and 64 minutes, then logged as{"event":"referral.charge_unresolved"}; re-run it withnpx convex run referralJobs:resolveChargeEvent '{"chargeId":"ch_…","kind":"refund"}'. A refund or dispute handled before its invoice's commission exists (a lateinvoice.paid) is caught when the commission accrues: that schedules one look at the invoice's payments and their charges (referralJobs:checkInvoiceCharges), retried the same way and logged as{"event":"referral.invoice_unchecked"}.refund.failed,refund.updatedandcharge.dispute.updatedare not handled: a refund that later fails, or a dispute that changes without closing, is corrected at that charge's next event or by hand.- Negative balance: a clawback after the referrer redeemed makes their balance negative. Credits already applied are not taken back; future commissions pay the difference first.
- Credit notes that only credit the customer balance (no refund) send no charge event. Void the commission by hand with
referralOps:voidCommission.
- Workspace credit: once at least $10 is available, a referrer can apply it to the bill of a workspace they own or administer that has a Stripe customer (Personal Settings → Referrals). It becomes a negative customer balance transaction with
metadata.referralRedemptionId, which Stripe takes off the workspace's next invoices, and it shows as Referral credit in that workspace's Organization Settings → Billing & Usage. The workspace must be billed in USD. Ten requests per person per hour.- Each credit is posted with a stored idempotency key (
referral-credit:<id>:1), and every attempt first looks the balance transaction up, so a retry or a crash never credits twice. Network errors, 409 and 429 responses and offline mode retry with the same key; a 5xx is never posted again, only looked up; any other 4xx fails the credit after a lookup finds nothing, and the amount returns to the referrer's balance. - A cron retries credits still processing every 15 minutes while billing is on. One that cannot be confirmed for a day after a 5xx, or that is still processing after 3 days, is logged as
{"event":"referral.redemption_stuck"}.
- Each credit is posted with a stored idempotency key (
- Moving to another workspace: until the workspace it is on subscribes, even to a trial, the referral moves to the workspace its referred person opens Checkout from, if they own it, it has never paid, and it was created after they signed up or is the one they added the code to.
- Cash payouts (
REFERRAL_PAYOUTS_ENABLED=trueon Convex and the web app): a referrer cashes out to a bank account through their own Stripe Connect account (Personal Settings → Referrals → Cash out with Stripe). See Cash payouts (Stripe Connect).
Setup
- Coupon: create a coupon, for example
referral-20-3mowithpercent_off=20,duration=repeatingandduration_in_months=3. Set its ID asSTRIPE_REFERRAL_COUPON_IDon Convex, and describe it inREFERRAL_DISCOUNT_LABELon the web app (for example20% off the first 3 paid months). Never create promotion codes for it.- The coupon's months start when the subscription is created, which is the start of a carried trial. With
BILLING_TRIAL_DAYSunder 28, 3 months cover 3 paid monthly invoices. For longer trials, setduration_in_monthsto2 + ceil((trialDays + 1) / 28)(couponMonthsNeeded(3, trialDays)insrc/referrals.ts) and word the label "at least the first 3 paid months". max_redemptionsandredeem_byare optional. When the coupon is used up, expired or deleted, Checkout continues without the discount and logs{"event":"referral.coupon_unavailable"}.- Annual prices (pricing-tiers P3.2): a repeating coupon discounts the whole first annual invoice. Use a separate
oncecoupon for annual prices, or none.
- The coupon's months start when the subscription is created, which is the start of a carried trial. With
- Settings: set
REFERRALS_ENABLED=trueon Convex and on the web app.REFERRAL_RATE_BPS,REFERRAL_MONTHSandREFERRAL_HOLD_DAYSare read on Convex. - Deploy order:
npx convex deploy --cmd '<build>'builds the web app first and pushes the Convex functions afterwards, and Vercel promotes the build only after both succeed, so forward deploys are safe. Never roll Convex back past the referral sign-up release (Phase 1) without first settingREFERRALS_ENABLED=falseon the web app: the web app would send referral codes to functions that no longer accept them, and referred sign-ins would fail.
Cash payouts (Stripe Connect)
- Accounts: Set up payouts creates an Accounts v2 connected account with the Express dashboard and the
recipientconfiguration (stripe_balance.stripe_transfers),fees_collectorandlosses_collectorset toapplication, andmetadata.userId. Stripe-hosted onboarding collects the identity, tax and bank details; OpenReview stores only the account ID, its country and its transfer status (referralPayoutAccounts). The idempotency key isreferral-account:<userId>:<COUNTRY>:<hash of contact email>, since Stripe keeps v2 keys for 30 days. - Status: the transfer status (
configuration.recipient.capabilities.stripe_balance.stripe_transfers.status) and the earliest requirement deadline are read from Stripe when Personal Settings → Referrals loads (at most once a minute per account), including the return from onboarding (?payouts=return), and again before every transfer. There is no Connect webhook or notification banner. An account onboards the first time its status isactive; after that, Continue setup opens anaccount_updatelink instead ofaccount_onboarding. - Cash out: at least $50, at most the available balance, ten requests per person per hour. Each one is a
/v1/transfersfrom the platform's balance withtransfer_group=referral-redemption-<id>andmetadata.referralRedemptionId, posted with a stored idempotency key (referral-transfer:<id>:1) after a lookup bytransfer_group, with the same retry rules as credits. Abalance_insufficientanswer keeps the cash-out processing, and once a lookup confirms no transfer exists, the next try uses a new key (…:2), because Stripe saves that answer under the old key for 24 hours. Before each post the referrer's balance is checked again: a cash-out not yet sent (paused, or waiting onbalance_insufficient) fails, returning the amount, once refunds or disputes have left the balance below zero. - Review: a cash-out that brings the referrer's cash-outs (all but failed ones) over $500 in 30 days waits in
reviewand logs{"event":"referral.payout_review"}, so splitting one doesn't skip it. Approve or reject them with the operator tools below; approving refuses when refunds or disputes since the request left the referrer's balance below zero. - Recent sign-in: setting up payouts, cashing out and opening the Stripe dashboard need a browser sign-in from the last 15 minutes. While payouts are on, so does linking another provider (Personal Settings → Account Settings), since the linked provider could later sign in fresh; the session a link starts keeps the linking session's sign-in time (
sessions.signedInAt). With an older session (or an API key) the request is refused and the web app signs the session out and asks for a new sign-in. - Switch: with
REFERRAL_PAYOUTS_ENABLED(orREFERRALS_ENABLED) off, the Cash out card is hidden, no new cash-outs are accepted, and cash-outs already processing pause (pausedAt) without a transfer. They are not reported as stuck or retried (so they never hold up credits); each 15-minute cron run logs{"event":"referral.redemptions_paused","count":n}while any wait, and sends them once the switch is back on (unless the balance check above cancels them).
Setup:
- Connect: enable Connect on the platform account (Accounts v2), complete the platform profile and the Express branding (name, icon, color), and acknowledge that the platform is liable for connected-account losses (losses are collected from the application).
- Countries: payouts go to US bank accounts only (
REFERRAL_PAYOUT_COUNTRIESinsrc/referrals.ts). Other countries need a code change and must be ones Stripe supports for cross-border payouts from the platform's country. - Funding: transfers draw from the platform's available Stripe balance, and Stripe doesn't retry a failed transfer. Under Settings → Payouts, keep a minimum balance for automatic payouts, or switch to manual payouts, or add funds with top-ups (US, UK and JP platforms). Otherwise automatic payouts sweep the balance and cash-outs wait with
balance_insufficientuntil funds arrive. - API key: add write access for Transfers, Accounts (v2) and Account Links (v2), and Login Links, to
STRIPE_SECRET_KEY's restricted key. Check the key's request log in the sandbox for denied calls. - Tax reporting: turn on Connect tax reporting and choose 1099-NEC or 1099-MISC with a tax advisor. Stripe issues no 1099-K when the application collects fees, so the platform files; the 1099-NEC/MISC threshold is $2,000 a year. Workspace credits are customer balance credits, not Connect transfers, so they don't appear in Stripe's 1099 totals.
- Turn it on: set
REFERRAL_PAYOUTS_ENABLED=trueon Convex and on the web app (where Personal Settings → Account Settings uses it to explain the 15-minute limit on linking accounts).
Operator tools
npx convex run referralOps:voidReferral '{"referralId":"…","reason":"…"}': stops a referral (abuse found by hand). Its commissions still on hold are voided; available ones stay.npx convex run referralOps:voidCommission '{"commissionId":"…","reason":"…"}': voids one commission, for example after a credit note that only credited the customer balance (no refund).npx convex run referralOps:resolveStuck '{"redemptionId":"…","outcome":"completed","stripeId":"cbtxn_…"}': settles a credit or cash-out logged as stuck, after you check Stripe by hand: the customer's balance transactions for itsreferralRedemptionId, or the transfers withtransfer_groupreferral-redemption-<id>."outcome":"failed"returns the amount to the referrer's balance; use it only when Stripe has no such object.npx convex run referralOps:approveRedemption '{"redemptionId":"…"}': sends a cash-out waiting in review.referralOps:rejectRedemption '{"redemptionId":"…","reason":"…"}'declines it and returns the amount to the referrer's balance; the referrer sees the reason in their activity.npx convex run referralJobs:refreshPayoutAccount '{"accountId":"acct_…"}': re-reads a payout account's status from Stripe.{"event":"referral.ledger_full"}: a referrer has 5000 credits and cash-outs, failed ones included. Balances read only that many, so they can't redeem anything more (andapproveRedemptionrefuses) until a running-balance table is added.- A commission job that failed is not retried. Run
npx convex run referrals:accrue '{"customer":"cus_…","subscription":"sub_…","id":"in_…","amountPaid":…,"total":…,"totalExcludingTax":…,"currency":"usd","invoiceCreated":<ms>,"paidAt":<ms>}'with the invoice's values from the Stripe Dashboard; an invoice that already has a commission is skipped. If the invoice's charge was refunded or disputed, then also runreferralJobs:resolveChargeEventfor that charge.
Guarantees
-
API version: requests pin
Stripe-Version. Invoice events are read from both the current shape (parent.subscription_details.subscription) and the older one (subscription). -
Signatures: webhooks are verified against the
Stripe-Signatureheader with a five-minute tolerance. -
Duplicates: each event ID is applied at most once.
-
Ordering: subscription events older than the last one applied are recorded as
staleand ignored, so redelivery and reordering cannot roll state back. Stripe timestamps are whole seconds, so an event from the same second as the last one is alsostalewhen it is the subscription's creation or arrives after a cancellation: an update to active that came first stays active, and a cancellation stays canceled.customer.updatedevents are ordered the same way on their own clock (customerEventCreated), so they never make a subscription event stale. -
Workspace linking: Checkout sets both
client_reference_idand subscription metadata. A subscription that claims a different workspace than its customer's is ignored.