formKeyValidator->validate($this->getRequest())) { $this->messageManager->addErrorMessage(__('Your session has expired. Please try again.')); return $this->resultRedirectFactory->create()->setPath('*/*/index'); } $id = (int)$this->getRequest()->getParam('id'); try { $this->applications->saveForCustomer( (int)$this->customerSession->getCustomerId(), (array)$this->getRequest()->getParams(), $id ); $this->messageManager->addSuccessMessage(__('Your VAT number has been submitted for review.')); return $this->resultRedirectFactory->create()->setPath('*/*/index'); } catch (\Throwable $exception) { $this->messageManager->addErrorMessage($exception->getMessage()); return $this->resultRedirectFactory->create()->setPath('*/*/' . ($id ? 'edit' : 'new'), $id ? ['id' => $id] : []); } } }