diff --git a/app/Mail/SupportMessageSent.php b/app/Mail/SupportMessageSent.php index f7c813836607..9b05fbabe89c 100644 --- a/app/Mail/SupportMessageSent.php +++ b/app/Mail/SupportMessageSent.php @@ -58,9 +58,9 @@ class SupportMessageSent extends Mailable $user = auth()->user(); if(Ninja::isHosted()) - $subject = "Hosted {$user->present()->name} - [{$plan} - DB:{$company->db}]"; + $subject = "Hosted {$user->present()->name} - [{$plan} - {$company->db}]"; else - $subject = "Self Host {$user->present()->name} - [{$plan} - DB:{$company->db}]"; + $subject = "Self Host {$user->present()->name} - [{$plan} - {$company->db}]"; return $this->from(config('mail.from.address'), config('mail.from.name')) ->replyTo($user->email, $user->present()->name()) diff --git a/app/Models/Client.php b/app/Models/Client.php index 07221902c95a..dbc42b4e6e97 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -407,7 +407,7 @@ class Client extends BaseModel implements HasLocalePreference } foreach ($gateways as $gateway) { - if (in_array(GatewayType::CREDIT_CARD, $gateway->driver($this)->gatewayTypes())) { + if (in_array(GatewayType::CREDIT_CARD, $gateway->driver($this)->gatewayTypeEnabled(GatewayType::CREDIT_CARD))) { return $gateway; } } @@ -432,11 +432,11 @@ class Client extends BaseModel implements HasLocalePreference } foreach ($gateways as $gateway) { - if ($this->currency()->code == 'USD' && in_array(GatewayType::BANK_TRANSFER, $gateway->driver($this)->gatewayTypes())) { + if ($this->currency()->code == 'USD' && in_array(GatewayType::BANK_TRANSFER, $gateway->driver($this)->gatewayTypeEnabled(GatewayType::BANK_TRANSFER))) { return $gateway; } - if ($this->currency()->code == 'EUR' && in_array(GatewayType::SEPA, $gateway->driver($this)->gatewayTypes())) { + if ($this->currency()->code == 'EUR' && in_array(GatewayType::SEPA, $gateway->driver($this)->gatewayTypeEnabled(GatewayType::SEPA))) { return $gateway; } } diff --git a/app/PaymentDrivers/AuthorizePaymentDriver.php b/app/PaymentDrivers/AuthorizePaymentDriver.php index 76874570c106..a7477507a7db 100644 --- a/app/PaymentDrivers/AuthorizePaymentDriver.php +++ b/app/PaymentDrivers/AuthorizePaymentDriver.php @@ -58,9 +58,7 @@ class AuthorizePaymentDriver extends BaseDriver { $types = []; - if ($this->company_gateway->fees_and_limits->{GatewayType::CREDIT_CARD}->is_enabled) { $types[] = GatewayType::CREDIT_CARD; - } return $types; } diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index a95c4e26ce23..eb6eb28a8534 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -26,6 +26,7 @@ use App\Models\Client; use App\Models\ClientContact; use App\Models\ClientGatewayToken; use App\Models\CompanyGateway; +use App\Models\GatewayType; use App\Models\Invoice; use App\Models\Payment; use App\Models\PaymentHash; @@ -546,4 +547,16 @@ class BaseDriver extends AbstractPaymentDriver $this->client->company, ); } + + /* Performs an extra iterate on the gatewayTypes() array and passes back only the enabled gateways*/ + public function gatewayTypeEnabled(GatewayType $type) + { + $types = []; + + if ($this->company_gateway->fees_and_limits->{$type}->is_enabled) { + $types[] = $type; + } + + return $types; + } } diff --git a/app/PaymentDrivers/BraintreePaymentDriver.php b/app/PaymentDrivers/BraintreePaymentDriver.php index 2fb1c391b3ff..dd1b1fbb207d 100644 --- a/app/PaymentDrivers/BraintreePaymentDriver.php +++ b/app/PaymentDrivers/BraintreePaymentDriver.php @@ -72,12 +72,9 @@ class BraintreePaymentDriver extends BaseDriver { $types = [ GatewayType::PAYPAL, + GatewayType::CREDIT_CARD ]; - - if ($this->company_gateway->fees_and_limits->{GatewayType::CREDIT_CARD}->is_enabled) { - $types[] = GatewayType::CREDIT_CARD; - } - + return $types; } diff --git a/app/PaymentDrivers/CheckoutComPaymentDriver.php b/app/PaymentDrivers/CheckoutComPaymentDriver.php index 9b681f1eb1cc..1d539c37613a 100644 --- a/app/PaymentDrivers/CheckoutComPaymentDriver.php +++ b/app/PaymentDrivers/CheckoutComPaymentDriver.php @@ -76,10 +76,8 @@ class CheckoutComPaymentDriver extends BaseDriver { $types = []; - if ($this->company_gateway->fees_and_limits->{GatewayType::CREDIT_CARD}->is_enabled) { - $types[] = GatewayType::CREDIT_CARD; - } - + $types[] = GatewayType::CREDIT_CARD; + return $types; } diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index c096729a1301..3075c8ef4c8d 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -115,11 +115,8 @@ class StripePaymentDriver extends BaseDriver { $types = [ GatewayType::CRYPTO, - ]; - - if ($this->company_gateway->fees_and_limits->{GatewayType::CREDIT_CARD}->is_enabled) { - $types[] = GatewayType::CREDIT_CARD; - } + GatewayType::CREDIT_CARD + ]; if ($this->client && isset($this->client->country) @@ -130,7 +127,7 @@ class StripePaymentDriver extends BaseDriver if ($this->client && isset($this->client->country) && in_array($this->client->country->iso_3166_3, ['USA']) - && $this->company_gateway->fees_and_limits->{GatewayType::BANK_TRANSFER}->is_enabled) { + ) { $types[] = GatewayType::BANK_TRANSFER; } diff --git a/app/PaymentDrivers/WePayPaymentDriver.php b/app/PaymentDrivers/WePayPaymentDriver.php index d1af97ac61cd..cebe3812c2d2 100644 --- a/app/PaymentDrivers/WePayPaymentDriver.php +++ b/app/PaymentDrivers/WePayPaymentDriver.php @@ -81,11 +81,8 @@ class WePayPaymentDriver extends BaseDriver { $types = []; - if($this->company_gateway->fees_and_limits->{GatewayType::BANK_TRANSFER}->is_enabled) - $types[] = GatewayType::CREDIT_CARD; - - if($this->company_gateway->fees_and_limits->{GatewayType::BANK_TRANSFER}->is_enabled) - $types[] = GatewayType::BANK_TRANSFER; + $types[] = GatewayType::CREDIT_CARD; + $types[] = GatewayType::BANK_TRANSFER; return $types; }