diff --git a/Model/Carrier/BobGo.php b/Model/Carrier/BobGo.php index fdb728381c75f0c1fd41b2ada18b4ff1016055eb..332ab93f2e48e0bfb80be0ce3cf909a5a74397cb 100644 --- a/Model/Carrier/BobGo.php +++ b/Model/Carrier/BobGo.php @@ -1360,7 +1360,7 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car $signature = base64_encode($rawSignature); // Set headers and post the data $this->curl->addHeader('Content-Type', 'application/json'); - $this->curl->addHeader('X-M-Webhook-Signature', $signature); + $this->curl->addHeader('x-m-webhook-signature', $signature); $payloadJson = json_encode($payload); $this->_logger->info('Webhooks payload: ' . $payloadJson); @@ -1377,20 +1377,13 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car $response = json_decode($responseBody, true); - if ($statusCode == 200 && isset($response['success']) && $response['success'] === true) { - $this->_logger->info('Webhook validation successful.'); -// throw new LocalizedException(__('Rates received but id field is empty or invalid.')); - return true; - } else { - $this->_logger->error('Webhook validation failed: ' . ($response['message'] ?? 'Unknown error')); -// throw new LocalizedException(__('Rates received but id field is empty or invalid.')); - return false; + if ($statusCode != 200) { + throw new LocalizedException(__('Status code from BobGo: %1', $statusCode)); } } catch (\Exception $e) { - $this->_logger->error('Webhook validation exception: ' . $e->getMessage()); -// throw new LocalizedException(__('Rates received but id field is empty or invalid.')); return false; } + return true; } } diff --git a/Model/Carrier/UData.php b/Model/Carrier/UData.php index a7e5d2e2f9b9c119c0f98d26ddcf68dc8ce7f808..adf83a27d10e5dafbef7fa9c7fb864e37759dc56 100644 --- a/Model/Carrier/UData.php +++ b/Model/Carrier/UData.php @@ -26,5 +26,5 @@ class UData * * @var string */ - public const WEBHOOK_URL = 'https://api.dev.bobgo.co.za/webhook/channel'; + public const WEBHOOK_URL = 'https://api.dev.bobgo.co.za/webhook/channel/magento'; } diff --git a/Observer/ConfigChangeObserver.php b/Observer/ConfigChangeObserver.php index 9cbde5d2e94bf7c0e4eecdfcdd56409bdfb26b30..8362feb89f8bee7db3a176872337d228588f183c 100644 --- a/Observer/ConfigChangeObserver.php +++ b/Observer/ConfigChangeObserver.php @@ -73,10 +73,8 @@ class ConfigChangeObserver implements ObserverInterface } // Test for webhooks - if (is_array($changedPaths) && in_array('carriers/bobgo/enable_webhooks', $changedPaths)) { - $this->logger->info('Webhooks test start: '); + 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(); - $this->logger->info('Webhooks test end: ' . $result); if ($this->bobGo->isWebhookEnabled()) { if ($result) { diff --git a/Observer/ModifyShippingDescription.php b/Observer/ModifyShippingDescription.php index 3c19823c2760145de5625f7df08f8332b9fd5206..2684798bcaa8bf713fee63841bbbf72ef0fe633a 100644 --- a/Observer/ModifyShippingDescription.php +++ b/Observer/ModifyShippingDescription.php @@ -25,26 +25,14 @@ class ModifyShippingDescription implements ObserverInterface // Get the current shipping description $shippingDescription = $order->getShippingDescription(); - // Log the original shipping description - $this->logger->info('Original Shipping Description: ' . $shippingDescription); - - // Get the shipping method used in the order (e.g., bobgo_10303_39_1) - $shippingMethod = $order->getShippingMethod(); - // Get the method title from the shipping description (which might already include the title) $methodTitle = $this->extractMethodTitle($shippingDescription); - // Log the method title for debugging - $this->logger->info('Extracted Method Title: ' . $methodTitle); - // Set the new dynamic shipping description based only on MethodTitle $newDescription = $methodTitle; // Update the shipping description in the order $order->setShippingDescription($newDescription); - - // Optionally log the new shipping description - $this->logger->info('Updated Shipping Description: ' . $newDescription); } /** diff --git a/Observer/OrderWebhookBase.php b/Observer/OrderWebhookBase.php index 6a5163f86e9571df2c92f6b76b9c4f3c81da1cbc..75767cc8020a7a80a85b2314a132758efa43ef92 100644 --- a/Observer/OrderWebhookBase.php +++ b/Observer/OrderWebhookBase.php @@ -66,7 +66,7 @@ abstract class OrderWebhookBase implements ObserverInterface // Set headers and post the data $this->curl->addHeader('Content-Type', 'application/json'); - $this->curl->addHeader('X-M-Webhook-Signature', $signature); + $this->curl->addHeader('x-m-webhook-signature', $signature); // Perform the API request $payloadJson = json_encode($data);