config = $config; $this->checkoutSession = $checkoutSession; } /** * Check whether payment method is enabled * * @inheritdoc */ public function dispatch(RequestInterface $request) { if (!$this->config->isActive() || !$this->config->isDisplayShoppingCart()) { $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true); /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); $resultRedirect->setPath('noRoute'); return $resultRedirect; } return parent::dispatch($request); } /** * @param CartInterface $quote * @return void * @throws \InvalidArgumentException */ protected function validateQuote($quote) { if (!$quote || !$quote->getItemsCount()) { throw new \InvalidArgumentException(__('Checkout failed to initialize. Verify and try again.')); } } }