NutriNaturals — Health & Supplement E-Commerce
Subscription-Based Supplement Store with Recurring Billing
Organic health and wellness supplement e-commerce store with product filtering, recurring subscription orders, verified customer reviews, and payment gateway integration. Built around a resilient recurring billing engine that recovers gracefully from failed charges.
Architecture & System Design
Subscriptions run through an explicit state machine handling pause, resume, and cancellation with prorated billing. Failed recurring payments enter a dunning workflow instead of silently cancelling the subscription.
- Subscription state machine handling pause, resume, cancel, and prorated billing
- Dunning management with automated retry schedule for failed recurring charges
- Verified-purchase-only review system to prevent review spam
- Product filtering by health category and ingredient
Engineering Challenges
Managing Subscription Lifecycle Changes
Customers pausing, resuming, or changing plans mid-cycle created inconsistent billing amounts and dates.
Built a subscription state machine that calculates prorated charges for pause/resume/upgrade transitions explicitly.
Subscription retention held at 78% with consistent, predictable billing.
Failed Recurring Payments Causing Churn
A single failed recurring charge would silently cancel a subscription, losing customers who simply had a temporary card issue.
Implemented dunning management with a scheduled retry sequence and proactive customer notifications before cancellation.
Recovered roughly 25% of failed payment attempts that would otherwise have churned.
Review Authenticity
Open review submission was attracting spam and unverified reviews that undermined customer trust.
Restricted review submission to accounts with a confirmed purchase record tied to the specific product.
Review spam eliminated and customer trust in ratings improved.
Core Features
Recurring Subscription Billing
State-machine-driven subscriptions supporting pause, resume, and prorated plan changes.
Clean Code
1<?php23namespace App\Services;45use App\Models\Subscription;6use App\Contracts\PaymentGateway;7use Illuminate\Support\Facades\DB;89class SubscriptionBillingService10{11 public function __construct(private PaymentGateway $gateway) {}1213 public function processRenewal(Subscription $subscription): void14 {15 DB::transaction(function () use ($subscription) {16 $charge = $this->gateway->charge(17 $subscription->customer,18 $subscription->plan->price19 );2021 if (! $charge->successful()) {22 $subscription->increment('failed_attempts');23 $subscription->update(['status' => 'past_due']);24 return;25 }2627 $subscription->update([28 'failed_attempts' => 0,29 'status' => 'active',30 'next_billing_at' => now()->addDays($subscription->plan->interval_days),31 ]);32 });33 }34}