芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/myvyralapp.com/bck/app/Http/Controllers/Api/Merchant/GatewaySettingController.php
first(); $data = [ 'wallet_status' => $setting->wallet_status, 'virtual_card_status' =>$setting->virtual_card_status, 'master_visa_status' =>$setting->master_visa_status, 'credentials' =>[ 'primary_key' => $setting->credentials->primary_key??'', 'secret_key' => $setting->credentials->secret_key??'' ], ]; $message = ['success' => ['Gateway Settings']]; return Helpers::success($data, $message); } public function updateWalletStatus(Request $request) { $validator = Validator::make($request->all(), [ 'status' => 'required|boolean' ]); if($validator->fails()){ $error = ['error'=>$validator->errors()->all()]; return Helpers::validation($error); } $setting = GatewaySetting::merchantAuth()->first(); if($request->status == true && $setting->wallet_status == true){ $error = ['error'=>['Your Wallet Balance System Already Enabled']]; return Helpers::error($error); } if($request->status == false && $setting->wallet_status == false){ $error = ['error'=>['Your Wallet Balance System Already Disabled']]; return Helpers::error($error); } try{ $status = $request->status; $setting->wallet_status = $status; $setting->save(); }catch(Exception $e){ $error = ['error'=>['Something went wrong! Please try again']]; return Helpers::error($error); } if($request->status == true ){ $message = ['success' => ['Wallet Balance System Enabled Successfully']]; return Helpers::onlysuccess($message); }else{ $message = ['success' => ['Wallet Balance System Disabled Successfully']]; return Helpers::onlysuccess($message); } } public function updateVirtualCardStatus(Request $request) { $validator = Validator::make($request->all(), [ 'status' => 'required|boolean' ]); if($validator->fails()){ $error = ['error'=>$validator->errors()->all()]; return Helpers::validation($error); } $setting = GatewaySetting::merchantAuth()->first(); if($request->status == true && $setting->virtual_card_status == true){ $error = ['error'=>['Your Virtual Card System Already Enabled']]; return Helpers::error($error); } if($request->status == false && $setting->virtual_card_status == false){ $error = ['error'=>['Your Virtual Card System Already Disabled']]; return Helpers::error($error); } try{ $status = $request->status; $setting->virtual_card_status = $status; $setting->save(); }catch(Exception $e){ $error = ['error'=>['Something went wrong! Please try again']]; return Helpers::error($error); } if($request->status == true ){ $message = ['success' => ['Virtual Card System Enabled Successfully']]; return Helpers::onlysuccess($message); }else{ $message = ['success' => ['Virtual Card System Disabled Successfully']]; return Helpers::onlysuccess($message); } } public function updateMasterCardStatus(Request $request) { $validator = Validator::make($request->all(), [ 'status' => 'required|boolean' ]); if($validator->fails()){ $error = ['error'=>$validator->errors()->all()]; return Helpers::validation($error); } $setting = GatewaySetting::merchantAuth()->first(); if($request->status == true && $setting->master_visa_status == true){ $error = ['error'=>['Your Master/Visa System Already Enabled']]; return Helpers::error($error); } if($request->status == false && $setting->master_visa_status == false){ $error = ['error'=>['Your Master/Visa System Already Disabled']]; return Helpers::error($error); } try{ $status = $request->status; $setting->master_visa_status = $status; $setting->save(); }catch(Exception $e){ $error = ['error'=>['Something went wrong! Please try again']]; return Helpers::error($error); } if($request->status == true ){ $message = ['success' => ['Master/Visa System Enabled Successfully']]; return Helpers::onlysuccess($message); }else{ $message = ['success' => ['Master/Visa System Disabled Successfully']]; return Helpers::onlysuccess($message); } } public function updateMasterCardCredentials(Request $request) { $validator = Validator::make($request->all(), [ 'primary_key' => "required|string|max:255", 'secret_key' => "required|string|max:255", ]); if($validator->fails()){ $error = ['error'=>$validator->errors()->all()]; return Helpers::validation($error); } $validated = $validator->validate(); $setting = GatewaySetting::merchantAuth()->first(); $setting->master_visa_status = true; $setting->credentials = [ 'primary_key' => $validated['primary_key']??$setting->primary_key, 'secret_key' => $validated['secret_key']??$setting->secret_key ]; $setting->save(); $message = ['success' => ['Master/Visa card credentials updated successfully!']]; return Helpers::onlysuccess($message); } }