|
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
|
|
|
* Constructor |
|
104
|
|
|
* |
|
105
|
|
|
* @param \Magento\Payment\Model\CcConfig $ccConfig |
|
106
|
|
|
* @param \Magento\Payment\Helper\Data $dataHelper |
|
107
|
|
|
* @param \Payone\Core\Helper\Country $countryHelper |
|
108
|
|
|
* @param \Payone\Core\Helper\Customer $customerHelper |
|
109
|
|
|
* @param \Payone\Core\Helper\Payment $paymentHelper |
|
110
|
|
|
* @param \Payone\Core\Helper\HostedIframe $hostedIframeHelper |
|
111
|
|
|
* @param \Payone\Core\Helper\Request $requestHelper |
|
112
|
|
|
* @param \Magento\Framework\Escaper $escaper |
|
113
|
|
|
* @param \Payone\Core\Helper\Consumerscore $consumerscoreHelper |
|
114
|
|
|
* @param \Payone\Core\Model\Api\Payolution\PrivacyDeclaration $privacyDeclaration |
|
115
|
|
|
*/ |
|
116
|
|
|
public function __construct( |
|
117
|
|
|
\Magento\Payment\Model\CcConfig $ccConfig, |
|
118
|
|
|
\Magento\Payment\Helper\Data $dataHelper, |
|
119
|
|
|
\Payone\Core\Helper\Country $countryHelper, |
|
120
|
|
|
\Payone\Core\Helper\Customer $customerHelper, |
|
121
|
|
|
\Payone\Core\Helper\Payment $paymentHelper, |
|
122
|
|
|
\Payone\Core\Helper\HostedIframe $hostedIframeHelper, |
|
123
|
|
|
\Payone\Core\Helper\Request $requestHelper, |
|
124
|
|
|
\Magento\Framework\Escaper $escaper, |
|
125
|
|
|
\Payone\Core\Helper\Consumerscore $consumerscoreHelper, |
|
126
|
|
|
\Payone\Core\Model\Api\Payolution\PrivacyDeclaration $privacyDeclaration |
|
127
|
|
|
) { |
|
128
|
|
|
parent::__construct($ccConfig, $dataHelper); |
|
129
|
|
|
$this->dataHelper = $dataHelper; |
|
130
|
|
|
$this->countryHelper = $countryHelper; |
|
131
|
|
|
$this->customerHelper = $customerHelper; |
|
132
|
|
|
$this->paymentHelper = $paymentHelper; |
|
133
|
|
|
$this->hostedIframeHelper = $hostedIframeHelper; |
|
134
|
|
|
$this->requestHelper = $requestHelper; |
|
135
|
|
|
$this->escaper = $escaper; |
|
136
|
|
|
$this->consumerscoreHelper = $consumerscoreHelper; |
|
137
|
|
|
$this->privacyDeclaration = $privacyDeclaration; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* Get the payment description text |
|
142
|
|
|
* |
|
143
|
|
|
* @param string $sCode |
|
144
|
|
|
* @return string |
|
145
|
|
|
*/ |
|
146
|
|
|
protected function getInstructionByCode($sCode) |
|
147
|
|
|
{ |
|
148
|
|
|
$oMethodInstance = $this->dataHelper->getMethodInstance($sCode); |
|
149
|
|
|
if ($oMethodInstance) { |
|
150
|
|
|
return nl2br($this->escaper->escapeHtml($oMethodInstance->getInstructions())); |
|
151
|
|
|
} |
|
152
|
|
|
return ''; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* Add payolution parameters to the config array |
|
157
|
|
|
* |
|
158
|
|
|
* @return array |
|
159
|
|
|
*/ |
|
160
|
|
|
protected function getPayolutionConfig() |
|
161
|
|
|
{ |
|
162
|
|
|
return [ |
|
163
|
|
|
'b2bMode' => [ |
|
164
|
|
|
'invoice' => $this->requestHelper->getConfigParam('b2b_mode', PayoneConfig::METHOD_PAYOLUTION_INVOICE, 'payone_payment'), |
|
165
|
|
|
'debit' => $this->requestHelper->getConfigParam('b2b_mode', PayoneConfig::METHOD_PAYOLUTION_DEBIT, 'payone_payment'), |
|
166
|
|
|
'installment' => $this->requestHelper->getConfigParam('b2b_mode', PayoneConfig::METHOD_PAYOLUTION_INSTALLMENT, 'payone_payment'), |
|
167
|
|
|
], |
|
168
|
|
|
'privacyDeclaration' => [ |
|
169
|
|
|
'invoice' => $this->privacyDeclaration->getPayolutionAcceptanceText(PayoneConfig::METHOD_PAYOLUTION_INVOICE), |
|
170
|
|
|
'debit' => $this->privacyDeclaration->getPayolutionAcceptanceText(PayoneConfig::METHOD_PAYOLUTION_DEBIT), |
|
171
|
|
|
'installment' => $this->privacyDeclaration->getPayolutionAcceptanceText(PayoneConfig::METHOD_PAYOLUTION_INSTALLMENT), |
|
172
|
|
|
], |
|
173
|
|
|
]; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* Add payone parameters to the config array |
|
178
|
|
|
* |
|
179
|
|
|
* @return array |
|
180
|
|
|
*/ |
|
181
|
|
|
protected function getPayoneConfig() |
|
182
|
|
|
{ |
|
183
|
|
|
return [ |
|
184
|
|
|
'availableCardTypes' => $this->paymentHelper->getAvailableCreditcardTypes(), |
|
185
|
|
|
'fieldConfig' => $this->hostedIframeHelper->getHostedFieldConfig(), |
|
186
|
|
|
'sepaCountries' => $this->countryHelper->getDebitSepaCountries(), |
|
187
|
|
|
'hostedRequest' => $this->requestHelper->getHostedIframeRequest(), |
|
188
|
|
|
'mandateManagementActive' => $this->paymentHelper->isMandateManagementActive(), |
|
189
|
|
|
'checkCvc' => (bool)$this->paymentHelper->isCheckCvcActive(), |
|
190
|
|
|
'requestBic' => (bool)$this->requestHelper->getConfigParam('request_bic', PayoneConfig::METHOD_DEBIT, 'payone_payment'), |
|
191
|
|
|
'requestIbanBicSofortUeberweisung' => (bool)$this->requestHelper->getConfigParam('show_iban', PayoneConfig::METHOD_OBT_SOFORTUEBERWEISUNG, 'payone_payment'), |
|
192
|
|
|
'validateBankCode' => (bool)$this->requestHelper->getConfigParam('check_bankaccount', PayoneConfig::METHOD_DEBIT, 'payone_payment'), |
|
193
|
|
|
'bankaccountcheckRequest' => $this->requestHelper->getBankaccountCheckRequest(), |
|
194
|
|
|
'bankCodeValidatedAndValid' => false, |
|
195
|
|
|
'blockedMessage' => $this->paymentHelper->getBankaccountCheckBlockedMessage(), |
|
196
|
|
|
'epsBankGroups' => Eps::getBankGroups(), |
|
197
|
|
|
'idealBankGroups' => Ideal::getBankGroups(), |
|
198
|
|
|
'customerHasGivenGender' => $this->customerHelper->customerHasGivenGender(), |
|
199
|
|
|
'customerHasGivenBirthday' => $this->customerHelper->customerHasGivenBirthday(), |
|
200
|
|
|
'addresscheckEnabled' => (int)$this->requestHelper->getConfigParam('enabled', 'address_check', 'payone_protect'), |
|
201
|
|
|
'addresscheckBillingEnabled' => $this->requestHelper->getConfigParam('check_billing', 'address_check', 'payone_protect') == 'NO' ? 0 : 1, |
|
202
|
|
|
'addresscheckShippingEnabled' => $this->requestHelper->getConfigParam('check_shipping', 'address_check', 'payone_protect') == 'NO' ? 0 : 1, |
|
203
|
|
|
'addresscheckConfirmCorrection' => (int)$this->requestHelper->getConfigParam('confirm_address_correction', 'address_check', 'payone_protect'), |
|
204
|
|
|
'canShowPaymentHintText' => $this->consumerscoreHelper->canShowPaymentHintText(), |
|
205
|
|
|
'paymentHintText' => $this->requestHelper->getConfigParam('payment_hint_text', 'creditrating', 'payone_protect'), |
|
206
|
|
|
'canShowAgreementMessage' => $this->consumerscoreHelper->canShowAgreementMessage(), |
|
207
|
|
|
'agreementMessage' => $this->requestHelper->getConfigParam('agreement_message', 'creditrating', 'payone_protect'), |
|
208
|
|
|
'payolution' => $this->getPayolutionConfig(), |
|
209
|
|
|
]; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* Returns the extended checkout-data array |
|
214
|
|
|
* |
|
215
|
|
|
* @return array |
|
216
|
|
|
*/ |
|
217
|
|
|
public function getConfig() |
|
218
|
|
|
{ |
|
219
|
|
|
$config = parent::getConfig(); |
|
220
|
|
|
$config = array_merge_recursive($config, [ |
|
221
|
|
|
'payment' => [ |
|
222
|
|
|
'payone' => $this->getPayoneConfig(), |
|
223
|
|
|
], |
|
224
|
|
|
]); |
|
225
|
|
|
foreach ($this->paymentHelper->getAvailablePaymentTypes() as $sCode) { |
|
226
|
|
|
$config['payment']['instructions'][$sCode] = $this->getInstructionByCode($sCode); |
|
227
|
|
|
} |
|
228
|
|
|
return $config; |
|
229
|
|
|
} |
|
230
|
|
|
} |
|
231
|
|
|
|