/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(CreateTransactionRequest $request, TransactionController $controller) { $message_code = 57; // initialize with illegal transaction // log activity try { $payer = User::findOrFail($request->payer_id)->with(['primary_account', 'account_status'])->first(); // get payer and primary a/c information $payee = OAuth_clients::with('user')->with('user.account_status')->whereId($request->payee_id)->first(); session()->flash('flash_message', 'Found Payee/Payer'); } catch (Exception $e) { session()->flash('flash_message', 'Cannot find payee/payer'); $message_code = 14; } $activity_id = Queue::push($this->logActivity($payer, $payee, $request->txn_currencyid, $request->amount_in_txn_currency), '', 'activity_log'); // authenticate Payee account if ($request->amount_in_txn_currency > 0) { // Check fraud $fraud = Queue::push($controller->checkFraud($payer)); if ($this->checkPayeeAccount($payee->user)) { // authenticate and transact for payer if (Hash::check($request->password, $payer->password)) { // check payee $message_code = $this->checkPayerAccount($payer, $request); if ($message_code = 0) { session()->flash('flash_message', 'Transaction approved'); } } else { session()->flash('flash_message', 'Payer Kudotsu account/PIN wrong.'); $message_code = 28; } } else { session()->flash('flash_message', 'Payee Kudotsu account not approved'); $message_code = 20; } Queue::push($controller->store($message_code, $payer, $payee), '', 'activity_log'); } else { session()->flash('flash_message', $payee . $request->payer_id . $payer); //'Invalid Amount or trying to pay yourself'); $message_code = 13; } return view('transaction.response'); }