This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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 - 2017 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\Methods\Payolution; |
||
28 | |||
29 | use Payone\Core\Model\PayoneConfig; |
||
30 | use Magento\Sales\Model\Order; |
||
31 | use Magento\Payment\Model\InfoInterface; |
||
32 | use Magento\Framework\Exception\LocalizedException; |
||
33 | use Payone\Core\Model\Methods\PayoneMethod; |
||
34 | use Magento\Framework\DataObject; |
||
35 | |||
36 | /** |
||
37 | * Base class for all Payolution methods |
||
38 | */ |
||
39 | class PayolutionBase extends PayoneMethod |
||
40 | { |
||
41 | /* Payment method sub types */ |
||
42 | const METHOD_PAYOLUTION_SUBTYPE_INVOICE = 'PYV'; |
||
43 | const METHOD_PAYOLUTION_SUBTYPE_DEBIT = 'PYD'; |
||
44 | const METHOD_PAYOLUTION_SUBTYPE_INSTALLMENT = 'PYS'; |
||
45 | |||
46 | /** |
||
47 | * Clearingtype for PAYONE authorization request |
||
48 | * |
||
49 | * @var string |
||
50 | */ |
||
51 | protected $sClearingtype = 'fnc'; |
||
52 | |||
53 | /** |
||
54 | * Payment method group identifier |
||
55 | * |
||
56 | * @var string |
||
57 | */ |
||
58 | protected $sGroupName = PayoneConfig::METHOD_GROUP_PAYOLUTION; |
||
59 | |||
60 | /** |
||
61 | * Payment method long sub type |
||
62 | * |
||
63 | * @var string|bool |
||
64 | */ |
||
65 | protected $sLongSubType = false; |
||
66 | |||
67 | /** |
||
68 | * Keys that need to be assigned to the additionalinformation fields |
||
69 | * |
||
70 | * @var array |
||
71 | */ |
||
72 | protected $aAssignKeys = [ |
||
73 | 'telephone', |
||
74 | 'b2bmode', |
||
75 | 'trade_registry_number', |
||
76 | 'dateofbirth' |
||
77 | ]; |
||
78 | |||
79 | /** |
||
80 | * PAYONE genericpayment pre_check request model |
||
81 | * |
||
82 | * @var \Payone\Core\Model\Api\Request\Genericpayment\PreCheck |
||
83 | */ |
||
84 | protected $precheckRequest; |
||
85 | |||
86 | /** |
||
87 | * Info instructions block path |
||
88 | * |
||
89 | * @var string |
||
90 | */ |
||
91 | protected $_infoBlockType = 'Payone\Core\Block\Info\ClearingReference'; |
||
92 | |||
93 | /** |
||
94 | * Constructor |
||
95 | * |
||
96 | * @param \Magento\Framework\Model\Context $context |
||
97 | * @param \Magento\Framework\Registry $registry |
||
98 | * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory |
||
99 | * @param \Magento\Framework\Api\AttributeValueFactory $customAttrFactory |
||
100 | * @param \Magento\Payment\Helper\Data $paymentData |
||
101 | * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig |
||
102 | * @param \Magento\Payment\Model\Method\Logger $logger |
||
103 | * @param \Payone\Core\Helper\Toolkit $toolkitHelper |
||
104 | * @param \Payone\Core\Helper\Shop $shopHelper |
||
105 | * @param \Magento\Framework\Url $url |
||
106 | * @param \Magento\Checkout\Model\Session $checkoutSession |
||
107 | * @param \Payone\Core\Model\Api\Request\Debit $debitRequest |
||
108 | * @param \Payone\Core\Model\Api\Request\Capture $captureRequest |
||
109 | * @param \Payone\Core\Model\Api\Request\Authorization $authorizationRequest |
||
110 | * @param \Payone\Core\Model\Api\Request\Genericpayment\PreCheck $precheckRequest |
||
111 | * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource |
||
112 | * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection |
||
113 | * @param array $data |
||
114 | */ |
||
115 | public function __construct( |
||
116 | \Magento\Framework\Model\Context $context, |
||
117 | \Magento\Framework\Registry $registry, |
||
118 | \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, |
||
119 | \Magento\Framework\Api\AttributeValueFactory $customAttrFactory, |
||
120 | \Magento\Payment\Helper\Data $paymentData, |
||
121 | \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, |
||
122 | \Magento\Payment\Model\Method\Logger $logger, |
||
123 | \Payone\Core\Helper\Toolkit $toolkitHelper, |
||
124 | \Payone\Core\Helper\Shop $shopHelper, |
||
125 | \Magento\Framework\Url $url, |
||
126 | \Magento\Checkout\Model\Session $checkoutSession, |
||
127 | \Payone\Core\Model\Api\Request\Debit $debitRequest, |
||
128 | \Payone\Core\Model\Api\Request\Capture $captureRequest, |
||
129 | \Payone\Core\Model\Api\Request\Authorization $authorizationRequest, |
||
130 | \Payone\Core\Model\Api\Request\Genericpayment\PreCheck $precheckRequest, |
||
131 | \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, |
||
132 | \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, |
||
133 | array $data = [] |
||
134 | ) { |
||
135 | parent::__construct($context, $registry, $extensionFactory, $customAttrFactory, $paymentData, $scopeConfig, $logger, $toolkitHelper, $shopHelper, $url, $checkoutSession, $debitRequest, $captureRequest, $authorizationRequest, $resource, $resourceCollection, $data); |
||
136 | $this->precheckRequest = $precheckRequest; |
||
137 | } |
||
138 | |||
139 | /** |
||
140 | * Return parameters specific to this payment type |
||
141 | * |
||
142 | * @param Order $oOrder |
||
143 | * @return array |
||
144 | */ |
||
145 | public function getPaymentSpecificParameters(Order $oOrder) |
||
146 | { |
||
147 | $aBaseParams = [ |
||
148 | 'financingtype' => $this->getSubType(), |
||
149 | 'api_version' => '3.10', |
||
150 | 'workorderid' => $this->getInfoInstance()->getAdditionalInformation('workorderid'), |
||
151 | ]; |
||
152 | |||
153 | $sBirthday = $this->getInfoInstance()->getAdditionalInformation('dateofbirth'); |
||
154 | if ($sBirthday) { |
||
155 | $aBaseParams['birthday'] = $sBirthday; |
||
156 | } |
||
157 | |||
158 | $blB2b = $this->getInfoInstance()->getAdditionalInformation('b2bmode'); |
||
159 | if ($blB2b == '1') { |
||
160 | $aBaseParams['add_paydata[b2b]'] = 'yes'; |
||
161 | $aBaseParams['add_paydata[company_trade_registry_number]'] = $this->getInfoInstance()->getAdditionalInformation('trade_registry_number'); |
||
162 | } |
||
163 | |||
164 | $aSubTypeParams = $this->getSubTypeSpecificParameters($oOrder); |
||
165 | $aParams = array_merge($aBaseParams, $aSubTypeParams); |
||
166 | return $aParams; |
||
167 | } |
||
168 | |||
169 | /** |
||
170 | * Method to trigger the Payone genericpayment request pre-check |
||
171 | * |
||
172 | * @param float $dAmount |
||
173 | * @param string|bool $sBirthday |
||
0 ignored issues
–
show
|
|||
174 | * @return array |
||
175 | * @throws LocalizedException |
||
176 | */ |
||
177 | public function sendPayonePreCheck($dAmount) |
||
178 | { |
||
179 | $oQuote = $this->checkoutSession->getQuote(); |
||
180 | $aResponse = $this->precheckRequest->sendRequest($this, $oQuote, $dAmount); |
||
181 | |||
182 | if ($aResponse['status'] == 'ERROR') {// request returned an error |
||
183 | throw new LocalizedException(__($aResponse['errorcode'].' - '.$aResponse['customermessage'])); |
||
184 | } elseif ($aResponse['status'] == 'OK') { |
||
185 | $this->getInfoInstance()->setAdditionalInformation('workorderid', $aResponse['workorderid']); |
||
186 | } |
||
187 | return $aResponse; |
||
188 | } |
||
189 | |||
190 | /** |
||
191 | * Return long subtype |
||
192 | * |
||
193 | * @return string |
||
194 | */ |
||
195 | public function getLongSubType() |
||
196 | { |
||
197 | return $this->sLongSubType; |
||
198 | } |
||
199 | |||
200 | /** |
||
201 | * Add the checkout-form-data to the checkout session |
||
202 | * |
||
203 | * @param DataObject $data |
||
204 | * @return $this |
||
205 | */ |
||
206 | public function assignData(DataObject $data) |
||
207 | { |
||
208 | parent::assignData($data); |
||
209 | |||
210 | $oInfoInstance = $this->getInfoInstance(); |
||
211 | View Code Duplication | foreach ($this->aAssignKeys as $sKey) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
212 | $sData = $this->toolkitHelper->getAdditionalDataEntry($data, $sKey); |
||
213 | if ($sData) { |
||
0 ignored issues
–
show
The expression
$sData of type string|null is loosely compared to true ; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like For '' == false // true
'' == null // true
'ab' == false // false
'ab' == null // false
// It is often better to use strict comparison
'' === false // false
'' === null // false
![]() |
|||
214 | $oInfoInstance->setAdditionalInformation($sKey, $sData); |
||
215 | } |
||
216 | } |
||
217 | |||
218 | return $this; |
||
219 | } |
||
220 | } |
||
221 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.