From a8d9e2caca0f17060546888795ed77d9455ba630 Mon Sep 17 00:00:00 2001 From: Ivana Nestorovic Date: Fri, 25 Apr 2025 16:46:31 +0200 Subject: [PATCH 1/4] Add clientIp field for Unzer object ISSUE:MAIN-2257 --- Model/Config.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Model/Config.php b/Model/Config.php index c8f03b0..4260845 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -8,6 +8,7 @@ use Magento\Payment\Model\CcConfig; use Magento\Payment\Model\MethodInterface; use Magento\Store\Model\ScopeInterface; +use Magento\Framework\HTTP\PhpEnvironment\Request; use Unzer\PAPI\Model\Logger\DebugHandler; use Unzer\PAPI\Model\Method\OverrideApiCredentialInterface; use UnzerSDK\Unzer; @@ -75,6 +76,11 @@ class Config extends \Magento\Payment\Gateway\Config\Config */ private ScopeConfigInterface $_scopeConfig; + /** + * @var Request + */ + private Request $_request; + /** * @var CcConfig */ @@ -94,6 +100,7 @@ public function __construct( ScopeConfigInterface $scopeConfig, DebugHandler $debugHandler, CcConfig $ccConfig, + Request $request, $methodCode = null, $pathPattern = self::DEFAULT_PATH_PATTERN ) { @@ -103,6 +110,7 @@ public function __construct( $this->_localeResolver = $localeResolver; $this->_scopeConfig = $scopeConfig; $this->ccConfig = $ccConfig; + $this->_request = $request; } /** @@ -178,6 +186,12 @@ public function getUnzerClient(string $storeId = null, MethodInterface $paymentM $this->_localeResolver->getLocale() ); + $remoteAddress = $this->_request->getClientIp(true); + + if (is_string($remoteAddress) && filter_var($remoteAddress, FILTER_VALIDATE_IP)) { + $client->setClientIp($remoteAddress); + } + $client->setDebugMode($this->isDebugMode($storeId)); $client->setDebugHandler($this->_debugHandler); From 9df93d5686d38fd37f46b744992976ca2e4ed767 Mon Sep 17 00:00:00 2001 From: Ivana Nestorovic Date: Wed, 30 Apr 2025 09:28:57 +0200 Subject: [PATCH 2/4] Add clientIp field for Unzer object ISSUE:MAIN-2257 --- Model/Config.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Model/Config.php b/Model/Config.php index c8f03b0..99992c9 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -8,6 +8,7 @@ use Magento\Payment\Model\CcConfig; use Magento\Payment\Model\MethodInterface; use Magento\Store\Model\ScopeInterface; +use Magento\Framework\HTTP\PhpEnvironment\Request; use Unzer\PAPI\Model\Logger\DebugHandler; use Unzer\PAPI\Model\Method\OverrideApiCredentialInterface; use UnzerSDK\Unzer; @@ -75,6 +76,11 @@ class Config extends \Magento\Payment\Gateway\Config\Config */ private ScopeConfigInterface $_scopeConfig; + /** + * @var Request + */ + private Request $_request; + /** * @var CcConfig */ @@ -94,6 +100,7 @@ public function __construct( ScopeConfigInterface $scopeConfig, DebugHandler $debugHandler, CcConfig $ccConfig, + Request $request, $methodCode = null, $pathPattern = self::DEFAULT_PATH_PATTERN ) { @@ -103,6 +110,7 @@ public function __construct( $this->_localeResolver = $localeResolver; $this->_scopeConfig = $scopeConfig; $this->ccConfig = $ccConfig; + $this->_request = $request; } /** @@ -178,6 +186,12 @@ public function getUnzerClient(string $storeId = null, MethodInterface $paymentM $this->_localeResolver->getLocale() ); + $remoteAddress = $this->_request->getClientIp(); + + if (filter_var($remoteAddress, FILTER_VALIDATE_IP)) { + $client->setClientIp($remoteAddress); + } + $client->setDebugMode($this->isDebugMode($storeId)); $client->setDebugHandler($this->_debugHandler); From 411deecfa20cc944bdc2e3ef797fad8939376a57 Mon Sep 17 00:00:00 2001 From: Boljanovic Date: Mon, 5 May 2025 14:52:56 +0200 Subject: [PATCH 3/4] Refactor config class --- Model/Config.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Model/Config.php b/Model/Config.php index 99992c9..db39d27 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -88,10 +88,12 @@ class Config extends \Magento\Payment\Gateway\Config\Config /** * Config constructor. + * * @param Resolver $localeResolver * @param ScopeConfigInterface $scopeConfig * @param DebugHandler $debugHandler * @param CcConfig $ccConfig + * @param Request $request * @param string|null $methodCode * @param string $pathPattern */ @@ -101,8 +103,8 @@ public function __construct( DebugHandler $debugHandler, CcConfig $ccConfig, Request $request, - $methodCode = null, - $pathPattern = self::DEFAULT_PATH_PATTERN + ?string $methodCode = null, + string $pathPattern = self::DEFAULT_PATH_PATTERN ) { parent::__construct($scopeConfig, $methodCode, $pathPattern); @@ -186,10 +188,10 @@ public function getUnzerClient(string $storeId = null, MethodInterface $paymentM $this->_localeResolver->getLocale() ); - $remoteAddress = $this->_request->getClientIp(); + $clientsIpAddress = $this->_request->getClientIp(); - if (filter_var($remoteAddress, FILTER_VALIDATE_IP)) { - $client->setClientIp($remoteAddress); + if (filter_var($clientsIpAddress, FILTER_VALIDATE_IP)) { + $client->setClientIp($clientsIpAddress); } $client->setDebugMode($this->isDebugMode($storeId)); From c0ece44979b686435dd419b12ecd2768fa4f5523 Mon Sep 17 00:00:00 2001 From: Boljanovic Date: Thu, 8 May 2025 14:31:02 +0200 Subject: [PATCH 4/4] [Release 3.2.7 - 2025-05-08] --- CHANGELOG.md | 4 ++++ composer.json | 2 +- etc/module.xml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 345a8cf..f7ca09d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [3.2.7](https://github.com/unzerdev/magento2/compare/3.2.6..3.2.7) +### Added +* Client's IP address in every request sent to Unzer API + ## [3.2.6](https://github.com/unzerdev/magento2/compare/3.2.5..3.2.6) ### Fixed * Discount amount when taxes are applied diff --git a/composer.json b/composer.json index 63c46c5..495efc3 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "unzerdev/magento2", "description": "This extension for Magento 2 provides a direct integration of the Unzer payment types to your Magento 2 shop via the Unzer Payment API (PAPI).", "type": "magento2-module", - "version": "3.2.6", + "version": "3.2.7", "license": "Apache-2.0", "require": { "php": "~7.4.0|~8.1.0|~8.2.0|~8.3.0", diff --git a/etc/module.xml b/etc/module.xml index f717fe6..80a570e 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,7 +1,7 @@ - +