public function indexAction($section) { $checkout_id = "none"; if ($this->request->query->get('checkout_id')) { $checkout_id = $this->request->query->get('checkout_id'); $user = $this->get('security.context')->getToken()->getUser(); /** @var $wp WePayService */ $wp = $this->get('my_wepay'); $response = $wp->upgradeAccount(10.69, 'Financial Evaluations Fee', 'SERVICE', array('name' => $user->getFirstName() . ' ' . $user->getLastName(), 'email' => $user->getEmail(), 'address' => $user->getAddress1(), 'city' => $user->getCity(), 'state' => $user->getState(), 'zip' => $user->getZip()->getZip())); if ($response->checkout_id) { $pay_id = $response->checkout_id; $wp = $this->container->get('my_wepay'); $pay_data = $wp->getTransInfo($pay_id); $wp_trans = new WepayTransaction(); foreach ($pay_data as $key => $value) { if ($value != '' && $key != 'mode') { $setter = $this->helper->camelCase('set_' . $key); $wp_trans->{$setter}($value); } } $wp_trans->setUser($user); try { $this->dPersist($wp_trans); $this->dFlush(); } catch (\Exception $e) { $logger = $this->get('logger'); $logger->err('Error while saving the user ' . $user_entity->getEmail() . ': ' . $e->getMessage()); $this->ajax->setAction('Yaw.CorePopup.showErrorPopup'); return $this->renderAjax('Layouts:error_popup', array('message' => 'Something wrong while saving the data.<br> Please contact our customer support using <a href="#">contact form</a>')); } } } $this->detailsAction(); if (!$this->isAjax()) { if (!method_exists($this, $section . 'Action')) { throw $this->createNotFoundException('Page does not exist.'); } return $this->render('User:db_index', array('checkout_id' => $checkout_id)); } else { $this->ajax->setData('state', $this->generateUrl('user_dashboard', array('section' => $section))); $this->ajax->setData('title', 'user_dashboard_' . $section); if ($this->request->query->get('block') == TRUE) { $this->ajax->setData('related_id', $section . '__user_dashboard_menu'); return $this->renderAjax('User:db_block'); } else { return $this->{$section . 'Action'}(); } } }
/** * Finish registration * * @return Response */ public function step_8Action() { $this->step = 8; $mailer = $this->get('fos_user.mailer'); $generator = $this->get('fos_user.util.token_generator'); /* @var $user_form Form */ /** @var $user_entity User */ list($user_form, $user_data, $user_entity) = $this->processUser(); /* @var $loan_form Form */ /** @var $loan_entity Loan */ list($loan_form, $loan_data, $loan_entity) = $this->processLoan(); /* @var $verify_form Form */ /* @var $verify_entity UserVerification */ list($verify_form, $verify_data, $verify_entity) = $this->processVeryfication(); $verify_entity->setType($user_entity->getProfileType()); $pay_id = $this->request->query->get('checkout_id'); $wp = $this->container->get('my_wepay'); $pay_data = $wp->getTransInfo($pay_id); $wp_trans = new WepayTransaction(); foreach ($pay_data as $key => $value) { if ($value != '' && $key != 'mode' && $key != 'dispute_uri') { $setter = $this->helper->camelCase('set_' . $key); $wp_trans->{$setter}($value); } } $wp_trans->setUser($user_entity); $user_entity->setEnabled(FALSE); if (NULL === $user_entity->getConfirmationToken()) { $user_entity->setConfirmationToken($generator->generateToken()); } $user_entity->setZip($this->repo('ZipCode')->findOneBy(array('zip' => $user_data['zip'])))->addLoan($loan_entity)->addVerification($verify_entity)->addWepayTransaction($wp_trans); $loan_entity->setUser($user_entity); $verify_entity->setUser($user_entity); try { $this->dPersist($wp_trans); $this->dPersist($verify_entity); $this->dPersist($loan_entity); $this->dPersist($user_entity); $this->dFlush(); $this->session->remove($user_form->getName()); $this->session->remove($loan_form->getName()); $this->session->remove($verify_form->getName()); $mailer->sendConfirmationEmailMessage($user_entity); return $this->render('Security:register_finish', array('step' => $this->step, 'form' => $user_form->createView())); } catch (\Exception $e) { $logger = $this->get('logger'); $logger->err('Error while saving the user ' . $user_entity->getEmail() . ': ' . $e->getMessage()); $this->ajax->setAction('Yaw.CorePopup.showErrorPopup'); return $this->renderAjax('Layouts:error_popup', array('message' => 'Something wrong while saving the data.<br> Please contact our customer support using <a href="#">contact form</a>')); } }