|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace WSW\SiftScience\Events; |
|
4
|
|
|
|
|
5
|
|
|
use InvalidArgumentException; |
|
6
|
|
|
use WSW\Email\Email; |
|
7
|
|
|
use WSW\Money\Money; |
|
8
|
|
|
use WSW\SiftScience\Entities\Address; |
|
9
|
|
|
use WSW\SiftScience\Entities\PaymentMethod; |
|
10
|
|
|
use WSW\SiftScience\Support\AllowedValues\TransactionStatus; |
|
11
|
|
|
use WSW\SiftScience\Support\AllowedValues\TransactionType; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class Transaction |
|
15
|
|
|
* |
|
16
|
|
|
* @package WSW\SiftScience\Events |
|
17
|
|
|
* @author Ronaldo Matos Rodrigues <[email protected]> |
|
18
|
|
|
*/ |
|
19
|
|
|
class Transaction extends BaseEvent |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @var string |
|
23
|
|
|
*/ |
|
24
|
|
|
private $id; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var Email |
|
28
|
|
|
*/ |
|
29
|
|
|
private $userEmail; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var string |
|
33
|
|
|
*/ |
|
34
|
|
|
private $transactionType; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var string |
|
38
|
|
|
*/ |
|
39
|
|
|
private $transactionStatus; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var Money |
|
43
|
|
|
*/ |
|
44
|
|
|
private $amount; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var string |
|
48
|
|
|
*/ |
|
49
|
|
|
private $orderId; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var Address |
|
53
|
|
|
*/ |
|
54
|
|
|
private $billingAddress; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @var Address |
|
58
|
|
|
*/ |
|
59
|
|
|
private $shippingAddress; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @var PaymentMethod |
|
63
|
|
|
*/ |
|
64
|
|
|
private $paymentMethod; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @var string |
|
68
|
|
|
*/ |
|
69
|
|
|
private $sellerUserId; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @var string |
|
73
|
|
|
*/ |
|
74
|
|
|
private $transferRecipientUserId; |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Transaction constructor. |
|
78
|
|
|
*/ |
|
79
|
3 |
|
public function __construct() |
|
80
|
|
|
{ |
|
81
|
3 |
|
$this->type = '$transaction'; |
|
82
|
3 |
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @return string |
|
86
|
|
|
*/ |
|
87
|
1 |
|
public function getId() |
|
88
|
|
|
{ |
|
89
|
1 |
|
return $this->id; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @param string $id |
|
94
|
|
|
* |
|
95
|
|
|
* @return $this |
|
96
|
|
|
*/ |
|
97
|
1 |
|
public function setId($id) |
|
98
|
|
|
{ |
|
99
|
1 |
|
$this->id = $id; |
|
100
|
|
|
|
|
101
|
1 |
|
return $this; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @return Email |
|
106
|
|
|
*/ |
|
107
|
1 |
|
public function getUserEmail() |
|
108
|
|
|
{ |
|
109
|
1 |
|
return $this->userEmail; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @param Email $userEmail |
|
114
|
|
|
* |
|
115
|
|
|
* @return $this |
|
116
|
|
|
*/ |
|
117
|
1 |
|
public function setUserEmail(Email $userEmail) |
|
118
|
|
|
{ |
|
119
|
1 |
|
$this->userEmail = $userEmail; |
|
120
|
|
|
|
|
121
|
1 |
|
return $this; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @return string |
|
126
|
|
|
*/ |
|
127
|
1 |
|
public function getTransactionType() |
|
128
|
|
|
{ |
|
129
|
1 |
|
return $this->transactionType; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* @param string $transactionType |
|
134
|
|
|
* |
|
135
|
|
|
* @return $this |
|
136
|
|
|
*/ |
|
137
|
2 |
|
public function setTransactionType($transactionType) |
|
138
|
|
|
{ |
|
139
|
2 |
|
if (!TransactionType::isValid($transactionType)) { |
|
140
|
1 |
|
throw new InvalidArgumentException('You should inform a valid transaction type.'); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
1 |
|
$this->transactionType = $transactionType; |
|
144
|
|
|
|
|
145
|
1 |
|
return $this; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* @return string |
|
150
|
|
|
*/ |
|
151
|
1 |
|
public function getTransactionStatus() |
|
152
|
|
|
{ |
|
153
|
1 |
|
return $this->transactionStatus; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* @param string $transactionStatus |
|
158
|
|
|
* |
|
159
|
|
|
* @return $this |
|
160
|
|
|
*/ |
|
161
|
2 |
|
public function setTransactionStatus($transactionStatus) |
|
162
|
|
|
{ |
|
163
|
2 |
|
if (!TransactionStatus::isValid($transactionStatus)) { |
|
164
|
1 |
|
throw new InvalidArgumentException('You should inform a valid transaction status.'); |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
1 |
|
$this->transactionStatus = $transactionStatus; |
|
168
|
|
|
|
|
169
|
1 |
|
return $this; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* @return Money |
|
174
|
|
|
*/ |
|
175
|
1 |
|
public function getAmount() |
|
176
|
|
|
{ |
|
177
|
1 |
|
return $this->amount; |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* @param Money $amount |
|
182
|
|
|
* |
|
183
|
|
|
* @return $this |
|
184
|
|
|
*/ |
|
185
|
1 |
|
public function setAmount(Money $amount) |
|
186
|
|
|
{ |
|
187
|
1 |
|
$this->amount = $amount; |
|
188
|
|
|
|
|
189
|
1 |
|
return $this; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* @return string |
|
194
|
|
|
*/ |
|
195
|
1 |
|
public function getOrderId() |
|
196
|
|
|
{ |
|
197
|
1 |
|
return $this->orderId; |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* @param string $orderId |
|
202
|
|
|
* |
|
203
|
|
|
* @return $this |
|
204
|
|
|
*/ |
|
205
|
1 |
|
public function setOrderId($orderId) |
|
206
|
|
|
{ |
|
207
|
1 |
|
$this->orderId = $orderId; |
|
208
|
|
|
|
|
209
|
1 |
|
return $this; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* @return Address |
|
214
|
|
|
*/ |
|
215
|
1 |
|
public function getBillingAddress() |
|
216
|
|
|
{ |
|
217
|
1 |
|
return $this->billingAddress; |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
/** |
|
221
|
|
|
* @param Address $billingAddress |
|
222
|
|
|
* |
|
223
|
|
|
* @return $this |
|
224
|
|
|
*/ |
|
225
|
1 |
|
public function setBillingAddress(Address $billingAddress) |
|
226
|
|
|
{ |
|
227
|
1 |
|
$this->billingAddress = $billingAddress; |
|
228
|
|
|
|
|
229
|
1 |
|
return $this; |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
/** |
|
233
|
|
|
* @return Address |
|
234
|
|
|
*/ |
|
235
|
1 |
|
public function getShippingAddress() |
|
236
|
|
|
{ |
|
237
|
1 |
|
return $this->shippingAddress; |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
/** |
|
241
|
|
|
* @param Address $shippingAddress |
|
242
|
|
|
* |
|
243
|
|
|
* @return $this |
|
244
|
|
|
*/ |
|
245
|
1 |
|
public function setShippingAddress(Address $shippingAddress) |
|
246
|
|
|
{ |
|
247
|
1 |
|
$this->shippingAddress = $shippingAddress; |
|
248
|
|
|
|
|
249
|
1 |
|
return $this; |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
/** |
|
253
|
|
|
* @return PaymentMethod |
|
254
|
|
|
*/ |
|
255
|
1 |
|
public function getPaymentMethod() |
|
256
|
|
|
{ |
|
257
|
1 |
|
return $this->paymentMethod; |
|
258
|
|
|
} |
|
259
|
|
|
|
|
260
|
|
|
/** |
|
261
|
|
|
* @param PaymentMethod $paymentMethod |
|
262
|
|
|
* |
|
263
|
|
|
* @return $this |
|
264
|
|
|
*/ |
|
265
|
1 |
|
public function setPaymentMethod(PaymentMethod $paymentMethod) |
|
266
|
|
|
{ |
|
267
|
1 |
|
$this->paymentMethod = $paymentMethod; |
|
268
|
|
|
|
|
269
|
1 |
|
return $this; |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
/** |
|
273
|
|
|
* @return string |
|
274
|
|
|
*/ |
|
275
|
1 |
|
public function getSellerUserId() |
|
276
|
|
|
{ |
|
277
|
1 |
|
return $this->sellerUserId; |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
/** |
|
281
|
|
|
* @param string $sellerUserId |
|
282
|
|
|
* |
|
283
|
|
|
* @return $this |
|
284
|
|
|
*/ |
|
285
|
1 |
|
public function setSellerUserId($sellerUserId) |
|
286
|
|
|
{ |
|
287
|
1 |
|
$this->sellerUserId = $sellerUserId; |
|
288
|
|
|
|
|
289
|
1 |
|
return $this; |
|
290
|
|
|
} |
|
291
|
|
|
|
|
292
|
|
|
/** |
|
293
|
|
|
* @return string |
|
294
|
|
|
*/ |
|
295
|
1 |
|
public function getTransferRecipientUserId() |
|
296
|
|
|
{ |
|
297
|
1 |
|
return $this->transferRecipientUserId; |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
|
|
/** |
|
301
|
|
|
* @param string $transferRecipientUserId |
|
302
|
|
|
* |
|
303
|
|
|
* @return $this |
|
304
|
|
|
*/ |
|
305
|
1 |
|
public function setTransferRecipientUserId($transferRecipientUserId) |
|
306
|
|
|
{ |
|
307
|
1 |
|
$this->transferRecipientUserId = $transferRecipientUserId; |
|
308
|
|
|
|
|
309
|
1 |
|
return $this; |
|
310
|
|
|
} |
|
311
|
|
|
} |
|
312
|
|
|
|