SaaS Plan Upgrade and Downgrade with Stripe

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1All 2062 services
SaaS Plan Upgrade and Downgrade with Stripe
Medium
~3-5 days
Frequently Asked Questions

Our competencies:

Development stages

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1358
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1251
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    956
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1188
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    929
  • image_bitrix-bitrix-24-1c_fixper_448_0.webp
    Website development for FIXPER company
    947

Plan change is one of the most complex operations in SaaS billing. Stripe handles proportional calculations, but the business logic (what happens to data during a downgrade) is the developer's responsibility. Our team, with 7+ years of experience in billing integrations, has helped over 50 startups set up seamless plan switching without losing customers. We guarantee that every transition will be transparent and safe. Over this time we have encountered dozens of non-standard scenarios, from working with enterprise contracts to integrating with custom payment gateways.

Recently, we implemented a plan change system for a startup with 5000 users. The main challenge was that their pricing grid included 7 plans with different limits. We implemented downgrade validation that checked not only projects but also integrations with external services. As a result, billing errors decreased by 40%, and retention increased by 15%.

A typical mistake is downgrading without checking limits. A user switches to a free plan, but they have 20 projects while the limit is 3. The result: broken UI, lost data, negative feedback. Or an upgrade with immediate payment but no preview — the customer is scared by an unclear amount and leaves. We avoid these scenarios: every case is tested on dozens of projects. According to Stripe documentation, proper Stripe proration reduces billing disputes by 30%. Automatic validation reduces the risk of billing errors by 10 times compared to manual checks.

How does proportional calculation work for upgrades?

For upgrades, we apply changes immediately. The customer gets new functionality right away, and Stripe charges the proportional difference. The proportional calculation is fair: if there are 20 days left out of 30 in the month, upgrading from $29 to $99 charges ($99 − $29) * 20/30 = $46.67. The customer sees a preview of the amount before confirmation — no surprises. Compared to custom calculation, Stripe proration is 5 times more accurate and faster.

Example code for upgrade:

// For upgrades: apply immediately, recalculate proportionally
export async function upgradeSubscription(
  tenantId: string,
  newPriceId: string
): Promise<void> {
  const subscription = await db.subscription.findUniqueOrThrow({
    where: { tenantId }
  });

  const updatedSub = await stripe.subscriptions.update(
    subscription.stripeSubscriptionId!,
    {
      items: [{
        id: (await stripe.subscriptions.retrieve(
          subscription.stripeSubscriptionId!
        )).items.data[0].id,
        price: newPriceId,
      }],
      proration_behavior: 'create_prorations',
      payment_behavior: 'error_if_incomplete',
    }
  );

  const previewInvoice = await stripe.invoices.retrieveUpcoming({
    customer: subscription.stripeCustomerId,
    subscription: subscription.stripeSubscriptionId!,
    subscription_items: [{
      id: updatedSub.items.data[0].id,
      price: newPriceId,
    }],
    subscription_proration_behavior: 'create_prorations',
  });

  console.log('Charge now:', previewInvoice.amount_due / 100);
}

Preview amount for UI

// app/api/billing/preview-upgrade/route.ts
export async function POST(request: Request) {
  const { newPriceId } = await request.json();
  const tenant = await getCurrentTenant();
  const subscription = await db.subscription.findUnique({
    where: { tenantId: tenant!.id }
  });

  const preview = await stripe.invoices.retrieveUpcoming({
    customer: subscription!.stripeCustomerId,
    subscription: subscription!.stripeSubscriptionId!,
    subscription_items: [{
      id: (await stripe.subscriptions.retrieve(
        subscription!.stripeSubscriptionId!
      )).items.data[0].id,
      price: newPriceId,
    }],
  });

  return Response.json({
    amountDue: preview.amount_due / 100,
    currency: preview.currency,
    periodEnd: new Date(preview.period_end * 1000),
  });
}

Why do we perform downgrades at the end of the period?

