1 <?php
2 /**
3 * @author Krzysztof Gzocha <krzysztof.gzocha@xsolve.pl>
4 */
5 namespace Team3\PayU\Communication\Response\Model;
6
7 use JMS\Serializer\Annotation as JMS;
8 use Team3\PayU\Order\Model\Money\Money;
9 use Team3\PayU\Order\Model\Money\MoneyInterface;
10
11 /**
12 * Class RefundModel
13 * @package Team3\PayU\Communication\Response\Model
14 * @JMS\AccessorOrder("alphabetical")
15 * @JMS\AccessType("public_methods")
16 */
17 class RefundModel implements RefundModelInterface
18 {
19 /**
20 * @var string
21 * @JMS\Type("string")
22 */
23 private $refundId;
24
25 /**
26 * @var string
27 * @JMS\Type("string")
28 */
29 private $extRefundId;
30
31 /**
32 * @var MoneyInterface
33 * @JMS\Type("integer")
34 */
35 private $amount;
36
37 /**
38 * @var string
39 * @JMS\Type("string")
40 */
41 private $currencyCode;
42
43 /**
44 * @var string
45 * @JMS\Type("string")
46 */
47 private $description;
48
49 /**
50 * @var \DateTime
51 * @JMS\Type("string")
52 */
53 private $creationDateTime;
54
55 /**
56 * @var string
57 * @JMS\Type("string")
58 */
59 private $status;
60
61 /**
62 * @var \DateTime
63 * @JMS\Type("string")
64 */
65 private $statusDateTime;
66
67 /**
68 * @JMS\PostDeserialize()
69 */
70 public function setCurrencyInAmount()
71 {
72 if (null === $this->currencyCode) {
73 return;
74 }
75
76 $this->amount = new Money(
77 $this->getAmount()->getValue(),
78 $this->currencyCode
79 );
80 }
81
82 /**
83 * @return bool
84 */
85 public function isPending()
86 {
87 return self::STATUS_PENDING === $this->status;
88 }
89
90 /**
91 * @return bool
92 */
93 public function isCanceled()
94 {
95 return self::STATUS_CANCELED === $this->status;
96 }
97
98 /**
99 * @return bool
100 */
101 public function isFinalized()
102 {
103 return self::STATUS_FINALIZED === $this->status;
104 }
105
106 /**
107 * @return string
108 */
109 public function getRefundId()
110 {
111 return $this->refundId;
112 }
113
114 /**
115 * @param string $refundId
116 *
117 * @return RefundModel
118 */
119 public function setRefundId($refundId)
120 {
121 $this->refundId = $refundId;
122
123 return $this;
124 }
125
126 /**
127 * @return string
128 */
129 public function getExtRefundId()
130 {
131 return $this->extRefundId;
132 }
133
134 /**
135 * @param string $extRefundId
136 *
137 * @return RefundModel
138 */
139 public function setExtRefundId($extRefundId)
140 {
141 $this->extRefundId = $extRefundId;
142
143 return $this;
144 }
145
146 /**
147 * @return MoneyInterface
148 */
149 public function getAmount()
150 {
151 return $this->amount;
152 }
153
154 /**
155 * @param int $amount
156 *
157 * @return $this
158 */
159 public function setAmount($amount)
160 {
161 $this->amount = new Money($amount / 100);
162
163 return $this;
164 }
165
166 /**
167 * @return string
168 */
169 public function getCurrencyCode()
170 {
171 return $this->currencyCode;
172 }
173
174 /**
175 * @param string $currencyCode
176 *
177 * @return RefundModel
178 */
179 public function setCurrencyCode($currencyCode)
180 {
181 $this->currencyCode = $currencyCode;
182
183 return $this;
184 }
185
186 /**
187 * @return string
188 */
189 public function getDescription()
190 {
191 return $this->description;
192 }
193
194 /**
195 * @param string $description
196 *
197 * @return RefundModel
198 */
199 public function setDescription($description)
200 {
201 $this->description = $description;
202
203 return $this;
204 }
205
206 /**
207 * @return \DateTime
208 */
209 public function getCreationDateTime()
210 {
211 return $this->creationDateTime;
212 }
213
214 /**
215 * @param string $creationDateTime
216 *
217 * @return RefundModel
218 */
219 public function setCreationDateTime($creationDateTime)
220 {
221 $this->creationDateTime = new \DateTime($creationDateTime);
222
223 return $this;
224 }
225
226 /**
227 * @return string
228 */
229 public function getStatus()
230 {
231 return $this->status;
232 }
233
234 /**
235 * @param string $status
236 *
237 * @return RefundModel
238 */
239 public function setStatus($status)
240 {
241 $this->status = $status;
242
243 return $this;
244 }
245
246 /**
247 * @return \DateTime
248 */
249 public function getStatusDateTime()
250 {
251 return $this->statusDateTime;
252 }
253
254 /**
255 * @param string $statusDateTime
256 *
257 * @return RefundModel
258 */
259 public function setStatusDateTime($statusDateTime)
260 {
261 $this->statusDateTime = new \DateTime($statusDateTime);
262
263 return $this;
264 }
265 }
266