Migrate from Stripe (legacy)
Replace local Stripe billing code with BillStack ownership.
Legacy (v1) API. This page describes the Stripe-first legacy API. It stays supported for existing integrations but is frozen: new features ship only in v2. Prefer v2 for new work: Existing Stripe accounts and first-time test setup.
Use this migration when your app currently creates Stripe customers, Checkout Sessions, Payment Links, webhooks, or portal sessions directly.
Target state
- Stripe credentials live in BillStack.
- Stripe webhook URL points to BillStack.
- Products, prices, subscriptions, invoices, and payment links are project scoped.
- Your app calls BillStack with a private API key.
- Your app reads entitlements instead of inspecting Stripe objects.
Step 1: Connect Stripe
When you connect a Stripe account to your BillStack team:
- Your Stripe secret key, publishable key, and webhook secret are encrypted with AES-256-GCM and stored
- BillStack creates an isolated PostgreSQL schema for your team (
stripe_team_{teamId}) - The sync engine runs migrations inside that schema
- BillStack verifies the keys by calling
stripe.accounts.retrieve()
Dashboard UI
- Log in to your BillStack dashboard
- Navigate to Team Settings > Stripe Connection
- Paste your Secret Key (
sk_live_...orsk_test_...) - Paste your Publishable Key (
pk_live_...orpk_test_...) - Paste your Webhook Secret (
whsec_...) — update this after configuring webhooks - Click Connect
API
curl -X POST "https://billing.w3dev.app/api/billstack/teams/{teamId}/stripe/connect" \
-H "Content-Type: application/json" \
-H "Cookie: <session-cookie>" \
-d '{
"secretKey": "sk_test_...",
"publishableKey": "pk_test_...",
"webhookSecret": "whsec_..."
}'Verify the connection:
curl "https://billing.w3dev.app/api/billstack/teams/{teamId}/stripe/status" \
-H "Cookie: <session-cookie>"Test vs live mode
A team has a test and a live environment, each with its own keys, webhook endpoint and synced data (see Test and live environments). Use test mode during migration:
- Connect your
sk_test_...keys in the Test keys slot (Integrations page, or/stripe/connectwith"environment": "test"). Ask_live_key is refused there. - Register the test webhook URL
https://billing.w3dev.app/api/webhooks/stripe/{teamId}/testin Stripe's test mode. - Complete all migration steps with
bs_test_API keys. - Connect your
sk_live_...keys, register the live URLhttps://billing.w3dev.app/api/webhooks/stripe/{teamId}in Stripe's live mode, and use Promote to live. Promotion copies your products, prices and settings into the live account; you do not disconnect anything.
A team whose only connected Stripe key is a test key is a test-only team, and its older bs_ API keys then act as test keys.
Disconnecting drops the team's synced data schema. BillStack re-syncs from Stripe when you reconnect and backfill.
Stripe key locations
| Key | Where to find |
|---|---|
| Secret Key | Stripe Dashboard > Developers > API keys |
| Publishable Key | Same page as above |
| Webhook Secret | Create when configuring webhooks — see Providers and Webhooks |
Step 2: Create API keys
Generate a private API key for server-to-server calls. See API Keys.
Step 3: Backfill existing data
Sync existing Stripe customers, products, and subscriptions. See Backfill Historical Data.
Step 4: Replace local Stripe calls
- Create the BillStack project for your app.
- Add
externalIdmapping for app users. - Replace local Checkout Session creation with Logged-in Checkout.
- Replace logged-out Stripe Payment Links with Public Pricing and Payment Links.
- Replace Stripe Customer Portal creation with Customer Portal and Admin.
- Replace local subscription checks with Entitlements.
- Move Stripe webhook handling to BillStack — see Providers and Webhooks.
- Remove Stripe secret environment variables from the product app.
Anonymous payment links
If your app already used Stripe Payment Links, store those URLs on BillStack prices as payment_link_url metadata. The public payment-link endpoint resolves the correct URL by tier and cycle.
Rollback
BillStack does not require destructive Stripe changes for code cutover. Keep the old app checkout code disabled behind a rollback branch or feature flag until entitlement sync is verified.