示例#1
0
文件: Order.php 项目: badelas/thelia
 /**
  * @param OrderEvent $event
  *
  * @throws \Thelia\Exception\TheliaProcessException
  */
 public function create(OrderEvent $event)
 {
     $session = $this->getSession();
     $dispatcher = $event->getDispatcher();
     $order = $event->getOrder();
     $paymentModule = ModuleQuery::create()->findPk($order->getPaymentModuleId());
     /** @var \Thelia\Module\PaymentModuleInterface $paymentModuleInstance */
     $paymentModuleInstance = $paymentModule->createInstance();
     $placedOrder = $this->createOrder($event->getDispatcher(), $event->getOrder(), $session->getCurrency(), $session->getLang(), $session->getSessionCart($dispatcher), $this->securityContext->getCustomerUser(), $paymentModuleInstance->manageStockOnCreation());
     $event->getDispatcher()->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());
     }
 }
示例#2
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());
     }
 }