Skip to content

Commit

Permalink
Set v1.0.9. Implemented method getSignatureFromUrl. Added ability to …
Browse files Browse the repository at this point in the history
…get signature from Url.
  • Loading branch information
Returnless committed Mar 19, 2021
1 parent 7bb6348 commit 3cec423
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
29 changes: 24 additions & 5 deletions Controller/Order/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,19 @@ public function execute()

// get Signature from Header
$returnlessSignature = $this->getSignatureFromHeader();

// get Signature from Url
if (empty($returnlessSignature)) {
$returnlessSignature = $this->getSignatureFromUrl();
}

// 1 validate Signature
if (empty($returnlessSignature)) {
$this->setResponse("Can't find header: '" . self::HEADER_SIGNATURE . "'", 401, true)
->returnResponse();
}

// validate Signature
// 2 validate Signature
$incrementId = $this->getRequest()->getParam('increment_id');
$integrationApiPassword = $this->config->getApiPassword();
$hashedSignature = hash_hmac("sha256" , $incrementId , $integrationApiPassword);
Expand Down Expand Up @@ -133,12 +140,24 @@ protected function getSignatureFromHeader()
{
$returnlessSignature = false;

if (empty($returnlessSignature)) {
$allheaders = getallheaders();
if (!empty($this->getRequest()->getHeader(self::HEADER_SIGNATURE))) {
$returnlessSignature = $this->getRequest()->getHeader(self::HEADER_SIGNATURE);
}

if (isset($allheaders[self::HEADER_SIGNATURE])) {
$returnlessSignature = $allheaders[self::HEADER_SIGNATURE];
return $returnlessSignature;
}

/**
* Get Signature form Url
*
* @return bool|mixed
*/
protected function getSignatureFromUrl()
{
$returnlessSignature = false;

if (!empty($this->getRequest()->getParam(self::HEADER_SIGNATURE))) {
$returnlessSignature = $this->getRequest()->getParam(self::HEADER_SIGNATURE);
}

return $returnlessSignature;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"OSL-3.0",
"AFL-3.0"
],
"version": "1.0.8"
"version": "1.0.9"
}
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Returnless_Connector" setup_version="1.0.8">
<module name="Returnless_Connector" setup_version="1.0.9">
<sequence>
<module name="Magento_Sales"/>
</sequence>
Expand Down

0 comments on commit 3cec423

Please sign in to comment.