Skip to content

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:

  1. Your Stripe secret key, publishable key, and webhook secret are encrypted with AES-256-GCM and stored
  2. BillStack creates an isolated PostgreSQL schema for your team (stripe_team_{teamId})
  3. The sync engine runs migrations inside that schema
  4. BillStack verifies the keys by calling stripe.accounts.retrieve()

Dashboard UI

  1. Log in to your BillStack dashboard
  2. Navigate to Team Settings > Stripe Connection
  3. Paste your Secret Key (sk_live_... or sk_test_...)
  4. Paste your Publishable Key (pk_live_... or pk_test_...)
  5. Paste your Webhook Secret (whsec_...) — update this after configuring webhooks
  6. 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:

  1. Connect your sk_test_... keys in the Test keys slot (Integrations page, or /stripe/connect with "environment": "test"). A sk_live_ key is refused there.
  2. Register the test webhook URL https://billing.w3dev.app/api/webhooks/stripe/{teamId}/test in Stripe's test mode.
  3. Complete all migration steps with bs_test_ API keys.
  4. Connect your sk_live_... keys, register the live URL https://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

KeyWhere to find
Secret KeyStripe Dashboard > Developers > API keys
Publishable KeySame page as above
Webhook SecretCreate 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

  1. Create the BillStack project for your app.
  2. Add externalId mapping for app users.
  3. Replace local Checkout Session creation with Logged-in Checkout.
  4. Replace logged-out Stripe Payment Links with Public Pricing and Payment Links.
  5. Replace Stripe Customer Portal creation with Customer Portal and Admin.
  6. Replace local subscription checks with Entitlements.
  7. Move Stripe webhook handling to BillStack — see Providers and Webhooks.
  8. Remove Stripe secret environment variables from the product app.

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.