Sync prices
1. Overview
This script synchronizes subscription plans and prices defined in supabase/data/*.csv to the Stripe environment (Test/Prod).
It ensures that the CSV files remain the Single Source of Truth (SSOT) for pricing data.
2. Prerequisites
-
Deno installed (v1.37+ recommended).
-
Stripe Secret Key (
STRIPE_SECRET_KEY) set in.envorstripe/.env.
3. Usage
Run the script using deno run from the project root.
# Run with local .env configuration
deno run --allow-all stripe/scripts/sync-prices.ts
4. Logic
-
Sync Products: Reads
subscription_plans.csvand creates/updates Stripe Products.-
Matches Products using
metadata['app_plan_id'].
-
-
Sync Prices: Reads
subscription_plan_prices.csvand creates Stripe Prices.-
Matches Prices using
lookup_key(Format:{plan_id}_{currency}_stripe). -
Updates are idempotent: If a Price with the same amount exists, it skips. If the amount differs, it archives the old Price and creates a new one.
-