diff --git a/app/Http/Requests/CompanyGateway/StoreCompanyGatewayRequest.php b/app/Http/Requests/CompanyGateway/StoreCompanyGatewayRequest.php index 47513d4f40f3..6d138eba258b 100644 --- a/app/Http/Requests/CompanyGateway/StoreCompanyGatewayRequest.php +++ b/app/Http/Requests/CompanyGateway/StoreCompanyGatewayRequest.php @@ -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); } } diff --git a/app/Http/Requests/CompanyGateway/UpdateCompanyGatewayRequest.php b/app/Http/Requests/CompanyGateway/UpdateCompanyGatewayRequest.php index cf7107b80ced..15c3e5e5a13a 100644 --- a/app/Http/Requests/CompanyGateway/UpdateCompanyGatewayRequest.php +++ b/app/Http/Requests/CompanyGateway/UpdateCompanyGatewayRequest.php @@ -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'])) {