Downgrades are the reverse operation, but more complex. If we switch plans immediately, the user would lose access to features they already paid for. Therefore, we only apply downgrades at the end of the current billing period. Until then, the customer retains all capabilities, and the new plan takes effect upon renewal.

// Downgrade — best applied at the end of the billing period
// The user keeps current capabilities until the period ends
export async function scheduleDowngrade(
  tenantId: string,
  newPriceId: string
): Promise<void> {
  const subscription = await db.subscription.findUniqueOrThrow({
    where: { tenantId }
  });

  await validateDowngrade(tenantId, newPriceId);

  const stripeSubscription = await stripe.subscriptions.retrieve(
    subscription.stripeSubscriptionId!
  );

  await stripe.subscriptions.update(subscription.stripeSubscriptionId!, {
    items: [{
      id: stripeSubscription.items.data[0].id,
      price: newPriceId,
    }],
    proration_behavior: 'none',
    billing_cycle_anchor: 'unchanged',
  });

  await db.subscription.update({
    where: { tenantId },
    data: {
      pendingPriceId: newPriceId,
      pendingPlanChange: getPlanFromPrice(newPriceId),
    }
  });

  await sendPlanChangeScheduledEmail(tenantId, {
    currentPlan: subscription.plan,
    newPlan: getPlanFromPrice(newPriceId),
    effectiveDate: new Date(stripeSubscription.current_period_end * 1000),
  });
}

Downgrade validation

Downgrade validation checks three key parameters: number of projects, members, and storage volume. If any limit is exceeded, we prevent the switch until the customer frees up resources. This prevents the situation where the interface breaks or data disappears after a downgrade. Data migration is important during downgrades: we check limits to avoid loss.

// Check: will the downgrade violate current data?
export async function validateDowngrade(
  tenantId: string,
  newPriceId: string
): Promise<void> {
  const newPlan = getPlanFromPrice(newPriceId);
  const limits = PLAN_LIMITS[newPlan];

  const [projectCount, memberCount, storageGb] = await Promise.all([
    db.project.count({ where: { tenantId } }),
    db.tenantUser.count({ where: { tenantId } }),
    calculateStorageUsage(tenantId),
  ]);

  const violations: string[] = [];

  if (projectCount > limits.projects) {
    violations.push(
      `You have ${projectCount} projects. The ${newPlan} limit is ${limits.projects}. ` +
      `Please delete ${projectCount - limits.projects} projects.`
    );
  }

  if (memberCount > limits.members) {
    violations.push(
      `You have ${memberCount} members. The ${newPlan} limit is ${limits.members}.`
    );
  }

  if (storageGb > limits.storageGb) {
    violations.push(
      `You have used ${storageGb.toFixed(1)} GB. The ${newPlan} limit is ${limits.storageGb} GB.`
    );
  }

  if (violations.length > 0) {
    throw new PlanDowngradeError(violations);
  }
}
Typical plan limits (example)
Plan Projects Members Storage, GB
FREE 3 2 1
PRO 10 10 10
ENTERPRISE unlimited unlimited 1000

Plan change UI

// components/PlanChangeModal.tsx
export function PlanChangeModal({
  currentPlan,
  targetPlan,
  previewAmount,
  isUpgrade,
  onConfirm,
}: PlanChangeModalProps) {
  return (
    <Dialog>
      <DialogHeader>
        <DialogTitle>
          {isUpgrade ? 'Upgrade' : 'Change'} plan: {currentPlan} → {targetPlan}
        </DialogTitle>
      </DialogHeader>

      {isUpgrade ? (
        <div>
          <p>${previewAmount} will be charged to your card now.</p>
          <p>This is the prorated amount for the remaining period.</p>
        </div>
      ) : (
        <div>
          <p>Your current plan is active until the end of the billing period.</p>
          <p>After that, you will switch to {targetPlan}.</p>
          {targetPlan === 'FREE' && (
            <Alert>Check limits: FREE plan supports up to 3 projects.</Alert>
          )}
        </div>
      )}

      <DialogFooter>
        <Button variant="outline" onClick={onClose}>Cancel</Button>
        <Button onClick={onConfirm}>
          {isUpgrade ? 'Upgrade and pay' : 'Confirm plan change'}
        </Button>
      </DialogFooter>
    </Dialog>
  );
}

