Skip to content

Commit

Permalink
Merge pull request #33 from paynl/feature/PLUG-938
Browse files Browse the repository at this point in the history
PLUG-938 : Updates for PHP 81
  • Loading branch information
woutse authored May 6, 2022
2 parents e435088 + c16abec commit edb55ab
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
21 changes: 12 additions & 9 deletions Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -232,7 +235,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);
Expand All @@ -246,17 +249,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()
Expand Down Expand Up @@ -288,7 +291,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);
}
Expand All @@ -312,7 +315,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()
Expand Down
6 changes: 3 additions & 3 deletions Model/Paymentmethod/Instore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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'];
Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion Model/Paymentmethod/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected function getState($status)
*/
public function getInstructions()
{
return trim($this->getConfigData('instructions'));
return $this->getConfigData('instructions');
}

public function getPaymentOptions()
Expand Down
2 changes: 1 addition & 1 deletion Setup/Patch/Data/UpdateFashionGiftcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit edb55ab

Please sign in to comment.