1: <?php
2:
3: /**
4: * A refund object
5: */
6: class Syspay_Merchant_Entity_Refund extends Syspay_Merchant_Entity implements
7: Syspay_Merchant_Entity_ReturnedEntityInterface
8: {
9: const TYPE = 'refund';
10:
11: /**
12: * @var integer
13: */
14: private $id;
15:
16: /**
17: * @var string
18: */
19: private $status;
20:
21: /**
22: * @var string
23: */
24: protected $reference;
25:
26: /**
27: * @var integer
28: */
29: protected $amount;
30:
31: /**
32: * @var string
33: */
34: protected $currency;
35:
36: /**
37: * @var string
38: */
39: protected $description;
40:
41: /**
42: * @var string
43: */
44: protected $extra;
45:
46: /**
47: * @var Syspay_Merchant_Entity_Payment
48: */
49: private $payment;
50:
51: /**
52: * @var DateTime
53: */
54: private $processingTime;
55:
56: /**
57: * Build a payment entity based on a json-decoded payment stdClass
58: *
59: * @param stdClass $response The payment data
60: * @return Syspay_Merchant_Entity_Payment The payment object
61: */
62: public static function buildFromResponse(stdClass $response)
63: {
64: $refund = new self();
65: $refund->setId(isset($response->id)?$response->id:null);
66: $refund->setReference(isset($response->reference)?$response->reference:null);
67: $refund->setAmount(isset($response->amount)?$response->amount:null);
68: $refund->setCurrency(isset($response->currency)?$response->currency:null);
69: $refund->setStatus(isset($response->status)?$response->status:null);
70: $refund->setExtra(isset($response->extra)?$response->extra:null);
71: $refund->setDescription(isset($response->description)?$response->description:null);
72:
73: if (isset($response->processing_time)
74: && !is_null($response->processing_time)) {
75: $refund->setProcessingTime(Syspay_Merchant_Utils::tsToDateTime($response->processing_time));
76: }
77:
78: if (isset($response->payment)) {
79: $refund->setPayment(Syspay_Merchant_Entity_Payment::buildFromResponse($response->payment));
80: }
81:
82: $refund->raw = $response;
83:
84: return $refund;
85: }
86:
87: /**
88: * Gets the value of id.
89: *
90: * @return integer
91: */
92: public function getId()
93: {
94: return $this->id;
95: }
96:
97: /**
98: * Sets the value of id.
99: *
100: * @param integer $id the id
101: *
102: * @return self
103: */
104: public function setId($id)
105: {
106: $this->id = $id;
107:
108: return $this;
109: }
110:
111: /**
112: * Gets the value of status.
113: *
114: * @return string
115: */
116: public function getStatus()
117: {
118: return $this->status;
119: }
120:
121: /**
122: * Sets the value of status.
123: *
124: * @param string $status the status
125: *
126: * @return self
127: */
128: public function setStatus($status)
129: {
130: $this->status = $status;
131:
132: return $this;
133: }
134:
135: /**
136: * Gets the value of reference.
137: *
138: * @return string
139: */
140: public function getReference()
141: {
142: return $this->reference;
143: }
144:
145: /**
146: * Sets the value of reference.
147: *
148: * @param string $reference the reference
149: *
150: * @return self
151: */
152: public function setReference($reference)
153: {
154: $this->reference = $reference;
155:
156: return $this;
157: }
158:
159: /**
160: * Gets the value of amount.
161: *
162: * @return integer
163: */
164: public function getAmount()
165: {
166: return $this->amount;
167: }
168:
169: /**
170: * Sets the value of amount.
171: *
172: * @param integer $amount the amount
173: *
174: * @return self
175: */
176: public function setAmount($amount)
177: {
178: $this->amount = $amount;
179:
180: return $this;
181: }
182:
183: /**
184: * Gets the value of currency.
185: *
186: * @return string
187: */
188: public function getCurrency()
189: {
190: return $this->currency;
191: }
192:
193: /**
194: * Sets the value of currency.
195: *
196: * @param string $currency the currency
197: *
198: * @return self
199: */
200: public function setCurrency($currency)
201: {
202: $this->currency = $currency;
203:
204: return $this;
205: }
206:
207: /**
208: * Gets the value of description.
209: *
210: * @return string
211: */
212: public function getDescription()
213: {
214: return $this->description;
215: }
216:
217: /**
218: * Sets the value of description.
219: *
220: * @param string $description the description
221: *
222: * @return self
223: */
224: public function setDescription($description)
225: {
226: $this->description = $description;
227:
228: return $this;
229: }
230:
231: /**
232: * Gets the value of extra.
233: *
234: * @return string
235: */
236: public function getExtra()
237: {
238: return $this->extra;
239: }
240:
241: /**
242: * Sets the value of extra.
243: *
244: * @param string $extra the extra
245: *
246: * @return self
247: */
248: public function setExtra($extra)
249: {
250: $this->extra = $extra;
251:
252: return $this;
253: }
254:
255: /**
256: * Gets the value of payment.
257: *
258: * @return Syspay_Merchant_Entity_Payment
259: */
260: public function getPayment()
261: {
262: return $this->payment;
263: }
264:
265: /**
266: * Sets the value of payment.
267: *
268: * @param Syspay_Merchant_Entity_Payment $payment the payment
269: *
270: * @return self
271: */
272: public function setPayment(Syspay_Merchant_Entity_Payment $payment)
273: {
274: $this->payment = $payment;
275:
276: return $this;
277: }
278:
279: /**
280: * Gets the value of processingTime.
281: *
282: * @return DateTime
283: */
284: public function getProcessingTime()
285: {
286: return $this->processingTime;
287: }
288:
289: /**
290: * Sets the value of processingTime.
291: *
292: * @param DateTime $processingTime the processingTime
293: *
294: * @return self
295: */
296: public function setProcessingTime(DateTime $processingTime)
297: {
298: $this->processingTime = $processingTime;
299:
300: return $this;
301: }
302: }
303: