feat: bust plan cache on customer.subscription.updated
This commit is contained in:
@@ -24,7 +24,8 @@ final class HandleStripeWebhook
|
|||||||
}
|
}
|
||||||
|
|
||||||
match ($type) {
|
match ($type) {
|
||||||
'customer.subscription.created' => $this->bustPlanCache($user),
|
'customer.subscription.created',
|
||||||
|
'customer.subscription.updated' => $this->bustPlanCache($user),
|
||||||
default => null,
|
default => null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,3 +28,15 @@ it('ignores subscription.created when the user is not found', function (): void
|
|||||||
|
|
||||||
expect(true)->toBeTrue();
|
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();
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user