1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

fix for company gateways if properties not set

This commit is contained in:
David Bomba 2020-09-02 08:11:59 +10:00
parent 3d8ddb23cf
commit 455e9a8e1d
2 changed files with 34 additions and 0 deletions

View File

@ -13,6 +13,7 @@ namespace App\Http\Requests\CompanyGateway;
use App\Http\Requests\Request;
use App\Http\ValidationRules\ValidCompanyGatewayFeesAndLimitsRule;
use App\Models\Gateway;
use App\Utils\Traits\CompanyGatewayFeesAndLimitsSaver;
class StoreCompanyGatewayRequest extends Request
@ -43,6 +44,22 @@ class StoreCompanyGatewayRequest extends Request
{
$input = $this->all();
$gateway = Gateway::where('key', $input['gateway_key'])->first();
$default_gateway_fields = json_decode($gateway->fields);
/*Force gateway properties */
if(isset($input['config']))
{
foreach(json_decode($input['config']) as $key => $value) {
$default_gateway_fields->{$key} = $value;
}
$input['config'] = json_encode($default_gateway_fields);
}
if (isset($input['config'])) {
$input['config'] = encrypt($input['config']);
}
@ -51,6 +68,7 @@ class StoreCompanyGatewayRequest extends Request
$input['fees_and_limits'] = $this->cleanFeesAndLimits($input['fees_and_limits']);
}
$this->replace($input);
}
}

View File

@ -14,6 +14,7 @@ namespace App\Http\Requests\CompanyGateway;
use App\Http\Requests\Request;
use App\Http\ValidationRules\ValidCompanyGatewayFeesAndLimitsRule;
use App\Models\Company;
use App\Models\Gateway;
use App\Utils\Traits\CompanyGatewayFeesAndLimitsSaver;
class UpdateCompanyGatewayRequest extends Request
@ -44,6 +45,21 @@ class UpdateCompanyGatewayRequest extends Request
{
$input = $this->all();
/*Force gateway properties */
if(isset($input['config']) && $input['gateway_key'])
{
$gateway = Gateway::where('key', $input['gateway_key'])->first();
$default_gateway_fields = json_decode($gateway->fields);
foreach(json_decode($input['config']) as $key => $value) {
$default_gateway_fields->{$key} = $value;
}
$input['config'] = json_encode($default_gateway_fields);
}
$input['config'] = encrypt($input['config']);
if (isset($input['fees_and_limits'])) {