@extends('layouts.app') @section('title', 'Subscription & Billing') @push('styles') @endpush @section('content') {{-- Flash Messages --}} @if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif {{-- No Gateway Warning --}} @if(count($gateways) === 0)
No payment gateway is currently enabled. Please contact the administrator to set up Paystack or Flutterwave before you can subscribe to a paid plan.
@endif {{-- Current Plan Banner --}}

{{ $currentPlan->name ?? 'Free Plan' }}

@if(($tenant->plan ?? 'free') === 'free') You're on the free plan. Upgrade to unlock more features and higher limits. @else @php $cancelled = $tenant->settings['subscription_cancelled'] ?? false; @endphp @if($cancelled) Your subscription is cancelled and will revert to Free at the end of the billing period. @else Your subscription is active. Thank you for being a subscriber! @endif @endif

@if($tenant->subscription_ends_at)
@if($tenant->settings['subscription_cancelled'] ?? false) Expires: {{ $tenant->subscription_ends_at->format('M d, Y') }} @else Renews: {{ $tenant->subscription_ends_at->format('M d, Y') }} @endif
@elseif(($tenant->plan ?? 'free') !== 'free')
Lifetime access
@endif
{{-- Usage Stats --}}

Current Usage

@php $usageItems = [ ['label' => 'Products', 'icon' => 'fa-boxes-stacked', 'used' => $usage['products'], 'limit' => $usage['products_limit']], ['label' => 'Staff Members', 'icon' => 'fa-user-group', 'used' => $usage['staff'], 'limit' => $usage['staff_limit']], ['label' => 'Order Forms', 'icon' => 'fa-file-lines', 'used' => $usage['forms'], 'limit' => $usage['forms_limit']], ['label' => 'Orders (this month)', 'icon' => 'fa-receipt', 'used' => $usage['orders_this_month'], 'limit' => $usage['orders_limit']], ]; @endphp @foreach($usageItems as $item) @php $isUnlimited = $item['limit'] == -1; $pct = $isUnlimited ? 0 : ($item['limit'] > 0 ? min(100, round($item['used'] / $item['limit'] * 100)) : 0); $barColor = $pct >= 90 ? 'red' : ($pct >= 70 ? 'yellow' : 'green'); @endphp
{{ $item['label'] }}
{{ number_format($item['used']) }} / {{ $isUnlimited ? 'Unlimited' : number_format($item['limit']) }}
@endforeach
{{-- Billing Cycle Toggle --}}
Monthly
Yearly Save 20%
{{-- Plans Grid --}}
@foreach($plans as $plan) @php $planKey = str_replace('inventory-', '', $plan->slug); $isCurrent = $planKey === ($tenant->plan ?? 'free'); $isRecommended = $planKey === 'growth' && ($tenant->plan ?? 'free') === 'free'; $limits = $plan->limits ?? []; $features = $plan->features ?? []; $monthlyPrice = $plan->price_monthly ?? 0; $yearlyPrice = $plan->price_yearly > 0 ? $plan->price_yearly : round($monthlyPrice * 12 * 0.8); $isFree = $monthlyPrice == 0; @endphp
@if($isCurrent)
Current Plan
@elseif($isRecommended) @endif
{{ $plan->name }}
{{ $plan->description ?? 'Perfect for getting started.' }}
@if($isFree) Free @else {{ $currency }}{{ number_format($monthlyPrice) }}/month @endif
@if($isCurrent) Current Plan @elseif($isFree)
@csrf
@else @endif
@endforeach
{{-- Cancel Subscription --}} @if(($tenant->plan ?? 'free') !== 'free' && !($tenant->settings['subscription_cancelled'] ?? false))

Cancel Subscription

Your plan will remain active until the end of your current billing period. After that, you'll be moved to the Free plan.

@csrf
@elseif($tenant->settings['subscription_cancelled'] ?? false)

Subscription Cancelled

Your {{ $currentPlan->name ?? 'current' }} plan will remain active until {{ $tenant->subscription_ends_at?->format('M d, Y') ?? 'end of period' }}. You can resubscribe anytime by selecting a plan above.

@endif {{-- Billing History --}}

Billing History

@if($payments->count() > 0)
@foreach($payments as $payment) @php $isComp = ($payment->gateway ?? '') === 'admin_override'; @endphp @endforeach
Date Reference Plan Cycle Amount Gateway Status Invoice
{{ $payment->created_at->format('M d, Y H:i') }} {{ $payment->reference }} {{ $payment->metadata['plan_name'] ?? $payment->plan?->name ?? '-' }} {{ ucfirst($payment->billing_cycle) }} @if($isComp) Complimentary @else {{ $currency }}{{ number_format($payment->amount, 2) }} @endif {{ $isComp ? 'Admin' : ucfirst($payment->gateway) }} @if($payment->status === 'completed') @elseif($payment->status === 'pending') @else @endif {{ ucfirst($payment->status) }} @if($payment->status === 'completed') Download @else @endif
@else

No billing history yet. Subscribe to a plan to see your invoices here.

@endif
@endsection @push('scripts') @endpush