resultJsonFactory = $resultJsonFactory; $this->crefoPayTransactionRepository = $crefoPayTransactionRepository; } public function execute() { /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); $quoteId = $this->getRequest()->getParam('quoteId'); $allowedPaymentMethods = '[]'; try { $crefoPayTransaction = $this->crefoPayTransactionRepository->getByQuoteId($quoteId); $crefoPayOrderId = $crefoPayTransaction->getCrefoPayOrderId(); $allowedPaymentMethods = $crefoPayTransaction->getPaymentMethods(); } catch (NoSuchEntityException $e) { $crefoPayOrderId = null; } return $resultJson->setData([ 'crefoPayOrderId' => $crefoPayOrderId, 'areAnyPaymentMethodsAllowed' => ($allowedPaymentMethods !== '[]') ]); } }