1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright © Getnet. All rights reserved. |
4
|
|
|
* |
5
|
|
|
* @author Bruno Elisei <[email protected]> |
6
|
|
|
* See LICENSE for license details. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Getnet\SplitExampleMagento\Model; |
10
|
|
|
|
11
|
|
|
use Magento\Framework\Serialize\Serializer\Json; |
12
|
|
|
use Magento\Store\Model\Store; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class to set flags for sub seller display setting. |
16
|
|
|
* |
17
|
|
|
* @SuppressWarnings(PHPMD.ExcessivePublicCount) |
18
|
|
|
*/ |
19
|
|
|
class Config |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* List Commissions. |
23
|
|
|
*/ |
24
|
|
|
public const XML_PATH_GETNET_SPLIT_COMMISSIONS = 'getnet_split/general/split_commisions/commisions'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Guarantor Name. |
28
|
|
|
*/ |
29
|
|
|
public const XML_PATH_GETNET_SPLIT_GUARANTOR_NAME = 'getnet_split/general/addtional_boleto/guarantor_name'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Guarantor Document. |
33
|
|
|
*/ |
34
|
|
|
public const XML_PATH_GETNET_SPLIT_GUARANTOR_DOCUMENT = 'getnet_split/general/addtional_boleto/guarantor_document'; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Type Release. |
38
|
|
|
*/ |
39
|
|
|
public const XML_PATH_GETNET_SPLIT_TYPE_RELEASE = 'getnet_split/general/payment_release/type_release'; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Cron BY. |
43
|
|
|
*/ |
44
|
|
|
public const XML_PATH_GETNET_SPLIT_CRON_BY = 'getnet_split/general/payment_release/cron_by'; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Release Days. |
48
|
|
|
*/ |
49
|
|
|
public const XML_PATH_GETNET_SPLIT_CRON_DAYS = 'getnet_split/general/payment_release/release_day'; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Core store config. |
53
|
|
|
* |
54
|
|
|
* @var \Magento\Framework\App\Config\ScopeConfigInterface |
55
|
|
|
*/ |
56
|
|
|
protected $_scopeConfig; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Core Json. |
60
|
|
|
* |
61
|
|
|
* @var Json |
62
|
|
|
*/ |
63
|
|
|
protected $json; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig |
67
|
|
|
* @param Json $json |
68
|
|
|
*/ |
69
|
|
|
public function __construct( |
70
|
|
|
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, |
71
|
|
|
Json $json |
72
|
|
|
) { |
73
|
|
|
$this->json = $json; |
74
|
|
|
$this->_scopeConfig = $scopeConfig; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Get Split Commissions. |
79
|
|
|
* |
80
|
|
|
* @param null|string|bool|int|Store $store |
81
|
|
|
* |
82
|
|
|
* @return array |
83
|
|
|
*/ |
84
|
|
|
public function getSplitCommissions($store = null) |
85
|
|
|
{ |
86
|
|
|
$listCommissions = $this->_scopeConfig->getValue( |
87
|
|
|
self::XML_PATH_GETNET_SPLIT_COMMISSIONS, |
88
|
|
|
\Magento\Store\Model\ScopeInterface::SCOPE_STORE, |
89
|
|
|
$store |
|
|
|
|
90
|
|
|
); |
91
|
|
|
|
92
|
|
|
if (is_array($listCommissions)) { |
93
|
|
|
return $listCommissions; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
return $this->json->unserialize($listCommissions); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Get Guarantor Name. |
101
|
|
|
* |
102
|
|
|
* @param null|string|bool|int|Store $store |
103
|
|
|
* |
104
|
|
|
* @return string|null |
105
|
|
|
*/ |
106
|
|
|
public function getGuarantorName($store = null): ?string |
107
|
|
|
{ |
108
|
|
|
return $this->_scopeConfig->getValue( |
109
|
|
|
self::XML_PATH_GETNET_SPLIT_GUARANTOR_NAME, |
110
|
|
|
\Magento\Store\Model\ScopeInterface::SCOPE_STORE, |
111
|
|
|
$store |
|
|
|
|
112
|
|
|
); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Get Guarantor Document. |
117
|
|
|
* |
118
|
|
|
* @param null|string|bool|int|Store $store |
119
|
|
|
* |
120
|
|
|
* @return string|null |
121
|
|
|
*/ |
122
|
|
|
public function getGuarantorDocument($store = null): ?string |
123
|
|
|
{ |
124
|
|
|
return $this->_scopeConfig->getValue( |
125
|
|
|
self::XML_PATH_GETNET_SPLIT_GUARANTOR_DOCUMENT, |
126
|
|
|
\Magento\Store\Model\ScopeInterface::SCOPE_STORE, |
127
|
|
|
$store |
|
|
|
|
128
|
|
|
); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Get Type Release. |
133
|
|
|
* |
134
|
|
|
* @param null|string|bool|int|Store $store |
135
|
|
|
* |
136
|
|
|
* @return string|null |
137
|
|
|
*/ |
138
|
|
|
public function getTypeRelease($store = null): ?string |
139
|
|
|
{ |
140
|
|
|
return $this->_scopeConfig->getValue( |
141
|
|
|
self::XML_PATH_GETNET_SPLIT_TYPE_RELEASE, |
142
|
|
|
\Magento\Store\Model\ScopeInterface::SCOPE_STORE, |
143
|
|
|
$store |
|
|
|
|
144
|
|
|
); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Get Cron By. |
149
|
|
|
* |
150
|
|
|
* @param null|string|bool|int|Store $store |
151
|
|
|
* |
152
|
|
|
* @return string|null |
153
|
|
|
*/ |
154
|
|
|
public function getCronBy($store = null): ?string |
155
|
|
|
{ |
156
|
|
|
return $this->_scopeConfig->getValue( |
157
|
|
|
self::XML_PATH_GETNET_SPLIT_CRON_BY, |
158
|
|
|
\Magento\Store\Model\ScopeInterface::SCOPE_STORE, |
159
|
|
|
$store |
|
|
|
|
160
|
|
|
); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Get Release Day. |
165
|
|
|
* |
166
|
|
|
* @param null|string|bool|int|Store $store |
167
|
|
|
* |
168
|
|
|
* @return string|null |
169
|
|
|
*/ |
170
|
|
|
public function getCronDays($store = null): ?string |
171
|
|
|
{ |
172
|
|
|
return $this->_scopeConfig->getValue( |
173
|
|
|
self::XML_PATH_GETNET_SPLIT_CRON_DAYS, |
174
|
|
|
\Magento\Store\Model\ScopeInterface::SCOPE_STORE, |
175
|
|
|
$store |
|
|
|
|
176
|
|
|
); |
177
|
|
|
} |
178
|
|
|
} |
179
|
|
|
|