feat: bust plan cache on customer.subscription.updated

This commit is contained in:
Ovidiu U
2026-04-23 10:31:07 +01:00
parent a39d4b1b94
commit 25b79f095b
2 changed files with 14 additions and 1 deletions

View File

@@ -28,3 +28,15 @@ it('ignores subscription.created when the user is not found', function (): void
expect(true)->toBeTrue();
});
it('busts the plan cache on customer.subscription.updated', function (): void {
$user = User::factory()->create(['stripe_id' => 'cus_updated_1']);
Cache::tags(['plans'])->put("plan_for_user_{$user->id}", 'stale', 3600);
(new HandleStripeWebhook)->handle(new WebhookReceived([
'type' => 'customer.subscription.updated',
'data' => ['object' => ['customer' => 'cus_updated_1']],
]));
expect(Cache::tags(['plans'])->get("plan_for_user_{$user->id}"))->toBeNull();
});