1 <?php
2
3 namespace PayPal\Api;
4
5 use PayPal\Common\PayPalResourceModel;
6 use PayPal\Validation\ArgumentValidator;
7 use PayPal\Rest\ApiContext;
8
9 /**
10 * Class Refund
11 *
12 * A refund transaction.
13 *
14 * @package PayPal\Api
15 *
16 * @property string id
17 * @property \PayPal\Api\Amount amount
18 * @property string state
19 * @property string reason
20 * @property string invoice_number
21 * @property string sale_id
22 * @property string capture_id
23 * @property string parent_payment
24 * @property string description
25 * @property string create_time
26 * @property string update_time
27 * @property string reason_code
28 * @property \PayPal\Api\Links[] links
29 */
30 class Refund extends PayPalResourceModel
31 {
32 /**
33 * ID of the refund transaction. 17 characters max.
34 *
35 * @param string $id
36 *
37 * @return $this
38 */
39 public function setId($id)
40 {
41 $this->id = $id;
42 return $this;
43 }
44
45 /**
46 * ID of the refund transaction. 17 characters max.
47 *
48 * @return string
49 */
50 public function getId()
51 {
52 return $this->id;
53 }
54
55 /**
56 * Details including both refunded amount (to payer) and refunded fee (to payee). 10 characters max.
57 *
58 * @param \PayPal\Api\Amount $amount
59 *
60 * @return $this
61 */
62 public function setAmount($amount)
63 {
64 $this->amount = $amount;
65 return $this;
66 }
67
68 /**
69 * Details including both refunded amount (to payer) and refunded fee (to payee). 10 characters max.
70 *
71 * @return \PayPal\Api\Amount
72 */
73 public function getAmount()
74 {
75 return $this->amount;
76 }
77
78 /**
79 * State of the refund.
80 * Valid Values: ["pending", "completed", "failed"]
81 *
82 * @param string $state
83 *
84 * @return $this
85 */
86 public function setState($state)
87 {
88 $this->state = $state;
89 return $this;
90 }
91
92 /**
93 * State of the refund.
94 *
95 * @return string
96 */
97 public function getState()
98 {
99 return $this->state;
100 }
101
102 /**
103 * Reason description for the Sale transaction being refunded.
104 *
105 * @param string $reason
106 *
107 * @return $this
108 */
109 public function setReason($reason)
110 {
111 $this->reason = $reason;
112 return $this;
113 }
114
115 /**
116 * Reason description for the Sale transaction being refunded.
117 *
118 * @return string
119 */
120 public function getReason()
121 {
122 return $this->reason;
123 }
124
125 /**
126 * Your own invoice or tracking ID number. Character length and limitations: 127 single-byte alphanumeric characters.
127 *
128 * @param string $invoice_number
129 *
130 * @return $this
131 */
132 public function setInvoiceNumber($invoice_number)
133 {
134 $this->invoice_number = $invoice_number;
135 return $this;
136 }
137
138 /**
139 * Your own invoice or tracking ID number. Character length and limitations: 127 single-byte alphanumeric characters.
140 *
141 * @return string
142 */
143 public function getInvoiceNumber()
144 {
145 return $this->invoice_number;
146 }
147
148 /**
149 * ID of the Sale transaction being refunded.
150 *
151 * @param string $sale_id
152 *
153 * @return $this
154 */
155 public function setSaleId($sale_id)
156 {
157 $this->sale_id = $sale_id;
158 return $this;
159 }
160
161 /**
162 * ID of the Sale transaction being refunded.
163 *
164 * @return string
165 */
166 public function getSaleId()
167 {
168 return $this->sale_id;
169 }
170
171 /**
172 * ID of the sale transaction being refunded.
173 *
174 * @param string $capture_id
175 *
176 * @return $this
177 */
178 public function setCaptureId($capture_id)
179 {
180 $this->capture_id = $capture_id;
181 return $this;
182 }
183
184 /**
185 * ID of the sale transaction being refunded.
186 *
187 * @return string
188 */
189 public function getCaptureId()
190 {
191 return $this->capture_id;
192 }
193
194 /**
195 * ID of the payment resource on which this transaction is based.
196 *
197 * @param string $parent_payment
198 *
199 * @return $this
200 */
201 public function setParentPayment($parent_payment)
202 {
203 $this->parent_payment = $parent_payment;
204 return $this;
205 }
206
207 /**
208 * ID of the payment resource on which this transaction is based.
209 *
210 * @return string
211 */
212 public function getParentPayment()
213 {
214 return $this->parent_payment;
215 }
216
217 /**
218 * Description of what is being refunded for.
219 *
220 * @param string $description
221 *
222 * @return $this
223 */
224 public function setDescription($description)
225 {
226 $this->description = $description;
227 return $this;
228 }
229
230 /**
231 * Description of what is being refunded for.
232 *
233 * @return string
234 */
235 public function getDescription()
236 {
237 return $this->description;
238 }
239
240 /**
241 * Time of refund as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6).
242 *
243 * @param string $create_time
244 *
245 * @return $this
246 */
247 public function setCreateTime($create_time)
248 {
249 $this->create_time = $create_time;
250 return $this;
251 }
252
253 /**
254 * Time of refund as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6).
255 *
256 * @return string
257 */
258 public function getCreateTime()
259 {
260 return $this->create_time;
261 }
262
263 /**
264 * Time that the resource was last updated.
265 *
266 * @param string $update_time
267 *
268 * @return $this
269 */
270 public function setUpdateTime($update_time)
271 {
272 $this->update_time = $update_time;
273 return $this;
274 }
275
276 /**
277 * Time that the resource was last updated.
278 *
279 * @return string
280 */
281 public function getUpdateTime()
282 {
283 return $this->update_time;
284 }
285
286 /**
287 * The reason code for the refund state being pending
288 * Valid Values: ["ECHECK"]
289 *
290 * @param string $reason_code
291 *
292 * @return $this
293 */
294 public function setReasonCode($reason_code)
295 {
296 $this->reason_code = $reason_code;
297 return $this;
298 }
299
300 /**
301 * The reason code for the refund state being pending
302 *
303 * @return string
304 */
305 public function getReasonCode()
306 {
307 return $this->reason_code;
308 }
309
310 /**
311 * Shows details for a refund, by ID.
312 *
313 * @param string $refundId
314 * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
315 * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
316 * @return Refund
317 */
318 public static function get($refundId, $apiContext = null, $restCall = null)
319 {
320 ArgumentValidator::validate($refundId, 'refundId');
321 $payLoad = "";
322 $json = self::executeCall(
323 "/v1/payments/refund/$refundId",
324 "GET",
325 $payLoad,
326 null,
327 $apiContext,
328 $restCall
329 );
330 $ret = new Refund();
331 $ret->fromJson($json);
332 return $ret;
333 }
334
335 }
336