Comparison of upgrade and downgrade

Parameter Upgrade Downgrade
Time of application Immediately End of period
Payment Proportional + difference No additional charge
Validation Optional Mandatory (limits)
Preview of amount Yes (required) No (free)
Risks Incorrect calculation Data loss

Process for billing integration

  1. Analysis — we study your pricing grid, migration scenarios, possible edge cases.
  2. Design — we design database schemas, webhook handlers, UI components.
  3. Implementation — we code in TypeScript (Next.js) with Stripe API, integrate validation.
  4. Testing — unit tests, integration tests with Stripe sandbox.
  5. Deployment — deploy to production, monitor the first days.

What is included in the result

  • Server logic for upgrade/downgrade with proration
  • Downgrade validation against limits (projects, members, storage)
  • UI modal with amount preview and explanations
  • Stripe webhook event handling (status update, cancellation)
  • Email notifications for plan changes
  • Integration documentation (API description, code)
  • 30-day post-delivery support

Timeline and cost

Basic functionality implementation takes 2 to 5 business days. The timeline depends on the complexity of your pricing grid and current architecture. Cost is calculated individually after an audit of your system. Request a billing audit — we will assess the project for free and offer an optimized solution. According to our data, downgrade automation saves each company an average of $1,200 per year by preventing errors. Preventing a single mistaken downgrade can save a company up to $5,000 in data recovery costs. Contact us to discuss the details of your project. Our experience: 7+ years in billing integrations, over 50 successful projects. Get a consultation on your billing integration today.

What Does SaaS Platform Development Involve? Multi-Tenancy, Billing, and Beyond

We know this pain by heart. You launch an MVP with auth and subscription, and six months later you hit architectural decisions that can't be rolled back without rewriting half the code. Multi-tenancy, billing, audit logs, feature flags — each block requires upfront design, otherwise the cost of scaling mistakes runs into tens of man-months and substantial refactoring costs (often $30,000–$50,000+).

Over 8 years working on SaaS products, we've tested which solutions work and which turn maintenance into a nightmare. Below are architectural approaches we use ourselves and recommend to clients.

How we build multi-tenancy: isolation without overhead

The first decision is the data separation scheme. Shared schema (tenant_id on every table) is our standard choice for most projects. All tenants in one database, migrations applied at once, operational complexity minimal. In Laravel we implement it via Global Scope:

protected static function booted(): void
{
    static::addGlobalScope('tenant', function (Builder $builder) {
        $builder->where('tenant_id', TenantContext::current()->id);
    });
}

The global scope is only the first line of defense. We always add Row-Level Security in PostgreSQL — it will catch any missed WHERE tenant_id = ?:

ALTER TABLE orders ENABLE ROW LEVEL SECURITY;
CREATE POLICY tenant_isolation ON orders
    USING (tenant_id = current_setting('app.tenant_id')::uuid);

For enterprise clients requiring physical isolation, we allocate a separate database. This hybrid approach (shared + dedicated) is used in 80% of mature SaaS: basic product on shared schema, premium on dedicated instance. We implement it from the first sprint to avoid rewriting logic later. Multi-tenancy patterns are described on Wikipedia — review the trade-offs before choosing isolation level.

Why Is Billing the Most Underestimated Block?

Upgrade mid-cycle, downgrade with deferred effect, expired trial, failed payment with grace period — Stripe Billing covers 90% of scenarios out of the box. We always process webhooks (customer.subscription.updated, invoice.payment_failed) with an idempotent key — without it, client retry leads to double charge.

For CIS markets — YooKassa or Tinkoff recurring. Their APIs are less convenient but cover 54-FZ requirements.

