Feat/multi item subscriptions
SI
4mo ago+5367+5367+0123456789012345678901234567890123456789-151-151-012345678901234567890123456789
Summary
- Extend
subscribe()with optionaladdOnPlanIdsso a base plan and add-ons share one Stripe Checkout session / subscription - Persist Stripe subscription item IDs and handle multi-item webhook updates, renewals, upgrades, and downgrades
- Add metered pricing support and docs/e2e coverage for combined checkout and add-on flows
Summary by cubic
Add combined checkout for base plans and add-ons under one Stripe subscription and payment. Adds metered usage billing with usage reporting, hardens multi-item flows for reliability, and adds a tagged-release publish workflow.
-
New Features
subscribe()supportsaddOnPlanIdsto combine base + add-ons into one Stripe Checkout/subscription.- Persist provider subscription item IDs and process multi-item webhooks for renewals, upgrades/downgrades, deletions; reject removing the only item; reconcile out-of-band item removals.
- Metered pricing: define plans with
price: { meteredBy, unitAmount, interval }and report usage viareportUsage(). - New methods:
addAddOn()andremoveAddOn()to attach/detach add-ons on active subscriptions. - Reliability and validation: de-dup/limit
addOnPlanIds(max 10); serialize add-on attach with an advisory lock and idempotency; paginate Stripe subscription items; reject empty checkout products; omit quantity for metered prices; enforceunitAmount >= $0.01; require metered products in usage checks; surface clearPROVIDER_OPERATION_UNSUPPORTEDwhen provider doesn’t implement optional add/remove/report operations.
-
Migration
- Run
paykitjs pushto apply0003_add_subscription_item_idand0004_add_metered_pricing. - Re-sync products so Stripe meters and metered prices are created for metered plans.
- If you maintain a custom provider: update
createSubscriptionCheckoutto acceptproviderProducts(array). Implement (or explicitly not support)addSubscriptionItem,removeSubscriptionItem, andreportUsageEvent; unsupported operations will throw a clear error.
- Run
Summary by CodeRabbit
-
New Features
- Combine base plans and add-ons in one checkout.
- Add or remove add-ons from active subscriptions.
- Support Stripe metered pricing and usage reporting.
- Preserve subscription items during upgrades, downgrades, renewals, and cancellations.
- Provide clearer errors for invalid subscription and usage operations.
-
Documentation
- Added guidance for add-ons, combined checkouts, metered billing, usage reporting, quotas, and webhook behavior.
-
Tests
- Added end-to-end coverage for add-ons, metered usage, renewals, plan changes, and subscription reconciliation.
-
Chores
- Added automated package publishing for versioned releases.