Skip to content
Snippets Groups Projects

Start webhook implementation

Merged Christel Loftus requested to merge magento_webhooks into dev

Files

+ 19
0
@@ -52,6 +52,7 @@ class ConfigChangeObserver implements ObserverInterface
{
$changedPaths = $observer->getEvent()->getData('changed_paths');
// Test for rates at checkout
if (is_array($changedPaths) && in_array('carriers/bobgo/active', $changedPaths)) {
if ($this->bobGo->isActive()) {
$result = $this->bobGo->triggerRatesTest();
@@ -70,5 +71,23 @@ class ConfigChangeObserver implements ObserverInterface
}
}
}
// Test for webhooks
if ((is_array($changedPaths) && in_array('carriers/bobgo/enable_webhooks', $changedPaths)) || (is_array($changedPaths) && in_array('carriers/bobgo/webhook_key', $changedPaths))) {
$result = $this->bobGo->triggerWebhookTest();
if ($this->bobGo->isWebhookEnabled()) {
if ($result) {
$this->messageManager->addSuccessMessage(
__('Webhook validation successful.')
);
} else {
$this->messageManager->addErrorMessage(
__('Webhook validation failed. Please check your internet connection
and use your Bob Go integration consumer secret key for webhook validation.')
);
}
}
}
}
}
Loading