feat: clear grace period on invoice.payment_succeeded

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ovidiu U
2026-04-23 10:37:50 +01:00
parent b9d457578c
commit 2078c4b83e
2 changed files with 34 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ final class HandleStripeWebhook
'customer.subscription.created',
'customer.subscription.updated' => $this->bustPlanCache($user),
'customer.subscription.deleted' => $this->handleSubscriptionDeleted($user),
'invoice.payment_succeeded' => $this->handlePaymentSucceeded($user),
default => null,
};
}
@@ -44,6 +45,12 @@ final class HandleStripeWebhook
$this->bustPlanCache($user);
}
private function handlePaymentSucceeded(User $user): void
{
$user->forceFill(['grace_period_until' => null])->save();
$this->bustPlanCache($user);
}
private function bustPlanCache(User $user): void
{
Cache::tags(['plans'])->forget("plan_for_user_{$user->id}");