You are a SaaS startup that needs to implement subscriptions? Or you already have a system but lose up to 20% of revenue due to auto-payment issues? Implementing a subscription model is not just about attaching a payment gateway—you need to design the full lifecycle: trial, grace period, failure handling, upgrades, and analytics. Our team has spent over a decade building such systems for dozens of projects, delivering more than 20 subscription solutions—from simple monthly plans to complex enterprise schemes with multi-currency support and trial periods. In this post, we break down the key technical decisions.
How Subscription Billing Works
A subscription model requires a well-thought-out data schema and business logic. Let's look at the database structure and choosing a payment provider.
Data Model
plans ( id, name, billing_period: monthly | yearly | weekly, price, currency, trial_days, features (jsonb), is_active ) subscriptions ( id, user_id, plan_id, status: trialing | active | past_due | canceled | expired, current_period_start, current_period_end, trial_ends_at, cancel_at_period_end (boolean), canceled_at, payment_method_id, external_subscription_id (id in payment system) ) subscription_invoices ( id, subscription_id, amount, currency, status: draft | open | paid | failed | void, attempt_count, next_attempt_at, paid_at, payment_id ) Choosing a Payment Provider
| Provider | Features | Market |
|---|---|---|
| Stripe Billing | Built-in subscription management, Smart Retries, Customer Portal | Global |
| YooKassa | Auto-payments via saved cards, requires own logic | Russia |
| CloudPayments | Built-in subscriptions with Webhooks | Russia |
Stripe Billing is the best choice for global SaaS: it handles retry logic itself and provides a ready-made Customer Portal. We have seen that using Stripe reduces development time by 30% compared to YooKassa. For the Russian market, YooKassa also works but requires implementing your own scheduler for recurring charges.
Why Choosing the Right Payment Provider Matters
The correct choice determines development complexity and the stability of auto-payments. Stripe Dunning Management recovers up to 15% of successful payments thanks to ML-optimized retry timing Stripe. This brings back more customers without your involvement.
How the Grace Period Works
After the first failed charge, the subscription enters past_due status—the user retains access but receives notifications. Subsequent retries:
- +1 day: first retry
- +3 days: second retry with email reminder
- +7 days: final attempt, warning of suspension
- +10 days: status becomes
expired, access revoked
Stripe Dunning Management does this automatically. Compare with manual implementation: in the first case, you get up to 15% additional payments, in the second—5–7%. The effect is clear.
Auto-Payments
With Stripe: the subscription is created once, Stripe manages renewals itself. With YooKassa—you need your own scheduler:
// Scheduled Job: every hour $dueSubscriptions = Subscription::where('status', 'active') ->where('current_period_end', '<=', now()) ->get(); foreach ($dueSubscriptions as $subscription) { dispatch(new RenewSubscriptionJob($subscription)); } RenewSubscriptionJob attempts to charge via the saved payment method. On success—updates current_period_end. On failure—transitions to past_due and schedules retries.
Plan Upgrades and Downgrades
Changing plans is nontrivial. The amount is recalculated proportionally to the remaining period:
- Upgrade (to a more expensive plan): immediate, charge the difference for the remaining time
- Downgrade (to a cheaper plan): takes effect at the start of the next period, credit applied
$unusedDays = $subscription->daysRemainingInPeriod(); $creditAmount = $unusedDays * ($currentPlan->dailyPrice()); $chargeAmount = $unusedDays * ($newPlan->dailyPrice()) - $creditAmount; Customer Portal and Subscription Management
Users should be able to:
- View current plan and next billing date
- Change plans (with proration)
- Update payment method (enter new card via hosted fields)
- Cancel subscription with reason (exit survey)
- Download invoices
Stripe provides a hosted Customer Portal for management. For a custom UI on YooKassa, you'd need to build your own. Typically, developing a custom portal takes 1–2 weeks, but we often offer a solution based on Stripe—it's cheaper and 40% faster.
Churn Prevention
Technical solutions to reduce subscription cancellations:
- Email reminders 3 and 7 days before billing with the amount
- Card expiration notice 30 days in advance
- Option to pause subscription (instead of cancel)
- Exit offer: 20% discount for the next month
These measures reduce churn by 15–20% in typical projects. We guarantee to implement these mechanisms in your system. Contact us for a consultation—we'll assess your current situation.
Common Pitfalls in Subscription Implementation
- Not handling payment method changes when a card is lost—losing customers
- Skipping dunning with a fixed lifespan—losing money
- Ignoring time zones—charges happen at inconvenient times
- Not checking for duplicate charges—double payments
Subscription Analytics
Key metrics: MRR (Monthly Recurring Revenue), Churn Rate, LTV, Trial-to-Paid Conversion, Average Revenue Per User. Calculating these requires specialized queries over historical subscription data—simply summing payments is insufficient. We build dashboards on these metrics so you see the real picture.
Development timeline: 4–6 weeks for a complete system with lifecycle management, retry logic, customer portal, and basic analytics. Contact us to evaluate your project—we'll find the optimal solution and give you an accurate timeline.







