Skip to content

digital-identity-platform-docs


digital-identity-platform-docs / supabase/functions/stripe-billing

supabase/functions/stripe-billing

Fileoverview

Stripe Billing Edge Function

Handles all Stripe billing operations including checkout, plan changes, subscription sync, auto-upgrade settings, and billing portal access.

Cloudflare Architecture Context

AttributeValue
Classification🔵 BACKEND-ONLY
PositionApp Backend (not on request path)
Receives Public TrafficNo (dashboard only)
Latency SensitiveNo
Safe to RetryDepends on action (checkout: no, sync: yes)
Failure BehaviorFail-closed (returns error to user)

Endpoint

POST /stripe-billing

Auth

Required - JWT in Authorization header

Remarks

Supported actions (via action field in request body):

  • checkout: Create Stripe Checkout session for new subscription
  • change-plan: Upgrade/downgrade existing subscription
  • preview-change: Preview proration for plan change
  • update-auto-upgrade: Toggle auto-upgrade setting
  • sync-subscription: Sync subscription state from Stripe
  • portal: Create Stripe Billing Portal session

Tables touched:

  • sgtm_containers (read)
  • sgtm_container_subscriptions (read/write)
  • billing_plans (read)
  • clients (read/write)
  • client_memberships (read via RLS)

External services:

  • Stripe API for all payment operations

Type Aliases

Released under proprietary license.