PAYONE-GmbH /
magento-2
| 1 | <?php |
||||
| 2 | |||||
| 3 | /** |
||||
| 4 | * PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify |
||||
| 5 | * it under the terms of the GNU Lesser General Public License as published by |
||||
| 6 | * the Free Software Foundation, either version 3 of the License, or |
||||
| 7 | * (at your option) any later version. |
||||
| 8 | * |
||||
| 9 | * PAYONE Magento 2 Connector is distributed in the hope that it will be useful, |
||||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
| 12 | * GNU Lesser General Public License for more details. |
||||
| 13 | * |
||||
| 14 | * You should have received a copy of the GNU Lesser General Public License |
||||
| 15 | * along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>. |
||||
| 16 | * |
||||
| 17 | * PHP version 5 |
||||
| 18 | * |
||||
| 19 | * @category Payone |
||||
| 20 | * @package Payone_Magento2_Plugin |
||||
| 21 | * @author FATCHIP GmbH <[email protected]> |
||||
| 22 | * @copyright 2003 - 2020 Payone GmbH |
||||
| 23 | * @license <http://www.gnu.org/licenses/> GNU Lesser General Public License |
||||
| 24 | * @link http://www.payone.de |
||||
| 25 | */ |
||||
| 26 | |||||
| 27 | namespace Payone\Core\Model\Plugins; |
||||
| 28 | |||||
| 29 | use Payone\Core\Model\PayoneConfig; |
||||
| 30 | use Magento\Payment\Model\MethodInterface; |
||||
|
0 ignored issues
–
show
|
|||||
| 31 | |||||
| 32 | class PaymentHelper |
||||
| 33 | { |
||||
| 34 | const XML_PATH_PAYMENT_METHODS = 'payment'; |
||||
| 35 | |||||
| 36 | /** |
||||
| 37 | * Array of all Payone klarna payment method codes |
||||
| 38 | * |
||||
| 39 | * @var array |
||||
| 40 | */ |
||||
| 41 | protected $payoneKlarnaMethods = [ |
||||
| 42 | PayoneConfig::METHOD_KLARNA_BASE, |
||||
| 43 | PayoneConfig::METHOD_KLARNA_INVOICE, |
||||
| 44 | PayoneConfig::METHOD_KLARNA_DEBIT, |
||||
| 45 | PayoneConfig::METHOD_KLARNA_INSTALLMENT, |
||||
| 46 | ]; |
||||
| 47 | |||||
| 48 | /** |
||||
| 49 | * Factory for payment method models |
||||
| 50 | * |
||||
| 51 | * @var \Magento\Payment\Model\Method\Factory |
||||
|
0 ignored issues
–
show
The type
Magento\Payment\Model\Method\Factory was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 52 | */ |
||||
| 53 | protected $_methodFactory; |
||||
| 54 | |||||
| 55 | /** |
||||
| 56 | * @var \Magento\Framework\App\Config\ScopeConfigInterface |
||||
|
0 ignored issues
–
show
The type
Magento\Framework\App\Config\ScopeConfigInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 57 | */ |
||||
| 58 | protected $scopeConfig; |
||||
| 59 | |||||
| 60 | /** |
||||
| 61 | * Construct |
||||
| 62 | * |
||||
| 63 | * @param \Magento\Framework\App\Helper\Context $context |
||||
| 64 | * @param \Magento\Payment\Model\Method\Factory $paymentMethodFactory |
||||
| 65 | */ |
||||
| 66 | public function __construct( |
||||
| 67 | \Magento\Framework\App\Helper\Context $context, |
||||
|
0 ignored issues
–
show
The type
Magento\Framework\App\Helper\Context was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 68 | \Magento\Payment\Model\Method\Factory $paymentMethodFactory |
||||
| 69 | ) { |
||||
| 70 | $this->_methodFactory = $paymentMethodFactory; |
||||
| 71 | $this->scopeConfig = $context->getScopeConfig(); |
||||
| 72 | } |
||||
| 73 | |||||
| 74 | /** |
||||
| 75 | * Get config name of method model |
||||
| 76 | * |
||||
| 77 | * @param string $code |
||||
| 78 | * @return string |
||||
| 79 | */ |
||||
| 80 | protected function getMethodModelConfigName($code) |
||||
| 81 | { |
||||
| 82 | return sprintf('%s/%s/model', self::XML_PATH_PAYMENT_METHODS, $code); |
||||
| 83 | } |
||||
| 84 | |||||
| 85 | /** |
||||
| 86 | * Retrieve method model object |
||||
| 87 | * |
||||
| 88 | * @param string $code |
||||
| 89 | * |
||||
| 90 | * @throws \Magento\Framework\Exception\LocalizedException |
||||
| 91 | * @return MethodInterface |
||||
| 92 | */ |
||||
| 93 | protected function getCoreMethodInstance($code) |
||||
| 94 | { |
||||
| 95 | $class = $this->scopeConfig->getValue( |
||||
| 96 | $this->getMethodModelConfigName($code), |
||||
| 97 | \Magento\Store\Model\ScopeInterface::SCOPE_STORE |
||||
|
0 ignored issues
–
show
The type
Magento\Store\Model\ScopeInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 98 | ); |
||||
| 99 | |||||
| 100 | if (!$class) { |
||||
| 101 | throw new \UnexpectedValueException('Payment model name is not provided in config!'); |
||||
| 102 | } |
||||
| 103 | |||||
| 104 | return $this->_methodFactory->create($class); |
||||
| 105 | } |
||||
| 106 | |||||
| 107 | /** |
||||
| 108 | * Retrieve method model object |
||||
| 109 | * |
||||
| 110 | * This plugin is necessary because the Klarna module "\Klarna\Kp\Plugin\Payment\Helper\DataPlugin" claims every |
||||
| 111 | * payment method with "klarna_" in the payment code for it's own payment model which blocks others to use such a payment code |
||||
| 112 | * |
||||
| 113 | * @param \Magento\Payment\Helper\Data $subject |
||||
| 114 | * @param callable $proceed |
||||
| 115 | * @param string $code |
||||
| 116 | * @return MethodInterface |
||||
| 117 | * @throws \Magento\Framework\Exception\LocalizedException |
||||
| 118 | */ |
||||
| 119 | public function aroundGetMethodInstance(\Magento\Payment\Helper\Data $subject, callable $proceed, $code) |
||||
|
0 ignored issues
–
show
The parameter
$subject is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The type
Magento\Payment\Helper\Data was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 120 | { |
||||
| 121 | if (!in_array($code, $this->payoneKlarnaMethods)) { |
||||
| 122 | return $proceed($code); |
||||
| 123 | } |
||||
| 124 | return $this->getCoreMethodInstance($code); |
||||
| 125 | } |
||||
| 126 | } |
||||
| 127 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths