1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright © Wirecard Brasil. All rights reserved. |
4
|
|
|
* |
5
|
|
|
* @author Bruno Elisei <[email protected]> |
6
|
|
|
* See COPYING.txt for license details. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Moip\Magento2\Gateway\Config; |
10
|
|
|
|
11
|
|
|
use Magento\Framework\App\Config\ScopeConfigInterface; |
|
|
|
|
12
|
|
|
use Magento\Store\Model\ScopeInterface; |
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class ConfigCc - Returns form of payment configuration properties. |
16
|
|
|
*/ |
17
|
|
|
class ConfigCc extends \Magento\Payment\Gateway\Config\Config |
|
|
|
|
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Method Code - Cc. |
21
|
|
|
* |
22
|
|
|
* @const string |
23
|
|
|
*/ |
24
|
|
|
const METHOD = 'moip_magento2_cc'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Cc Tyoes - Cc. |
28
|
|
|
* |
29
|
|
|
* @const array |
30
|
|
|
*/ |
31
|
|
|
const CC_TYPES = 'payment/moip_magento2_cc/cctypes'; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* CVV Enabled - Cc. |
35
|
|
|
* |
36
|
|
|
* @const boolean |
37
|
|
|
*/ |
38
|
|
|
const CVV_ENABLED = 'cvv_enabled'; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Active - Cc. |
42
|
|
|
* |
43
|
|
|
* @const boolean |
44
|
|
|
*/ |
45
|
|
|
const ACTIVE = 'active'; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Title - Cc. |
49
|
|
|
* |
50
|
|
|
* @const string |
51
|
|
|
*/ |
52
|
|
|
const TITLE = 'title'; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Mapper CC. |
56
|
|
|
* |
57
|
|
|
* @const string |
58
|
|
|
*/ |
59
|
|
|
const CC_MAPPER = 'cctypes_moip_magento2_cc_mapper'; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Use tax document capture - Cc. |
63
|
|
|
* |
64
|
|
|
* @const boolean |
65
|
|
|
*/ |
66
|
|
|
const USE_GET_TAX_DOCUMENT = 'get_tax_document'; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Use birth date capture - Cc. |
70
|
|
|
* |
71
|
|
|
* @const boolean |
72
|
|
|
*/ |
73
|
|
|
const USE_GET_BIRTH_DATE = 'get_birth_date'; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Use phone capture - Cc. |
77
|
|
|
* |
78
|
|
|
* @const boolean |
79
|
|
|
*/ |
80
|
|
|
const USE_GET_PHONE = 'get_phone'; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @var ScopeConfigInterface |
84
|
|
|
*/ |
85
|
|
|
private $scopeConfig; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param ScopeConfigInterface $scopeConfig |
89
|
|
|
*/ |
90
|
|
|
public function __construct( |
91
|
|
|
ScopeConfigInterface $scopeConfig |
92
|
|
|
) { |
93
|
|
|
$this->scopeConfig = $scopeConfig; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Should the cvv field be shown. |
98
|
|
|
* |
99
|
|
|
* @param int|null $storeId |
100
|
|
|
* |
101
|
|
|
* @return bool |
102
|
|
|
*/ |
103
|
|
|
public function isCvvEnabled($storeId = null) |
104
|
|
|
{ |
105
|
|
|
$pathPattern = 'payment/%s/%s'; |
106
|
|
|
|
107
|
|
|
return (bool) $this->scopeConfig->getValue( |
108
|
|
|
sprintf($pathPattern, self::METHOD, self::CVV_ENABLED), |
109
|
|
|
ScopeInterface::SCOPE_STORE, |
110
|
|
|
$storeId |
111
|
|
|
); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Get Payment configuration status. |
116
|
|
|
* |
117
|
|
|
* @return bool |
118
|
|
|
*/ |
119
|
|
|
public function isActive($storeId = null): bool |
120
|
|
|
{ |
121
|
|
|
$pathPattern = 'payment/%s/%s'; |
122
|
|
|
|
123
|
|
|
return (bool) $this->scopeConfig->getValue( |
124
|
|
|
sprintf($pathPattern, self::METHOD, self::ACTIVE), |
125
|
|
|
ScopeInterface::SCOPE_STORE, |
126
|
|
|
$storeId |
127
|
|
|
); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Get title of payment. |
132
|
|
|
* |
133
|
|
|
* @return string|null |
134
|
|
|
*/ |
135
|
|
|
public function getTitle($storeId = null) |
136
|
|
|
{ |
137
|
|
|
$pathPattern = 'payment/%s/%s'; |
138
|
|
|
|
139
|
|
|
return $this->scopeConfig->getValue( |
140
|
|
|
sprintf($pathPattern, self::METHOD, self::TITLE), |
141
|
|
|
ScopeInterface::SCOPE_STORE, |
142
|
|
|
$storeId |
143
|
|
|
); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Get if you use document capture on the form. |
148
|
|
|
* |
149
|
|
|
* @return string|null |
150
|
|
|
*/ |
151
|
|
|
public function getUseTaxDocumentCapture($storeId = null) |
152
|
|
|
{ |
153
|
|
|
$pathPattern = 'payment/%s/%s'; |
154
|
|
|
|
155
|
|
|
return (bool) $this->scopeConfig->getValue( |
|
|
|
|
156
|
|
|
sprintf($pathPattern, self::METHOD, self::USE_GET_TAX_DOCUMENT), |
157
|
|
|
ScopeInterface::SCOPE_STORE, |
158
|
|
|
$storeId |
159
|
|
|
); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Get if you use birth date capture on the form. |
164
|
|
|
* |
165
|
|
|
* @return string|null |
166
|
|
|
*/ |
167
|
|
|
public function getUseBirthDateCapture($storeId = null) |
168
|
|
|
{ |
169
|
|
|
$pathPattern = 'payment/%s/%s'; |
170
|
|
|
|
171
|
|
|
return (bool) $this->scopeConfig->getValue( |
|
|
|
|
172
|
|
|
sprintf($pathPattern, self::METHOD, self::USE_GET_BIRTH_DATE), |
173
|
|
|
ScopeInterface::SCOPE_STORE, |
174
|
|
|
$storeId |
175
|
|
|
); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* Get if you use phone capture on the form. |
180
|
|
|
* |
181
|
|
|
* @return string|null |
182
|
|
|
*/ |
183
|
|
|
public function getUsePhoneCapture($storeId = null) |
184
|
|
|
{ |
185
|
|
|
$pathPattern = 'payment/%s/%s'; |
186
|
|
|
|
187
|
|
|
return (bool) $this->scopeConfig->getValue( |
|
|
|
|
188
|
|
|
sprintf($pathPattern, self::METHOD, self::USE_GET_PHONE), |
189
|
|
|
ScopeInterface::SCOPE_STORE, |
190
|
|
|
$storeId |
191
|
|
|
); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* Should the cc types. |
196
|
|
|
* |
197
|
|
|
* @param int|null $storeId |
198
|
|
|
* |
199
|
|
|
* @return bool |
200
|
|
|
*/ |
201
|
|
|
public function getCcAvailableTypes($storeId = null) |
202
|
|
|
{ |
203
|
|
|
return $this->scopeConfig->getValue( |
204
|
|
|
self::CC_TYPES, |
205
|
|
|
ScopeInterface::SCOPE_STORE, |
206
|
|
|
$storeId |
207
|
|
|
); |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* Cc Mapper. |
212
|
|
|
* |
213
|
|
|
* @param int|null $storeId |
214
|
|
|
* |
215
|
|
|
* @return array |
216
|
|
|
*/ |
217
|
|
|
public function getCcTypesMapper($storeId = null): array |
218
|
|
|
{ |
219
|
|
|
$pathPattern = 'payment/%s/%s'; |
220
|
|
|
|
221
|
|
|
$ccTypesMapper = $this->scopeConfig->getValue( |
222
|
|
|
sprintf($pathPattern, self::METHOD, self::CC_MAPPER), |
223
|
|
|
ScopeInterface::SCOPE_STORE, |
224
|
|
|
$storeId |
225
|
|
|
); |
226
|
|
|
|
227
|
|
|
$result = json_decode($ccTypesMapper, true); |
228
|
|
|
|
229
|
|
|
return is_array($result) ? $result : []; |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* Get info interest. |
234
|
|
|
* |
235
|
|
|
* @return array |
236
|
|
|
*/ |
237
|
|
|
public function getInfoInterest($storeId = null) |
238
|
|
|
{ |
239
|
|
|
$juros = []; |
240
|
|
|
$juros['0'] = 0; |
241
|
|
|
$juros['1'] = 0; |
242
|
|
|
$juros['2'] = $this->scopeConfig->getValue( |
243
|
|
|
'payment/moip_magento2_cc/installment_installment_2', |
244
|
|
|
ScopeInterface::SCOPE_STORE, |
245
|
|
|
$storeId |
246
|
|
|
); |
247
|
|
|
$juros['3'] = $this->scopeConfig->getValue( |
248
|
|
|
'payment/moip_magento2_cc/installment_installment_3', |
249
|
|
|
ScopeInterface::SCOPE_STORE, |
250
|
|
|
$storeId |
251
|
|
|
); |
252
|
|
|
$juros['4'] = $this->scopeConfig->getValue( |
253
|
|
|
'payment/moip_magento2_cc/installment_installment_4', |
254
|
|
|
ScopeInterface::SCOPE_STORE, |
255
|
|
|
$storeId |
256
|
|
|
); |
257
|
|
|
$juros['5'] = $this->scopeConfig->getValue( |
258
|
|
|
'payment/moip_magento2_cc/installment_installment_5', |
259
|
|
|
ScopeInterface::SCOPE_STORE, |
260
|
|
|
$storeId |
261
|
|
|
); |
262
|
|
|
$juros['6'] = $this->scopeConfig->getValue( |
263
|
|
|
'payment/moip_magento2_cc/installment_installment_6', |
264
|
|
|
ScopeInterface::SCOPE_STORE, |
265
|
|
|
$storeId |
266
|
|
|
); |
267
|
|
|
$juros['7'] = $this->scopeConfig->getValue( |
268
|
|
|
'payment/moip_magento2_cc/installment_installment_7', |
269
|
|
|
ScopeInterface::SCOPE_STORE, |
270
|
|
|
$storeId |
271
|
|
|
); |
272
|
|
|
$juros['8'] = $this->scopeConfig->getValue( |
273
|
|
|
'payment/moip_magento2_cc/installment_installment_8', |
274
|
|
|
ScopeInterface::SCOPE_STORE, |
275
|
|
|
$storeId |
276
|
|
|
); |
277
|
|
|
$juros['9'] = $this->scopeConfig->getValue( |
278
|
|
|
'payment/moip_magento2_cc/installment_installment_9', |
279
|
|
|
ScopeInterface::SCOPE_STORE, |
280
|
|
|
$storeId |
281
|
|
|
); |
282
|
|
|
$juros['10'] = $this->scopeConfig->getValue( |
283
|
|
|
'payment/moip_magento2_cc/installment_installment_10', |
284
|
|
|
ScopeInterface::SCOPE_STORE, |
285
|
|
|
$storeId |
286
|
|
|
); |
287
|
|
|
$juros['11'] = $this->scopeConfig->getValue( |
288
|
|
|
'payment/moip_magento2_cc/installment_installment_11', |
289
|
|
|
ScopeInterface::SCOPE_STORE, |
290
|
|
|
$storeId |
291
|
|
|
); |
292
|
|
|
$juros['12'] = $this->scopeConfig->getValue( |
293
|
|
|
'payment/moip_magento2_cc/installment_installment_12', |
294
|
|
|
ScopeInterface::SCOPE_STORE, |
295
|
|
|
$storeId |
296
|
|
|
); |
297
|
|
|
|
298
|
|
|
return $juros; |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
/** |
302
|
|
|
* Get type Interest. |
303
|
|
|
* |
304
|
|
|
* @return string |
305
|
|
|
*/ |
306
|
|
|
public function getTypeInstallment($storeId = null) |
307
|
|
|
{ |
308
|
|
|
return $this->scopeConfig->getValue( |
309
|
|
|
'payment/moip_magento2_cc/installment_type_interest', |
310
|
|
|
ScopeInterface::SCOPE_STORE, |
311
|
|
|
$storeId |
312
|
|
|
); |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* Get min installment. |
317
|
|
|
* |
318
|
|
|
* @return int |
319
|
|
|
*/ |
320
|
|
|
public function getMinInstallment($storeId = null) |
321
|
|
|
{ |
322
|
|
|
return $this->scopeConfig->getValue( |
323
|
|
|
'payment/moip_magento2_cc/installment_min_installment', |
324
|
|
|
ScopeInterface::SCOPE_STORE, |
325
|
|
|
$storeId |
326
|
|
|
); |
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
/** |
330
|
|
|
* Get max installment. |
331
|
|
|
* |
332
|
|
|
* @return int |
333
|
|
|
*/ |
334
|
|
|
public function getMaxInstallment($storeId = null) |
335
|
|
|
{ |
336
|
|
|
return $this->scopeConfig->getValue( |
337
|
|
|
'payment/moip_magento2_cc/installment_max_installment', |
338
|
|
|
ScopeInterface::SCOPE_STORE, |
339
|
|
|
$storeId |
340
|
|
|
); |
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
/** |
344
|
|
|
* Get is enable instant purchase. |
345
|
|
|
* |
346
|
|
|
* @return int |
347
|
|
|
*/ |
348
|
|
|
public function getEnableInstantPurchase($storeId = null) |
349
|
|
|
{ |
350
|
|
|
return $this->scopeConfig->getValue( |
351
|
|
|
'payment/moip_magento2_cc/instant_purchase_enable', |
352
|
|
|
ScopeInterface::SCOPE_STORE, |
353
|
|
|
$storeId |
354
|
|
|
); |
355
|
|
|
} |
356
|
|
|
} |
357
|
|
|
|
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