From Zero to Production: Building Enterprise Billing in 6 Weeks
How I built a complete subscription billing system for a hospitality SaaS platform serving 20,000+ locations, featuring per-location pricing, multi-tier subscriptions, free trials, and feature gating-all with zero billing errors.

Project Overview
A hospitality SaaS platform needed a robust subscription system to monetize their growing customer base across multiple locations. Working solo, I built a complete Stripe-powered billing system handling three subscription tiers, per-location quantity-based pricing, 30-day free trials, and dynamic feature gating-all in 6 weeks.
Background & Context
The platform operates a freemium SaaS model serving bars and restaurants with inventory management software. Revenue comes from two paid tiers (Essential at $79-99/mo and Professional at $129-149/mo) with per-location pricing. The free tier is limited to one location, while paid tiers support unlimited locations with each location billed separately.
Key Challenges
Building Testing Infrastructure from Scratch
The existing codebase had no local testing environment for billing operations. There was no way to test webhook events, billing failures, edge cases, or subscription lifecycle events without affecting production data. This made development extremely risky and slow.
Rebuilt the entire testing infrastructure from the ground up. Created a comprehensive test environment supporting Stripe test mode, webhook event simulation, failure scenario testing, and edge case validation. Implemented automated testing workflows for subscription changes, location additions/removals, and trial conversions. This transformed development from risky production testing to safe, iterative local development.
Dynamic Subscription Schedule Management
Users frequently change their billing setup-adding locations, removing locations, upgrading tiers, downgrading tiers, or switching between monthly and annual billing. Each operation required different Stripe schedule logic: some needed schedule cancellation, others needed modification, and some required creating new schedules entirely. Handling all permutations correctly while avoiding billing gaps or double-charges was complex.
Implemented a sophisticated schedule management system that determines the correct operation based on current state and desired state. Created decision trees for upgrade/downgrade scenarios, location quantity changes, and billing frequency switches. Used Stripe Schedules API to handle future-dated changes seamlessly, ensuring prorated billing calculations and preventing edge cases like overlapping subscriptions or missed billing cycles.
Per-Location Quantity-Based Billing
The pricing model charges per location-one location on Free plan, unlimited locations on paid plans with each location billed separately. This required tracking location count as a Stripe subscription quantity, handling additions/removals mid-cycle with proper proration, and preventing billing errors when users rapidly add/remove locations.
Leveraged Stripe's quantity-based subscription model where each subscription item quantity represents the number of active locations. Built an internal API that syncs location count to Stripe in real-time, automatically updating subscription quantities and triggering prorated billing adjustments. Implemented atomic operations to prevent race conditions when multiple locations are added/removed simultaneously.
Real-Time Feature Gating with Stripe State
The application needed to instantly enable/disable features based on subscription tier (e.g., POS integrations only on Pro, unlimited reporting on Essential+). Feature access had to reflect Stripe subscription state in real-time, handling scenarios like payment failures, trial expirations, downgrades, and cancellations without manual intervention.
Built an internal feature gating API that queries Stripe subscription status as the source of truth. Webhook automation updates local database state when subscription events occur (payment success/failure, trial end, cancellation). Application checks subscription tier before rendering premium features, with graceful fallbacks and upgrade prompts for locked features. This ensures feature access always matches billing state with zero manual reconciliation.
Trial Management with Early Upgrade Incentives
The Professional tier offers a 30-day free trial to encourage adoption, but the platform also wanted to incentivize early trial upgrades with discounts. Managing trial states, preventing trial abuse, handling trial-to-paid conversions, and applying early upgrade discounts required careful coordination between Stripe and internal systems.
Implemented trial management using Stripe's native trial period functionality combined with an internal API tracking trial status. Created early upgrade discount logic that applies promotional pricing when users convert before trial expiration. Built webhook handlers for trial_will_end and trial_end events to notify users and handle automatic conversions. Used Stripe Customer metadata to prevent users from creating multiple trial accounts.
Technical Approach
The implementation centers around Stripe Subscriptions API with quantity-based billing for per-location pricing. I prioritized webhook-driven state synchronization, ensuring billing state always propagates to feature access control. The architecture separates concerns: Stripe handles billing logic and payment processing, an internal API manages subscription state and feature gating, and webhook handlers keep both systems synchronized. Comprehensive testing infrastructure enabled confident iteration without production risk.
Three-Tier Subscription Architecture
Free tier (1 location limit), Essential tier ($79-99/mo, unlimited locations), and Professional tier ($129-149/mo, unlimited locations). Monthly and annual billing options with appropriate pricing adjustments. Feature differentiation handled via subscription tier metadata.
Quantity-Based Per-Location Pricing
Stripe subscription quantities represent active location count. Internal API syncs location additions/removals to Stripe subscription quantity field, triggering automatic prorated billing adjustments. Atomic database operations prevent double-billing during rapid location changes.
Stripe Schedule Management System
Complex logic for handling subscription modifications: upgrades/downgrades create new schedules with appropriate proration, billing frequency changes (monthly ↔ annual) use schedule phases, and location quantity updates modify existing schedules. Decision trees determine whether to cancel, modify, or create schedules based on operation type.
Webhook-Driven State Synchronization
Comprehensive webhook handlers for all subscription lifecycle events: customer.subscription.created, updated, deleted, trial_will_end, payment_succeeded, payment_failed. Webhooks update internal database state, trigger feature access changes, send user notifications, and log audit trails. Idempotent processing prevents duplicate operations.
Feature Gating API
Internal API queries Stripe subscription state to determine feature access in real-time. Application checks tier and payment status before rendering premium features (POS integrations, advanced reporting, invoice automation). Graceful degradation for payment failures with upgrade prompts for locked features.
Trial Management Pipeline
30-day free trial for Professional tier using Stripe's trial_period_days. Internal API tracks trial status and eligibility. Webhook automation sends trial expiration reminders (7-day, 1-day), handles trial-to-paid conversions, and applies early upgrade discounts. Customer metadata prevents trial abuse.
Comprehensive Testing Infrastructure
Built from scratch: local Stripe test mode environment, webhook event simulator, failure scenario testing (declined cards, expired cards, insufficient funds), edge case validation (simultaneous location changes, rapid upgrades/downgrades), and automated test suites for subscription lifecycle operations.
Early Upgrade Discount System
Promotional pricing for users who convert from trial to paid before trial expiration. Logic calculates remaining trial days and applies proportional discount to first billing cycle. Implemented using Stripe promotion codes with trial conversion webhook triggers.
Results & Impact
The billing system launched successfully and has been running in production with zero billing errors and zero customer support tickets related to billing. The platform handles complex multi-location billing seamlessly, with automatic proration and real-time feature gating. Trial conversions improved due to streamlined user experience and early upgrade incentives. The comprehensive testing infrastructure enables confident iteration and feature additions without production risk.
“The new billing system handles everything flawlessly-multi-location pricing, trials, upgrades, downgrades-all without manual intervention. We haven't had a single billing support ticket since launch.”
Key Takeaways
- Investing in comprehensive testing infrastructure upfront pays massive dividends-local billing testing is essential
- Stripe Schedules are powerful for handling complex subscription modifications and future-dated changes
- Quantity-based subscriptions elegantly solve per-unit pricing models (locations, seats, usage tiers)
- Webhook-driven state synchronization ensures billing and feature access stay in sync without manual reconciliation
- Feature gating should query Stripe as source of truth rather than maintaining separate billing state
- Trial management requires careful coordination between Stripe native trials and internal business logic
- Always handle proration correctly-users notice billing inconsistencies immediately
- Idempotent webhook processing is critical-Stripe can deliver events multiple times or out of order
- Edge cases matter: test simultaneous operations, rapid changes, and failure scenarios extensively
- Clear subscription lifecycle state machines prevent bugs in complex upgrade/downgrade scenarios

"I highly recommend Dean to anyone looking for a reliable and professional partner for their software development needs."
Ben Harris - CEO of Lunar Cow Publishing
Need similar work for your project?
Book a free consultation to discuss how we can help you achieve results like these.