CancelSubscription handles ending a subscription. The default behavior cancels at the end of the current billing period, giving the subscriber access through the period they have already paid for. You can also cancel immediately when access should end right away. Both paths update the gateway record and persist the status change in your database before firing SubscriptionCanceled.
Calling styles
- Facade
- Direct action
Use
cancel() or cancelSubscription() on a BillableContext. Both methods delegate to CancelSubscription internally.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
$subscription | Subscription | Yes | The subscription to cancel |
$immediately | bool | No | false = cancel at period end; true = cancel now. Defaults to the value of config('subscribd.cancel_policy') |
Grace period behavior
When you cancel at period end, the subscription enters a grace period — it retainsstatus = 'grace' until the current billing period expires. During the grace period:
$user->subscribed('default')returnstrue$user->onGracePeriod('default')returnstrue- Entitlement checks continue to pass
- The subscriber can resume the subscription (see below)
'canceled'.
Resuming during the grace period
A subscriber who cancels at period end can change their mind and reactivate before the period expires. Callresume() on the facade or use the ResumeSubscription action.
Subscription query scopes
Use Eloquent query scopes to find subscriptions in specific states.Immediate cancellation bypasses the grace period entirely. The subscription moves directly from
'active' or 'trialing' to 'canceled' and the subscriber loses access immediately.Global cancel policy
You can set the default cancellation behavior inconfig/subscribd.php. The per-call $immediately parameter always takes precedence.
Events fired
SubscriptionCanceled is dispatched after the cancellation is recorded. Use it to revoke access, notify the subscriber, or clean up associated resources.