/** * Store a newly created resource in storage. */ public function store(Request $request) { $this->validate($request, ['title' => 'required', 'short' => 'required', 'status' => 'required', 'rpc_host' => 'required', 'rpc_port' => 'required', 'rpc_username' => 'required', 'rpc_password' => 'required']); Wallet::create($request->all()); Session::flash('flash_message', 'Wallet added!'); return redirect('admin/wallets'); }
public function index(Request $request) { //get info for this payment $payTypeInfo = Pay::find(Pay::PAY_TYPE_MOBIO); //calc promo period $promoUntilDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') + $payTypeInfo->pay_promo_period, date('Y'))); //get incoming params $message = isset($request->message) ? $request->message : null; $item = isset($request->item) ? $request->item : null; $fromnum = isset($request->fromnum) ? $request->fromnum : null; $extid = isset($request->extid) ? $request->extid : null; $servID = isset($request->servID) ? $request->servID : null; //check if ping is comming from allowed ips $mobio_remote_address = explode(',', $payTypeInfo->pay_allowed_ip); if (in_array($request->ip(), $mobio_remote_address)) { $sms_reply = trans('payment_mobio.There is error, please contact us.'); $item = trim($item); if (!empty($item)) { try { $pay_type = mb_strtolower(mb_substr($item, 0, 1)); //make ad vip if ($pay_type == 'a') { $ad_id = mb_substr($item, 1); $adInfo = Ad::find($ad_id); if (!empty($adInfo)) { //update ad $adInfo->ad_promo = 1; $adInfo->ad_promo_until = $promoUntilDate; $adInfo->save(); //add money to wallet $wallet_data = ['user_id' => $adInfo->user_id, 'ad_id' => $ad_id, 'sum' => $payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_mobio.Payment via Mobio SMS')]; Wallet::create($wallet_data); //subtract money from wallet $wallet_data = ['user_id' => $adInfo->user_id, 'ad_id' => $ad_id, 'sum' => -$payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_fortumo.Your ad #:ad_id is Promo Until :date.', ['ad_id' => $ad_id, 'date' => $promoUntilDate])]; Wallet::create($wallet_data); $sms_reply = trans('payment_mobio.Your ad #:ad_id is Promo Until :date.', ['ad_id' => $ad_id, 'date' => $promoUntilDate]); Cache::flush(); } } //add money to wallet if ($pay_type == 'w') { $user_id = mb_substr($item, 1); $userInfo = User::find($user_id); if (!empty($userInfo)) { //save money to wallet $wallet_data = ['user_id' => $userInfo->user_id, 'sum' => $payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_mobio.Add Money to Wallet via Mobio SMS')]; Wallet::create($wallet_data); $sms_reply = trans('payment_mobio.You have added :money to your wallet.', ['money' => number_format($payTypeInfo->pay_sum, 2) . config('dc.site_price_sign')]); Cache::flush(); } } } catch (\Exception $e) { } } file_get_contents("http://mobio.bg/paynotify/pnsendsms.php?servID={$servID}&tonum={$fromnum}&extid={$extid}&message=" . urlencode($sms_reply)); } }
public function index(Request $request) { $sms_reply = trans('payment_fortumo.There is error, please contact us.'); //get info for this payment $payTypeInfo = Pay::find(Pay::PAY_TYPE_FORTUMO); //calc promo period $promoUntilDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') + $payTypeInfo->pay_promo_period, date('Y'))); //get incoming params $message = isset($request->message) ? $request->message : null; $status = isset($request->status) ? $request->status : null; $billing_type = isset($request->billing_type) ? $request->billing_type : null; //check if ping is comming from allowed ips $fortumo_remote_address = explode(',', $payTypeInfo->pay_allowed_ip); if (in_array($request->ip(), $fortumo_remote_address) && $this->check_signature($request->all(), $payTypeInfo->pay_secret)) { $message = trim($message); if (!empty($message) && (preg_match("/OK/i", $status) || preg_match("/MO/i", $billing_type) && preg_match("/pending/i", $status))) { try { $pay_type = mb_strtolower(mb_substr($message, 0, 1)); //make ad vip if ($pay_type == 'a') { $ad_id = mb_substr($message, 1); $adInfo = Ad::find($ad_id); if (!empty($adInfo)) { //update ad $adInfo->ad_promo = 1; $adInfo->ad_promo_until = $promoUntilDate; $adInfo->save(); //add money to wallet $wallet_data = ['user_id' => $adInfo->user_id, 'ad_id' => $ad_id, 'sum' => $payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_fortumo.Payment via Fortumo SMS')]; Wallet::create($wallet_data); //subtract money from wallet $wallet_data = ['user_id' => $adInfo->user_id, 'ad_id' => $ad_id, 'sum' => -$payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_fortumo.Your ad #:ad_id is Promo Until :date.', ['ad_id' => $ad_id, 'date' => $promoUntilDate])]; Wallet::create($wallet_data); $sms_reply = trans('payment_fortumo.Your ad #:ad_id is Promo Until :date.', ['ad_id' => $ad_id, 'date' => $promoUntilDate]); Cache::flush(); } } //add money to wallet if ($pay_type == 'w') { $user_id = mb_substr($message, 1); $userInfo = User::find($user_id); if (!empty($userInfo)) { //save money to wallet $wallet_data = ['user_id' => $userInfo->user_id, 'sum' => $payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_fortumo.Add Money to Wallet via Fortumo SMS')]; Wallet::create($wallet_data); $sms_reply = trans('payment_fortumo.You have added :money to your wallet.', ['money' => number_format($payTypeInfo->pay_sum, 2) . config('dc.site_price_sign')]); Cache::flush(); } } } catch (\Exception $e) { } } } echo $sms_reply; }
public function edit(Request $request) { $id = 0; if (isset($request->id)) { $id = $request->id; } $modelData = new \stdClass(); if ($id > 0) { try { $modelData = Wallet::findOrFail($id); } catch (ModelNotFoundException $e) { session()->flash('message', trans('admin_common.Invalid Wallet Item')); return redirect(url('admin/wallet')); } } /** * form is submitted check values and save if needed */ if ($request->isMethod('post')) { /** * validate data */ $rules = ['user_id' => 'required|integer|not_in:0', 'ad_id' => 'integer|not_in:0', 'sum' => 'required|numeric|not_in:0', 'wallet_date' => 'required|max:255', 'wallet_description' => 'required|max:255']; $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { $this->throwValidationException($request, $validator); } /** * get data from form */ $data = $request->all(); if (empty($data['ad_id'])) { unset($data['ad_id']); } /** * save or update */ if (!isset($modelData->wallet_id)) { Wallet::create($data); } else { $modelData->update($data); } /** * clear cache, set message, redirect to list */ Cache::flush(); session()->flash('message', trans('admin_common.Wallet Item saved')); return redirect(url('admin/wallet')); } return view('admin.wallet.wallet_edit', ['modelData' => $modelData]); }