
To complete the final step of handling entitlements, we need to accurately track the number of credits consumed by each customer. This ensures that the credit counter decreases as templates are generated, so customers only use the credits included in their plan. That’s exactly what we’ll implement in this tutorial.

Understanding how credit-based entitlements work by tracking and decrementing usage counters each time a user generates an email template in Vibe Coding Academy's system.
Learn how billing cycle events trigger credit refreshes using Stripe's invoice.paid webhook with the subscription_cycle billing reason to reset user credits automatically.
Discover Stripe's test clocks feature for simulating future billing cycles, enabling developers to verify credit refresh logic without waiting for actual subscription periods to end.
The key to testing subscription workflows lies in manually creating corresponding database records when using Stripe test clocks, since artificial customer creation bypasses normal webhook flows.
Interactive diagram used in the video
Track customer credit usage to decrease counters when templates are generated within plan limits.
Continue your learning journey with these carefully curated courses
Learn how to connect your application to a Supabase database, then validate the setup by creating your first API endpoints to perform basic CRUD operations (Create, Read, Update, Delete).

Many third-party integrations rely on webhooks. Stripe is one of the most important examples, which makes it essential to understand how to implement webhooks correctly in your app and build reliable business logic on top of them.