Skip to content

Legacy Logged-in Checkout

Create checkout sessions for known app users through BillStack.

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: Create an idempotent checkout.

Logged-in checkout is the default flow for authenticated users. It lets BillStack create or reuse the project customer, apply referral codes, select the provider, and return a hosted checkout URL.

Request

curl -X POST "https://billing.w3dev.app/api/billstack/teams/{teamId}/projects/{projectId}/checkout/start" \
  -H "Authorization: Bearer <private-api-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "externalId": "user_123",
    "email": "user@example.com",
    "phone": "+14155550123",
    "name": "Example User",
    "tier": "pro",
    "cycle": "annual",
    "provider": "stripe",
    "referralCode": "ABCD1234",
    "successUrl": "https://app.example.com/billing?checkout=success",
    "cancelUrl": "https://app.example.com/pricing?checkout=cancelled"
  }'

externalId, either email or phone, tier, cycle, successUrl, and cancelUrl are required.

Response

{
  "checkoutUrl": "https://checkout.stripe.com/c/pay/...",
  "customerId": "pc_...",
  "provider": "stripe",
  "intentId": "cs_..."
}

Redirect the browser to checkoutUrl.

Provider selection

This legacy v1 checkout route serves the team's default region only: it always uses the default payment provider (Stripe or Razorpay) and never takes a country. The customer's phone number never selects a provider and checkout never falls back to another one. provider is optional; if you send it, it must match the default region's provider (otherwise PAYMENT_PROVIDER_CONFLICT). A customer who is already pinned to a non-default region gets 409 REGION_REQUIRES_V2; use the v2 checkout for them.

Regions and country routing are v2 only. For v2 checkout, use team-scoped provider connections, project-scoped bindings, regions, and explicit country confirmation. v2 does not silently fall back between providers; see Multi-provider v2.

Your product app should not load provider SDK secrets. Provider credentials and webhook secrets belong in BillStack.

Referral behavior

If a referral code is present, send it in referralCode.

For logged-out users with a referral code, route them to signup/login first. After identity exists, call logged-in checkout so the referral can attach to the new customer.

Error handling

Return BillStack error messages to logs with enough context to debug externalId, tier, cycle, provider, and referral presence. Avoid logging raw API keys or provider secrets.