Gate payment gateway behind Pro and Business plans.
Deploy Ladill POS / deploy (push) Successful in 1m9s

Free accounts keep cash sales only; connecting a gateway and card/MoMo
checkout require a paid plan, with settings upsell copy for free users.
This commit is contained in:
isaacclad
2026-07-15 21:04:09 +00:00
parent 689c9924df
commit 836aa83f41
6 changed files with 133 additions and 32 deletions
@@ -53,6 +53,7 @@ class SettingsController extends Controller
'tables' => $this->scopeToLocation($request, PosTable::owned($owner))
->orderBy('area')->orderBy('position')->orderBy('label')->get(),
'gateway' => $this->gateway->settingFor($account),
'canUsePaymentGateway' => $this->subscriptions->canUsePaymentGateway($account),
]);
}
@@ -144,6 +145,7 @@ class SettingsController extends Controller
/**
* Upsert merchant gateway credentials for the acting account.
* Blank secret fields keep the previously stored encrypted values.
* Free plan cannot connect or change gateway credentials.
*/
protected function persistGateway(Request $request, User $user): void
{
@@ -160,6 +162,11 @@ class SettingsController extends Controller
return;
}
if (! $this->subscriptions->canUsePaymentGateway($user)) {
// Ignore gateway fields on free plan (other settings may still save).
return;
}
$attributes = [
'provider' => $provider !== '' ? $provider : $existing->provider,
'is_active' => $request->boolean('gateway_is_active'),
@@ -4,6 +4,7 @@ namespace App\Services\Payments;
use App\Models\PaymentGatewaySetting;
use App\Models\User;
use App\Services\Pos\SubscriptionService;
use Illuminate\Support\Facades\Http;
use RuntimeException;
@@ -18,6 +19,10 @@ class MerchantGatewayService
public function isConfigured(User|string $owner): bool
{
if (! $this->ownerMayUseGateway($owner)) {
return false;
}
return (bool) $this->settingFor($owner)?->isConfigured();
}
@@ -62,6 +67,10 @@ class MerchantGatewayService
protected function requireConfigured(User|string $owner): PaymentGatewaySetting
{
if (! $this->ownerMayUseGateway($owner)) {
throw new RuntimeException('Connecting your own payment gateway requires a paid plan. Upgrade to Pro or Business.');
}
$setting = $this->settingFor($owner);
if (! $setting?->isConfigured()) {
throw new RuntimeException('Connect Paystack, Flutterwave, or Hubtel in Settings before accepting online payments.');
@@ -70,6 +79,19 @@ class MerchantGatewayService
return $setting;
}
protected function ownerMayUseGateway(User|string $owner): bool
{
$user = $owner instanceof User
? $owner
: User::query()->where('public_id', (string) $owner)->first();
if (! $user) {
return false;
}
return app(SubscriptionService::class)->canUsePaymentGateway($user);
}
/**
* @param array<string, mixed> $metadata
* @return array{checkout_url: string, reference: string, provider: string}
+6
View File
@@ -69,6 +69,12 @@ class SubscriptionService
return $this->hasPaidPlan($user);
}
/** Own payment gateway (Paystack / Flutterwave / Hubtel) requires Pro or Business. */
public function canUsePaymentGateway(User $user): bool
{
return $this->hasPaidPlan($user);
}
public function productCount(string $ownerRef, bool $restaurant): int
{
if ($restaurant) {