Skip to content
Get the kit

Stripe

Stripe is the kit’s default payment provider. You are the merchant of record, which means the most control and the most reach; sales tax is your responsibility (Stripe Tax can automate it, BILLING_AUTOMATIC_TAX).

Create an account at stripe.com and copy the Secret key from the API keys page. Start in test mode (sk_test_…); live mode works the same later.

The wizard’s payments step does the rest, asking for the key without echoing it, and stops with the same command when the key or the Blaze plan is missing (what it asks):

Terminal window
pnpm create extstart --payments-setup

By hand, the same work is six commands from backend/functions, in this order. No Stripe CLI is needed; the scripts drive the Stripe API. The webhook must exist before the first deploy binds its secret.

Terminal window
cp .env.example .env

In that .env, replace <your-project-id> with your Firebase project id.

Terminal window
firebase functions:secrets:set STRIPE_SECRET_KEY
Terminal window
pnpm seed:stripe
Terminal window
pnpm stripe:webhook
Terminal window
pnpm firebase:deploy
Terminal window
pnpm run doctor

Then a test checkout: Verify.

  • seed:stripe creates the catalog by lookup key: premium_monthly, premium_yearly, premium_lifetime, premium_metered_monthly, and the packs credits_pack_small / credits_pack_large. Change amounts freely in the Stripe dashboard: the backend resolves by lookup_key only and the extension shows what the provider returns, so no copy needs updating (see prices come from your provider). The keys must match site.config.ts → pricing.plans. Rerunning is a safe no-op, except that an archived product behind a seeded price is reactivated, since checkout refuses it while the key still resolves.
  • stripe:webhook registers …/api/billing/webhook with the events the backend handles and stores the signing secret. Rerunning is a safe no-op.
  • firebase:deploy is the one deploy: the API function, the Firestore rules, and Hosting: your website (the site template) with the checkout success, cancel, and portal return pages, the sign-in fallback, and the uninstall survey next to it (backend/firebase-hosting). The functions deploy runs with --force: the first deploy of a project applies the Firebase CLI’s default cleanup policy for function container images (older than one day are deleted) instead of stopping to ask, and a function you remove from the source is deleted without a confirmation. Change the policy any time with firebase functions:artifacts:setpolicy --days N.
  • doctor checks project, secrets, deployed API, webhook, and that every plan the config sells is on sale in the catalog the extension reads (GET /billing/prices), naming the fix for one that is not (never seeded, or its price or product archived). Run it whenever billing misbehaves.

Non-secret configuration lives in backend/functions/.env: BILLING_SUCCESS_URL, BILLING_CANCEL_URL, BILLING_PORTAL_RETURN_URL, BILLING_TRIAL_DAYS, BILLING_AUTOMATIC_TAX, BILLING_ALLOW_PROMO_CODES. BILLING_TRIAL_DAYS starts a trial on every eligible subscription checkout, so it ships at 0 and must equal the days of a trial: { days, card: true } in paywall.config.ts: the wall advertises one number, Stripe enforces the other, and pnpm run doctor flags a mismatch.

4242 4242 4242 4242 (success), 4000 0000 0000 9995 (declined), 4000 0027 6000 3184 (3DS challenge). Any future expiry/CVC.

backend/functions/.secret.local
STRIPE_SECRET_KEY=sk_test_…
STRIPE_WEBHOOK_SECRET=whsec_… # printed by `pnpm stripe:listen` on start
Terminal window
pnpm serve
pnpm stripe:listen

serve starts the functions, Firestore, and auth emulators; stripe:listen forwards test-mode events to the emulated webhook.

Point WXT_API_URL at http://127.0.0.1:5001/<project>/us-central1/api while testing locally. Prefer real Checkout sessions with test cards over stripe trigger; they exercise the uid-metadata path end to end.