mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for payment methods - gateway types
This commit is contained in:
parent
a351b30539
commit
7dbe870ce0
@ -13,6 +13,7 @@ namespace App\Models;
|
|||||||
|
|
||||||
use App\DataMapper\ClientSettings;
|
use App\DataMapper\ClientSettings;
|
||||||
use App\DataMapper\CompanySettings;
|
use App\DataMapper\CompanySettings;
|
||||||
|
use App\Models\CompanyGateway;
|
||||||
use App\Models\Presenters\ClientPresenter;
|
use App\Models\Presenters\ClientPresenter;
|
||||||
use App\Services\Client\ClientService;
|
use App\Services\Client\ClientService;
|
||||||
use App\Utils\Traits\AppSetup;
|
use App\Utils\Traits\AppSetup;
|
||||||
@ -422,35 +423,57 @@ class Client extends BaseModel implements HasLocalePreference
|
|||||||
|
|
||||||
public function getBankTransferGateway() :?CompanyGateway
|
public function getBankTransferGateway() :?CompanyGateway
|
||||||
{
|
{
|
||||||
$company_gateways = $this->getSetting('company_gateway_ids');
|
$pms = $this->service()->getPaymentMethods(0);
|
||||||
|
|
||||||
|
if($this->currency()->code == 'USD' && in_array(GatewayType::BANK_TRANSFER, array_column($pms, 'gateway_type_id'))){
|
||||||
|
|
||||||
|
foreach($pms as $pm){
|
||||||
|
if($pm['gateway_type_id'] == GatewayType::BANK_TRANSFER)
|
||||||
|
return CompanyGateway::find($pm['company_gateway_id']);
|
||||||
|
}
|
||||||
|
|
||||||
if (strlen($company_gateways) >= 1) {
|
|
||||||
$transformed_ids = $this->transformKeys(explode(',', $company_gateways));
|
|
||||||
$gateways = $this->company
|
|
||||||
->company_gateways
|
|
||||||
->whereIn('id', $transformed_ids)
|
|
||||||
->sortby(function ($model) use ($transformed_ids) {
|
|
||||||
return array_search($model->id, $transformed_ids);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$gateways = $this->company->company_gateways;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($gateways as $gateway) {
|
if($this->currency()->code == 'EUR' && in_array(GatewayType::BANK_TRANSFER, array_column($pms, 'gateway_type_id'))){
|
||||||
if ($this->currency()->code == 'USD' && in_array(GatewayType::BANK_TRANSFER, $gateway->driver($this)->gatewayTypeEnabled(GatewayType::BANK_TRANSFER))) {
|
|
||||||
return $gateway;
|
foreach($pms as $pm){
|
||||||
|
if($pm['gateway_type_id'] == GatewayType::SEPA)
|
||||||
|
return CompanyGateway::find($pm['company_gateway_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->currency()->code == 'EUR' && in_array(GatewayType::SEPA, $gateway->driver($this)->gatewayTypeEnabled(GatewayType::SEPA))) {
|
|
||||||
return $gateway;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
// $company_gateways = $this->getSetting('company_gateway_ids');
|
||||||
|
|
||||||
|
// if (strlen($company_gateways) >= 1) {
|
||||||
|
// $transformed_ids = $this->transformKeys(explode(',', $company_gateways));
|
||||||
|
// $gateways = $this->company
|
||||||
|
// ->company_gateways
|
||||||
|
// ->whereIn('id', $transformed_ids)
|
||||||
|
// ->sortby(function ($model) use ($transformed_ids) {
|
||||||
|
// return array_search($model->id, $transformed_ids);
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// $gateways = $this->company->company_gateways;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// foreach ($gateways as $gateway) {
|
||||||
|
// 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)->gatewayTypeEnabled(GatewayType::SEPA))) {
|
||||||
|
// return $gateway;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBankTransferMethodType()
|
public function getBankTransferMethodType()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->currency()->code == 'USD') {
|
if ($this->currency()->code == 'USD') {
|
||||||
return GatewayType::BANK_TRANSFER;
|
return GatewayType::BANK_TRANSFER;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user