1 <?php
2
3 namespace PayPal\Api;
4
5 use PayPal\Common\PayPalModel;
6 use PayPal\Converter\FormatConverter;
7 use PayPal\Validation\NumericValidator;
8 use PayPal\Validation\UrlValidator;
9
10 /**
11 * Class Item
12 *
13 * Item details.
14 *
15 * @package PayPal\Api
16 *
17 * @property string sku
18 * @property string name
19 * @property string description
20 * @property string quantity
21 * @property string price
22 * @property string currency
23 * @property string tax
24 * @property string url
25 */
26 class Item extends PayPalModel
27 {
28 /**
29 * Stock keeping unit corresponding (SKU) to item.
30 *
31 * @param string $sku
32 *
33 * @return $this
34 */
35 public function setSku($sku)
36 {
37 $this->sku = $sku;
38 return $this;
39 }
40
41 /**
42 * Stock keeping unit corresponding (SKU) to item.
43 *
44 * @return string
45 */
46 public function getSku()
47 {
48 return $this->sku;
49 }
50
51 /**
52 * Item name. 127 characters max.
53 *
54 * @param string $name
55 *
56 * @return $this
57 */
58 public function setName($name)
59 {
60 $this->name = $name;
61 return $this;
62 }
63
64 /**
65 * Item name. 127 characters max.
66 *
67 * @return string
68 */
69 public function getName()
70 {
71 return $this->name;
72 }
73
74 /**
75 * Description of the item. Only supported when the `payment_method` is set to `paypal`.
76 *
77 * @param string $description
78 *
79 * @return $this
80 */
81 public function setDescription($description)
82 {
83 $this->description = $description;
84 return $this;
85 }
86
87 /**
88 * Description of the item. Only supported when the `payment_method` is set to `paypal`.
89 *
90 * @return string
91 */
92 public function getDescription()
93 {
94 return $this->description;
95 }
96
97 /**
98 * Number of a particular item. 10 characters max.
99 *
100 * @param string $quantity
101 *
102 * @return $this
103 */
104 public function setQuantity($quantity)
105 {
106 $this->quantity = $quantity;
107 return $this;
108 }
109
110 /**
111 * Number of a particular item. 10 characters max.
112 *
113 * @return string
114 */
115 public function getQuantity()
116 {
117 return $this->quantity;
118 }
119
120 /**
121 * Item cost. 10 characters max.
122 *
123 * @param string|double $price
124 *
125 * @return $this
126 */
127 public function setPrice($price)
128 {
129 NumericValidator::validate($price, "Price");
130 $price = FormatConverter::formatToPrice($price, $this->getCurrency());
131 $this->price = $price;
132 return $this;
133 }
134
135 /**
136 * Item cost. 10 characters max.
137 *
138 * @return string
139 */
140 public function getPrice()
141 {
142 return $this->price;
143 }
144
145 /**
146 * 3-letter [currency code](https://developer.paypal.com/docs/integration/direct/rest_api_payment_country_currency_support/).
147 *
148 * @param string $currency
149 *
150 * @return $this
151 */
152 public function setCurrency($currency)
153 {
154 $this->currency = $currency;
155 return $this;
156 }
157
158 /**
159 * 3-letter [currency code](https://developer.paypal.com/docs/integration/direct/rest_api_payment_country_currency_support/).
160 *
161 * @return string
162 */
163 public function getCurrency()
164 {
165 return $this->currency;
166 }
167
168 /**
169 * Tax of the item. Only supported when the `payment_method` is set to `paypal`.
170 *
171 * @param string|double $tax
172 *
173 * @return $this
174 */
175 public function setTax($tax)
176 {
177 NumericValidator::validate($tax, "Tax");
178 $tax = FormatConverter::formatToPrice($tax, $this->getCurrency());
179 $this->tax = $tax;
180 return $this;
181 }
182
183 /**
184 * Tax of the item. Only supported when the `payment_method` is set to `paypal`.
185 *
186 * @return string
187 */
188 public function getTax()
189 {
190 return $this->tax;
191 }
192
193 /**
194 * URL linking to item information. Available to payer in transaction history.
195 *
196 * @param string $url
197 * @throws \InvalidArgumentException
198 * @return $this
199 */
200 public function setUrl($url)
201 {
202 UrlValidator::validate($url, "Url");
203 $this->url = $url;
204 return $this;
205 }
206
207 /**
208 * URL linking to item information. Available to payer in transaction history.
209 *
210 * @return string
211 */
212 public function getUrl()
213 {
214 return $this->url;
215 }
216
217 /**
218 * Category type of the item.
219 * Valid Values: ["DIGITAL", "PHYSICAL"]
220 * @deprecated Not publicly available
221 * @param string $category
222 *
223 * @return $this
224 */
225 public function setCategory($category)
226 {
227 $this->category = $category;
228 return $this;
229 }
230
231 /**
232 * Category type of the item.
233 * @deprecated Not publicly available
234 * @return string
235 */
236 public function getCategory()
237 {
238 return $this->category;
239 }
240
241 /**
242 * Weight of the item.
243 * @deprecated Not publicly available
244 * @param \PayPal\Api\Measurement $weight
245 *
246 * @return $this
247 */
248 public function setWeight($weight)
249 {
250 $this->weight = $weight;
251 return $this;
252 }
253
254 /**
255 * Weight of the item.
256 * @deprecated Not publicly available
257 * @return \PayPal\Api\Measurement
258 */
259 public function getWeight()
260 {
261 return $this->weight;
262 }
263
264 /**
265 * Length of the item.
266 * @deprecated Not publicly available
267 * @param \PayPal\Api\Measurement $length
268 *
269 * @return $this
270 */
271 public function setLength($length)
272 {
273 $this->length = $length;
274 return $this;
275 }
276
277 /**
278 * Length of the item.
279 * @deprecated Not publicly available
280 * @return \PayPal\Api\Measurement
281 */
282 public function getLength()
283 {
284 return $this->length;
285 }
286
287 /**
288 * Height of the item.
289 * @deprecated Not publicly available
290 * @param \PayPal\Api\Measurement $height
291 *
292 * @return $this
293 */
294 public function setHeight($height)
295 {
296 $this->height = $height;
297 return $this;
298 }
299
300 /**
301 * Height of the item.
302 * @deprecated Not publicly available
303 * @return \PayPal\Api\Measurement
304 */
305 public function getHeight()
306 {
307 return $this->height;
308 }
309
310 /**
311 * Width of the item.
312 * @deprecated Not publicly available
313 * @param \PayPal\Api\Measurement $width
314 *
315 * @return $this
316 */
317 public function setWidth($width)
318 {
319 $this->width = $width;
320 return $this;
321 }
322
323 /**
324 * Width of the item.
325 * @deprecated Not publicly available
326 * @return \PayPal\Api\Measurement
327 */
328 public function getWidth()
329 {
330 return $this->width;
331 }
332
333 /**
334 * Set of optional data used for PayPal risk determination.
335 * @deprecated Not publicly available
336 * @param \PayPal\Api\NameValuePair[] $supplementary_data
337 *
338 * @return $this
339 */
340 public function setSupplementaryData($supplementary_data)
341 {
342 $this->supplementary_data = $supplementary_data;
343 return $this;
344 }
345
346 /**
347 * Set of optional data used for PayPal risk determination.
348 * @deprecated Not publicly available
349 * @return \PayPal\Api\NameValuePair[]
350 */
351 public function getSupplementaryData()
352 {
353 return $this->supplementary_data;
354 }
355
356 /**
357 * Append SupplementaryData to the list.
358 * @deprecated Not publicly available
359 * @param \PayPal\Api\NameValuePair $nameValuePair
360 * @return $this
361 */
362 public function addSupplementaryData($nameValuePair)
363 {
364 if (!$this->getSupplementaryData()) {
365 return $this->setSupplementaryData(array($nameValuePair));
366 } else {
367 return $this->setSupplementaryData(
368 array_merge($this->getSupplementaryData(), array($nameValuePair))
369 );
370 }
371 }
372
373 /**
374 * Remove SupplementaryData from the list.
375 * @deprecated Not publicly available
376 * @param \PayPal\Api\NameValuePair $nameValuePair
377 * @return $this
378 */
379 public function removeSupplementaryData($nameValuePair)
380 {
381 return $this->setSupplementaryData(
382 array_diff($this->getSupplementaryData(), array($nameValuePair))
383 );
384 }
385
386 /**
387 * Set of optional data used for PayPal post-transaction notifications.
388 * @deprecated Not publicly available
389 * @param \PayPal\Api\NameValuePair[] $postback_data
390 *
391 * @return $this
392 */
393 public function setPostbackData($postback_data)
394 {
395 $this->postback_data = $postback_data;
396 return $this;
397 }
398
399 /**
400 * Set of optional data used for PayPal post-transaction notifications.
401 * @deprecated Not publicly available
402 * @return \PayPal\Api\NameValuePair[]
403 */
404 public function getPostbackData()
405 {
406 return $this->postback_data;
407 }
408
409 /**
410 * Append PostbackData to the list.
411 * @deprecated Not publicly available
412 * @param \PayPal\Api\NameValuePair $nameValuePair
413 * @return $this
414 */
415 public function addPostbackData($nameValuePair)
416 {
417 if (!$this->getPostbackData()) {
418 return $this->setPostbackData(array($nameValuePair));
419 } else {
420 return $this->setPostbackData(
421 array_merge($this->getPostbackData(), array($nameValuePair))
422 );
423 }
424 }
425
426 /**
427 * Remove PostbackData from the list.
428 * @deprecated Not publicly available
429 * @param \PayPal\Api\NameValuePair $nameValuePair
430 * @return $this
431 */
432 public function removePostbackData($nameValuePair)
433 {
434 return $this->setPostbackData(
435 array_diff($this->getPostbackData(), array($nameValuePair))
436 );
437 }
438
439 }
440