public function signup() { $payment_settings = PaymentSetting::first(); if ($payment_settings->live_mode) { User::setStripeKey($payment_settings->live_secret_key); } else { User::setStripeKey($payment_settings->test_secret_key); } $token = Input::get('stripeToken'); $user_data = array('username' => Input::get('username'), 'email' => Input::get('email'), 'password' => Hash::make(Input::get('password'))); $input = Input::all(); unset($input['stripeToken']); $validation = Validator::make($input, User::$rules); if ($validation->fails()) { //echo $validation->messages(); //print_r($validation->errors()); die(); return Redirect::to('/signup')->with(array('note' => 'Sorry, there was an error creating your account.', 'note_type' => 'error', 'messages'))->withErrors($validation)->withInput(\Request::only('username', 'email')); } $user = new User($user_data); $user->save(); try { $user->subscription('monthly')->create($token, ['email' => $user->email]); Auth::loginUsingId($user->id); return Redirect::to('/')->with(array('note' => 'Welcome! Your Account has been Successfully Created!', 'note_type' => 'success')); } catch (Exception $e) { Auth::logout(); $user->delete(); return Redirect::to('/signup')->with(array('note' => 'Sorry, there was an error with your card: ' . $e->getMessage(), 'note_type' => 'error'))->withInput(\Request::only('username', 'email')); } }
public function renew($username) { $user = User::where('username', '=', $username)->first(); $payment_settings = PaymentSetting::first(); if ($payment_settings->live_mode) { User::setStripeKey($payment_settings->live_secret_key); } else { User::setStripeKey($payment_settings->test_secret_key); } if (Auth::user()->username == $username) { $data = array('user' => $user, 'post_route' => URL::to('user') . '/' . $user->username . '/update', 'type' => 'renew_subscription', 'menu' => Menu::orderBy('order', 'ASC')->get(), 'payment_settings' => $payment_settings, 'video_categories' => VideoCategory::all(), 'post_categories' => PostCategory::all(), 'theme_settings' => ThemeHelper::getThemeSettings(), 'pages' => Page::all()); return View::make('Theme::user', $data); } else { return Redirect::to('/'); } }