private function getOrderMock($from, $to) { $order = new Order(); $order->setPaymentFrom(new \DateTime($from)); $order->setPaymentTo(new \DateTime($to)); return $order; }
private function paymentRender(Order $order) { $currentUser = $this->getUser(); if ($order->getAnnouncement()->getAdvertiser()->getId() != $currentUser->getId()) { return $this->redirect($this->generateUrl('_welcome')); } return array('order' => $order); }
/** * @Route("/{banner}/pay/save", name="user_banner_pay_save") * @Method("POST") * @Template("HyperAdsBundle:User:Banner/pay.html.twig") */ public function paySaveAction(Request $request, Banner $banner) { $this->accessDeniedWhenInvalidUser($banner); $orderType = new OrderType(); $orderType->setAnnouncement($banner); $order = new Order(); $order->setAnnouncement($banner); $orderForm = $this->createForm($orderType, $order); $orderForm->bind($request); /** @var $calculator \Hyper\AdsBundle\Helper\PricesCalculator */ $calculator = $this->get('hyper_ads.prices_calculator'); $em = $this->getDoctrine()->getManager(); if ($orderForm->isValid()) { /** @var $orderNumberGenerator \Hyper\AdsBundle\Helper\OrderNumberGenerator */ $orderNumberGenerator = $this->get('hyper_ads.order_number_generator'); /** @var $zone \Hyper\AdsBundle\Entity\Zone */ $zone = $orderForm->get('zone')->getData(); $amount = $calculator->getAmountToPayForAnnouncementInZone($banner, $zone); $order->setAmount($amount); $order->setOrderNumber($orderNumberGenerator->getBannerPaymentOrderNumber($banner, $this->getUser())); $order->setZone($zone); $paymentMethods = $this->container->getParameter('banner_payment_methods'); $paymentInstruction = new PaymentInstruction($amount, $this->container->getParameter('ads_default_currency'), $paymentMethods[0]); $order->setPaymentInstruction($paymentInstruction); $em->persist($paymentInstruction); $em->persist($order); $em->flush(); return $this->redirect($this->generateUrl('user_banner_list')); } $zoneRepository = $em->getRepository('HyperAdsBundle:Zone'); return array('zones' => $zoneRepository->findAll(), 'banner' => $banner, 'orderForm' => $orderForm->createView(), 'zonePrices' => $calculator->getPossibleDayPricesForAnnouncement($banner)); }