Add subscription quantity support
Closed
PA
5mo ago+342+342+012345678901234567890123456789-9-9-0123456789
Summary
- Add optional subscription quantity support to subscribe input and provider calls
- Pass quantity through Stripe checkout, create, update, and scheduled changes
- Sync subscription item quantity from provider/webhooks into the existing local subscription quantity column
Out of scope
- Checkout command idempotency keys
- Resuming open Checkout Sessions
- Automatic tax, Tax ID, or billing address collection
- App-specific organization or entitlement logic
Test Plan
- pnpm test:unit
- pnpm --filter paykitjs typecheck
- pnpm lint
- pnpm --filter paykitjs build
Summary by cubic
Add end-to-end subscription quantity support. Quantity flows from the subscribe API through Stripe Checkout/create/update/scheduled changes, and is stored and synced in the local subscription.
-
New Features
- Subscribe API accepts optional quantity (positive integer), default 1.
- Stripe provider sends quantity to Checkout line items, direct create, update, and schedules; normalizes quantity on reads.
- Same-plan quantity changes update the active subscription in place.
- Webhooks, scheduled activations, and local writes persist and emit quantity.
-
Migration
- Provider interface now requires a quantity param for
createSubscriptionCheckout,createSubscription,updateSubscription, andscheduleSubscriptionChange. Update custom providers/callers accordingly. - If using the public
subscribeendpoint, no changes are required (quantity defaults to 1).
- Provider interface now requires a quantity param for
Summary by CodeRabbit
- New Features
- Subscription flows now support selecting a quantity for plans.
- Quantity is now carried through checkout, subscription updates, scheduled changes, and webhook-based syncs.
- Bug Fixes
- Existing subscriptions now keep the correct quantity when changing between the same plan.
- Subscription details and billing state now stay aligned with the selected quantity.
- Tests
- Added coverage for quantity validation and for provider/database sync behavior.