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; |
28
|
|
|
|
29
|
|
|
use Payone\Core\Model\PayoneConfig; |
30
|
|
|
use Payone\Core\Model\Methods\OnlineBankTransfer\Eps; |
31
|
|
|
use Payone\Core\Model\Methods\OnlineBankTransfer\Ideal; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Extension for config provider to extend the javascript |
35
|
|
|
* data-array in the checkout |
36
|
|
|
*/ |
37
|
|
|
class ConfigProvider extends \Magento\Payment\Model\CcGenericConfigProvider |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
/** |
40
|
|
|
* Payment helper object |
41
|
|
|
* |
42
|
|
|
* @var \Magento\Payment\Helper\Data |
|
|
|
|
43
|
|
|
*/ |
44
|
|
|
protected $dataHelper; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* PAYONE country helper |
48
|
|
|
* |
49
|
|
|
* @var \Payone\Core\Helper\Country |
50
|
|
|
*/ |
51
|
|
|
protected $countryHelper; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* PAYONE country helper |
55
|
|
|
* |
56
|
|
|
* @var \Payone\Core\Helper\Customer |
57
|
|
|
*/ |
58
|
|
|
protected $customerHelper; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* PAYONE payment helper |
62
|
|
|
* |
63
|
|
|
* @var \Payone\Core\Helper\Payment |
64
|
|
|
*/ |
65
|
|
|
protected $paymentHelper; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* PAYONE hosted iframe helper |
69
|
|
|
* |
70
|
|
|
* @var \Payone\Core\Helper\HostedIframe |
71
|
|
|
*/ |
72
|
|
|
protected $hostedIframeHelper; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* PAYONE request helper |
76
|
|
|
* |
77
|
|
|
* @var \Payone\Core\Helper\Request |
78
|
|
|
*/ |
79
|
|
|
protected $requestHelper; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Escaper object |
83
|
|
|
* |
84
|
|
|
* @var \Magento\Framework\Escaper |
|
|
|
|
85
|
|
|
*/ |
86
|
|
|
protected $escaper; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* PAYONE request helper |
90
|
|
|
* |
91
|
|
|
* @var \Payone\Core\Helper\Consumerscore |
92
|
|
|
*/ |
93
|
|
|
protected $consumerscoreHelper; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Privacy declaration object |
97
|
|
|
* |
98
|
|
|
* @var \Payone\Core\Model\Api\Payolution\PrivacyDeclaration |
99
|
|
|
*/ |
100
|
|
|
protected $privacyDeclaration; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Checkout session |
104
|
|
|
* |
105
|
|
|
* @var \Magento\Checkout\Model\Session |
|
|
|
|
106
|
|
|
*/ |
107
|
|
|
protected $checkoutSession; |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Customer session |
111
|
|
|
* |
112
|
|
|
* @var \Magento\Customer\Model\Session |
|
|
|
|
113
|
|
|
*/ |
114
|
|
|
protected $customerSession; |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* PAYONE shop helper |
118
|
|
|
* |
119
|
|
|
* @var \Payone\Core\Helper\Shop |
120
|
|
|
*/ |
121
|
|
|
protected $shopHelper; |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Resource model for saved payment data |
125
|
|
|
* |
126
|
|
|
* @var \Payone\Core\Model\ResourceModel\SavedPaymentData |
127
|
|
|
*/ |
128
|
|
|
protected $savedPaymentData; |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @var \Payone\Core\Model\Methods\Ratepay\Installment\Proxy |
|
|
|
|
132
|
|
|
*/ |
133
|
|
|
protected $ratepayInstallment; |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Constructor |
137
|
|
|
* |
138
|
|
|
* @param \Magento\Payment\Model\CcConfig $ccConfig |
139
|
|
|
* @param \Magento\Payment\Helper\Data $dataHelper |
140
|
|
|
* @param \Payone\Core\Helper\Country $countryHelper |
141
|
|
|
* @param \Payone\Core\Helper\Customer $customerHelper |
142
|
|
|
* @param \Payone\Core\Helper\Payment $paymentHelper |
143
|
|
|
* @param \Payone\Core\Helper\HostedIframe $hostedIframeHelper |
144
|
|
|
* @param \Payone\Core\Helper\Request $requestHelper |
145
|
|
|
* @param \Magento\Framework\Escaper $escaper |
146
|
|
|
* @param \Payone\Core\Helper\Consumerscore $consumerscoreHelper |
147
|
|
|
* @param \Payone\Core\Model\Api\Payolution\PrivacyDeclaration $privacyDeclaration |
148
|
|
|
* @param \Magento\Checkout\Model\Session $checkoutSession |
149
|
|
|
* @param \Magento\Customer\Model\Session $customerSession |
150
|
|
|
* @param \Payone\Core\Helper\Shop $shopHelper |
151
|
|
|
* @param \Payone\Core\Model\ResourceModel\SavedPaymentData $savedPaymentData |
152
|
|
|
* @param \Payone\Core\Model\Methods\Ratepay\Installment\Proxy $ratepayInstallment |
153
|
|
|
*/ |
154
|
|
|
public function __construct( |
155
|
|
|
\Magento\Payment\Model\CcConfig $ccConfig, |
|
|
|
|
156
|
|
|
\Magento\Payment\Helper\Data $dataHelper, |
157
|
|
|
\Payone\Core\Helper\Country $countryHelper, |
158
|
|
|
\Payone\Core\Helper\Customer $customerHelper, |
159
|
|
|
\Payone\Core\Helper\Payment $paymentHelper, |
160
|
|
|
\Payone\Core\Helper\HostedIframe $hostedIframeHelper, |
161
|
|
|
\Payone\Core\Helper\Request $requestHelper, |
162
|
|
|
\Magento\Framework\Escaper $escaper, |
163
|
|
|
\Payone\Core\Helper\Consumerscore $consumerscoreHelper, |
164
|
|
|
\Payone\Core\Model\Api\Payolution\PrivacyDeclaration $privacyDeclaration, |
165
|
|
|
\Magento\Checkout\Model\Session $checkoutSession, |
166
|
|
|
\Magento\Customer\Model\Session $customerSession, |
167
|
|
|
\Payone\Core\Helper\Shop $shopHelper, |
168
|
|
|
\Payone\Core\Model\ResourceModel\SavedPaymentData $savedPaymentData, |
169
|
|
|
\Payone\Core\Model\Methods\Ratepay\Installment\Proxy $ratepayInstallment |
170
|
|
|
) { |
171
|
|
|
parent::__construct($ccConfig, $dataHelper); |
172
|
|
|
$this->dataHelper = $dataHelper; |
173
|
|
|
$this->countryHelper = $countryHelper; |
174
|
|
|
$this->customerHelper = $customerHelper; |
175
|
|
|
$this->paymentHelper = $paymentHelper; |
176
|
|
|
$this->hostedIframeHelper = $hostedIframeHelper; |
177
|
|
|
$this->requestHelper = $requestHelper; |
178
|
|
|
$this->escaper = $escaper; |
179
|
|
|
$this->consumerscoreHelper = $consumerscoreHelper; |
180
|
|
|
$this->privacyDeclaration = $privacyDeclaration; |
181
|
|
|
$this->checkoutSession = $checkoutSession; |
182
|
|
|
$this->customerSession = $customerSession; |
183
|
|
|
$this->shopHelper = $shopHelper; |
184
|
|
|
$this->savedPaymentData = $savedPaymentData; |
185
|
|
|
$this->ratepayInstallment = $ratepayInstallment; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* Get the payment description text |
190
|
|
|
* |
191
|
|
|
* @param string $sCode |
192
|
|
|
* @return string |
193
|
|
|
*/ |
194
|
|
|
protected function getInstructionByCode($sCode) |
195
|
|
|
{ |
196
|
|
|
$oMethodInstance = $this->dataHelper->getMethodInstance($sCode); |
197
|
|
|
if ($oMethodInstance) { |
198
|
|
|
return nl2br($this->escaper->escapeHtml($oMethodInstance->getInstructions())); |
199
|
|
|
} |
200
|
|
|
return ''; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Add payolution parameters to the config array |
205
|
|
|
* |
206
|
|
|
* @return array |
207
|
|
|
*/ |
208
|
|
|
protected function getPayolutionConfig() |
209
|
|
|
{ |
210
|
|
|
return [ |
211
|
|
|
'b2bMode' => [ |
212
|
|
|
'invoice' => $this->requestHelper->getConfigParam('b2b_mode', PayoneConfig::METHOD_PAYOLUTION_INVOICE, 'payone_payment'), |
213
|
|
|
], |
214
|
|
|
'privacyDeclaration' => [ |
215
|
|
|
'invoice' => $this->privacyDeclaration->getPayolutionAcceptanceText(PayoneConfig::METHOD_PAYOLUTION_INVOICE), |
216
|
|
|
'debit' => $this->privacyDeclaration->getPayolutionAcceptanceText(PayoneConfig::METHOD_PAYOLUTION_DEBIT), |
217
|
|
|
'installment' => $this->privacyDeclaration->getPayolutionAcceptanceText(PayoneConfig::METHOD_PAYOLUTION_INSTALLMENT), |
218
|
|
|
], |
219
|
|
|
]; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* Add payone parameters to the config array |
224
|
|
|
* |
225
|
|
|
* @return array |
226
|
|
|
*/ |
227
|
|
|
protected function getPayoneConfig() |
228
|
|
|
{ |
229
|
|
|
return [ |
230
|
|
|
'locale' => $this->shopHelper->getLocale(), |
231
|
|
|
'fullLocale' => $this->requestHelper->getConfigParam('code', 'locale', 'general'), |
232
|
|
|
'availableCardTypes' => $this->paymentHelper->getAvailableCreditcardTypes(), |
233
|
|
|
'availableApplePayTypes' => $this->paymentHelper->getAvailableApplePayTypes(), |
234
|
|
|
'fieldConfig' => $this->hostedIframeHelper->getHostedFieldConfig(), |
235
|
|
|
'sepaCountries' => $this->countryHelper->getEnabledCountries(PayoneConfig::METHOD_DEBIT), |
236
|
|
|
'trustlyCountries' => $this->countryHelper->getEnabledCountries(PayoneConfig::METHOD_TRUSTLY), |
237
|
|
|
'hostedRequest' => $this->requestHelper->getHostedIframeRequest(), |
238
|
|
|
'mandateManagementActive' => $this->paymentHelper->isMandateManagementActive(), |
239
|
|
|
'checkCvc' => (bool)$this->paymentHelper->isCheckCvcActive(), |
240
|
|
|
'ccMinValidity' => $this->requestHelper->getConfigParam('min_validity_period', PayoneConfig::METHOD_CREDITCARD, 'payone_payment'), |
241
|
|
|
'requestBic' => (bool)$this->requestHelper->getConfigParam('request_bic', PayoneConfig::METHOD_DEBIT, 'payone_payment'), |
242
|
|
|
'trustlyRequestBic' => (bool)$this->requestHelper->getConfigParam('request_bic', PayoneConfig::METHOD_TRUSTLY, 'payone_payment'), |
243
|
|
|
'requestIbanBicSofortUeberweisung' => (bool)$this->requestHelper->getConfigParam('show_iban', PayoneConfig::METHOD_OBT_SOFORTUEBERWEISUNG, 'payone_payment'), |
244
|
|
|
'validateBankCode' => (bool)$this->requestHelper->getConfigParam('check_bankaccount', PayoneConfig::METHOD_DEBIT, 'payone_payment'), |
245
|
|
|
'disableSafeInvoice' => (bool)$this->requestHelper->getConfigParam('disable_after_refusal', PayoneConfig::METHOD_SAFE_INVOICE, 'payone_payment'), |
246
|
|
|
'bankaccountcheckRequest' => $this->requestHelper->getBankaccountCheckRequest(), |
247
|
|
|
'bankCodeValidatedAndValid' => false, |
248
|
|
|
'blockedMessage' => $this->paymentHelper->getBankaccountCheckBlockedMessage(), |
249
|
|
|
'epsBankGroups' => Eps::getBankGroups(), |
250
|
|
|
'idealBankGroups' => Ideal::getBankGroups(), |
251
|
|
|
'customerBirthday' => $this->customerHelper->getCustomerBirthday(), |
252
|
|
|
'addresscheckEnabled' => (int)$this->requestHelper->getConfigParam('enabled', 'address_check', 'payone_protect'), |
253
|
|
|
'addresscheckBillingEnabled' => $this->requestHelper->getConfigParam('check_billing', 'address_check', 'payone_protect') == 'NO' ? 0 : 1, |
254
|
|
|
'addresscheckShippingEnabled' => $this->requestHelper->getConfigParam('check_shipping', 'address_check', 'payone_protect') == 'NO' ? 0 : 1, |
255
|
|
|
'addresscheckConfirmCorrection' => (int)$this->requestHelper->getConfigParam('confirm_address_correction', 'address_check', 'payone_protect'), |
256
|
|
|
'canShowPaymentHintText' => $this->consumerscoreHelper->canShowPaymentHintText(), |
257
|
|
|
'paymentHintText' => $this->requestHelper->getConfigParam('payment_hint_text', 'creditrating', 'payone_protect'), |
258
|
|
|
'canShowAgreementMessage' => $this->consumerscoreHelper->canShowAgreementMessage(), |
259
|
|
|
'agreementMessage' => $this->requestHelper->getConfigParam('agreement_message', 'creditrating', 'payone_protect'), |
260
|
|
|
'consumerScoreEnabledMethods' => $this->consumerscoreHelper->getConsumerscoreEnabledMethods(), |
261
|
|
|
'payolution' => $this->getPayolutionConfig(), |
262
|
|
|
'canceledPaymentMethod' => $this->getCanceledPaymentMethod(), |
263
|
|
|
'isError' => $this->checkoutSession->getPayoneIsError(), |
264
|
|
|
'orderDeferredExists' => (bool)version_compare($this->shopHelper->getMagentoVersion(), '2.1.0', '>='), |
265
|
|
|
'saveCCDataEnabled' => (bool)$this->requestHelper->getConfigParam('save_data_enabled', PayoneConfig::METHOD_CREDITCARD, 'payone_payment'), |
266
|
|
|
'savedPaymentData' => $this->savedPaymentData->getSavedPaymentData($this->checkoutSession->getQuote()->getCustomerId()), |
267
|
|
|
'isPaydirektOneKlickDisplayable' => $this->isPaydirektOneKlickDisplayable(), |
268
|
|
|
'currency' => $this->requestHelper->getConfigParam('currency'), |
269
|
|
|
'klarnaTitles' => $this->paymentHelper->getKlarnaMethodTitles(), |
270
|
|
|
'storeName' => $this->shopHelper->getStoreName(), |
271
|
|
|
'ratepayAllowedMonths' => $this->getRatepayAllowedMonths(), |
272
|
|
|
]; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* Returns the extended checkout-data array |
277
|
|
|
* |
278
|
|
|
* @return array |
279
|
|
|
*/ |
280
|
|
|
public function getConfig() |
281
|
|
|
{ |
282
|
|
|
$config = parent::getConfig(); |
283
|
|
|
$config = array_merge_recursive($config, [ |
284
|
|
|
'payment' => [ |
285
|
|
|
'payone' => $this->getPayoneConfig(), |
286
|
|
|
], |
287
|
|
|
]); |
288
|
|
|
foreach ($this->paymentHelper->getAvailablePaymentTypes() as $sCode) { |
289
|
|
|
$config['payment']['instructions'][$sCode] = $this->getInstructionByCode($sCode); |
290
|
|
|
} |
291
|
|
|
return $config; |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* Get canceled payment method from session |
296
|
|
|
* |
297
|
|
|
* @return string|bool |
298
|
|
|
*/ |
299
|
|
|
protected function getCanceledPaymentMethod() |
300
|
|
|
{ |
301
|
|
|
$sPaymentMethod = $this->checkoutSession->getPayoneCanceledPaymentMethod(); |
302
|
|
|
$this->checkoutSession->unsPayoneCanceledPaymentMethod(); |
303
|
|
|
if ($sPaymentMethod) { |
304
|
|
|
return $sPaymentMethod; |
305
|
|
|
} |
306
|
|
|
return false; |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* Check if paydirekt oneklick is enabled, user is logged in and not yet marked as registered with paydirekt |
311
|
|
|
* |
312
|
|
|
* @return bool |
313
|
|
|
*/ |
314
|
|
|
protected function isPaydirektOneKlickDisplayable() |
315
|
|
|
{ |
316
|
|
|
if ($this->customerSession->isLoggedIn() && (bool)$this->customerSession->getCustomer()->getPayonePaydirektRegistered() === false) { |
317
|
|
|
return (bool)$this->requestHelper->getConfigParam('oneklick_active', PayoneConfig::METHOD_PAYDIREKT, 'payone_payment'); |
318
|
|
|
} |
319
|
|
|
return false; |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
protected function getRatepayAllowedMonths() |
323
|
|
|
{ |
324
|
|
|
if ($this->paymentHelper->isPaymentMethodActive(PayoneConfig::METHOD_RATEPAY_INSTALLMENT) === true) { |
325
|
|
|
return $this->ratepayInstallment->getAllowedMonths(); |
326
|
|
|
} |
327
|
|
|
return []; |
328
|
|
|
} |
329
|
|
|
} |
330
|
|
|
|
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