diff --git a/.version b/.version index f225a78..aedc15b 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -2.5.2 +2.5.3 diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 7e45c77..a6d3a84 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 2.5.3 + +### Added + +- Validation for notification request + ## 2.5.2 ### Fixed diff --git a/Notification/NotificationProcessor.php b/Notification/NotificationProcessor.php index 950008f..42a2ba4 100644 --- a/Notification/NotificationProcessor.php +++ b/Notification/NotificationProcessor.php @@ -28,17 +28,29 @@ public function __construct(NotificationProcessorFactoryInterface $factory, Tpay public function process() { $strategy = $this->factory->create($this->request->getPost()->toArray()); + $storeId = null; - if ($strategy instanceof BlikAliasNotificationProcessor) { - $storeId = null; - } else { - $orderId = $this->request->getPost('order_id') ? base64_decode($this->request->getPost('order_id')) : base64_decode($this->request->getPost('tr_crc')); - $storeId = $this->getOrderStore($orderId); + if (!$strategy instanceof BlikAliasNotificationProcessor) { + $orderId = $this->getOrderId(); + if ($orderId) { + $storeId = $this->getOrderStore($orderId); + } } $strategy->process($storeId); } + private function getOrderId(): ?string + { + $value = $this->request->getPost('order_id') ?? $this->request->getPost('tr_crc'); + + if (null === $value) { + return null; + } + + return base64_decode($value); + } + private function getOrderStore(string $orderId): ?int { $order = $this->tpayService->getOrderById($orderId); diff --git a/composer.json b/composer.json index 821831e..b83b5a4 100755 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "composer-runtime-api": "^2.0", "magento/framework": "^103.0", "magento/module-csp": "^100.4.5-p6", - "tpay-com/tpay-openapi-php": "^2.2.1", + "tpay-com/tpay-openapi-php": "^2.2.3", "tpay-com/tpay-php": "^2.4.7" }, "suggest": {