diff --git a/app/Http/Controllers/ClientPortal/PaymentMethodController.php b/app/Http/Controllers/ClientPortal/PaymentMethodController.php index 2ab293af23..809dedac63 100644 --- a/app/Http/Controllers/ClientPortal/PaymentMethodController.php +++ b/app/Http/Controllers/ClientPortal/PaymentMethodController.php @@ -149,11 +149,11 @@ class PaymentMethodController extends Controller private function getClientGateway() { if (request()->query('method') == GatewayType::CREDIT_CARD) { - return $gateway = auth()->user()->client->getCreditCardGateway(); + return auth()->user()->client->getCreditCardGateway(); } - if (request()->query('method') == GatewayType::BANK_TRANSFER) { - return $gateway = auth()->user()->client->getBankTransferGateway(); + if (in_array(request()->query('method'), [GatewayType::BANK_TRANSFER, GatewayType::DIRECT_DEBIT])) { + return auth()->user()->client->getBankTransferGateway(); } abort(404, 'Gateway not found.'); diff --git a/app/Models/Client.php b/app/Models/Client.php index aaf56737c4..8aade69c19 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -518,6 +518,18 @@ class Client extends BaseModel implements HasLocalePreference } + if ($this->country->iso_3166_3 == 'GBR' && in_array(GatewayType::DIRECT_DEBIT, array_column($pms, 'gateway_type_id'))) { + foreach ($pms as $pm) { + if ($pm['gateway_type_id'] == GatewayType::DIRECT_DEBIT) { + $cg = CompanyGateway::find($pm['company_gateway_id']); + + if ($cg && $cg->fees_and_limits->{GatewayType::DIRECT_DEBIT}->is_enabled) { + return $cg; + } + } + } + } + return null; // $company_gateways = $this->getSetting('company_gateway_ids'); @@ -556,6 +568,10 @@ class Client extends BaseModel implements HasLocalePreference if ($this->currency()->code == 'EUR') { return GatewayType::SEPA; } + + if ($this->currency()->code == 'GBP') { + return GatewayType::DIRECT_DEBIT; + } } public function getCurrencyCode()