|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / dev2.destoffenstraat.com / app / code / WeSupply / Toolbox / Controller / Api / |
Filename | /home/dev2.destoffenstraat.com/app/code/WeSupply/Toolbox/Controller/Api/Notify.php |
Size | 2.66 kb |
Permission | rwxrwxrwx |
Owner | root : root |
Create time | 17-Aug-2025 10:26 |
Last modified | 17-May-2021 07:15 |
Last accessed | 22-Aug-2025 11:30 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
namespace WeSupply\Toolbox\Controller\Api;
use Magento\Framework\App\Response\Http;
class Notify extends \Magento\Framework\App\Action\Action
{
private $returnsInterface;
private $weSupplyApiInterface;
private $helper;
private $logger;
/**
* Flag constructor.
* @param \Magento\Framework\App\Action\Context $context
* @param \WeSupply\Toolbox\Helper\Data $helper
* @param \WeSupply\Toolbox\Api\ReturnsInterface $returnsInterface
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\WeSupply\Toolbox\Helper\Data $helper,
\WeSupply\Toolbox\Api\ReturnsInterface $returnsInterface,
\WeSupply\Toolbox\Api\WeSupplyApiInterface $weSupplyApi,
\Psr\Log\LoggerInterface $logger
)
{
parent::__construct($context);
$this->helper = $helper;
$this->returnsInterface = $returnsInterface;
$this->weSupplyApiInterface = $weSupplyApi;
$this->logger = $logger;
}
public function execute()
{
$params = $this->getRequest()->getParams();
$result = $this->_validateParams($params);
if ($result) {
/** Add the error response */
//$response .= $this->addResponseStatus('true', 'ERROR', $result);
$this->getResponse()
->setStatusCode(Http::STATUS_CODE_500)
->setContent($result);
return;
}else{
if(isset($params['returns'])){
// @TODO This event is deprecated | to be removed
// $this->_eventManager->dispatch('wesupply_return_request');
}
}
}
/**
* @param $params
* @return bool|\Magento\Framework\Phrase
*/
private function _validateParams($params)
{
$guid = isset($params['guid']) ? $params['guid'] : false;
$clientName = isset($params['ClientName']) ? $params['ClientName'] : false;
//$orderId = isset($params['OrderId']) ? $params['OrderId'] : false;
$requiredGuid = $this->helper->getGuid();
$requiredClientName = $this->helper->getClientName();
if (!$guid) {
return __('guid is required. Please specify it');
}
if (!$clientName) {
return __('ClientName is required. Please specify it');
}
if ($guid != $requiredGuid) {
return __('guid is invalid');
}
if ($clientName != $requiredClientName) {
return __('ClientName is invalid');
}
$this->guid = $guid;
//$this->orderId = preg_replace("/^".OrderInfoBuilder::PREFIX.'/', '', $orderId);
return false;
}
}
namespace WeSupply\Toolbox\Controller\Api;
use Magento\Framework\App\Response\Http;
class Notify extends \Magento\Framework\App\Action\Action
{
private $returnsInterface;
private $weSupplyApiInterface;
private $helper;
private $logger;
/**
* Flag constructor.
* @param \Magento\Framework\App\Action\Context $context
* @param \WeSupply\Toolbox\Helper\Data $helper
* @param \WeSupply\Toolbox\Api\ReturnsInterface $returnsInterface
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\WeSupply\Toolbox\Helper\Data $helper,
\WeSupply\Toolbox\Api\ReturnsInterface $returnsInterface,
\WeSupply\Toolbox\Api\WeSupplyApiInterface $weSupplyApi,
\Psr\Log\LoggerInterface $logger
)
{
parent::__construct($context);
$this->helper = $helper;
$this->returnsInterface = $returnsInterface;
$this->weSupplyApiInterface = $weSupplyApi;
$this->logger = $logger;
}
public function execute()
{
$params = $this->getRequest()->getParams();
$result = $this->_validateParams($params);
if ($result) {
/** Add the error response */
//$response .= $this->addResponseStatus('true', 'ERROR', $result);
$this->getResponse()
->setStatusCode(Http::STATUS_CODE_500)
->setContent($result);
return;
}else{
if(isset($params['returns'])){
// @TODO This event is deprecated | to be removed
// $this->_eventManager->dispatch('wesupply_return_request');
}
}
}
/**
* @param $params
* @return bool|\Magento\Framework\Phrase
*/
private function _validateParams($params)
{
$guid = isset($params['guid']) ? $params['guid'] : false;
$clientName = isset($params['ClientName']) ? $params['ClientName'] : false;
//$orderId = isset($params['OrderId']) ? $params['OrderId'] : false;
$requiredGuid = $this->helper->getGuid();
$requiredClientName = $this->helper->getClientName();
if (!$guid) {
return __('guid is required. Please specify it');
}
if (!$clientName) {
return __('ClientName is required. Please specify it');
}
if ($guid != $requiredGuid) {
return __('guid is invalid');
}
if ($clientName != $requiredClientName) {
return __('ClientName is invalid');
}
$this->guid = $guid;
//$this->orderId = preg_replace("/^".OrderInfoBuilder::PREFIX.'/', '', $orderId);
return false;
}
}