Add optional owner gateway routing to Merchant.
Deploy Ladill Merchant / deploy (push) Successful in 44s
Deploy Ladill Merchant / deploy (push) Successful in 44s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,15 +3,23 @@
|
||||
namespace App\Http\Controllers\Qr;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\PaymentGatewaySetting;
|
||||
use App\Models\QrSetting;
|
||||
use App\Services\Billing\BillingClient;
|
||||
use App\Services\Billing\PlanEntitlementService;
|
||||
use App\Services\Payments\MerchantGatewayService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class AccountController extends Controller
|
||||
{
|
||||
public function __construct(private BillingClient $billing) {}
|
||||
public function __construct(
|
||||
private BillingClient $billing,
|
||||
private PlanEntitlementService $entitlements,
|
||||
private MerchantGatewayService $gateway,
|
||||
) {}
|
||||
|
||||
private function topupUrl(): string
|
||||
{
|
||||
@@ -65,6 +73,8 @@ class AccountController extends Controller
|
||||
return view('merchant.settings', [
|
||||
'account' => $account,
|
||||
'settings' => $settings,
|
||||
'gateway' => $this->gateway->settingFor($account),
|
||||
'canUsePaymentGateway' => $this->entitlements->canUseCustomPaymentGateway($account),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -77,6 +87,10 @@ class AccountController extends Controller
|
||||
'product_updates' => ['nullable', 'boolean'],
|
||||
'notify_registrations' => ['nullable', 'boolean'],
|
||||
'notify_payouts' => ['nullable', 'boolean'],
|
||||
'gateway_provider' => ['nullable', Rule::in(['', PaymentGatewaySetting::PROVIDER_PAYSTACK])],
|
||||
'gateway_public_key' => ['nullable', 'string', 'max:2000'],
|
||||
'gateway_secret_key' => ['nullable', 'string', 'max:2000'],
|
||||
'gateway_is_active' => ['nullable', 'boolean'],
|
||||
]);
|
||||
|
||||
QrSetting::updateOrCreate(
|
||||
@@ -89,6 +103,25 @@ class AccountController extends Controller
|
||||
],
|
||||
);
|
||||
|
||||
if ($this->entitlements->canUseCustomPaymentGateway($account)) {
|
||||
$provider = trim((string) ($data['gateway_provider'] ?? ''));
|
||||
$setting = PaymentGatewaySetting::query()->where('owner_ref', $account->public_id)->first();
|
||||
if ($provider !== '' || $setting) {
|
||||
$setting ??= new PaymentGatewaySetting(['owner_ref' => $account->public_id]);
|
||||
if ($provider !== '') {
|
||||
$setting->provider = $provider;
|
||||
}
|
||||
if (filled($data['gateway_public_key'] ?? null)) {
|
||||
$setting->public_key = $data['gateway_public_key'];
|
||||
}
|
||||
if (filled($data['gateway_secret_key'] ?? null)) {
|
||||
$setting->secret_key = $data['gateway_secret_key'];
|
||||
}
|
||||
$setting->is_active = $provider !== '' && $request->boolean('gateway_is_active');
|
||||
$setting->save();
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->route('account.settings')->with('success', 'Settings saved.');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user