Test and live environments
How a team's test and live environments work in the dashboard, with its default payment provider, separate test and live keys, and the choice between the provider's test mode and the BillStack sandbox.
Every team has a test environment and, once it is promoted, a live environment. Test data and live data never mix: customers, products, prices, subscriptions, invoices and API keys belong to exactly one environment.
Dashboard addresses
| Environment | Address |
|---|---|
| Live | /v2/{team}/... |
| Test | /v2/{team}/test/... |
These are the addresses of the current (v2) dashboard. The legacy dashboard keeps its old addresses, /dashboard/{team}/... for live and /dashboard/{team}/test/... for test, and every existing /dashboard/... bookmark keeps working. Use the user menu to switch between the two dashboards; a team that has only Stripe-mirror data opens the legacy dashboard by default.
Existing live addresses and bookmarks do not change. Pages are the same in both environments; the address decides which data they show. Every test page shows a Test mode banner, and the Test / Live switcher in the top bar takes you to the same page in the other environment.
test is therefore reserved: a project cannot use test as its slug.
New teams start in test
A new team has no live environment yet. You can create as many teams as you like: every new team starts in test, so creating teams is free and has no limit.
- Create the team and choose its default payment provider (Stripe or Razorpay). You land in the test environment.
- You can change the default provider until you connect keys. A team can later connect a second payment provider (one account of each) and give it a region; the default provider keeps serving every country no region claims. RevenueCat is a separate entitlement source and does not count toward that choice. See Regions.
- Connect the provider's test keys first, or skip them and use the BillStack sandbox, which needs no provider keys.
- Create
bs_test_API keys and integrate against the test environment.
The Live entry in the switcher stays closed, and the live keys slot on the Integrations page stays locked, until the team is promoted to live. The switcher shows Promote to live in its place.
Promote to live
Promote to live opens a dialog that checks the team is ready, previews what will change, and runs the promotion in the background.
Before you can promote, the dialog checks that:
- the team has chosen its default payment provider;
- live keys are connected and the provider accepts them (
sk_live_for Stripe,rzp_live_for Razorpay); - the live account has a webhook endpoint at
/api/webhooks/{provider}/{teamId}with a signing secret saved, delivering the events BillStack uses; - the team owner has a live team allowance available (
LIVE_TEAM_LIMIT).
If keys are missing, the dialog shows the same form as the Integrations page.
Live team allowance. The free plan includes 1 live team per owner. If you already own a live team, the Live team allowance available check fails on your other teams and they stay in test, where you can keep building with no limit. Only live teams you own count: teams where you are a member or admin, test-only teams and suspended teams do not. To raise the limit, contact support.
The limit applies only when a team goes live for the first time:
- Teams that were already live are not affected.
- Syncing a live team again is never blocked, even if its owner owns other live teams.
A promotion copies configuration, not data:
| Copied from test to live | Not copied |
|---|---|
| Products, prices and tiers (created again in your live account) | Customers, subscriptions, invoices and payments |
| Tier features, entitlement policies and add-ons | Checkout intents and entitlement snapshots |
| Referral program and analytics settings | Referral codes, referrals, webhook events |
| Lifetime deal campaigns and their steps, as a draft | Campaign sales, sold units, payment rejections and payment links |
| API keys: create live keys after promoting |
A promoted lifetime campaign arrives in live as a draft with no sales. Activate it in the live environment when you want to sell: activating creates its Stripe Payment Links in your live account. Syncing again only updates a live campaign's name, availability window and sold-out price. Its status, steps and sales are never changed.
The preview lists every product, price and setting that would be created, updated or left alone. Your test environment is only read, so it keeps working.
If a promotion stops (for example the provider is unavailable), nothing already copied is lost: Resume continues where it stopped, and nothing is created twice.
Syncing again
Prices managed on the project Catalog page are published to each environment on their own: use Publish to live on a price (or catalog.publishPriceVariant with mode: "live" and a live key; a test key is refused). Sync catalog to live below copies the project's legacy Stripe prices from the Billing tab.
Once a team is live, the switcher offers Sync catalog to live. It runs the same promotion again: new and changed products, prices and settings are added or updated, and nothing in live is ever deleted. A live price is never edited. If its amount or billing interval differs from the test price, a new price version is created and the old one stops selling when it has no subscribers; a price with subscribers is left exactly as it is, so existing customers are unaffected.
Pull live catalog into test
Once a team is live, the reverse of a promotion is also available: Pull live catalog copies the live catalog into the test environment, so test can be refreshed from what is live. It appears in the Test / Live switcher and in the Test mode banner, only while you are viewing the test environment of a team that is live.
The dialog checks that the team is ready (it is live, its test keys are connected and verified as test keys or the team is on the BillStack sandbox, and no promotion or pull is running), previews what will change, and runs the pull in the background. Live is only read and stays exactly as it is.
| Copied from live to test | Not copied |
|---|---|
| Products, prices and tiers (created again in your test account) | Customers, subscriptions, invoices and payments |
| Tier features, entitlement policies and add-ons | Checkout intents and entitlement snapshots |
| Referral program and analytics settings | Referral codes and referrals |
| Lifetime deal campaigns and their steps, as a draft | Regional alternate prices, API keys |
The pull writes to the sandbox your test environment runs on. With the provider sandbox it creates the products and prices in your Stripe test account; with the BillStack sandbox it creates them in the sandbox catalog and needs no test keys. The dialog has a Target selector: choosing the other sandbox runs the switch first (typed confirmation, test data reset) and then the pull.
A pull follows the same rules as a sync to live: it adds and updates, and nothing in test is ever deleted. A test price whose amount or billing interval differs from the live price gets a new price version; a price with subscribers is left as it is. Pulling again when test already matches live changes nothing, and objects that were promoted from test are matched, not duplicated.
If a pull stops, Resume continues where it stopped and nothing is created twice. A pull never changes whether the team is live.
Sample data
A new test environment has no customers, so the dashboard looks empty. On the Overview page of the test environment, the Sample data card creates a few fake customers with subscriptions in your test environment (in your Stripe test account on the provider sandbox, in the sandbox itself on the BillStack sandbox), so you can see the dashboard with data. Once the environment has customers the card shrinks to a compact strip with Add sample data and Remove sample data.
- What it creates (provider sandbox): 5 customers (
Sample Customer 1, ... withsample+...@example.comemails), each with a Stripe test card and one subscription. The subscriptions are spread over the active recurring prices of the project's test catalog. From 4 customers on, the last one gets a test card whose charges fail, so you also get a failed payment to look at. - Needs: a project with at least one active recurring price in its test catalog (otherwise the request is refused with
TEST_CATALOG_EMPTY) and permission to manage providers. On the provider sandbox it also needs Stripe test keys, and Razorpay teams do not have this feature yet: the buttons are disabled and say why. On the BillStack sandbox it works for Stripe and Razorpay teams alike. - Safe by construction: it only ever writes to the key in the Test slot, refuses anything that is not a test key, and stops at the first object Stripe reports as live. It never touches live data.
- Marked: every object carries
billstack_sample: "true". Remove sample data deletes only customers with that marker (their subscriptions are cancelled and their cards detached), never any other customer. - Appears shortly: the dashboard reads the mirror of your Stripe account, so a sync is queued right after the data is created and the numbers show up when it finishes.
On the BillStack sandbox the same card creates the fake customers and subscriptions directly in the sandbox, with no Stripe account involved, and they appear in the dashboard straight away (there is no sync to wait for). The card offers Attach to a new test clock: the samples are then billed on simulated time, so advancing the clock on the Test clocks page runs their renewals, trial ends and retries. Remove sample data removes the samples and drops the sample clock once it is empty.
These are dashboard session routes, not legacy integration APIs. The API is POST /api/billstack/teams/{teamId}/environments/sample-data with { "projectId": "...", "count": 5 } (count is 1 to 10, default 5; add "withClock": true on the BillStack sandbox) and DELETE with an optional { "projectId": "..." }. Both need a signed-in dashboard session; API keys are not accepted.
Provider sandbox or BillStack sandbox
A team's test environment runs on one of two sandboxes. You choose per team, and you can change your mind later.
| Provider sandbox (default) | BillStack sandbox | |
|---|---|---|
| What simulates the payments | Your payment provider's own test mode (Stripe or Razorpay test keys) | BillStack itself |
| Needs provider keys | Yes, test keys in the Test keys slot | No |
| Hosted checkout | The provider's checkout, with the provider's test cards | A BillStack checkout page at /sandbox/checkout/{token}, with the BillStack test cards |
| Finishing a payment without a browser | No | Yes, the simulate API |
| Moving time (renewals, trial ends, dunning) | Only by waiting, or with the provider's own tooling | Test clocks: freeze time, advance it, and the renewals, trial ends, invoices, payment attempts and retries run in order |
| Fidelity | The most faithful to live behaviour | A simulation of the common flows; see limitations |
| Works on Razorpay teams | Yes | Yes |
Pick the provider sandbox to check how your provider really behaves before you go live. Pick the BillStack sandbox for fast end-to-end tests: an agent or a CI job can create a checkout, pay it with the simulate API and read the entitlement in seconds, without keys, a browser or waiting. To test renewals and failed payments, create sample data on a test clock in the dashboard, then advance the clock. Customers created by your own API checkouts renew on real time, not on a clock.
The BillStack sandbox is test mode only. It is never a live payment provider, it is never used by a bs_live_ key, and it does not appear in the Live environment. Everything in the dashboard and the API keeps working the same way: customers, subscriptions, invoices and entitlements show up on the same pages, and checkouts are created with the same endpoints. Only the payment itself is simulated. Details, test cards, clocks and the simulate API are on BillStack sandbox.
The current choice is shown as a BillStack sandbox badge next to the Test mode banner (the provider sandbox has no badge) and in the Sandbox section of the Integrations page.
Switching sandbox
Open the Sandbox section on the Integrations page of the test environment, choose the other sandbox and confirm by typing reset test data. A team that has no test billing data yet (a brand-new team, which is how the setup wizard switches it) needs no confirmation. You need the permission to manage providers; API keys cannot switch (the call is PUT /api/billstack/teams/{teamId}/environments/sandbox with { "kind": "provider" | "native", "confirm": "reset test data" }, where confirm may be left out for a team without test billing data, and needs a signed-in dashboard session).
Switching resets the test environment's billing data and keeps its configuration:
| Reset | Kept |
|---|---|
| Test customers, subscriptions, invoices and entitlement snapshots | Products, prices, tiers, entitlement policies and referral settings of the test catalog |
| The test mirror of your provider account | Your API keys, the provider keys you connected and every region |
| Test payments and entitlement grants recorded from the provider events | Everything in the Live environment, untouched |
| Everything in the BillStack sandbox, when you leave it (customers, subscriptions, clocks, checkout sessions) |
After the reset the test catalog is linked to the new sandbox: the live catalog is pulled in first when the team is live, and the existing test catalog is published to the new sandbox either way, so checkout works straight away. A customer that existed before the switch does not exist afterwards; create new ones, or use sample data.
If a switch fails, the previous sandbox is restored and the test catalog is linked back to it. If a switch is interrupted (for example the request timed out), choose the sandbox your test environment shows again: the call finds the unfinished switch, links the test catalog and, for a live team, pulls the live catalog, without resetting any data ({ "status": "repaired" }). Asking for the sandbox you are on when nothing is unfinished changes nothing ({ "status": "unchanged" }).
The switch is refused while a promotion, a pull or a clock advance is running (SWITCH_BLOCKED). If it fails half-way (SWITCH_FAILED) the previous sandbox is restored and you can repeat it. The switch only ever touches test data: it cannot change live data, keys or configuration.
Limitations of the BillStack sandbox
The BillStack sandbox simulates the common billing flows, not every provider feature.
Included: one-time payments and recurring subscriptions (daily, weekly, monthly and yearly intervals, with month-end handling), trials, cancel at period end and immediate cancel, renewal invoices, payment attempts driven by the test cards, simulated 3D Secure, retries after a failed renewal, full and partial refunds, and test clocks.
Deferred (not simulated yet): proration and plan changes on a live subscription, quantities above 1, coupons and discounts, tax, currency conversion, metered billing, disputes, payment-method update flows, and a customer portal. A BillStack-hosted portal session answers PORTAL_UNSUPPORTED, and a checkout for more than one unit answers QUANTITY_UNSUPPORTED.
Provider surfaces that are not available. These features call your payment provider directly, and a team on the BillStack sandbox has no provider test account. They answer 409 NATIVE_SANDBOX_UNSUPPORTED through the API and show Not available in the native sandbox in the dashboard, and nothing falls back to Stripe:
- referral credit payouts and the referral import;
- adding, listing, removing or defaulting a customer's saved cards through the dashboard, and setup intents;
- the Stripe publishable key of the team;
- the sample data generator for the provider sandbox (the BillStack sandbox has its own, below);
- dashboard detail pages that read a Stripe object straight from the provider.
Switch to the provider sandbox to use these in test.
Test keys and live keys
The Integrations page shows each of the team's payment providers with two slots, Test keys and Live keys. A key must match its slot: a sk_live_ key is refused in the Test slot and a sk_test_ key in the Live slot, with a message that names the mix-up. Regions follow the same split: a region is draft or active separately in the test and live environments.
Teams that were live before environments existed keep their live setup unchanged. Their test environment is always available alongside it.
Existing teams
If your team was live before environments existed, nothing you integrated changes:
- Your
bs_andpk_API keys keep working and are live keys. https://billing.w3dev.app/api/webhooks/stripe/{teamId}(and the Razorpay equivalent) stays your live webhook URL.- Your live dashboard addresses (the legacy
/dashboard/{team}/...ones) and your mirrored Stripe data are unchanged. - Your test environment is available next to it. Connect test keys in the Test keys slot, register
.../{teamId}/testin the provider's test mode and createbs_test_keys. See Providers and webhooks.
A team whose only connected Stripe key is a test key (sk_test_) is treated as a test-only team: its dashboard moves to the test environment, its earlier bs_ keys act as test keys, and it goes live by connecting live keys and using Promote to live.
See API keys for how a key selects its environment on API requests.