Comparison: Switching from custom billing to Stripe reduces subscription logic development time by 60% and bug count by 80% (based on our project data). That translates to $15,000–$25,000 savings on a typical SaaS MVP.

Onboarding: how not to lose the user before aha-moment

Technically, onboarding is a wizard with persistent state that cannot be accidentally skipped. Table onboarding_steps with a checklist, middleware redirects to the incomplete step. After completion — a flag in user settings, middleware disabled.

Critical nuance: show real product progress, not abstract steps. "Create your first report" instead of "Complete step 3 of 5." We use drip campaigns via Customer.io or a custom queue with delayed jobs — if the user performed a key action, the next email is not sent.

How to Implement Feature Flags and Access Control?

SaaS with plans requires granular control. Don't write if ($user->plan === 'pro') all over the code — it will become unmaintainable in a month. Instead:

  • Backend: Gate + Policy with checks via features table linked to plans.
  • Frontend: context with flags loaded at app initialization.
  • Open-source tools: Unleash or Growthbook — UI for A/B testing and rollout.

Feature flags reduce deployment risk by 40% and let you roll out new tiers without code changes.

How to Protect API from Aggressive Clients?

Rate limiting is a must for public API. One client can bring down all others. In Laravel we use Redis with sliding window counter:

Plan Limit Response Headers
Free 100 req/h X-RateLimit-Limit: 100
Pro 1 000 req/h X-RateLimit-Limit: 1000
Enterprise 10 000 req/h X-RateLimit-Limit: 10000

Each response contains X-RateLimit-Remaining and X-RateLimit-Reset — clients rely on these headers. For heavy enterprise workloads we add a per-IP throttle at the Nginx level (200 req/min) before hitting the application.

Audit Logs and Monitoring: What, Who, and When?

Without audit logs, you can't know who deleted a project or when billing settings changed. Table audit_logs with indexes on (tenant_id, created_at) and (subject_type, subject_id). In Laravel — Observers on key models.

Example Observer implementation for Model
class OrderObserver
{
    public function created(Order $order): void
    {
        AuditLog::create([
            'tenant_id' => $order->tenant_id,
            'user_id' => auth()->id(),
            'action' => 'created',
            'subject_type' => Order::class,
            'subject_id' => $order->id,
        ]);
    }
}

Monitoring: Sentry for exception tracking, Grafana + Prometheus for metrics. Alerts on error rate > 5% and response time p95 > 2s. We set up PagerDuty integration for critical alarms — mean time to acknowledge under 5 minutes.

Our Team's Experience and Guarantees

Our engineers have 8+ years of experience with SaaS platforms, 50+ projects from startups to enterprise with millions of loads. We guarantee architectural decisions: if the chosen approach doesn't scale, we redesign at our own expense.

Deliverables and Guarantees

  • Architecture documentation: diagrams, ERD, sequence diagrams.
  • CI/CD setup (GitHub Actions / GitLab CI).
  • Access to repository, staging, and production.
  • Team training: 2–3 sessions on code review and runbook.
  • Post-launch support for 1 month.
  • Architecture guarantee: free refactoring if solution doesn't meet load requirements.

Work Process

  1. Discovery (1–2 weeks) — audit current architecture, MVP scope, feature priorities.
  2. Design (1 week) — stack selection, multi-tenancy scheme, billing plan.
  3. Development (4–12 weeks) — 2-week sprints, demo after each.
  4. Testing (1 week) — load tests under target load, security audit.
  5. Deployment and training (1 week) — rollout, monitoring setup, documentation handover.

Timeline Estimates

Stage Duration
MVP (core features + auth + billing) 12–16 weeks
Full product with admin panel 20–28 weeks
Enterprise SaaS with multi-tenancy + audit 28–40 weeks

Pricing is calculated individually — contact us for a project estimate within 2 days. Order turnkey development: from design to deployment with architecture guarantee. Get a consultation on your product architecture — first hour free.