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\Methods\Klarna; |
||
28 | |||
29 | use Payone\Core\Model\PayoneConfig; |
||
30 | use Magento\Sales\Model\Order; |
||
0 ignored issues
–
show
|
|||
31 | use Magento\Payment\Model\InfoInterface; |
||
0 ignored issues
–
show
The type
Magento\Payment\Model\InfoInterface 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 ![]() |
|||
32 | use Magento\Framework\Exception\LocalizedException; |
||
0 ignored issues
–
show
The type
Magento\Framework\Exception\LocalizedException 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 ![]() |
|||
33 | use Payone\Core\Model\Methods\PayoneMethod; |
||
34 | use Magento\Framework\DataObject; |
||
0 ignored issues
–
show
The type
Magento\Framework\DataObject 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 ![]() |
|||
35 | |||
36 | /** |
||
37 | * Base class for all Klarna methods |
||
38 | */ |
||
39 | class KlarnaBase extends PayoneMethod |
||
40 | { |
||
41 | /* Payment method sub types */ |
||
42 | const METHOD_KLARNA_SUBTYPE_INVOICE = 'KIV'; |
||
43 | const METHOD_KLARNA_SUBTYPE_DEBIT = 'KDD'; |
||
44 | const METHOD_KLARNA_SUBTYPE_INSTALLMENT = 'KIS'; |
||
45 | |||
46 | /** |
||
47 | * Payment method code for pseudo-payment-type Klarna |
||
48 | * |
||
49 | * @var string |
||
50 | */ |
||
51 | protected $_code = PayoneConfig::METHOD_KLARNA_BASE; |
||
52 | |||
53 | /** |
||
54 | * Clearingtype for PAYONE authorization request |
||
55 | * |
||
56 | * @var string |
||
57 | */ |
||
58 | protected $sClearingtype = 'fnc'; |
||
59 | |||
60 | /** |
||
61 | * Payment method group identifier |
||
62 | * |
||
63 | * @var string |
||
64 | */ |
||
65 | protected $sGroupName = PayoneConfig::METHOD_GROUP_KLARNA; |
||
66 | |||
67 | /** |
||
68 | * Payment method long sub type |
||
69 | * |
||
70 | * @var string|bool |
||
71 | */ |
||
72 | protected $sLongSubType = false; |
||
73 | |||
74 | /** |
||
75 | * Determines if the redirect-parameters have to be added |
||
76 | * to the authorization-request |
||
77 | * |
||
78 | * @var bool |
||
79 | */ |
||
80 | protected $blNeedsRedirectUrls = true; |
||
81 | |||
82 | /** |
||
83 | * Determines if the invoice information has to be added |
||
84 | * to the authorization-request |
||
85 | * |
||
86 | * @var bool |
||
87 | */ |
||
88 | protected $blNeedsProductInfo = true; |
||
89 | |||
90 | /** |
||
91 | * Info instructions block path |
||
92 | * |
||
93 | * @var string |
||
94 | */ |
||
95 | protected $_infoBlockType = 'Payone\Core\Block\Info\ClearingReference'; |
||
96 | |||
97 | /** |
||
98 | * Return parameters specific to this payment type |
||
99 | * |
||
100 | * @param Order $oOrder |
||
101 | * @return array |
||
102 | */ |
||
103 | public function getPaymentSpecificParameters(Order $oOrder) |
||
104 | { |
||
105 | $aBaseParams = [ |
||
106 | 'financingtype' => $this->getSubType(), |
||
107 | 'add_paydata[authorization_token]' => $this->getInfoInstance()->getAdditionalInformation('authorization_token'), |
||
108 | 'customerid' => '', // Klarna payment methods return an error when customerid is transmitted... |
||
109 | ]; |
||
110 | |||
111 | $oBilling = $oOrder->getBillingAddress(); |
||
112 | if ($oBilling->getCompany()) { |
||
113 | $aBaseParams['add_paydata[organization_entity_type]'] = 'OTHER'; |
||
114 | $aBaseParams['add_paydata[organization_registry_id]'] = ''; |
||
115 | } |
||
116 | |||
117 | $oShipping = $oOrder->getShippingAddress(); |
||
118 | if ($oShipping) { |
||
119 | $aBaseParams['add_paydata[shipping_email]'] = $oOrder->getCustomerEmail(); |
||
120 | $aBaseParams['add_paydata[shipping_title]'] = ''; |
||
121 | $aBaseParams['add_paydata[shipping_telephonenumber]'] = $oShipping->getTelephone(); |
||
122 | } |
||
123 | |||
124 | $aSubTypeParams = $this->getSubTypeSpecificParameters($oOrder); |
||
125 | $aParams = array_merge($aBaseParams, $aSubTypeParams); |
||
126 | return $aParams; |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * Add the checkout-form-data to the checkout session |
||
131 | * |
||
132 | * @param DataObject $data |
||
133 | * @return $this |
||
134 | */ |
||
135 | public function assignData(DataObject $data) |
||
136 | { |
||
137 | parent::assignData($data); |
||
138 | |||
139 | $oInfoInstance = $this->getInfoInstance(); |
||
140 | $oInfoInstance->setAdditionalInformation('authorization_token', $this->toolkitHelper->getAdditionalDataEntry($data, 'authorization_token')); |
||
141 | |||
142 | return $this; |
||
143 | } |
||
144 | |||
145 | /** |
||
146 | * Checks if a company is given in the billing address |
||
147 | * |
||
148 | * @param \Magento\Quote\Api\Data\CartInterface|null $quote |
||
149 | * @return bool |
||
150 | */ |
||
151 | protected function isB2BOrder(?\Magento\Quote\Api\Data\CartInterface $quote = null) |
||
0 ignored issues
–
show
The type
Magento\Quote\Api\Data\CartInterface 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 ![]() |
|||
152 | { |
||
153 | if ($quote === null) { |
||
154 | $quote = $this->checkoutSession->getQuote(); |
||
155 | } |
||
156 | |||
157 | if ($quote && $quote->getBillingAddress() && !empty($quote->getBillingAddress()->getCompany())) { |
||
158 | return true; |
||
159 | } |
||
160 | return false; |
||
161 | } |
||
162 | } |
||
163 |
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