/** * Show the form for creating a new resource. * GET /payment/create * * @return Response */ public function create() { setlocale(LC_MONETARY, "en_US"); $discount = Session::get('discount'); if (!$discount) { $discount = 0; } $user = Auth::user(); $discount = $discount['percent'] * Cart::total(); $subtotal = Cart::total() - $discount; $taxfree = Cart::total(false) - $discount; $fee = $subtotal / getenv("SV_FEE") - $subtotal; $tax = $subtotal - $taxfree; $total = $fee + $tax + $subtotal; if (!$total) { return Redirect::action('HomeController@getIndex'); } if ($user->profile->customer_vault) { $param = array('report_type' => 'customer_vault', 'customer_vault_id' => $user->profile->customer_vault); $payment = new Payment(); $vault = $payment->ask($param); //return $vault; return View::make('pages.public.checkout')->with('page_title', 'Checkout')->withUser($user)->with('products', Cart::contents())->with('subtotal', $subtotal)->with('service_fee', $fee)->with('tax', $tax)->with('cart_total', $total)->with('discount', $discount)->with('vault', $vault); } else { $vault = false; return View::make('pages.public.checkout')->with('page_title', 'Checkout')->withUser($user)->with('products', Cart::contents())->with('subtotal', $subtotal)->with('service_fee', $fee)->with('tax', $tax)->with('cart_total', $total)->with('discount', $discount)->with('vault', $vault); } }
public function report() { //add security to avoid stealing of information $user = Auth::user(); $club = $user->Clubs()->FirstOrFail(); $type = Input::get('expType'); $from = date('Ymd', strtotime(Input::get('expFrom'))); $to = date('Ymd', strtotime(Input::get('expTo'))); $payments = Payment::where('club_id', '=', $club->id)->with('player')->whereBetween('created_at', array($from, $to))->get(); $param = array('transaction_type' => 'cc', 'action_type' => 'refund,sale', 'condition' => 'pendingsettlement,complete,failed', 'club' => $club->id, 'start_date' => $from . '000000', 'end_date' => $to . '235959'); $payment = new Payment(); $transactions = $payment->ask($param); //return $transactions; //return json_decode(json_encode($transactions->transaction),true); // return View::make('export.lacrosse.accounting.all') // ->with('payments', $transactions->transaction); //return json_decode(json_encode($transactions->transaction),true); Excel::create('transactions', function ($excel) use($transactions) { $excel->sheet('Sheetname', function ($sheet) use($transactions) { $sheet->setOrientation('landscape'); // first row styling and writing content $sheet->loadView('export.lacrosse.accounting.all')->with('payments', $transactions->transaction); }); })->download('xlsx'); }
public function vaultEdit($id) { $user = Auth::user(); $title = 'League Together - Settings'; $follow = Follower::where("user_id", "=", $user->id)->FirstOrFail(); $club = Club::find($follow->club_id); if ($user->profile->customer_vault) { $param = array('report_type' => 'customer_vault', 'customer_vault_id' => $user->profile->customer_vault, 'club' => $club->id); $payment = new Payment(); $vault = $payment->ask($param); } if (isset($vault)) { return View::make('app.account.settings.vaultEdit')->with('page_title', $title)->with('vault', $vault)->withUser($user); } return Redirect::action('AccountController@settings'); }
public function PaymentSuccess($id) { $result = Session::get('result'); $user = Auth::user(); $participant = Participant::find($id); $player = $participant->player; $club = $participant->event->club; $title = 'League Together - ' . $participant->event->club->name . ' Events'; if (!$result) { return Redirect::action('AccountController@index'); } $param = array('transaction_id' => $result->transactionid, 'club' => $club->id, 'action_type' => $result->type); $payment = new Payment(); $transaction = json_decode(json_encode($payment->ask($param)), false); $items = Cart::contents(); // Clean the cart Cart::destroy(); return View::make('app.club.event.participant.checkout.success')->with('page_title', 'Payment Complete')->withUser($user)->with('products', $items)->with('result', $result)->with('transaction', $transaction->transaction); }
public function error($param, $id, $playerid) { setlocale(LC_MONETARY, "en_US"); $club = Club::Find($id); $user = Auth::user(); $player = Player::find($playerid); $query = array('report_type' => 'customer_vault', 'customer_vault_id' => $user->profile->customer_vault, 'club' => $club->id); $payment = new Payment(); $vault = json_decode(json_encode($payment->ask($query)), false); //convert object to array $dt = json_decode(json_encode($param), false); //clean duplicates from array //$club = array_unique($club); //cart content $items = Cart::contents(); $data = array('data' => $dt, 'vault' => $vault, 'products' => $items, 'club' => $club, 'player' => $player); $mail = Mail::send('emails.receipt.error', $data, function ($message) use($user, $club) { $message->to($user->email, $user->profile->firstname . ' ' . $user->profile->lastname)->subject("Payment Declined | {$club->name}"); foreach ($club->users()->get() as $value) { $message->bcc($value->email, $club->name)->subject("Payment Declined - {$club->name}"); } }); return $mail; }
public function PaymentSuccessTeam($club, $id) { $result = Session::get('result'); $user = Auth::user(); $team = Team::find($id); $club = Club::find($club); $title = 'League Together - ' . $club->name . ' Teams'; if (!$result) { return Redirect::action('AccountController@index'); } /* $param = array( 'report_type' => 'customer_vault', 'customer_vault_id' => $user->profile->customer_vault, 'club' => $club->id ); $payment = new Payment; $vault = $payment->ask($param);*/ //get transaction data from CF $param = array('transaction_id' => $result->transactionid, 'club' => $club->id, 'action_type' => $result->type); $payment = new Payment(); $transaction = json_decode(json_encode($payment->ask($param)), false); $items = Cart::contents(); // Clean the cart Cart::destroy(); return View::make('app.public.club.team.success')->with('page_title', 'Payment Complete')->withUser($user)->with('products', $items)->with('result', $result)->with('transaction', $transaction->transaction); }