1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Getnet\API; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class Credit |
7
|
|
|
* |
8
|
|
|
* @package Getnet\API |
9
|
|
|
*/ |
10
|
|
|
class Credit implements \JsonSerializable |
11
|
|
|
{ |
12
|
|
|
//Pagamento completo à vista |
13
|
|
|
const TRANSACTION_TYPE_FULL = "FULL"; |
14
|
|
|
//Pagamento parcelado sem juros |
15
|
|
|
const TRANSACTION_TYPE_INSTALL_NO_INTEREST = "INSTALL_NO_INTEREST"; |
16
|
|
|
//Pagamento parcelado com juros |
17
|
|
|
const TRANSACTION_TYPE_INSTALL_WITH_INTEREST = "INSTALL_WITH_INTEREST"; |
18
|
|
|
|
19
|
|
|
/** @var */ |
20
|
|
|
private $authenticated; |
21
|
|
|
|
22
|
|
|
/** @var */ |
23
|
|
|
private $delayed; |
24
|
|
|
|
25
|
|
|
/** @var */ |
26
|
|
|
private $dynamic_mcc; |
27
|
|
|
|
28
|
|
|
/** @var */ |
29
|
|
|
private $number_installments; |
30
|
|
|
|
31
|
|
|
/** @var */ |
32
|
|
|
private $pre_authorization; |
33
|
|
|
|
34
|
|
|
/** @var */ |
35
|
|
|
private $save_card_data; |
36
|
|
|
|
37
|
|
|
/** @var */ |
38
|
|
|
private $soft_descriptor; |
39
|
|
|
|
40
|
|
|
/** @var */ |
41
|
|
|
private $transaction_type; |
42
|
|
|
|
43
|
|
|
/** @var */ |
44
|
|
|
private $card; |
45
|
|
|
|
46
|
|
|
/** @var */ |
47
|
|
|
private $cardholder_mobile; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Credit constructor. |
51
|
|
|
* @param $pre_authorization |
52
|
|
|
*/ |
53
|
|
|
public function __construct($pre_authorization) |
54
|
|
|
{ |
55
|
|
|
$this->pre_authorization = $pre_authorization; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return array|mixed |
60
|
|
|
*/ |
61
|
|
View Code Duplication |
public function jsonSerialize() |
|
|
|
|
62
|
|
|
{ |
63
|
|
|
$vars = get_object_vars($this); |
64
|
|
|
$vars_clear = array_filter($vars, function ($value) { |
65
|
|
|
return null !== $value; |
66
|
|
|
}); |
67
|
|
|
|
68
|
|
|
return $vars_clear; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return mixed |
73
|
|
|
*/ |
74
|
|
|
public function getAuthenticated() |
75
|
|
|
{ |
76
|
|
|
return $this->authenticated; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param $authenticated |
81
|
|
|
* @return $this |
82
|
|
|
*/ |
83
|
|
|
public function setAuthenticated($authenticated) |
84
|
|
|
{ |
85
|
|
|
$this->authenticated = $authenticated; |
86
|
|
|
|
87
|
|
|
return $this; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return mixed |
92
|
|
|
*/ |
93
|
|
|
public function getDelayed() |
94
|
|
|
{ |
95
|
|
|
return $this->delayed; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @param $delayed |
100
|
|
|
* @return $this |
101
|
|
|
*/ |
102
|
|
|
public function setDelayed($delayed) |
103
|
|
|
{ |
104
|
|
|
$this->delayed = $delayed; |
105
|
|
|
|
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @return mixed |
111
|
|
|
*/ |
112
|
|
|
public function getDynamicMcc() |
113
|
|
|
{ |
114
|
|
|
return $this->dynamic_mcc; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @param $dynamic_mcc |
119
|
|
|
* @return $this |
120
|
|
|
*/ |
121
|
|
|
public function setDynamicMcc($dynamic_mcc) |
122
|
|
|
{ |
123
|
|
|
$this->dynamic_mcc = (int)$dynamic_mcc; |
124
|
|
|
|
125
|
|
|
return $this; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @return mixed |
130
|
|
|
*/ |
131
|
|
|
public function getNumberInstallments() |
132
|
|
|
{ |
133
|
|
|
return $this->number_installments; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @param $number_installments |
138
|
|
|
* @return $this |
139
|
|
|
*/ |
140
|
|
|
public function setNumberInstallments($number_installments) |
141
|
|
|
{ |
142
|
|
|
$this->number_installments = (int)$number_installments; |
143
|
|
|
|
144
|
|
|
return $this; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @return mixed |
149
|
|
|
*/ |
150
|
|
|
public function getPreAuthorization() |
151
|
|
|
{ |
152
|
|
|
return $this->pre_authorization; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @param $pre_authorization |
157
|
|
|
* @return $this |
158
|
|
|
*/ |
159
|
|
|
public function setPreAuthorization($pre_authorization) |
160
|
|
|
{ |
161
|
|
|
$this->pre_authorization = $pre_authorization; |
162
|
|
|
|
163
|
|
|
return $this; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @return mixed |
168
|
|
|
*/ |
169
|
|
|
public function getSaveCardData() |
170
|
|
|
{ |
171
|
|
|
return $this->save_card_data; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @param $save_card_data |
176
|
|
|
* @return $this |
177
|
|
|
*/ |
178
|
|
|
public function setSaveCardData($save_card_data) |
179
|
|
|
{ |
180
|
|
|
$this->save_card_data = $save_card_data; |
181
|
|
|
|
182
|
|
|
return $this; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @return mixed |
187
|
|
|
*/ |
188
|
|
|
public function getSoftDescriptor() |
189
|
|
|
{ |
190
|
|
|
return $this->soft_descriptor; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @param $soft_descriptor |
195
|
|
|
* @return $this |
196
|
|
|
*/ |
197
|
|
|
public function setSoftDescriptor($soft_descriptor) |
198
|
|
|
{ |
199
|
|
|
$this->soft_descriptor = (string)$soft_descriptor; |
200
|
|
|
|
201
|
|
|
return $this; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @return mixed |
206
|
|
|
*/ |
207
|
|
|
public function getTransactionType() |
208
|
|
|
{ |
209
|
|
|
return $this->transaction_type; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* @param $transaction_type |
214
|
|
|
* @return $this |
215
|
|
|
*/ |
216
|
|
|
public function setTransactionType($transaction_type) |
217
|
|
|
{ |
218
|
|
|
$this->transaction_type = (string)$transaction_type; |
219
|
|
|
|
220
|
|
|
return $this; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* @param $token |
225
|
|
|
* @return Card |
226
|
|
|
*/ |
227
|
|
|
public function card($token) |
228
|
|
|
{ |
229
|
|
|
$card = new Card($token); |
230
|
|
|
|
231
|
|
|
$this->setCard($card); |
232
|
|
|
|
233
|
|
|
return $card; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @return Card |
238
|
|
|
*/ |
239
|
|
|
public function getCard() |
240
|
|
|
{ |
241
|
|
|
return $this->card; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @param Card $card |
246
|
|
|
* @return $this |
247
|
|
|
*/ |
248
|
|
|
public function setCard(Card $card) |
249
|
|
|
{ |
250
|
|
|
$this->card = $card; |
251
|
|
|
|
252
|
|
|
return $this; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* @return mixed |
257
|
|
|
*/ |
258
|
|
|
public function getCardholderMobile() |
259
|
|
|
{ |
260
|
|
|
return $this->cardholder_mobile; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
/** |
264
|
|
|
* @param $cardholder_mobile |
265
|
|
|
* @return $this |
266
|
|
|
*/ |
267
|
|
|
public function setCardholderMobile($cardholder_mobile) |
268
|
|
|
{ |
269
|
|
|
$this->cardholder_mobile = (string)$cardholder_mobile; |
270
|
|
|
|
271
|
|
|
return $this; |
272
|
|
|
} |
273
|
|
|
} |
274
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.