Bill Frontdesk Pro and Enterprise per branch.
Deploy Ladill Frontdesk / deploy (push) Successful in 47s

Pro is GHS 990/branch/mo and Enterprise is GHS 1990/branch/mo, with the
Care-style branch selector UI, self-serve Enterprise checkout, and renewal
charges scaled to billed branches.
This commit is contained in:
isaacclad
2026-07-16 00:42:34 +00:00
parent 3bbd1a8ddd
commit bdbf572f19
9 changed files with 295 additions and 61 deletions
+16 -8
View File
@@ -18,7 +18,7 @@ class ProRenewalService
public function dueOrganizations(): Collection
{
return Organization::query()
->where('settings->plan', 'pro')
->whereIn('settings->plan', ['pro', 'enterprise'])
->whereNotNull('settings->plan_expires_at')
->get()
->filter(fn (Organization $organization) => $this->isDue($organization));
@@ -27,7 +27,7 @@ class ProRenewalService
public function isDue(Organization $organization): bool
{
$settings = $organization->settings ?? [];
if (($settings['plan'] ?? '') !== 'pro') {
if (! in_array($settings['plan'] ?? '', ['pro', 'enterprise'], true)) {
return false;
}
if (array_key_exists('auto_renew', $settings) && $settings['auto_renew'] === false) {
@@ -47,24 +47,32 @@ class ProRenewalService
}
$settings = $organization->settings ?? [];
$price = $this->plans->proPriceMinor();
$reference = 'frontdesk-pro-'.$organization->id.'-'.now()->format('YmdHis');
$plan = (string) ($settings['plan'] ?? 'pro');
$branches = max(
1,
(int) ($settings['billed_branches'] ?? 0),
$this->plans->activeBranchCount($organization),
);
$price = $this->plans->priceForBranches($plan, $branches);
$reference = 'frontdesk-'.$plan.'-'.$organization->id.'-'.now()->format('YmdHis');
$label = $plan === 'enterprise' ? 'Enterprise' : 'Pro';
try {
$charged = $this->billing->debit(
$organization->owner_ref,
$price,
'frontdesk_pro_renewal',
'frontdesk_'.$plan.'_renewal',
$reference,
'Ladill Frontdesk Pro — monthly renewal',
'Ladill Frontdesk '.$label.' — '.$branches.' branch(es) monthly renewal',
);
} catch (\Throwable) {
$charged = false;
}
if ($charged) {
$settings['plan'] = 'pro';
$settings['plan'] = $plan;
$settings['auto_renew'] = true;
$settings['billed_branches'] = $branches;
$settings['plan_expires_at'] = now()
->addDays((int) config('frontdesk.pro.period_days', 30))
->toIso8601String();
@@ -78,7 +86,7 @@ class ProRenewalService
$graceEnd = $expires->copy()->addDays((int) config('frontdesk.pro.grace_days', 3));
if ($graceEnd->isPast()) {
$settings['plan'] = 'free';
unset($settings['plan_expires_at']);
unset($settings['plan_expires_at'], $settings['billed_branches']);
$settings['plan_renewal_error'] = 'Suspended after failed renewal.';
} else {
$settings['plan_renewal_error'] = 'Renewal failed — top up your wallet.';