From b14ac451c4c0f54f97ef2bd579f4bf799238ae55 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 3 Jul 2020 18:14:15 +1000 Subject: [PATCH] Payment methods --- app/Models/Client.php | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/app/Models/Client.php b/app/Models/Client.php index 53587c304951..41ddb0fcf693 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -377,6 +377,29 @@ class Client extends BaseModel implements HasLocalePreference return null; } + public function getBankTransferGateway() :?CompanyGateway + { + $company_gateways = $this->getSetting('company_gateway_ids'); + + if (strlen($company_gateways)>=1) { + $gateways = $this->company->company_gateways->whereIn('id', $company_gateways); + } else { + $gateways = $this->company->company_gateways; + } + + foreach ($gateways as $gateway) { + if ($this->currency()->code == 'USD' && in_array(GatewayType::BANK_TRANSFER, $gateway->driver($this)->gatewayTypes())) { + return $gateway; + } + + if ($this->currency()->code == 'EUR' && in_array(GatewayType::SEPA, $gateway->driver($this)->gatewayTypes())) { + return $gateway; + } + } + + return null; + } + public function getCurrencyCode() { if ($this->currency()) { @@ -386,15 +409,6 @@ class Client extends BaseModel implements HasLocalePreference return 'USD'; } - public function getPaymentMethodByType($amount, $type) :array - { - $gateways = $this->company->company_gateways; - - $gateways = $gateways->map(function ($gateway) use($type){ - - }); - } - /** * Generates an array of payment urls per client * for a given amount.