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).
Set up
Section titled “Set up”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):
pnpm create extstart --payments-setupBy 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.
cp .env.example .envIn that .env, replace <your-project-id> with your Firebase project
id.
firebase functions:secrets:set STRIPE_SECRET_KEYpnpm seed:stripepnpm stripe:webhookpnpm firebase:deploypnpm run doctorThen a test checkout: Verify.
What the scripts do
Section titled “What the scripts do”seed:stripecreates the catalog by lookup key:premium_monthly,premium_yearly,premium_lifetime,premium_metered_monthly, and the packscredits_pack_small/credits_pack_large. Change amounts freely in the Stripe dashboard: the backend resolves bylookup_keyonly and the extension shows what the provider returns, so no copy needs updating (see prices come from your provider). The keys must matchsite.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:webhookregisters…/api/billing/webhookwith the events the backend handles and stores the signing secret. Rerunning is a safe no-op.firebase:deployis 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 withfirebase functions:artifacts:setpolicy --days N.doctorchecks 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.
Billing knobs
Section titled “Billing knobs”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.
Test cards
Section titled “Test cards”4242 4242 4242 4242 (success), 4000 0000 0000 9995 (declined),
4000 0027 6000 3184 (3DS challenge). Any future expiry/CVC.
Local dev loop (emulators)
Section titled “Local dev loop (emulators)”STRIPE_SECRET_KEY=sk_test_…STRIPE_WEBHOOK_SECRET=whsec_… # printed by `pnpm stripe:listen` on startpnpm servepnpm stripe:listenserve 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.