feat(paykit): add Stripe currency support
Merged
MA
5mo ago+1985+1985+0123456789012345678901234567890123456789-20-20-01234567890123456789
Summary
- add global Stripe currency support for
usdandeur - persist product price currency and backfill existing paid products to
usd - create a new Stripe Price when amount, interval, or currency changes
- add focused unit coverage and EUR product-sync E2E coverage
Tests
- pnpm --filter paykitjs typecheck
- pnpm test:unit
- pnpm --filter paykitjs build
- pnpm format:check
- pnpm lint
- PAYKIT_ALLOW_UNSIGNED_PAYLOADS=1 E2E_STRIPE_WHSEC=whsec_dummy pnpm --filter e2e exec vitest run --project=cli cli/push.test.ts
- full Stripe E2E earlier: 19 files / 21 tests passed
No release/changset in this PR; release will happen separately.
Summary by cubic
Adds global Stripe currency support for usd and eur. Products now store priceCurrency, plan hashes include currency, syncing/subscriptions handle currency changes, and the CLI formats EUR prices.
-
New Features
- Add
stripe.currencyoption (usdoreur, defaultusd) with strict lowercase 3-letter validation. - Normalize paid plans with the configured currency and include it in plan hashes; persist
priceCurrencyon products and backfill existing paid plans tousd. - Create a new Stripe Price when amount, interval, or currency changes; provider uses the plan’s currency for price creation and the configured currency for invoices.
- Handle cross-currency paid plan changes by creating a new checkout-backed subscription.
- Improve CLI
formatPriceto localize currency and support EUR. - Resolve stored products by semantic plan match when only the hash changed to avoid unnecessary churn.
- Add
-
Migration
- Run DB migration
0002_add-product-price-currency. - Re-run product sync (e.g.,
paykitjs push) to create currency-specific Stripe Prices (setstripe.currencytoeurif needed, then push).
- Run DB migration
Summary by CodeRabbit
Release Notes
- New Features
- Added multi-currency product pricing with support for USD and EUR.
- Plans now carry a currency setting where applicable, affecting hashing and product matching.
- Switching between paid plans of different currencies now uses checkout flow.
- Improvements
- Price display uses locale-aware currency formatting.
- Product sync now tracks and syncs the plan’s currency.
- Validation
- Stripe currency input is now strictly validated (lowercase 3-letter, supported set).
- Database
- Added
price_currencyto products and initialized existing records.
- Added
- Tests
- Expanded formatting, schema, and end-to-end sync coverage (including EUR).