

1// 1. Listen for subscription changes
2app.post('/webhooks/stripe', async (req, res) => {
3 const event = stripe.webhooks.constructEvent(
4 req.body, sig, secret
5 );
6
7 if (event.type === 'customer.subscription.updated') {
8 const sub = event.data.object;
9 const plan = await db.plans.findByStripePriceId(
10 sub.items[0].price.id
11 );
12 await db.entitlements.upsert({
13 customerId: sub.customer,
14 planId: plan.id,
15 features: plan.features,
16 limits: plan.limits,
17 });
18 await redis.del(`entitlements:${sub.customer}`);
19 }
20});
21
22// 2. Check entitlements on every request
23async function checkAccess(customerId, feature) {
24 let ent = await redis.get(
25 `entitlements:${customerId}`
26 );
27 if (!ent) {
28 ent = await db.entitlements.findByCustomer(
29 customerId
30 );
31 await redis.set(
32 `entitlements:${customerId}`, ent, 'EX', 300
33 );
34 }
35 const limit = ent.limits[feature];
36 const usage = await db.usage.count({
37 customerId, feature, period: 'month'
38 });
39 return usage < limit;
40}
41
42// 3. Track usage and sync to Stripe
43async function trackUsage(customerId, feature) {
44 await db.usage.insert({
45 customerId, feature, timestamp: Date.now()
46 });
47 const meterId = await db.meters.findByFeature(
48 feature
49 );
50 await stripe.billing.meterEvents.create({
51 event_name: meterId,
52 payload: {
53 stripe_customer_id: customerId,
54 value: '1',
55 },
56 });
57}
58
59// 4. Handle overrides, trials, custom plans...
60// (another 200 lines)1import { SchematicClient } from
2 "@schematichq/schematic-typescript-node";
3
4const client = new SchematicClient({ apiKey });
5
6// Check access
7const hasAccess = await client.checkFlag(
8 { company: { id: "acme-corp" } },
9 "api-calls"
10);
11
12// Track usage
13client.track({
14 event: "api-call",
15 company: { id: "acme-corp" },
16});
17
18// Schematic handles the rest:
19// webhooks, caching, usage aggregation,
20// Stripe sync, overrides, trialsDecouple pricing and billing logic from your codebase. Change plans, limits, and pricing models without deploying code.

Usage-based, credits, overages, seats, flat-rate, or hybrid. Launch and iterate on any model Stripe supports without rebuilding your billing integration.
Manage overrides and custom plans for sales-led deals. Bump limits, grant features, set expiration dates, leave notes for context. Use overrides to get customers over the line.

Version your plans and bulk-migrate customers between them. Grandfather legacy pricing without maintaining parallel code paths.
Power paywalls, usage counters, and limit alerts. Surface upgrade paths in your product with drop-in billing components.

Know who's overusing, underpaying, and ready to expand. Map usage to revenue opportunities and spot upgrade triggers automatically. Surface monetization opportunities with a unified view of billing and usage data.

Connect your Stripe account in one click. Import your products, prices, subscriptions, and customers. Bidirectional sync keeps everything up to date automatically.



Define plans, entitlements, usage-based limits, and credits in Schematic. Map them to your Stripe products. Implement the SDK to enforce access in your application.

Grant beta features, bump limits, set expiration dates, and leave notes — all without leaving the Stripe dashboard. Your sales and support teams already live in Stripe.

Real-time visibility into how every customer uses features against their plan limits. Spot overages, underuse, and expansion opportunities at a glance.

Sync your Stripe products, prices, and meters. Configure entitlements in minutes.
Not sure how Schematic fits your stack? Walk through it with the team.
