From 82f425f62c49182972cff159dcaa2d63688fd395 Mon Sep 17 00:00:00 2001 From: woutse Date: Fri, 6 May 2022 13:52:23 +0200 Subject: [PATCH 1/2] Updated trims --- Model/Config.php | 12 ++++++------ Model/Paymentmethod/Instore.php | 6 +++--- Model/Paymentmethod/PaymentMethod.php | 2 +- Setup/Patch/Data/UpdateFashionGiftcard.php | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Model/Config.php b/Model/Config.php index 2c13790c..067136cd 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -232,7 +232,7 @@ public function configureSDK() } if (!empty($apiToken) && !empty($serviceId)) { - if (!empty(trim($gateway)) && substr(trim($gateway), 0, 4) === "http") { + if (!empty($gateway) && substr(trim($gateway), 0, 4) === "http") { \Paynl\Config::setApiBase(trim($gateway)); } \Paynl\Config::setApiToken($apiToken); @@ -246,17 +246,17 @@ public function configureSDK() public function getApiToken() { - return trim($this->store->getConfig('payment/paynl/apitoken')); + return $this->store->getConfig('payment/paynl/apitoken'); } public function getTokencode() { - return trim($this->store->getConfig('payment/paynl/tokencode')); + return $this->store->getConfig('payment/paynl/tokencode'); } public function getServiceId() { - return trim($this->store->getConfig('payment/paynl/serviceid')); + return $this->store->getConfig('payment/paynl/serviceid'); } public function getFailoverGateway() @@ -288,7 +288,7 @@ public function getIconUrl($methodCode, $paymentOptionId) } } $iconUrl = 'https://static.pay.nl/payment_profiles/' . $iconsize . '/' . $paymentOptionId . '.png'; - $customUrl = trim($this->store->getConfig('payment/paynl/iconurl')); + $customUrl = $this->store->getConfig('payment/paynl/iconurl'); if (!empty($customUrl)) { $iconUrl = str_replace('#paymentOptionId#', $paymentOptionId, $customUrl); } @@ -312,7 +312,7 @@ public function getIconSize() public function getUseAdditionalValidation() { - return trim($this->store->getConfig('payment/paynl/use_additional_validation')); + return $this->store->getConfig('payment/paynl/use_additional_validation'); } public function getCancelURL() diff --git a/Model/Paymentmethod/Instore.php b/Model/Paymentmethod/Instore.php index 0ebcf7e9..b473bd06 100644 --- a/Model/Paymentmethod/Instore.php +++ b/Model/Paymentmethod/Instore.php @@ -135,7 +135,7 @@ public function isCurrentIpValid() { $onlyAllowedIPs = $this->_scopeConfig->getValue('payment/' . $this->_code . '/exclusiveforipaddress', 'store'); - if (empty(trim($onlyAllowedIPs))) { + if (empty($onlyAllowedIPs)) { return true; # No IP is given, so all ips are valid } @@ -146,7 +146,7 @@ public function isCurrentAgentValid() { $specifiedUserAgent = $this->_scopeConfig->getValue('payment/' . $this->_code . '/exclusiveforuseragent', 'store'); - if (empty(trim($specifiedUserAgent)) || $specifiedUserAgent == 'No') { + if (empty($specifiedUserAgent) || $specifiedUserAgent == 'No') { return true; } $currentUserAgent = $_SERVER['HTTP_USER_AGENT']; @@ -165,7 +165,7 @@ public function isCurrentAgentValid() return $specifiedUserAgent == $user_browser; } else { $custom_useragents = $this->_scopeConfig->getValue('payment/' . $this->_code . '/exclusiveforuseragent_custom', 'store'); - if (empty(trim($custom_useragents))) { + if (empty($custom_useragents)) { return true; } diff --git a/Model/Paymentmethod/PaymentMethod.php b/Model/Paymentmethod/PaymentMethod.php index d4c6e2e3..b48d0ef4 100644 --- a/Model/Paymentmethod/PaymentMethod.php +++ b/Model/Paymentmethod/PaymentMethod.php @@ -121,7 +121,7 @@ protected function getState($status) */ public function getInstructions() { - return trim($this->getConfigData('instructions')); + return $this->getConfigData('instructions'); } public function getPaymentOptions() diff --git a/Setup/Patch/Data/UpdateFashionGiftcard.php b/Setup/Patch/Data/UpdateFashionGiftcard.php index 6f7fd057..49a766af 100644 --- a/Setup/Patch/Data/UpdateFashionGiftcard.php +++ b/Setup/Patch/Data/UpdateFashionGiftcard.php @@ -48,7 +48,7 @@ public function apply() $tableName = $this->resourceConnection->getTableName('core_config_data'); $path = 'payment/paynl_payment_fashiongiftcard/payment_option_id'; - $query = "SELECT `value` FROM " . $tableName . " WHERE scope = 'default' AND `path`= '" . $path . "'"; + $query = "SELECT `value` FROM " . $tableName . " WHERE scope = 'default' AND `path`= :path "; $result = $connection->fetchOne($query, ['path' => $path]); if (!$result) { From c16abecc073851202b5a85c369c6ca0a5936a58f Mon Sep 17 00:00:00 2001 From: woutse Date: Fri, 6 May 2022 14:04:05 +0200 Subject: [PATCH 2/2] Updated explode --- Model/Config.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Model/Config.php b/Model/Config.php index 067136cd..364c1981 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -142,9 +142,12 @@ public function isTestMode() $ip = isset($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : $remoteIP; $ipconfig = $this->store->getConfig('payment/paynl/testipaddress'); - $allowed_ips = explode(',', $ipconfig); - if (in_array($ip, $allowed_ips) && filter_var($ip, FILTER_VALIDATE_IP) && strlen($ip) > 0 && count($allowed_ips) > 0) { - return true; + + if(!empty($ipconfig)) { + $allowed_ips = explode(',', $ipconfig); + if (in_array($ip, $allowed_ips) && filter_var($ip, FILTER_VALIDATE_IP) && strlen($ip) > 0 && count($allowed_ips) > 0) { + return true; + } } return $this->store->getConfig('payment/paynl/testmode') == 1; }