Skip to content

Commit

Permalink
Merging 2.1 webhook link changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rbpotter committed Aug 30, 2016
1 parent 6b0a460 commit f3bf0be
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
12 changes: 11 additions & 1 deletion Controller/Webhooks/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,22 @@ protected function handleGuaranteeChange($caseData)

public function execute()
{
if(!$this->_api->enabled()) return;
if(!$this->_api->enabled())
{
echo "This plugin is not currently enabled";
return;
}

$rawRequest = $this->getRawPost();

$request = $this->getRequest();
$hash = $request->getHeader('X-SIGNIFYD-SEC-HMAC-SHA256');
$topic = $request->getHeader('X-SIGNIFYD-TOPIC');
if($hash == null)
{
echo "You have successfully reached the webhook endpoint";
return;
}

if ($this->_api->validWebhookRequest($rawRequest, $hash, $topic)) {
// For the webhook test, all of the request data will be invalid
Expand Down
43 changes: 43 additions & 0 deletions Model/WebhookLink.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* Copyright � 2015 SIGNIFYD Inc. All rights reserved.
* See LICENSE.txt for license details.
*/
namespace Signifyd\Connect\Model;

use Magento\Config\Model\Config\CommentInterface;
use Magento\Framework\UrlInterface;


/**
* Defines link data for the comment field in the config page
*/
class WebhookLink implements CommentInterface
{
/**
* @var \Magento\Framework\UrlInterface
*/
protected $_urlInterface;

public function __construct(
UrlInterface $urlInterface)
{
$this->_urlInterface = $urlInterface;
}

public function getCommentText($elementValue)
{
$url = "";
if($this->_urlInterface != null)
{
$url = $this->_urlInterface->getRouteUrl("signifyd/webhooks/index");
$url = str_replace("/admin", "", $url);
$url = "<a href=\"" . $url . "\">$url</a>";
}
else
{
$url = "{{store url}}/signifyd/webhooks/index";
}
return "Scores will be updated via webhooks. Please setup webhooks on your Signifyd account page (Webhook URL for this site is $url";
}
}
2 changes: 1 addition & 1 deletion etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<label>Advanced</label>
<field id="retrieve_score" translate="label" type="select" sortOrder="31" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Retrieve Signifyd scores</label>
<comment>Scores will be updated via webhooks. Please setup webhooks on your Signifyd account page (Webhook URL for this site is {{base_url}}/signifyd/webhooks/index</comment>
<comment><model>Signifyd\Connect\Model\WebhookLink</model></comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="hold_orders" translate="label comment" type="select" sortOrder="33" showInDefault="1" showInWebsite="0" showInStore="0">
Expand Down

0 comments on commit f3bf0be

Please sign in to comment.