We've repeatedly encountered projects where subscriptions broke due to unprocessed webhooks: payments failed, access remained even after cancellation, and reporting was absent. As a result, the company lost up to 30% of revenue solely from churn. Our experience in this area — 8+ years, during which we've implemented over 30 subscription systems for media, SaaS, and educational platforms. One recent project — a media service with 50,000 paying subscribers: after switching to our architecture, churn dropped by 35% in a quarter.
The subscription system solves critical problems
The first and foremost — customer churn due to payment failures. If a payment fails and the user doesn't get notified, they lose access and leave. We implement a grace period and automatic retry attempts. According to Stripe documentation, without a grace period up to 40% of customers leave after the first payment error; with our implementation this figure drops to 5%, making our solution 8 times better at retaining customers. The second problem — incorrect invoicing when changing plans. Proportional calculation via Stripe solves this. The third — feature-level access management: for example, granting access to 4K only to annual plan subscribers. Everything is built into the data schema.
Another common issue — webhook idempotency. Without a unique key, duplicate event delivery leads to double charging. We implement webhook_idempotency_key at the database level, eliminating duplication.
Why proper subscription lifecycle matters
The subscription lifecycle — trialing → active → past_due → expired or cancelled — must be strictly followed. Each status is verified on the backend: SubscriptionAccessGuard checks not only status but also grace_period_ends_at. This prevents giving access to an expired subscription. We use an event-driven approach: each status change generates an event subscribed to by a notifier (email/Telegram).
Reduce churn with a grace period
When a payment fails, the subscription transitions to past_due, and a grace period (up to 7 days) begins. During this period access is fully preserved, and the user receives an email asking to update payment details. If payment is not received, access is blocked, but all data is retained: the customer can resume the subscription without losing history. Our grace period implementation is twice as effective as the standard one due to active notifications: we send up to 3 emails with different timing.
Implementation architecture and process
We use Laravel (PHP 8.3+) and PostgreSQL. Payment provider — Stripe or YooKassa via a PaymentProviderFactory. All status changes arrive via webhook — this is the single source of truth. The subscription lifecycle: trialing → active → past_due → expired or cancelled.
Database schema example
Schema::create('subscription_plans', function (Blueprint $table) { $table->id(); $table->string('name'); $table->string('slug')->unique(); $table->decimal('price_monthly', 10, 2)->nullable(); $table->decimal('price_yearly', 10, 2)->nullable(); $table->integer('trial_days')->default(0); $table->jsonb('features'); $table->boolean('is_active')->default(true); $table->timestamps(); }); Schema::create('subscriptions', function (Blueprint $table) { $table->id(); $table->foreignId('user_id')->constrained(); $table->foreignId('plan_id')->constrained('subscription_plans'); $table->enum('billing_period', ['monthly', 'yearly']); $table->enum('status', ['trialing', 'active', 'past_due', 'cancelled', 'expired']); $table->string('payment_provider'); $table->string('provider_subscription_id')->nullable(); $table->string('provider_customer_id')->nullable(); $table->timestamp('trial_ends_at')->nullable(); $table->timestamp('current_period_start'); $table->timestamp('current_period_end'); $table->timestamp('grace_period_ends_at')->nullable(); $table->timestamp('cancelled_at')->nullable(); $table->timestamp('ends_at')->nullable(); $table->timestamps(); $table->index(['user_id', 'status']); $table->index('current_period_end'); }); Example of creating a subscription via CreateSubscriptionAction — a transaction synchronizing provider and local DB. The webhook handler StripeWebhookHandler processes events invoice.paid, invoice.payment_failed, customer.subscription.updated, customer.subscription.deleted. Access control via SubscriptionAccessGuard, which checks status, grace period, and plan features.
Supported tariff models
Any: fixed price per period, unit-based subscription (charge per number of objects/users), freemium with trial, and combined — free tier with upgrade options. All models are configurable via admin panel without code changes.
Stages of work
| Stage | Duration | Description |
|---|---|---|
| Analytics | 2–3 days | Study business logic, model tariffs and limits |
| Design | 3–5 days | DB schemas, API endpoints, payment provider integration |
| Implementation | 7–10 days | Coding subscriptions, webhook, access management |
| Testing | 2–3 days | Cover all scenarios: successful payment, failure, upgrade, cancellation |
| Deployment and monitoring | 1–2 days | Set up error notifications, webhook logs |
What's included in the work?
| Component | Description |
|---|---|
| Data schema | Tables plans, subscriptions, events |
| Payment integration | Stripe/YooKassa: subscriptions, webhook, error handling |
| Access management | Middleware, guard for feature checks |
| Personal account | UI for plan change, cancellation, viewing history |
| Notifications | Email/Telegram about renewal, failure, grace period expiration |
| Documentation | API description, testing instructions |
Common mistakes we prevent: incorrect timezone handling (grace period ending in the middle of the day), lack of webhook logs (difficult to debug), ignoring provider test modes.
Timeline and guarantees
Full cycle — from 16 to 20 business days. We provide a guarantee on correct payment processing and webhook handling for 30 days after delivery. All changes via git, with code review by a senior developer. More about best practices — in Stripe documentation. Contact us for a consultation — we'll discuss your business model and choose the optimal solution. Order the implementation of a subscription system for your project.







