mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Company Gateway cleanup
This commit is contained in:
parent
ebf5767bf4
commit
3d468e5f40
@ -25,6 +25,7 @@ class StoreCompanyGatewayRequest extends Request
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function authorize() : bool
|
public function authorize() : bool
|
||||||
{
|
{
|
||||||
return auth()->user()->isAdmin();
|
return auth()->user()->isAdmin();
|
||||||
@ -43,27 +44,32 @@ class StoreCompanyGatewayRequest extends Request
|
|||||||
protected function prepareForValidation()
|
protected function prepareForValidation()
|
||||||
{
|
{
|
||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
|
|
||||||
$gateway = Gateway::where('key', $input['gateway_key'])->first();
|
$gateway = Gateway::where('key', $input['gateway_key'])->first();
|
||||||
|
|
||||||
$default_gateway_fields = json_decode($gateway->fields);
|
$default_gateway_fields = json_decode($gateway->fields);
|
||||||
|
|
||||||
/*Force gateway properties */
|
/*Force gateway properties */
|
||||||
if (isset($input['config']) && is_object(json_decode($input['config']))) {
|
if (isset($input['config']) && is_object(json_decode($input['config']))) {
|
||||||
|
|
||||||
foreach (json_decode($input['config']) as $key => $value) {
|
foreach (json_decode($input['config']) as $key => $value) {
|
||||||
|
|
||||||
$default_gateway_fields->{$key} = $value;
|
$default_gateway_fields->{$key} = $value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$input['config'] = json_encode($default_gateway_fields);
|
$input['config'] = json_encode($default_gateway_fields);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($input['config'])) {
|
if (isset($input['config']))
|
||||||
$input['config'] = encrypt($input['config']);
|
$input['config'] = encrypt($input['config']);
|
||||||
}
|
|
||||||
|
if (isset($input['fees_and_limits']))
|
||||||
if (isset($input['fees_and_limits'])) {
|
|
||||||
$input['fees_and_limits'] = $this->cleanFeesAndLimits($input['fees_and_limits']);
|
$input['fees_and_limits'] = $this->cleanFeesAndLimits($input['fees_and_limits']);
|
||||||
}
|
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -78,24 +78,6 @@ trait CompanyGatewayFeesAndLimitsSaver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function cleanFeesAndLimits($fees_and_limits)
|
|
||||||
// {
|
|
||||||
// $new_arr = [];
|
|
||||||
|
|
||||||
// foreach ($fees_and_limits as $key => $value) {
|
|
||||||
// $fal = new FeesAndLimits;
|
|
||||||
|
|
||||||
// foreach ($value as $k => $v) {
|
|
||||||
// $fal->{$k} = $v;
|
|
||||||
// $fal->{$k} = BaseSettings::castAttribute(FeesAndLimits::$casts[$k], $v);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $new_arr[$key] = (array)$fal;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return $new_arr;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
public function cleanFeesAndLimits($fees_and_limits)
|
public function cleanFeesAndLimits($fees_and_limits)
|
||||||
{
|
{
|
||||||
$new_arr = [];
|
$new_arr = [];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user