1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Fixes for gateways

This commit is contained in:
David Bomba 2021-06-30 21:21:46 +10:00
parent 1922fa16fc
commit d353ef9a5f
8 changed files with 27 additions and 27 deletions

View File

@ -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())

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}