Add Queue Enterprise billing and visible upgrade CTAs for all roles.
Deploy Ladill Queue / deploy (push) Successful in 1m32s
Deploy Ladill Queue / deploy (push) Successful in 1m32s
Enterprise charges per active branch (GHS 299+) with wallet subscribe/renew; sidebar and dashboard upsell no longer gated behind settings.view. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Models\Member;
|
|||||||
use App\Models\ServiceQueue;
|
use App\Models\ServiceQueue;
|
||||||
use App\Services\Qms\DashboardStats;
|
use App\Services\Qms\DashboardStats;
|
||||||
use App\Services\Qms\OrganizationResolver;
|
use App\Services\Qms\OrganizationResolver;
|
||||||
|
use App\Services\Qms\PlanService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
@@ -42,7 +43,9 @@ class DashboardController extends Controller
|
|||||||
|
|
||||||
$operational = $this->stats->forOrganization($owner, $organization->id, $branchScope);
|
$operational = $this->stats->forOrganization($owner, $organization->id, $branchScope);
|
||||||
$branches = (clone $branchQuery)->withCount('serviceQueues')->orderBy('name')->get();
|
$branches = (clone $branchQuery)->withCount('serviceQueues')->orderBy('name')->get();
|
||||||
|
$plans = app(PlanService::class);
|
||||||
|
$hasPaidPlan = $plans->hasPaidPlan($organization);
|
||||||
|
|
||||||
return view('qms.dashboard', compact('organization', 'orgStats', 'branches', 'operational'));
|
return view('qms.dashboard', compact('organization', 'orgStats', 'branches', 'operational', 'hasPaidPlan'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,21 +24,27 @@ class ProController extends Controller
|
|||||||
$expiresAt = ! empty($settings['plan_expires_at'])
|
$expiresAt = ! empty($settings['plan_expires_at'])
|
||||||
? Carbon::parse($settings['plan_expires_at'])
|
? Carbon::parse($settings['plan_expires_at'])
|
||||||
: null;
|
: null;
|
||||||
|
$planKey = $plans->planKey($organization);
|
||||||
|
$branchCount = $plans->activeBranchCount($organization);
|
||||||
|
$enterprisePrice = $plans->enterprisePriceMinor($organization);
|
||||||
|
|
||||||
return view('qms.pro.index', [
|
return view('qms.pro.index', [
|
||||||
'organization' => $organization,
|
'organization' => $organization,
|
||||||
'isPro' => $plans->isPro($organization),
|
'planKey' => $planKey,
|
||||||
|
'isPro' => $planKey === 'pro',
|
||||||
|
'isEnterprise' => $planKey === 'enterprise',
|
||||||
|
'hasPaidPlan' => $plans->hasPaidPlan($organization),
|
||||||
'canManage' => $canManage,
|
'canManage' => $canManage,
|
||||||
'priceMinor' => $plans->proPriceMinor(),
|
'proPriceMinor' => $plans->proPriceMinor(),
|
||||||
|
'enterprisePricePerBranchMinor' => $plans->enterprisePricePerBranchMinor(),
|
||||||
|
'enterprisePriceMinor' => $enterprisePrice,
|
||||||
|
'branchCount' => $branchCount,
|
||||||
|
'canSubscribeEnterprise' => $plans->canSubscribeEnterprise($organization),
|
||||||
|
'enterpriseMinBranches' => (int) config('qms.enterprise.min_branches', 2),
|
||||||
'currency' => (string) config('billing.currency', 'GHS'),
|
'currency' => (string) config('billing.currency', 'GHS'),
|
||||||
'planExpiresAt' => $expiresAt,
|
'planExpiresAt' => $expiresAt,
|
||||||
'proFeatures' => [
|
'enterpriseBilledBranches' => (int) ($settings['enterprise_billed_branches'] ?? $branchCount),
|
||||||
'Unlimited branches & queues',
|
'salesUrl' => ladill_platform_url('contact-sales'),
|
||||||
'Advanced routing rules',
|
|
||||||
'Digital displays & kiosk devices',
|
|
||||||
'Appointment reminders',
|
|
||||||
'Analytics & report exports',
|
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,25 +53,78 @@ class ProController extends Controller
|
|||||||
$this->authorizeAbility($request, 'settings.manage');
|
$this->authorizeAbility($request, 'settings.manage');
|
||||||
$organization = $this->organization($request);
|
$organization = $this->organization($request);
|
||||||
|
|
||||||
if ($plans->isPro($organization)) {
|
if ($plans->hasPaidPlan($organization)) {
|
||||||
return redirect()->route('qms.pro.index')
|
return redirect()->route('qms.pro.index')
|
||||||
->with('success', 'Your organization is already on Queue Pro.');
|
->with('success', 'Your organization already has an active paid plan.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$priceMinor = $plans->proPriceMinor();
|
return $this->chargePlan(
|
||||||
|
$organization,
|
||||||
|
$billing,
|
||||||
|
$plans->proPriceMinor(),
|
||||||
|
'pro',
|
||||||
|
'queue_pro',
|
||||||
|
'queue-pro-'.$organization->id.'-'.now()->format('Y-m-d-His'),
|
||||||
|
'Ladill Queue Pro — monthly subscription',
|
||||||
|
'Welcome to Queue Pro — active for one month.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function subscribeEnterprise(Request $request, PlanService $plans, BillingClient $billing): RedirectResponse
|
||||||
|
{
|
||||||
|
$this->authorizeAbility($request, 'settings.manage');
|
||||||
|
$organization = $this->organization($request);
|
||||||
|
|
||||||
|
if ($plans->hasPaidPlan($organization)) {
|
||||||
|
return redirect()->route('qms.pro.index')
|
||||||
|
->with('success', 'Your organization already has an active paid plan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $plans->canSubscribeEnterprise($organization)) {
|
||||||
|
$min = (int) config('qms.enterprise.min_branches', 2);
|
||||||
|
|
||||||
|
return redirect()->route('qms.pro.index')
|
||||||
|
->with('error', "Enterprise billing requires at least {$min} active branches. Add another branch or choose Pro for a single site.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$priceMinor = $plans->enterprisePriceMinor($organization);
|
||||||
|
|
||||||
|
return $this->chargePlan(
|
||||||
|
$organization,
|
||||||
|
$billing,
|
||||||
|
$priceMinor,
|
||||||
|
'enterprise',
|
||||||
|
'queue_enterprise',
|
||||||
|
'queue-enterprise-'.$organization->id.'-'.now()->format('Y-m-d-His'),
|
||||||
|
'Ladill Queue Enterprise — monthly subscription',
|
||||||
|
'Welcome to Queue Enterprise — active for one month.',
|
||||||
|
$plans->activeBranchCount($organization),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function chargePlan(
|
||||||
|
$organization,
|
||||||
|
BillingClient $billing,
|
||||||
|
int $priceMinor,
|
||||||
|
string $plan,
|
||||||
|
string $billingSource,
|
||||||
|
string $reference,
|
||||||
|
string $description,
|
||||||
|
string $successMessage,
|
||||||
|
?int $enterpriseBranches = null,
|
||||||
|
): RedirectResponse {
|
||||||
try {
|
try {
|
||||||
if (! $billing->canAfford($organization->owner_ref, $priceMinor)) {
|
if (! $billing->canAfford($organization->owner_ref, $priceMinor)) {
|
||||||
return redirect()->route('qms.pro.index')
|
return redirect()->route('qms.pro.index')
|
||||||
->with('error', 'Insufficient wallet balance. Top up your Ladill wallet to upgrade to Pro.');
|
->with('error', 'Insufficient wallet balance. Top up your Ladill wallet to upgrade.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$charged = $billing->debit(
|
$charged = $billing->debit(
|
||||||
$organization->owner_ref,
|
$organization->owner_ref,
|
||||||
$priceMinor,
|
$priceMinor,
|
||||||
'queue_pro',
|
$billingSource,
|
||||||
'queue-pro-'.$organization->id.'-'.now()->format('Y-m-d-His'),
|
$reference,
|
||||||
'Ladill Queue Pro — monthly subscription',
|
$description,
|
||||||
);
|
);
|
||||||
} catch (\Throwable) {
|
} catch (\Throwable) {
|
||||||
return redirect()->route('qms.pro.index')
|
return redirect()->route('qms.pro.index')
|
||||||
@@ -74,19 +133,21 @@ class ProController extends Controller
|
|||||||
|
|
||||||
if (! $charged) {
|
if (! $charged) {
|
||||||
return redirect()->route('qms.pro.index')
|
return redirect()->route('qms.pro.index')
|
||||||
->with('error', 'Insufficient wallet balance. Top up your Ladill wallet to upgrade to Pro.');
|
->with('error', 'Insufficient wallet balance. Top up your Ladill wallet to upgrade.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$settings = $organization->settings ?? [];
|
$settings = $organization->settings ?? [];
|
||||||
$settings['plan'] = 'pro';
|
$settings['plan'] = $plan;
|
||||||
$settings['auto_renew'] = true;
|
$settings['auto_renew'] = true;
|
||||||
$settings['plan_expires_at'] = now()
|
$settings['plan_expires_at'] = now()
|
||||||
->addDays((int) config('qms.pro.period_days', 30))
|
->addDays((int) config('qms.pro.period_days', 30))
|
||||||
->toIso8601String();
|
->toIso8601String();
|
||||||
|
if ($enterpriseBranches !== null) {
|
||||||
|
$settings['enterprise_billed_branches'] = $enterpriseBranches;
|
||||||
|
}
|
||||||
unset($settings['plan_renewal_error']);
|
unset($settings['plan_renewal_error']);
|
||||||
$organization->update(['settings' => $settings]);
|
$organization->update(['settings' => $settings]);
|
||||||
|
|
||||||
return redirect()->route('qms.pro.index')
|
return redirect()->route('qms.pro.index')->with('success', $successMessage);
|
||||||
->with('success', 'Welcome to Queue Pro — active for one month.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,16 +34,28 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
View::composer('partials.sidebar', function ($view) {
|
View::composer('partials.sidebar', function ($view) {
|
||||||
/** @var User|null $user */
|
/** @var User|null $user */
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
|
$planKey = 'free';
|
||||||
$isPro = false;
|
$isPro = false;
|
||||||
|
$isEnterprise = false;
|
||||||
|
$hasPaidPlan = false;
|
||||||
|
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$organization = app(OrganizationResolver::class)->resolveForUser($user);
|
$organization = app(OrganizationResolver::class)->resolveForUser($user);
|
||||||
if ($organization) {
|
if ($organization) {
|
||||||
$isPro = app(PlanService::class)->isPro($organization);
|
$plans = app(PlanService::class);
|
||||||
|
$planKey = $plans->planKey($organization);
|
||||||
|
$isPro = $planKey === 'pro';
|
||||||
|
$isEnterprise = $planKey === 'enterprise';
|
||||||
|
$hasPaidPlan = $plans->hasPaidPlan($organization);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$view->with('isPro', $isPro);
|
$view->with([
|
||||||
|
'planKey' => $planKey,
|
||||||
|
'isPro' => $isPro,
|
||||||
|
'isEnterprise' => $isEnterprise,
|
||||||
|
'hasPaidPlan' => $hasPaidPlan,
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
View::composer(['partials.topbar'], function ($view) {
|
View::composer(['partials.topbar'], function ($view) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services\Qms;
|
namespace App\Services\Qms;
|
||||||
|
|
||||||
|
use App\Models\Branch;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
@@ -12,7 +13,7 @@ class PlanService
|
|||||||
$settings = $organization->settings ?? [];
|
$settings = $organization->settings ?? [];
|
||||||
$plan = (string) ($settings['plan'] ?? 'free');
|
$plan = (string) ($settings['plan'] ?? 'free');
|
||||||
|
|
||||||
if ($plan === 'pro' && ! empty($settings['plan_expires_at'])) {
|
if (in_array($plan, ['pro', 'enterprise'], true) && ! empty($settings['plan_expires_at'])) {
|
||||||
if (Carbon::parse($settings['plan_expires_at'])->isPast()) {
|
if (Carbon::parse($settings['plan_expires_at'])->isPast()) {
|
||||||
return 'free';
|
return 'free';
|
||||||
}
|
}
|
||||||
@@ -31,6 +32,24 @@ class PlanService
|
|||||||
return $this->planKey($organization) === 'pro';
|
return $this->planKey($organization) === 'pro';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isEnterprise(Organization $organization): bool
|
||||||
|
{
|
||||||
|
return $this->planKey($organization) === 'enterprise';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasPaidPlan(Organization $organization): bool
|
||||||
|
{
|
||||||
|
return in_array($this->planKey($organization), ['pro', 'enterprise'], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function activeBranchCount(Organization $organization): int
|
||||||
|
{
|
||||||
|
return Branch::query()
|
||||||
|
->where('organization_id', $organization->id)
|
||||||
|
->where('is_active', true)
|
||||||
|
->count();
|
||||||
|
}
|
||||||
|
|
||||||
public function maxBranches(Organization $organization): ?int
|
public function maxBranches(Organization $organization): ?int
|
||||||
{
|
{
|
||||||
return config('qms.plans.'.$this->planKey($organization).'.max_branches');
|
return config('qms.plans.'.$this->planKey($organization).'.max_branches');
|
||||||
@@ -59,4 +78,21 @@ class PlanService
|
|||||||
{
|
{
|
||||||
return (int) config('qms.plans.pro.price_minor', 9900);
|
return (int) config('qms.plans.pro.price_minor', 9900);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function enterprisePricePerBranchMinor(): int
|
||||||
|
{
|
||||||
|
return (int) config('qms.plans.enterprise.price_minor_per_branch', 29900);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function enterprisePriceMinor(Organization $organization): int
|
||||||
|
{
|
||||||
|
$branches = max(1, $this->activeBranchCount($organization));
|
||||||
|
|
||||||
|
return $branches * $this->enterprisePricePerBranchMinor();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canSubscribeEnterprise(Organization $organization): bool
|
||||||
|
{
|
||||||
|
return $this->activeBranchCount($organization) >= (int) config('qms.enterprise.min_branches', 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class ProRenewalService
|
|||||||
public function dueOrganizations(): Collection
|
public function dueOrganizations(): Collection
|
||||||
{
|
{
|
||||||
return Organization::query()
|
return Organization::query()
|
||||||
->where('settings->plan', 'pro')
|
->whereIn('settings->plan', ['pro', 'enterprise'])
|
||||||
->whereNotNull('settings->plan_expires_at')
|
->whereNotNull('settings->plan_expires_at')
|
||||||
->get()
|
->get()
|
||||||
->filter(fn (Organization $organization) => $this->isDue($organization));
|
->filter(fn (Organization $organization) => $this->isDue($organization));
|
||||||
@@ -27,7 +27,8 @@ class ProRenewalService
|
|||||||
public function isDue(Organization $organization): bool
|
public function isDue(Organization $organization): bool
|
||||||
{
|
{
|
||||||
$settings = $organization->settings ?? [];
|
$settings = $organization->settings ?? [];
|
||||||
if (($settings['plan'] ?? '') !== 'pro') {
|
$plan = (string) ($settings['plan'] ?? 'free');
|
||||||
|
if (! in_array($plan, ['pro', 'enterprise'], true)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (array_key_exists('auto_renew', $settings) && $settings['auto_renew'] === false) {
|
if (array_key_exists('auto_renew', $settings) && $settings['auto_renew'] === false) {
|
||||||
@@ -47,27 +48,37 @@ class ProRenewalService
|
|||||||
}
|
}
|
||||||
|
|
||||||
$settings = $organization->settings ?? [];
|
$settings = $organization->settings ?? [];
|
||||||
$price = $this->plans->proPriceMinor();
|
$plan = (string) ($settings['plan'] ?? 'free');
|
||||||
$reference = 'queue-pro-'.$organization->id.'-'.now()->format('YmdHis');
|
$isEnterprise = $plan === 'enterprise';
|
||||||
|
$price = $isEnterprise
|
||||||
|
? $this->plans->enterprisePriceMinor($organization)
|
||||||
|
: $this->plans->proPriceMinor();
|
||||||
|
$reference = ($isEnterprise ? 'queue-enterprise-' : 'queue-pro-')
|
||||||
|
.$organization->id.'-'.now()->format('YmdHis');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$charged = $this->billing->debit(
|
$charged = $this->billing->debit(
|
||||||
$organization->owner_ref,
|
$organization->owner_ref,
|
||||||
$price,
|
$price,
|
||||||
'queue_pro_renewal',
|
$isEnterprise ? 'queue_enterprise_renewal' : 'queue_pro_renewal',
|
||||||
$reference,
|
$reference,
|
||||||
'Ladill Queue Pro — monthly renewal',
|
$isEnterprise
|
||||||
|
? 'Ladill Queue Enterprise — monthly renewal'
|
||||||
|
: 'Ladill Queue Pro — monthly renewal',
|
||||||
);
|
);
|
||||||
} catch (\Throwable) {
|
} catch (\Throwable) {
|
||||||
$charged = false;
|
$charged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($charged) {
|
if ($charged) {
|
||||||
$settings['plan'] = 'pro';
|
$settings['plan'] = $plan;
|
||||||
$settings['auto_renew'] = true;
|
$settings['auto_renew'] = true;
|
||||||
$settings['plan_expires_at'] = now()
|
$settings['plan_expires_at'] = now()
|
||||||
->addDays((int) config('qms.pro.period_days', 30))
|
->addDays((int) config('qms.pro.period_days', 30))
|
||||||
->toIso8601String();
|
->toIso8601String();
|
||||||
|
if ($isEnterprise) {
|
||||||
|
$settings['enterprise_billed_branches'] = $this->plans->activeBranchCount($organization);
|
||||||
|
}
|
||||||
unset($settings['plan_renewal_error']);
|
unset($settings['plan_renewal_error']);
|
||||||
$organization->update(['settings' => $settings]);
|
$organization->update(['settings' => $settings]);
|
||||||
|
|
||||||
@@ -78,7 +89,7 @@ class ProRenewalService
|
|||||||
$graceEnd = $expires->copy()->addDays((int) config('qms.pro.grace_days', 3));
|
$graceEnd = $expires->copy()->addDays((int) config('qms.pro.grace_days', 3));
|
||||||
if ($graceEnd->isPast()) {
|
if ($graceEnd->isPast()) {
|
||||||
$settings['plan'] = 'free';
|
$settings['plan'] = 'free';
|
||||||
unset($settings['plan_expires_at']);
|
unset($settings['plan_expires_at'], $settings['enterprise_billed_branches']);
|
||||||
$settings['plan_renewal_error'] = 'Suspended after failed renewal.';
|
$settings['plan_renewal_error'] = 'Suspended after failed renewal.';
|
||||||
} else {
|
} else {
|
||||||
$settings['plan_renewal_error'] = 'Renewal failed — top up your wallet.';
|
$settings['plan_renewal_error'] = 'Renewal failed — top up your wallet.';
|
||||||
|
|||||||
@@ -199,6 +199,10 @@ return [
|
|||||||
'period_days' => (int) env('QUEUE_PRO_PERIOD_DAYS', 30),
|
'period_days' => (int) env('QUEUE_PRO_PERIOD_DAYS', 30),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'enterprise' => [
|
||||||
|
'min_branches' => (int) env('QUEUE_ENTERPRISE_MIN_BRANCHES', 2),
|
||||||
|
],
|
||||||
|
|
||||||
'rule_types' => [
|
'rule_types' => [
|
||||||
'overflow' => 'Overflow routing',
|
'overflow' => 'Overflow routing',
|
||||||
'priority_boost' => 'Priority boost',
|
'priority_boost' => 'Priority boost',
|
||||||
|
|||||||
@@ -98,19 +98,21 @@
|
|||||||
</svg>
|
</svg>
|
||||||
<span>Settings</span>
|
<span>Settings</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
@php $proActive = request()->routeIs('qms.pro.*'); @endphp
|
|
||||||
@if (! empty($isPro))
|
|
||||||
<a href="{{ route('qms.pro.index') }}" class="group mt-0.5 flex items-center gap-3 rounded-lg px-3 py-2 text-[13px] transition {{ $proActive ? 'bg-indigo-50 text-indigo-700 font-semibold' : 'text-slate-600 hover:bg-slate-50 hover:text-slate-900' }}">
|
|
||||||
<svg class="h-[18px] w-[18px] shrink-0 text-amber-500" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2.25c.3 0 .58.18.7.46l2.36 5.5 5.96.5a.75.75 0 0 1 .43 1.31l-4.53 3.9 1.36 5.83a.75.75 0 0 1-1.12.81L12 17.77l-5.16 3a.75.75 0 0 1-1.12-.81l1.36-5.83-4.53-3.9a.75.75 0 0 1 .43-1.31l5.96-.5 2.36-5.5c.12-.28.4-.46.7-.46Z"/></svg>
|
|
||||||
<span>Queue Pro</span>
|
|
||||||
</a>
|
|
||||||
@else
|
|
||||||
<a href="{{ route('qms.pro.index') }}" class="group mt-0.5 flex items-center gap-3 rounded-lg bg-gradient-to-r from-indigo-600 to-emerald-500 px-3 py-2 text-[13px] font-semibold text-white shadow-sm transition hover:opacity-95">
|
|
||||||
<svg class="h-[18px] w-[18px] shrink-0" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2.25c.3 0 .58.18.7.46l2.36 5.5 5.96.5a.75.75 0 0 1 .43 1.31l-4.53 3.9 1.36 5.83a.75.75 0 0 1-1.12.81L12 17.77l-5.16 3a.75.75 0 0 1-1.12-.81l1.36-5.83-4.53-3.9a.75.75 0 0 1 .43-1.31l5.96-.5 2.36-5.5c.12-.28.4-.46.7-.46Z"/></svg>
|
|
||||||
<span>Upgrade to Pro</span>
|
|
||||||
</a>
|
|
||||||
@endif
|
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
<div class="shrink-0 {{ $permissions->can($member, 'settings.view') ? '' : 'border-t border-slate-200' }} px-3 py-3">
|
||||||
|
@php $proActive = request()->routeIs('qms.pro.*'); @endphp
|
||||||
|
@if (! empty($hasPaidPlan))
|
||||||
|
<a href="{{ route('qms.pro.index') }}" class="group flex items-center gap-3 rounded-lg px-3 py-2 text-[13px] transition {{ $proActive ? 'bg-indigo-50 text-indigo-700 font-semibold' : 'text-slate-600 hover:bg-slate-50 hover:text-slate-900' }}">
|
||||||
|
<svg class="h-[18px] w-[18px] shrink-0 text-amber-500" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2.25c.3 0 .58.18.7.46l2.36 5.5 5.96.5a.75.75 0 0 1 .43 1.31l-4.53 3.9 1.36 5.83a.75.75 0 0 1-1.12.81L12 17.77l-5.16 3a.75.75 0 0 1-1.12-.81l1.36-5.83-4.53-3.9a.75.75 0 0 1 .43-1.31l5.96-.5 2.36-5.5c.12-.28.4-.46.7-.46Z"/></svg>
|
||||||
|
<span>{{ ! empty($isEnterprise) ? 'Queue Enterprise' : 'Queue Pro' }}</span>
|
||||||
|
</a>
|
||||||
|
@else
|
||||||
|
<a href="{{ route('qms.pro.index') }}" class="group flex items-center gap-3 rounded-lg bg-gradient-to-r from-indigo-600 to-emerald-500 px-3 py-2 text-[13px] font-semibold text-white shadow-sm transition hover:opacity-95">
|
||||||
|
<svg class="h-[18px] w-[18px] shrink-0" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2.25c.3 0 .58.18.7.46l2.36 5.5 5.96.5a.75.75 0 0 1 .43 1.31l-4.53 3.9 1.36 5.83a.75.75 0 0 1-1.12.81L12 17.77l-5.16 3a.75.75 0 0 1-1.12-.81l1.36-5.83-4.53-3.9a.75.75 0 0 1 .43-1.31l5.96-.5 2.36-5.5c.12-.28.4-.46.7-.46Z"/></svg>
|
||||||
|
<span>Upgrade to Pro</span>
|
||||||
|
</a>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -68,6 +68,16 @@
|
|||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@if (empty($hasPaidPlan))
|
||||||
|
<div class="mb-6 flex flex-col gap-3 rounded-2xl border border-indigo-200 bg-gradient-to-r from-indigo-50 to-emerald-50 px-5 py-4 sm:flex-row sm:items-center sm:justify-between">
|
||||||
|
<div>
|
||||||
|
<p class="font-semibold text-slate-900">Unlock Queue Pro or Enterprise</p>
|
||||||
|
<p class="mt-0.5 text-sm text-slate-600">Unlimited branches, advanced routing, Care & Frontdesk integrations — from GHS 99/mo.</p>
|
||||||
|
</div>
|
||||||
|
<a href="{{ route('qms.pro.index') }}" class="btn-primary shrink-0">View plans</a>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
<section class="mb-8">
|
<section class="mb-8">
|
||||||
<h2 class="mb-3 text-sm font-semibold uppercase tracking-wide text-slate-500">Live operations</h2>
|
<h2 class="mb-3 text-sm font-semibold uppercase tracking-wide text-slate-500">Live operations</h2>
|
||||||
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-5">
|
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-5">
|
||||||
|
|||||||
@@ -1,51 +1,113 @@
|
|||||||
<x-app-layout title="Pro" heading="Queue Pro">
|
<x-app-layout title="Plans" heading="Queue plans">
|
||||||
@php
|
@php
|
||||||
$price = number_format($priceMinor / 100, 2);
|
$proPrice = number_format($proPriceMinor / 100, 0);
|
||||||
|
$enterprisePerBranch = number_format($enterprisePricePerBranchMinor / 100, 0);
|
||||||
|
$enterpriseTotal = number_format($enterprisePriceMinor / 100, 0);
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
<div class="mx-auto max-w-2xl">
|
<div class="mx-auto max-w-5xl space-y-6">
|
||||||
<div class="overflow-hidden rounded-2xl border border-slate-200 bg-white">
|
@if (session('success'))
|
||||||
<div class="bg-gradient-to-r from-indigo-700 via-teal-600 to-cyan-500 px-6 py-7 text-white">
|
<div class="rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-800">{{ session('success') }}</div>
|
||||||
<div class="flex items-center gap-2">
|
@endif
|
||||||
<span class="rounded-md bg-white/20 px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide">Pro</span>
|
@if (session('error'))
|
||||||
@if ($isPro)
|
<div class="rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-800">{{ session('error') }}</div>
|
||||||
<span class="rounded-md bg-emerald-400/90 px-2 py-0.5 text-[11px] font-semibold text-emerald-950">Active</span>
|
@endif
|
||||||
@endif
|
|
||||||
</div>
|
<div class="rounded-2xl border border-slate-200 bg-white px-6 py-5">
|
||||||
<h1 class="mt-3 text-2xl font-bold">Ladill Queue Pro</h1>
|
<h1 class="text-2xl font-bold text-slate-900">Choose your Queue plan</h1>
|
||||||
<p class="mt-1 text-sm text-white/80">Unlimited branches, queues, and advanced queue management.</p>
|
<p class="mt-1 text-sm text-slate-600">Billed monthly from your Ladill wallet. Enterprise includes a one-time setup fee — <a href="{{ $salesUrl }}" class="font-medium text-indigo-600 hover:text-indigo-800" target="_blank" rel="noopener">contact sales</a> for onboarding.</p>
|
||||||
<p class="mt-4 text-3xl font-bold">{{ $currency }} {{ $price }}<span class="text-base font-medium text-white/70"> / month</span></p>
|
</div>
|
||||||
|
|
||||||
|
<div class="grid gap-5 lg:grid-cols-3">
|
||||||
|
{{-- Free --}}
|
||||||
|
<div class="flex flex-col rounded-2xl border border-slate-200 bg-white p-6 {{ $planKey === 'free' ? 'ring-2 ring-indigo-500' : '' }}">
|
||||||
|
<p class="text-xs font-semibold uppercase tracking-wide text-slate-500">Free</p>
|
||||||
|
<p class="mt-2 text-3xl font-bold text-slate-900">GHS 0</p>
|
||||||
|
<p class="mt-1 text-sm text-slate-500">1 branch · 5 queues</p>
|
||||||
|
<ul class="mt-5 flex-1 space-y-2 text-sm text-slate-700">
|
||||||
|
<li>Core queue & tickets</li>
|
||||||
|
<li>1 kiosk · 1 display</li>
|
||||||
|
<li>Basic analytics</li>
|
||||||
|
</ul>
|
||||||
|
@if ($planKey === 'free')
|
||||||
|
<p class="mt-6 text-sm font-medium text-indigo-700">Current plan</p>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="px-6 py-6">
|
{{-- Pro --}}
|
||||||
<ul class="grid gap-3 sm:grid-cols-2">
|
<div class="flex flex-col rounded-2xl border border-slate-200 bg-white p-6 {{ $planKey === 'pro' ? 'ring-2 ring-indigo-500' : '' }}">
|
||||||
@foreach ($proFeatures as $feature)
|
<p class="text-xs font-semibold uppercase tracking-wide text-indigo-600">Pro</p>
|
||||||
<li class="flex items-start gap-2 text-sm text-slate-700">
|
<p class="mt-2 text-3xl font-bold text-slate-900">{{ $currency }} {{ $proPrice }}<span class="text-base font-medium text-slate-500">/mo</span></p>
|
||||||
<svg class="mt-0.5 h-4 w-4 shrink-0 text-emerald-500" fill="none" viewBox="0 0 24 24" stroke-width="2.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="m4.5 12.75 6 6 9-13.5"/></svg>
|
<p class="mt-1 text-sm text-slate-500">Unlimited branches & queues</p>
|
||||||
<span>{{ $feature }}</span>
|
<ul class="mt-5 flex-1 space-y-2 text-sm text-slate-700">
|
||||||
</li>
|
<li>Advanced routing rules</li>
|
||||||
@endforeach
|
<li>Unlimited kiosks & displays</li>
|
||||||
|
<li>Care & Frontdesk API</li>
|
||||||
|
<li>Reports & exports</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<div class="mt-6">
|
||||||
<div class="mt-6 border-t border-slate-100 pt-6">
|
@if ($planKey === 'pro')
|
||||||
@if ($isPro)
|
<p class="text-sm text-slate-600">
|
||||||
<div class="text-sm text-slate-600">
|
Active
|
||||||
@if ($planExpiresAt)
|
@if ($planExpiresAt)
|
||||||
Pro is active until <strong>{{ $planExpiresAt->format('d M Y') }}</strong>.
|
until <strong>{{ $planExpiresAt->format('d M Y') }}</strong>
|
||||||
@else
|
|
||||||
Your organization is on Queue Pro.
|
|
||||||
@endif
|
@endif
|
||||||
</div>
|
.
|
||||||
|
</p>
|
||||||
@elseif ($canManage)
|
@elseif ($canManage)
|
||||||
<form method="post" action="{{ route('qms.pro.subscribe') }}">
|
<form method="post" action="{{ route('qms.pro.subscribe') }}">
|
||||||
@csrf
|
@csrf
|
||||||
<button class="btn-primary w-full sm:w-auto">
|
<button class="btn-primary w-full">Upgrade to Pro</button>
|
||||||
Upgrade to Pro — {{ $currency }} {{ $price }}/mo from wallet
|
|
||||||
</button>
|
|
||||||
</form>
|
</form>
|
||||||
<p class="mt-3 text-xs text-slate-400">Billed monthly from your Ladill wallet.</p>
|
|
||||||
@else
|
@else
|
||||||
<p class="rounded-xl bg-slate-50 px-4 py-3 text-sm text-slate-500">Ask an organization administrator to upgrade this workspace to Pro.</p>
|
<p class="text-sm text-slate-500">Ask an admin to upgrade.</p>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Enterprise --}}
|
||||||
|
<div class="flex flex-col rounded-2xl border border-slate-200 bg-gradient-to-b from-slate-900 to-slate-800 p-6 text-white {{ $planKey === 'enterprise' ? 'ring-2 ring-amber-400' : '' }}">
|
||||||
|
<p class="text-xs font-semibold uppercase tracking-wide text-amber-300">Enterprise</p>
|
||||||
|
<p class="mt-2 text-3xl font-bold">{{ $currency }} {{ $enterprisePerBranch }}<span class="text-base font-medium text-slate-300">/branch/mo</span></p>
|
||||||
|
<p class="mt-1 text-sm text-slate-300">
|
||||||
|
@if ($branchCount > 0)
|
||||||
|
{{ $branchCount }} active {{ str('branch')->plural($branchCount) }} = {{ $currency }} {{ $enterpriseTotal }}/mo
|
||||||
|
@else
|
||||||
|
Per-branch billing for multi-site
|
||||||
|
@endif
|
||||||
|
</p>
|
||||||
|
<ul class="mt-5 flex-1 space-y-2 text-sm text-slate-200">
|
||||||
|
<li>Everything in Pro</li>
|
||||||
|
<li>Full API & integrations</li>
|
||||||
|
<li>Advanced analytics + SLA</li>
|
||||||
|
<li>Dedicated onboarding (setup fee)</li>
|
||||||
|
</ul>
|
||||||
|
<div class="mt-6 space-y-2">
|
||||||
|
@if ($planKey === 'enterprise')
|
||||||
|
<p class="text-sm text-slate-200">
|
||||||
|
Active
|
||||||
|
@if ($planExpiresAt)
|
||||||
|
until <strong class="text-white">{{ $planExpiresAt->format('d M Y') }}</strong>
|
||||||
|
@endif
|
||||||
|
@if ($enterpriseBilledBranches > 0)
|
||||||
|
· billed for {{ $enterpriseBilledBranches }} {{ str('branch')->plural($enterpriseBilledBranches) }}
|
||||||
|
@endif
|
||||||
|
.
|
||||||
|
</p>
|
||||||
|
@elseif ($canManage)
|
||||||
|
@if ($canSubscribeEnterprise)
|
||||||
|
<form method="post" action="{{ route('qms.pro.subscribe-enterprise') }}">
|
||||||
|
@csrf
|
||||||
|
<button class="w-full rounded-xl bg-amber-400 px-4 py-2.5 text-sm font-semibold text-slate-900 hover:bg-amber-300">
|
||||||
|
Upgrade to Enterprise — {{ $currency }} {{ $enterpriseTotal }}/mo
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@else
|
||||||
|
<p class="text-sm text-slate-300">Add at least {{ $enterpriseMinBranches }} active branches, or choose Pro for a single site.</p>
|
||||||
|
@endif
|
||||||
|
<a href="{{ $salesUrl }}" target="_blank" rel="noopener" class="block text-center text-xs text-amber-200 underline hover:text-white">Contact sales for setup & SLA</a>
|
||||||
|
@else
|
||||||
|
<p class="text-sm text-slate-300">Ask an admin to upgrade.</p>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -172,5 +172,6 @@ Route::middleware(['auth', 'platform.session'])->group(function () {
|
|||||||
|
|
||||||
Route::get('/pro', [ProController::class, 'index'])->name('qms.pro.index');
|
Route::get('/pro', [ProController::class, 'index'])->name('qms.pro.index');
|
||||||
Route::post('/pro/subscribe', [ProController::class, 'subscribe'])->name('qms.pro.subscribe');
|
Route::post('/pro/subscribe', [ProController::class, 'subscribe'])->name('qms.pro.subscribe');
|
||||||
|
Route::post('/pro/subscribe-enterprise', [ProController::class, 'subscribeEnterprise'])->name('qms.pro.subscribe-enterprise');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
use App\Http\Middleware\EnsurePlatformSession;
|
use App\Http\Middleware\EnsurePlatformSession;
|
||||||
|
use App\Models\Branch;
|
||||||
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Services\Qms\OrganizationResolver;
|
use App\Services\Qms\OrganizationResolver;
|
||||||
@@ -40,17 +42,50 @@ class QmsProTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_pro_page_renders_for_free_organization(): void
|
public function test_pro_page_renders_three_tier_pricing(): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->owner)
|
$this->actingAs($this->owner)
|
||||||
->get(route('qms.pro.index'))
|
->get(route('qms.pro.index'))
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertSee('Ladill Queue Pro')
|
->assertSee('Choose your Queue plan')
|
||||||
->assertSee('GHS 99')
|
->assertSee('GHS 99')
|
||||||
|
->assertSee('GHS 299')
|
||||||
|
->assertSee('Upgrade to Pro')
|
||||||
|
->assertSee('Enterprise');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_sidebar_shows_upgrade_to_pro_on_dashboard(): void
|
||||||
|
{
|
||||||
|
$this->actingAs($this->owner)
|
||||||
|
->get(route('qms.dashboard'))
|
||||||
|
->assertOk()
|
||||||
->assertSee('Upgrade to Pro');
|
->assertSee('Upgrade to Pro');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_subscribe_upgrades_organization(): void
|
public function test_sidebar_shows_upgrade_for_operator_without_settings_access(): void
|
||||||
|
{
|
||||||
|
$operator = User::create([
|
||||||
|
'public_id' => 'queue-operator-001',
|
||||||
|
'name' => 'Operator',
|
||||||
|
'email' => 'operator@example.com',
|
||||||
|
'password' => bcrypt('password'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
Member::create([
|
||||||
|
'owner_ref' => $this->organization->owner_ref,
|
||||||
|
'organization_id' => $this->organization->id,
|
||||||
|
'user_ref' => $operator->public_id,
|
||||||
|
'role' => 'queue_operator',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->actingAs($operator)
|
||||||
|
->get(route('qms.dashboard'))
|
||||||
|
->assertOk()
|
||||||
|
->assertSee('Upgrade to Pro')
|
||||||
|
->assertDontSee(route('qms.settings.edit'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_subscribe_upgrades_organization_to_pro(): void
|
||||||
{
|
{
|
||||||
Http::fake([
|
Http::fake([
|
||||||
'billing.test/can-afford*' => Http::response(['affordable' => true]),
|
'billing.test/can-afford*' => Http::response(['affordable' => true]),
|
||||||
@@ -65,6 +100,35 @@ class QmsProTest extends TestCase
|
|||||||
$this->assertSame('pro', $this->organization->fresh()->settings['plan']);
|
$this->assertSame('pro', $this->organization->fresh()->settings['plan']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_subscribe_enterprise_requires_multiple_branches(): void
|
||||||
|
{
|
||||||
|
Http::fake([
|
||||||
|
'billing.test/can-afford*' => Http::response(['affordable' => true]),
|
||||||
|
'billing.test/debit' => Http::response(['ok' => true]),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->actingAs($this->owner)
|
||||||
|
->post(route('qms.pro.subscribe-enterprise'))
|
||||||
|
->assertRedirect(route('qms.pro.index'))
|
||||||
|
->assertSessionHas('error');
|
||||||
|
|
||||||
|
Branch::create([
|
||||||
|
'owner_ref' => $this->organization->owner_ref,
|
||||||
|
'organization_id' => $this->organization->id,
|
||||||
|
'name' => 'Second',
|
||||||
|
'is_active' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->actingAs($this->owner)
|
||||||
|
->post(route('qms.pro.subscribe-enterprise'))
|
||||||
|
->assertRedirect(route('qms.pro.index'))
|
||||||
|
->assertSessionHas('success');
|
||||||
|
|
||||||
|
$settings = $this->organization->fresh()->settings;
|
||||||
|
$this->assertSame('enterprise', $settings['plan']);
|
||||||
|
$this->assertSame(2, $settings['enterprise_billed_branches']);
|
||||||
|
}
|
||||||
|
|
||||||
public function test_pro_renew_extends_subscription_when_wallet_charges(): void
|
public function test_pro_renew_extends_subscription_when_wallet_charges(): void
|
||||||
{
|
{
|
||||||
$this->organization->update([
|
$this->organization->update([
|
||||||
@@ -85,4 +149,37 @@ class QmsProTest extends TestCase
|
|||||||
$this->assertSame('pro', $settings['plan']);
|
$this->assertSame('pro', $settings['plan']);
|
||||||
$this->assertTrue(now()->parse($settings['plan_expires_at'])->isFuture());
|
$this->assertTrue(now()->parse($settings['plan_expires_at'])->isFuture());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_enterprise_renew_charges_per_active_branch(): void
|
||||||
|
{
|
||||||
|
Branch::create([
|
||||||
|
'owner_ref' => $this->organization->owner_ref,
|
||||||
|
'organization_id' => $this->organization->id,
|
||||||
|
'name' => 'Second',
|
||||||
|
'is_active' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->organization->update([
|
||||||
|
'settings' => array_merge($this->organization->settings ?? [], [
|
||||||
|
'plan' => 'enterprise',
|
||||||
|
'auto_renew' => true,
|
||||||
|
'enterprise_billed_branches' => 2,
|
||||||
|
'plan_expires_at' => now()->subDay()->toIso8601String(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
|
||||||
|
Http::fake([
|
||||||
|
'billing.test/debit' => function ($request) {
|
||||||
|
$this->assertSame(59800, (int) $request['amount_minor']);
|
||||||
|
|
||||||
|
return Http::response(['ok' => true]);
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->artisan('qms:pro-renew')->assertSuccessful();
|
||||||
|
|
||||||
|
$settings = $this->organization->fresh()->settings;
|
||||||
|
$this->assertSame('enterprise', $settings['plan']);
|
||||||
|
$this->assertSame(2, $settings['enterprise_billed_branches']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user