ItemList.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. namespace PayPal\Api;
  3. use PayPal\Common\PayPalModel;
  4. /**
  5. * Class ItemList
  6. *
  7. * List of items being paid for.
  8. *
  9. * @package PayPal\Api
  10. *
  11. * @property \PayPal\Api\Item[] items
  12. * @property \PayPal\Api\ShippingAddress shipping_address
  13. * @property string shipping_method
  14. * @property string shipping_phone_number
  15. */
  16. class ItemList extends PayPalModel
  17. {
  18. /**
  19. * List of items.
  20. *
  21. * @param \PayPal\Api\Item[] $items
  22. *
  23. * @return $this
  24. */
  25. public function setItems($items)
  26. {
  27. $this->items = array_values($items);
  28. return $this;
  29. }
  30. /**
  31. * List of items.
  32. *
  33. * @return \PayPal\Api\Item[]
  34. */
  35. public function getItems()
  36. {
  37. return $this->items;
  38. }
  39. /**
  40. * Append Items to the list.
  41. *
  42. * @param \PayPal\Api\Item $item
  43. * @return $this
  44. */
  45. public function addItem($item)
  46. {
  47. if (!$this->getItems()) {
  48. return $this->setItems(array($item));
  49. } else {
  50. return $this->setItems(
  51. array_merge($this->getItems(), array($item))
  52. );
  53. }
  54. }
  55. /**
  56. * Remove Items from the list.
  57. *
  58. * @param \PayPal\Api\Item $item
  59. * @return $this
  60. */
  61. public function removeItem($item)
  62. {
  63. return $this->setItems(
  64. array_diff($this->getItems(), array($item))
  65. );
  66. }
  67. /**
  68. * Shipping address.
  69. *
  70. * @param \PayPal\Api\ShippingAddress $shipping_address
  71. *
  72. * @return $this
  73. */
  74. public function setShippingAddress($shipping_address)
  75. {
  76. $this->shipping_address = $shipping_address;
  77. return $this;
  78. }
  79. /**
  80. * Shipping address.
  81. *
  82. * @return \PayPal\Api\ShippingAddress
  83. */
  84. public function getShippingAddress()
  85. {
  86. return $this->shipping_address;
  87. }
  88. /**
  89. * Shipping method used for this payment like USPSParcel etc.
  90. *
  91. * @param string $shipping_method
  92. *
  93. * @return $this
  94. */
  95. public function setShippingMethod($shipping_method)
  96. {
  97. $this->shipping_method = $shipping_method;
  98. return $this;
  99. }
  100. /**
  101. * Shipping method used for this payment like USPSParcel etc.
  102. *
  103. * @return string
  104. */
  105. public function getShippingMethod()
  106. {
  107. return $this->shipping_method;
  108. }
  109. /**
  110. * Allows merchant's to share payer’s contact number with PayPal for the current payment. Final contact number of payer associated with the transaction might be same as shipping_phone_number or different based on Payer’s action on PayPal. The phone number must be represented in its canonical international format, as defined by the E.164 numbering plan
  111. *
  112. * @param string $shipping_phone_number
  113. *
  114. * @return $this
  115. */
  116. public function setShippingPhoneNumber($shipping_phone_number)
  117. {
  118. $this->shipping_phone_number = $shipping_phone_number;
  119. return $this;
  120. }
  121. /**
  122. * Allows merchant's to share payer’s contact number with PayPal for the current payment. Final contact number of payer associated with the transaction might be same as shipping_phone_number or different based on Payer’s action on PayPal. The phone number must be represented in its canonical international format, as defined by the E.164 numbering plan
  123. *
  124. * @return string
  125. */
  126. public function getShippingPhoneNumber()
  127. {
  128. return $this->shipping_phone_number;
  129. }
  130. }