/** * Returns all the blog posts. * * @return View */ public function updateBill() { // get list outlet active $validator = Validator::make(Input::all(), DealTransaction::$rules); $detail = $this->deal->detail(Input::get('deal_id')); if (!Auth::user()) { return Redirect::to('purchase/' . $detail->id)->with('message', 'Login please!'); } if ($validator->passes()) { $data = Input::except('_token'); $bill = DealTransaction::find(Input::get('id')); $bill->qty = $data['qty']; $bill->phone_number = $data['phone_number']; $bill->amount = $data['amount']; $bill->total = $data['amount'] * $data['qty']; if ($bill->save()) { User::where('id', Auth::user()->id)->update(array('phone_number' => $data['phone_number'])); return View::make('site.purchase.pay', compact('bill')); } return Redirect::to('user/transaction/edit/' . Input::get('id'))->withInput()->withErrors($validator); } }
public function getPaymentStatus() { // Get the payment ID before session clear $payment_id = Session::get('paypal_payment_id'); $bill_id = Session::get('bill_id'); // clear the session payment ID Session::forget('paypal_payment_id'); Session::forget('bill_id'); if (empty(Input::get('PayerID')) || empty(Input::get('token'))) { return Redirect::route('original.route')->with('error', 'Payment failed'); } $payment = Payment::get($payment_id, $this->_api_context); // PaymentExecution object includes information necessary // to execute a PayPal account payment. // The payer_id is added to the request query parameters // when the user is redirected from paypal back to your site $execution = new PaymentExecution(); $execution->setPayerId(Input::get('PayerID')); //Execute the payment $result = $payment->execute($execution, $this->_api_context); // echo '<pre>';print_r($result);echo '</pre>';exit; // DEBUG RESULT, remove it later if ($result->getState() == 'approved') { // payment made $Bill = DealTransaction::find($bill_id); $Bill->payment_status = 1; $Bill->status = 1; $Bill->payment_id = $payment_id; $Bill->save(); echo '<center><h1>PAID SUCCESSFULLY!!!</h1><center><p>Please wait while we redirecting to homepage</p></center></center><script>setTimeout(function(){ location.href="/../"; }, 3000);</script>'; die; } //return Redirect::route('original.route'); echo '<center><h1>PAID FAILED!!!</h1></center><center><p>Please wait while we redirecting to homepage</p></center><script>setTimeout(function(){ location.href="/../"; }, 3000);</script>'; die; }