/**
  * @Route("/")
  * @Method("GET")
  */
 public function listBankAccounts()
 {
     $bankAccounts = [];
     /* @var Account $account */
     $account = $this->getDoctrine()->getRepository(Account::getEntityClassByUser($this->getUser()))->findOneBy(['user' => $this->getUser()]);
     if ($account) {
         $bankAccounts = $account->getBankAccounts();
     }
     return $this->createJSONResponse($this->jmsSerialization($bankAccounts, ['api']));
 }
 /**
  * @Route("/")
  * @Template("CivixFrontBundle:PaymentSettings:index.html.twig")
  * @Method("GET")
  */
 public function indexAction()
 {
     $cards = null;
     $bankAccounts = null;
     /* @var Customer $customer */
     $customer = $this->getDoctrine()->getRepository(Customer::getEntityClassByUser($this->getUser()))->findOneBy(['user' => $this->getUser()]);
     if ($customer) {
         $cards = $customer->getCards();
     }
     /* @var Account $account */
     $account = $this->getDoctrine()->getRepository(Account::getEntityClassByUser($this->getUser()))->findOneBy(['user' => $this->getUser()]);
     if ($account) {
         $bankAccounts = $account->getBankAccounts();
     }
     return ['bankAccounts' => $bankAccounts, 'cards' => $cards, 'customer' => $customer, 'return_path' => $this->generateUrl('civix_front_' . $this->getUser()->getType() . '_paymentsettings_index')];
 }
Пример #3
0
 private function createAccount(UserInterface $user)
 {
     $entityClass = Account::getEntityClassByUser($user);
     /* @var $account AccountInterface */
     $account = new $entityClass();
     $account->setUser($user);
     $response = \Stripe\Account::create(['managed' => true, 'metadata' => ['id' => $user->getId(), 'type' => $user->getType()], 'email' => $user->getEmail()]);
     $account->setStripeId($response->id)->setSecretKey($response->keys->secret)->setPublishableKey($response->keys->publishable);
     $this->em->persist($account);
     $this->em->flush($account);
     return $account;
 }