Пример #1
0
 /**
  * @param OrderEvent $event
  *
  * @throws \Thelia\Exception\TheliaProcessException
  */
 public function create(OrderEvent $event)
 {
     $session = $this->getSession();
     $placedOrder = $this->createOrder($event->getDispatcher(), $event->getOrder(), $session->getCurrency(), $session->getLang(), $session->getCart(), $this->securityContext->getCustomerUser());
     $event->getDispatcher()->dispatch(TheliaEvents::ORDER_BEFORE_PAYMENT, new OrderEvent($placedOrder));
     /* but memorize placed order */
     $event->setOrder(new \Thelia\Model\Order());
     $event->setPlacedOrder($placedOrder);
     /* empty cart */
     $dispatcher = $event->getDispatcher();
     /* call pay method */
     $payEvent = new OrderPaymentEvent($placedOrder);
     $dispatcher->dispatch(TheliaEvents::MODULE_PAY, $payEvent);
     if ($payEvent->hasResponse()) {
         $event->setResponse($payEvent->getResponse());
     }
 }
Пример #2
0
 /**
  * @param OrderEvent $event
  *
  * @throws \Thelia\Exception\TheliaProcessException
  * @param $eventName
  * @param EventDispatcherInterface $dispatcher
  */
 public function create(OrderEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     $session = $this->getSession();
     $order = $event->getOrder();
     $paymentModule = ModuleQuery::create()->findPk($order->getPaymentModuleId());
     /** @var \Thelia\Module\PaymentModuleInterface $paymentModuleInstance */
     $paymentModuleInstance = $paymentModule->createInstance();
     $placedOrder = $this->createOrder($dispatcher, $event->getOrder(), $session->getCurrency(), $session->getLang(), $session->getSessionCart($dispatcher), $this->securityContext->getCustomerUser(), $paymentModuleInstance->manageStockOnCreation());
     $dispatcher->dispatch(TheliaEvents::ORDER_BEFORE_PAYMENT, new OrderEvent($placedOrder));
     /* but memorize placed order */
     $event->setOrder(new OrderModel());
     $event->setPlacedOrder($placedOrder);
     /* call pay method */
     $payEvent = new OrderPaymentEvent($placedOrder);
     $dispatcher->dispatch(TheliaEvents::MODULE_PAY, $payEvent);
     if ($payEvent->hasResponse()) {
         $event->setResponse($payEvent->getResponse());
     }
 }
 /**
  * Provides access to the current logged customer attributes thought the accessor
  *
  * @param  array $params
  * @param  \Smarty $smarty
  * @return string the value of the requested attribute
  */
 public function customerDataAccess($params, &$smarty)
 {
     return $this->dataAccess("Customer User", $params, $this->securityContext->getCustomerUser());
 }