Swapping Plans
TheSwapPlan action changes a subscription’s plan mid-cycle. It handles proration, reconciles PlanItem quantities, and syncs with the gateway — all inside a database transaction.
Basic plan swap
- Computes a proration adjustment based on the configured strategy
- Updates the subscription at the gateway
- Reconciles
SubscriptionItemrecords for PlanItems (adds, removes, or updates quantities) - Updates the local subscription record
- Fires
SubscriptionUpdated
Proration strategies
The strategy is set globally inconfig/subscribd.php and can be overridden per-swap via the options array:
| Strategy | Behaviour |
|---|---|
now | Immediate prorated credit/charge (default) |
renewal | New price applies at next renewal; no immediate charge |
none | New price at next renewal; no credit |
ProrationEngine computes the adjustment and applies it via a charge or credit balance sync.
See Proration for a detailed breakdown with worked examples.
Overriding PlanItem quantities on swap
Pass aplan_items map to set specific quantities for the new plan’s items:
- Items present on both the old and new plan:
price_snapshotis updated; quantity uses the override if provided, otherwise the existing quantity is preserved. - Items absent from the new plan: the
SubscriptionItemis deleted. - Items new on the new plan: quantity uses the override if provided, otherwise the PlanItem’s
included_quantity. - The gateway base item (with
plan_item_key = null) is never touched by reconciliation.
Swap on a named subscription slot
Listening to swap events
SwapPlan fires SubscriptionUpdated on success:
Preventing swaps in your UI
Validate before callingSwapPlan to enforce business rules:
Using the SubscriptionManager Livewire component
Thesubscription-manager component handles plan swapping in the UI automatically, including a confirmation modal and proration preview:
Next steps
- Proration — Deep dive into all three proration strategies
- Canceling — Cancel immediately or at period end
- Subscription Status — Full status and date reference