Skip to main content

BuyupPeriodEndCancellation

\Benecaster\Membership\BuyupPeriodEndCancellation

Class Premium

Ends one held buy-up at the end of its current billing period. The subscriber keeps it until then, and nothing is refunded or prorated.

It has two callers, deliberately sharing one path: the subscriber’s Remove button on the account page, and a tier upgrade that moves them onto a tier that does not offer a paid buy-up they hold. A second cancellation path is how the two would drift apart — one marking Stripe and the other forgetting the grant, or benecaster_buyup_cancelled firing twice or never.

Stripe has no per-item cancel-at-period-end, so this marks the subscription item’s metadata and the grant row; the webhook cascade deletes the item when the period rolls over, and benecaster_buyup_revoked fires then. Stripe errors propagate, so the caller decides whether a failure is fatal (the Remove button) or logged and skipped (an upgrade that has already been paid for).

Neither step sends an email or raises an admin notice: not when the buy-up is set to end, and not when it actually ends. To tell the subscriber or the podcaster, listen to benecaster_buyup_cancelled or benecaster_buyup_revoked.

Constructor Dependencies

Type Description
\Benecaster\Payment\StripeSubscriptionManager Marks the buy-up's subscription item to be removed at period end.
\Benecaster\Membership\SubscriberBuyupRepository Marks the grant row as ending at period end.

Methods

Method Visibility Since Description
cancel( array $grant, int $show_id ): bool Public — Ends the grant (a benecaster_subscriber_buyups row) at period end and fires benecaster_buyup_cancelled. Returns false, and does nothing, when the grant was already set to end.