Example #1
0
 /**
  * @param PurchaseCompleteEvent $event
  */
 public function abandonCart(PurchaseCompleteEvent $event)
 {
     if (in_array($event->getSubject()->getState(), [PaymentInterface::STATE_PENDING, PaymentInterface::STATE_PROCESSING, PaymentInterface::STATE_COMPLETED])) {
         $this->cartProvider->abandonCart();
         return;
     }
     $event->setResponse(new RedirectResponse($this->router->generate($this->redirectTo)));
 }
Example #2
0
 public function process(OrderInterface $order)
 {
     $order->setCheckoutState(OrderCheckoutStates::STATE_COMPLETED);
     $order->setShippingState(ShipmentInterface::STATE_PENDING);
     $order->setPaymentState(PaymentInterface::STATE_PENDING);
     $order->setState(OrderInterface::STATE_CONFIRMED);
     $order->setOrderedAt(new \DateTime());
     $this->confirmMailer->sendMail($order);
     $this->cartProvider->abandonCart();
 }
 function it_should_not_abandon_cart_if_payment_status_unknown(CartProviderInterface $cartProvider, PurchaseCompleteEvent $event, PaymentInterface $payment)
 {
     $payment->getState()->willReturn(PaymentInterface::STATE_UNKNOWN);
     $cartProvider->abandonCart()->shouldNotBeCalled();
     $event->setResponse(new RedirectResponse('/payment'))->shouldBeCalled();
     $this->abandonCart($event);
 }
Example #4
0
 /**
  * @param CartEvent $event
  */
 public function clearCart(CartEvent $event)
 {
     $this->cartManager->remove($event->getCart());
     $this->cartManager->flush();
     $this->cartProvider->abandonCart();
 }