/** * @throws \Magento\Framework\Exception\LocalizedException */ public function execute() { // if version is in the notification string show the module version $response = $this->getRequest()->getParams(); if (isset($response['version'])) { $this->getResponse()->clearHeader('Content-Type')->setHeader('Content-Type', 'text/html')->setBody($this->_adyenHelper->getModuleVersion()); return; } try { $notificationItems = json_decode(file_get_contents('php://input'), true); // log the notification $this->_adyenLogger->addAdyenNotification("The content of the notification is: " . print_r($notificationItems, 1)); $notificationMode = isset($notificationItems['live']) ? $notificationItems['live'] : ""; if ($notificationMode != "" && $this->_validateNotificationMode($notificationMode)) { foreach ($notificationItems['notificationItems'] as $notificationItem) { $status = $this->_processNotification($notificationItem['NotificationRequestItem'], $notificationMode); if ($status != true) { $this->_return401(); return; } } $this->_adyenLogger->addAdyenNotification("The result is accepted"); $this->getResponse()->clearHeader('Content-Type')->setHeader('Content-Type', 'text/html')->setBody("[accepted]"); return; } else { if ($notificationMode == "") { $this->_return401(); return; } throw new \Magento\Framework\Exception\LocalizedException(__('Mismatch between Live/Test modes of Magento store and the Adyen platform')); } } catch (Exception $e) { throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage())); } }