Company Gateway cleanup

This commit is contained in:
David Bomba 2021-01-22 07:45:00 +11:00
parent ebf5767bf4
commit 3d468e5f40
2 changed files with 12 additions and 24 deletions

View File

@ -25,6 +25,7 @@ class StoreCompanyGatewayRequest extends Request
*
* @return bool
*/
public function authorize() : bool
{
return auth()->user()->isAdmin();
@ -43,27 +44,32 @@ class StoreCompanyGatewayRequest extends Request
protected function prepareForValidation()
{
$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']) && is_object(json_decode($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'])) {
if (isset($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']);
}
$this->replace($input);
}
}

View File

@ -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)
{
$new_arr = [];