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 - 2016 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\Api\Request; |
||||
| 28 | |||||
| 29 | use Payone\Core\Helper\Country as CountryHelper; |
||||
| 30 | use Payone\Core\Model\PayoneConfig; |
||||
| 31 | use Payone\Core\Model\Methods\PayoneMethod; |
||||
| 32 | use Magento\Quote\Model\Quote\Address as QuoteAddress; |
||||
|
0 ignored issues
–
show
|
|||||
| 33 | use Magento\Sales\Model\Order\Address as OrderAddress; |
||||
|
0 ignored issues
–
show
The type
Magento\Sales\Model\Order\Address 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...
|
|||||
| 34 | |||||
| 35 | /** |
||||
| 36 | * Base class for all PAYONE requests that need the address methods |
||||
| 37 | */ |
||||
| 38 | abstract class AddressRequest extends Base |
||||
| 39 | { |
||||
| 40 | /** |
||||
| 41 | * PAYONE customer helper |
||||
| 42 | * |
||||
| 43 | * @var \Payone\Core\Helper\Customer |
||||
| 44 | */ |
||||
| 45 | protected $customerHelper; |
||||
| 46 | |||||
| 47 | /** |
||||
| 48 | * Constructor |
||||
| 49 | * |
||||
| 50 | * @param \Payone\Core\Helper\Shop $shopHelper |
||||
| 51 | * @param \Payone\Core\Helper\Environment $environmentHelper |
||||
| 52 | * @param \Payone\Core\Helper\Api $apiHelper |
||||
| 53 | * @param \Payone\Core\Helper\Toolkit $toolkitHelper |
||||
| 54 | * @param \Payone\Core\Model\ResourceModel\ApiLog $apiLog |
||||
| 55 | * @param \Payone\Core\Helper\Customer $customerHelper |
||||
| 56 | */ |
||||
| 57 | public function __construct( |
||||
| 58 | \Payone\Core\Helper\Shop $shopHelper, |
||||
| 59 | \Payone\Core\Helper\Environment $environmentHelper, |
||||
| 60 | \Payone\Core\Helper\Api $apiHelper, |
||||
| 61 | \Payone\Core\Helper\Toolkit $toolkitHelper, |
||||
| 62 | \Payone\Core\Model\ResourceModel\ApiLog $apiLog, |
||||
| 63 | \Payone\Core\Helper\Customer $customerHelper |
||||
| 64 | ) { |
||||
| 65 | parent::__construct($shopHelper, $environmentHelper, $apiHelper, $toolkitHelper, $apiLog); |
||||
| 66 | $this->customerHelper = $customerHelper; |
||||
| 67 | } |
||||
| 68 | |||||
| 69 | /** |
||||
| 70 | * Add address-parameters to the request |
||||
| 71 | * |
||||
| 72 | * @param QuoteAddress|OrderAddress $oAddress |
||||
| 73 | * @param bool $blIsShipping |
||||
| 74 | * @return void |
||||
| 75 | */ |
||||
| 76 | protected function addAddress($oAddress, $blIsShipping = false) |
||||
| 77 | { |
||||
| 78 | $sPre = ''; |
||||
| 79 | if ($blIsShipping === true) { |
||||
| 80 | $sPre = 'shipping_'; // add shipping prefix for shipping addresses |
||||
| 81 | } |
||||
| 82 | $this->addParameter($sPre.'firstname', $oAddress->getFirstname()); |
||||
| 83 | $this->addParameter($sPre.'lastname', $oAddress->getLastname()); |
||||
| 84 | if ($oAddress->getCompany()) {// company name existing? |
||||
| 85 | $this->addParameter($sPre.'company', $oAddress->getCompany()); |
||||
| 86 | } |
||||
| 87 | |||||
| 88 | $aStreet = $oAddress->getStreet(); |
||||
| 89 | $sStreet = is_array($aStreet) ? implode(' ', $aStreet) : $aStreet; // street may be an array |
||||
| 90 | $this->addParameter($sPre.'street', trim($sStreet ?? '')); |
||||
| 91 | $this->addParameter($sPre.'zip', $oAddress->getPostcode()); |
||||
| 92 | $this->addParameter($sPre.'city', $oAddress->getCity()); |
||||
| 93 | $this->addParameter($sPre.'country', $oAddress->getCountryId()); |
||||
| 94 | |||||
| 95 | if (CountryHelper::isStateNeeded($oAddress->getCountryId()) && $oAddress->getRegionCode()) { |
||||
| 96 | $this->addParameter($sPre.'state', $this->customerHelper->getRegionCode($oAddress)); |
||||
| 97 | } |
||||
| 98 | } |
||||
| 99 | |||||
| 100 | /** |
||||
| 101 | * Add user-data to the request |
||||
| 102 | * |
||||
| 103 | * @param QuoteAddress|OrderAddress $oBilling |
||||
| 104 | * @param PayoneMethod $oPayment |
||||
| 105 | * @param string $iGender |
||||
| 106 | * @param string $sEmail |
||||
| 107 | * @param string $sDob |
||||
| 108 | * @param bool $blIsUpdateUser |
||||
| 109 | * @return void |
||||
| 110 | */ |
||||
| 111 | protected function addUserDataParameters($oBilling, PayoneMethod $oPayment, $iGender, $sEmail, $sDob, $blIsUpdateUser = false) |
||||
|
0 ignored issues
–
show
The parameter
$oPayment 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...
|
|||||
| 112 | { |
||||
| 113 | $this->addAddress($oBilling); |
||||
| 114 | |||||
| 115 | if ($iGender || $blIsUpdateUser) { |
||||
| 116 | $this->addParameter('salutation', $this->customerHelper->getSalutationParameter($iGender), $blIsUpdateUser); |
||||
|
0 ignored issues
–
show
$iGender of type string is incompatible with the type integer expected by parameter $iGender of Payone\Core\Helper\Custo...etSalutationParameter().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 117 | $this->addParameter('gender', $this->customerHelper->getGenderParameter($iGender), $blIsUpdateUser); |
||||
|
0 ignored issues
–
show
$iGender of type string is incompatible with the type integer expected by parameter $iGender of Payone\Core\Helper\Customer::getGenderParameter().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 118 | } |
||||
| 119 | |||||
| 120 | $this->addParameter('email', $sEmail); |
||||
| 121 | if ($blIsUpdateUser || $oBilling->getTelephone()) { |
||||
| 122 | $this->addParameter('telephonenumber', $oBilling->getTelephone(), $blIsUpdateUser); |
||||
| 123 | } |
||||
| 124 | |||||
| 125 | // Might be needed again with new Klarna in if-statement: in_array($oPayment->getCode(), [PayoneConfig::METHOD_KLARNA]) && in_array($oBilling->getCountryId(), ['DE', 'NL', 'AT']) |
||||
| 126 | if ($blIsUpdateUser || ($sDob != '0000-00-00 00:00:00' && $sDob != '')) { |
||||
| 127 | $this->addParameter('birthday', str_replace('-', '', date('Ymd', strtotime($sDob)), $blIsUpdateUser)); |
||||
|
0 ignored issues
–
show
$blIsUpdateUser of type boolean is incompatible with the type integer|null expected by parameter $count of str_replace().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 128 | } |
||||
| 129 | |||||
| 130 | $this->addParameter('language', $this->shopHelper->getLocale()); |
||||
| 131 | if ($blIsUpdateUser || $oBilling->getVatId() != '') { |
||||
| 132 | $this->addParameter('vatid', $oBilling->getVatId(), $blIsUpdateUser); |
||||
| 133 | } |
||||
| 134 | } |
||||
| 135 | } |
||||
| 136 |
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