From 0d20e756369184988f3d470f57d80b5e6ef9a70d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Tue, 19 Oct 2021 18:05:27 +0200 Subject: [PATCH] Allow GatewayType\SEPA to show on methods page --- .../ClientPortal/PaymentMethodController.php | 2 +- app/Models/Client.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ClientPortal/PaymentMethodController.php b/app/Http/Controllers/ClientPortal/PaymentMethodController.php index 2ab293af2397..3dcc0dfe8eef 100644 --- a/app/Http/Controllers/ClientPortal/PaymentMethodController.php +++ b/app/Http/Controllers/ClientPortal/PaymentMethodController.php @@ -152,7 +152,7 @@ class PaymentMethodController extends Controller return $gateway = auth()->user()->client->getCreditCardGateway(); } - if (request()->query('method') == GatewayType::BANK_TRANSFER) { + if (in_array(request()->query('method'), [GatewayType::BANK_TRANSFER, GatewayType::SEPA])) { return $gateway = auth()->user()->client->getBankTransferGateway(); } diff --git a/app/Models/Client.php b/app/Models/Client.php index 1a739f288604..ddb18656c779 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -518,6 +518,18 @@ class Client extends BaseModel implements HasLocalePreference } + if ($this->currency()->code == 'EUR' && in_array(GatewayType::SEPA, array_column($pms, 'gateway_type_id'))) { + foreach ($pms as $pm) { + if ($pm['gateway_type_id'] == GatewayType::SEPA) { + $cg = CompanyGateway::find($pm['company_gateway_id']); + + if ($cg && $cg->fees_and_limits->{GatewayType::SEPA}->is_enabled) { + return $cg; + } + } + } + } + return null; }