Files
ladill-events/app/Models/PaymentGatewaySetting.php
isaaccladandCursor 1bcbdbfdb1
Deploy Ladill Events / deploy (push) Successful in 51s
Make Events payment routing plan-aware.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-21 19:47:10 +00:00

52 lines
1.2 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class PaymentGatewaySetting extends Model
{
public const PROVIDER_PAYSTACK = 'paystack';
public const PROVIDER_FLUTTERWAVE = 'flutterwave';
public const PROVIDER_HUBTEL = 'hubtel';
protected $fillable = [
'owner_ref',
'provider',
'public_key',
'secret_key',
'webhook_secret',
'is_active',
'metadata',
];
protected function casts(): array
{
return [
'public_key' => 'encrypted',
'secret_key' => 'encrypted',
'webhook_secret' => 'encrypted',
'is_active' => 'boolean',
'metadata' => 'array',
];
}
public function isConfigured(): bool
{
if (! $this->is_active) {
return false;
}
$public = trim((string) $this->public_key);
$secret = trim((string) $this->secret_key);
return match ($this->provider) {
self::PROVIDER_PAYSTACK => str_starts_with($public, 'pk_') && str_starts_with($secret, 'sk_'),
self::PROVIDER_FLUTTERWAVE, self::PROVIDER_HUBTEL => $public !== '' && $secret !== '',
default => false,
};
}
}