/** * anyDisconnectBraintree * -------------------------------------------------- * @return Deletes the logged in user's braintree connection. * -------------------------------------------------- */ public function anyDisconnectBraintree() { /* Try to disconnect */ try { $connector = new BraintreeConnector(Auth::user()); $connector->disconnect(); } catch (StripeNotConnected $e) { } /* Redirect */ return Redirect::route('settings.settings'); }
/** * postBraintreeConnect * -------------------------------------------------- * @return Saves the user braintree connect settings * -------------------------------------------------- */ public function postBraintreeConnect() { // Validation. $rules = array('publicKey' => 'required', 'privateKey' => 'required', 'merchantID' => 'required', 'environment' => 'required'); // Run the validation rules on the inputs. $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { // validation error -> sending back $failedAttribute = $validator->invalid(); return Redirect::back()->with('error', 'Please correct the form errors')->withErrors($validator->errors())->withInput(); // sending back data } $braintreeConnector = new BraintreeConnector(Auth::user()); $braintreeConnector->generateAccessToken(Input::except('_token')); /* Render the page */ return Redirect::route('signup-wizard.financial-connections'); }