public function addFlash(PurchaseCompleteEvent $event) { switch ($event->getSubject()->getState()) { case PaymentInterface::STATE_COMPLETED: $type = 'success'; $message = 'sylius.checkout.success'; break; case PaymentInterface::STATE_PROCESSING: case PaymentInterface::STATE_PENDING: $type = 'notice'; $message = 'sylius.checkout.processing'; break; case PaymentInterface::STATE_NEW: $type = 'notice'; $message = 'sylius.checkout.new'; break; case PaymentInterface::STATE_VOID: case PaymentInterface::STATE_CANCELLED: $type = 'notice'; $message = 'sylius.checkout.canceled'; break; case PaymentInterface::STATE_FAILED: $type = 'error'; $message = 'sylius.checkout.failed'; break; default: $type = 'error'; $message = 'sylius.checkout.unknown'; break; } $this->session->getBag('flashes')->add($type, $this->translator->trans($message, [], 'flashes')); }
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); }