Skip to content

Commit

Permalink
[chg] Clean unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
m1k3lm committed Feb 18, 2019
1 parent b7c4059 commit f47a168
Showing 1 changed file with 0 additions and 114 deletions.
114 changes: 0 additions & 114 deletions Model/AbstractConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ public function getValue($key, $storeId = null)
ScopeInterface::SCOPE_STORE,
$this->_storeId
);
$value = $this->_prepareValue($underscored, $value);
return $value;
}
}
Expand All @@ -195,117 +194,4 @@ protected function _getSpecificConfigPath($fieldName)
return "payment/{$this->_methodCode}/{$fieldName}";
}

/**
* Perform additional config value preparation and return new value if needed
*
* @param string $key Underscored key
* @param string $value Old value
* @return string Modified value or old value
*/
protected function _prepareValue($key, $value)
{
// Always set payment action as "Sale" for Unilateral payments in EC
if ($key == 'payment_action' &&
$value != self::PAYMENT_ACTION_SALE &&
$this->_methodCode == self::METHOD_WPP_EXPRESS &&
$this->shouldUseUnilateralPayments()
) {
return self::PAYMENT_ACTION_SALE;
}
return $value;
}

/**
* Check whether method available for checkout or not
*
* @param null $methodCode
*
* @return bool
*/
public function isMethodAvailable($methodCode = null)
{
$methodCode = $methodCode ?: $this->_methodCode;

return $this->isMethodActive($methodCode);
}

/**
* Check whether method active in configuration and supported for merchant country or not
*
* @param string $method Method code
* @return bool
*
* @todo: refactor this
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function isMethodActive($method)
{
switch ($method) {
case Config::METHOD_WPS_EXPRESS:
case Config::METHOD_WPP_EXPRESS:
$isEnabled = $this->_scopeConfig->isSetFlag(
'payment/' . Config::METHOD_WPS_EXPRESS . '/active',
ScopeInterface::SCOPE_STORE,
$this->_storeId
)
|| $this->_scopeConfig->isSetFlag(
'payment/' . Config::METHOD_WPP_EXPRESS . '/active',
ScopeInterface::SCOPE_STORE,
$this->_storeId
);
$method = Config::METHOD_WPP_EXPRESS;
break;
case Config::METHOD_WPS_BML:
case Config::METHOD_WPP_BML:
$isEnabled = $this->_scopeConfig->isSetFlag(
'payment/' . Config::METHOD_WPS_BML . '/active',
ScopeInterface::SCOPE_STORE,
$this->_storeId
)
|| $this->_scopeConfig->isSetFlag(
'payment/' . Config::METHOD_WPP_BML . '/active',
ScopeInterface::SCOPE_STORE,
$this->_storeId
);
$method = Config::METHOD_WPP_BML;
break;
case Config::METHOD_PAYMENT_PRO:
case Config::METHOD_PAYFLOWPRO:
$isEnabled = $this->_scopeConfig->isSetFlag(
'payment/' . Config::METHOD_PAYMENT_PRO . '/active',
ScopeInterface::SCOPE_STORE,
$this->_storeId
)
|| $this->_scopeConfig->isSetFlag(
'payment/' . Config::METHOD_PAYFLOWPRO . '/active',
ScopeInterface::SCOPE_STORE,
$this->_storeId
);
$method = Config::METHOD_PAYFLOWPRO;
break;
default:
$isEnabled = $this->_scopeConfig->isSetFlag(
"payment/{$method}/active",
ScopeInterface::SCOPE_STORE,
$this->_storeId
);
}

return $this->isMethodSupportedForCountry($method) && $isEnabled;
}

/**
* Check whether method supported for specified country or not
*
* @param string|null $method
* @param string|null $countryCode
* @return bool
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function isMethodSupportedForCountry($method = null, $countryCode = null)
{
return true;
}
}

0 comments on commit f47a168

Please sign in to comment.