diff --git a/Controller/Webhooks/Index.php b/Controller/Webhooks/Index.php
index ecb17db..6f97956 100644
--- a/Controller/Webhooks/Index.php
+++ b/Controller/Webhooks/Index.php
@@ -77,7 +77,7 @@ public function execute()
try {
$content = $this->getRequest()->getContent();
-
+
$headers = $this->getRequest()->getHeaders()->toArray();
$signature = hash_hmac('sha256', $content, $this->_monduConfig->getWebhookSecret());
if ($signature !== ($headers['X-Mondu-Signature'] ?? null)) {
@@ -94,7 +94,6 @@ public function execute()
case 'order/pending':
[$resBody, $resStatus] = $this->handlePending($params);
break;
- case 'order/canceled':
case 'order/declined':
[$resBody, $resStatus] = $this->handleDeclinedOrCanceled($params);
break;
@@ -135,7 +134,12 @@ public function handlePending($params): array
if (empty($order->getData())) {
return [['message' => 'Order does not exist', 'error' => 0], 200];
}
-
+ $order->setState(Order::STATE_PAYMENT_REVIEW);
+ $order->setStatus(Order::STATE_PAYMENT_REVIEW);
+ $order->addStatusHistoryComment(
+ __('Mondu: Order Status changed to Payment Review by a webhook')
+ );
+ $order->save();
$this->_monduLogger->updateLogMonduData($monduId, $params['order_state']);
return [['message' => 'ok', 'error' => 0], 200];
@@ -163,6 +167,12 @@ public function handleConfirmed($params): array
return [['message' => 'Order does not exist', 'error' => 0], 200];
}
+ $order->setState(Order::STATE_PROCESSING);
+ $order->setStatus(Order::STATE_PROCESSING);
+ $order->addStatusHistoryComment(
+ __('Mondu: Order Status changed to Processing by a webhook')
+ );
+ $order->save();
$this->_monduLogger->updateLogMonduData($monduId, $params['order_state'], $viban);
return [['message' => 'ok', 'error' => 0], 200];
@@ -190,6 +200,10 @@ public function handleDeclinedOrCanceled($params): array
return [['message' => 'Order does not exist', 'error' => 0], 200];
}
+ $order->addStatusHistoryComment(
+ __('Mondu: Order has been declined')
+ );
+
if ($orderState === 'canceled') {
$order->setStatus(Order::STATE_CANCELED)->save();
} elseif ($orderState === 'declined') {
diff --git a/Model/Ui/ConfigProvider.php b/Model/Ui/ConfigProvider.php
index 4bbc379..84dea40 100644
--- a/Model/Ui/ConfigProvider.php
+++ b/Model/Ui/ConfigProvider.php
@@ -101,7 +101,7 @@ public function getApiUrl($path = null): string
return $baseUrl . ($path ? '/'.$path : '');
}
- /**
+ /**
* Returns mondu.js url
*
* @return string
diff --git a/Observer/AfterPlaceOrder.php b/Observer/AfterPlaceOrder.php
new file mode 100644
index 0000000..48b803e
--- /dev/null
+++ b/Observer/AfterPlaceOrder.php
@@ -0,0 +1,53 @@
+monduLogger = $monduLogger;
+ }
+
+ /**
+ * Execute
+ *
+ * @param Observer $observer
+ * @return void
+ */
+ public function _execute(Observer $observer)
+ {
+ $order = $observer->getEvent()->getOrder();
+ $monduUuid = $order->getMonduReferenceId();
+ $orderData = $this->monduLogger->getTransactionByOrderUid($monduUuid);
+
+ if (isset($orderData['mondu_state']) && $orderData['mondu_state'] === 'pending') {
+ $order->addStatusHistoryComment(
+ __('Mondu: Order Status changed to Payment Review because it needs manual confirmation')
+ );
+ $order->setState(\Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW);
+ $order->setStatus(\Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW);
+ $order->save();
+ }
+ }
+}
diff --git a/Observer/Config/Save.php b/Observer/Config/Save.php
index 6bc6338..483c168 100644
--- a/Observer/Config/Save.php
+++ b/Observer/Config/Save.php
@@ -31,8 +31,7 @@ class Save implements ObserverInterface
private $subscriptions = [
'order/confirmed',
'order/declined',
- 'order/pending',
- 'order/canceled'
+ 'order/pending'
];
/**
@@ -94,11 +93,6 @@ public function execute(Observer $observer)
->setTopic('order/declined')
->process();
- $this->requestFactory
- ->create(RequestFactory::WEBHOOKS_REQUEST_METHOD)
- ->setTopic('order/canceled')
- ->process();
-
$this->monduConfig->clearConfigurationCache();
} catch (\Exception $e) {
throw new LocalizedException(__($e->getMessage()));
diff --git a/Observer/CreateOrder.php b/Observer/CreateOrder.php
index fc3816b..c4de23d 100644
--- a/Observer/CreateOrder.php
+++ b/Observer/CreateOrder.php
@@ -150,7 +150,6 @@ public function _execute(Observer $observer)
$order->setData('mondu_reference_id', $orderUid);
$order->addStatusHistoryComment(__('Mondu: order id %1', $orderData['uuid']));
-
$order->save();
$this->monduFileLogger->info('Saved the order in Magento ', ['orderNumber' => $order->getIncrementId()]);
diff --git a/composer.json b/composer.json
index b45d676..681fe5f 100644
--- a/composer.json
+++ b/composer.json
@@ -2,7 +2,7 @@
"name": "mondu_gmbh/magento2-payment",
"description": "Mondu payment method for magento 2",
"type": "magento2-module",
- "version": "2.2.1",
+ "version": "2.2.2",
"license": [
"MIT"
],
diff --git a/docker-compose.yml b/docker-compose.yml
index 8c1cc7e..14fde9a 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -7,17 +7,19 @@ services:
ports:
- 80:8080
environment:
+ - BITNAMI_DEBUG=true
- MAGENTO_HOST=localhost
- MAGENTO_MODE=developer
- MAGENTO_DATABASE_HOST=mariadb
- MAGENTO_DATABASE_PORT_NUMBER=3306
- MAGENTO_DATABASE_USER=bn_magento
- MAGENTO_DATABASE_NAME=bitnami_magento
+ - MAGENTO_ELASTICSEARCH_HOST=elasticsearch
+ - MAGENTO_ELASTICSEARCH_PORT_NUMBER=9200
- MAGENTO_USERNAME=mondu
- - MAGENTO_PASSWORD=mondu
+ - MAGENTO_PASSWORD=mondu123
+ - MAGENTO_EMAIL=mondu@mondu.ai
- ALLOW_EMPTY_PASSWORD=yes
- - ELASTICSEARCH_HOST=elasticsearch
- - ELASTICSEARCH_PORT_NUMBER=9200
- PHP_MEMORY_LIMIT=5120M
volumes:
- magento_data:/bitnami/magento
diff --git a/etc/events.xml b/etc/events.xml
index 72d89f6..08d53b7 100644
--- a/etc/events.xml
+++ b/etc/events.xml
@@ -5,6 +5,9 @@
+
+
+
-
+