mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Reimplement fees and limits logic
This commit is contained in:
parent
83fc30f7e7
commit
daa3cc2b68
@ -448,28 +448,30 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
if ($company_gateways) {
|
||||
$gateways = $this->company->company_gateways->whereIn('id', $payment_gateways); //this will never hit
|
||||
} else {
|
||||
$gateways = $this->company->company_gateways;
|
||||
$gateways = $this->company->company_gateways->where('is_deleted', false);
|
||||
}
|
||||
|
||||
$gateways->filter(function ($method) use ($amount) {
|
||||
$valid_gateways = $gateways->filter(function ($method) use ($amount) {
|
||||
|
||||
$fees_and_limits = $method->fees_and_limits;
|
||||
|
||||
if(!$fees_and_limits)
|
||||
return false;
|
||||
if(isset($method->fees_and_limits))
|
||||
$fees_and_limits = $method->fees_and_limits->{"1"};
|
||||
else
|
||||
return true;
|
||||
|
||||
if ((property_exists($fees_and_limits, 'min_limit')) && $fees_and_limits->min_limit !== null && $amount < $fees_and_limits->min_limit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((property_exists($fees_and_limits, 'max_limit')) && $fees_and_limits->max_limit !== null && $amount > $fees_and_limits->min_limit) {
|
||||
if ((property_exists($fees_and_limits, 'min_limit')) && $fees_and_limits->min_limit !== null && $amount < $fees_and_limits->min_limit)
|
||||
return false;
|
||||
|
||||
if ((property_exists($fees_and_limits, 'max_limit')) && $fees_and_limits->max_limit !== null && $amount > $fees_and_limits->min_limit)
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
|
||||
})->all();
|
||||
|
||||
$payment_methods = [];
|
||||
|
||||
foreach ($gateways as $gateway) {
|
||||
foreach ($valid_gateways as $gateway) {
|
||||
foreach ($gateway->driver($this)->gatewayTypes() as $type) {
|
||||
$payment_methods[] = [$gateway->id => $type];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user