feat(messaging): suite-channel patient email/SMS and entitlement sync
Deploy Ladill Care / deploy (push) Successful in 40s
Deploy Ladill Care / deploy (push) Successful in 40s
Prefer platform suite messaging for patient email/SMS, fall back to product keys; write suite entitlements on Pro wallet, prepaid, and renewal.
This commit is contained in:
@@ -258,12 +258,24 @@ class ProController extends Controller
|
||||
$settings['auto_renew'] = true;
|
||||
$settings['billing_method'] = 'wallet_monthly';
|
||||
$settings['billed_branches'] = $billedBranches;
|
||||
$settings['plan_expires_at'] = now()
|
||||
->addDays((int) config('care.pro.period_days', 30))
|
||||
->toIso8601String();
|
||||
$expires = now()->addDays((int) config('care.pro.period_days', 30));
|
||||
$settings['plan_expires_at'] = $expires->toIso8601String();
|
||||
unset($settings['plan_renewal_error'], $settings['enterprise_billed_branches']);
|
||||
$organization->update(['settings' => $settings]);
|
||||
|
||||
$billing->syncSuiteEntitlement(
|
||||
$organization->owner_ref,
|
||||
$plan === 'enterprise' ? 'enterprise' : 'pro',
|
||||
'active',
|
||||
$reference,
|
||||
[
|
||||
'period_starts_at' => now()->toIso8601String(),
|
||||
'period_ends_at' => $expires->toIso8601String(),
|
||||
'source' => 'wallet_debit',
|
||||
'metadata' => ['billed_branches' => $billedBranches],
|
||||
],
|
||||
);
|
||||
|
||||
return redirect()->route('care.pro.index')->with('success', $successMessage);
|
||||
}
|
||||
|
||||
@@ -278,8 +290,23 @@ class ProController extends Controller
|
||||
$settings['auto_renew'] = false;
|
||||
$settings['billing_method'] = 'paystack_prepaid';
|
||||
$settings['billed_branches'] = $billedBranches;
|
||||
$settings['plan_expires_at'] = now()->addMonths($months)->toIso8601String();
|
||||
$expires = now()->addMonths($months);
|
||||
$settings['plan_expires_at'] = $expires->toIso8601String();
|
||||
unset($settings['plan_renewal_error'], $settings['enterprise_billed_branches']);
|
||||
$organization->update(['settings' => $settings]);
|
||||
|
||||
// Prepaid already writes entitlements on platform checkout; sync as repair.
|
||||
app(BillingClient::class)->syncSuiteEntitlement(
|
||||
$organization->owner_ref,
|
||||
$plan === 'enterprise' ? 'enterprise' : 'pro',
|
||||
'active',
|
||||
'care-prepaid-sync-'.$organization->id.'-'.now()->format('YmdHis'),
|
||||
[
|
||||
'period_starts_at' => now()->toIso8601String(),
|
||||
'period_ends_at' => $expires->toIso8601String(),
|
||||
'source' => 'checkout',
|
||||
'metadata' => ['billed_branches' => $billedBranches],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user