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