4 use PayPal\Common\PPModel;
5 use PayPal\Rest\IResource;
7 use PayPal\Rest\ApiContext;
10 use PayPal\Transport\PPRestCall;
12 class Sale extends PPModel implements IResource {
14 private static $credential;
18 * @deprecated. Pass ApiContext to create/get methods instead
20 public static function setCredential($credential) {
21 self::$credential = $credential;
25 * Identifier of the authorization transaction.
28 public function setId($id) {
34 * Identifier of the authorization transaction.
37 public function getId() {
43 * Time the resource was created.
44 * @param string $create_time
46 public function setCreateTime($create_time) {
47 $this->create_time = $create_time;
52 * Time the resource was created.
55 public function getCreateTime() {
56 return $this->create_time;
60 * Time the resource was created.
61 * @param string $create_time
62 * @deprecated. Instead use setCreateTime
64 public function setCreate_time($create_time) {
65 $this->create_time = $create_time;
69 * Time the resource was created.
71 * @deprecated. Instead use getCreateTime
73 public function getCreate_time() {
74 return $this->create_time;
78 * Time the resource was last updated.
79 * @param string $update_time
81 public function setUpdateTime($update_time) {
82 $this->update_time = $update_time;
87 * Time the resource was last updated.
90 public function getUpdateTime() {
91 return $this->update_time;
95 * Time the resource was last updated.
96 * @param string $update_time
97 * @deprecated. Instead use setUpdateTime
99 public function setUpdate_time($update_time) {
100 $this->update_time = $update_time;
104 * Time the resource was last updated.
106 * @deprecated. Instead use getUpdateTime
108 public function getUpdate_time() {
109 return $this->update_time;
113 * Amount being collected.
114 * @param PayPal\Api\Amount $amount
116 public function setAmount($amount) {
117 $this->amount = $amount;
122 * Amount being collected.
123 * @return PayPal\Api\Amount
125 public function getAmount() {
126 return $this->amount;
131 * State of the sale transaction.
132 * @param string $state
134 public function setState($state) {
135 $this->state = $state;
140 * State of the sale transaction.
143 public function getState() {
149 * ID of the Payment resource that this transaction is based on.
150 * @param string $parent_payment
152 public function setParentPayment($parent_payment) {
153 $this->parent_payment = $parent_payment;
158 * ID of the Payment resource that this transaction is based on.
161 public function getParentPayment() {
162 return $this->parent_payment;
166 * ID of the Payment resource that this transaction is based on.
167 * @param string $parent_payment
168 * @deprecated. Instead use setParentPayment
170 public function setParent_payment($parent_payment) {
171 $this->parent_payment = $parent_payment;
175 * ID of the Payment resource that this transaction is based on.
177 * @deprecated. Instead use getParentPayment
179 public function getParent_payment() {
180 return $this->parent_payment;
186 * @param PayPal\Api\Links $links
188 public function setLinks($links) {
189 $this->links = $links;
195 * @return PayPal\Api\Links
197 public function getLinks() {
203 public static function get($saleId, $apiContext = null) {
204 if (($saleId == null) || (strlen($saleId) <= 0)) {
205 throw new \InvalidArgumentException("saleId cannot be null or empty");
208 if ($apiContext == null) {
209 $apiContext = new ApiContext(self::$credential);
211 $call = new PPRestCall($apiContext);
212 $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/sale/$saleId", "GET", $payLoad);
214 $ret->fromJson($json);
218 public function refund($refund, $apiContext = null) {
219 if ($this->getId() == null) {
220 throw new \InvalidArgumentException("Id cannot be null");
222 if (($refund == null)) {
223 throw new \InvalidArgumentException("refund cannot be null or empty");
225 $payLoad = $refund->toJSON();
226 if ($apiContext == null) {
227 $apiContext = new ApiContext(self::$credential);
229 $call = new PPRestCall($apiContext);
230 $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/sale/{$this->getId()}/refund", "POST", $payLoad);
232 $ret->fromJson($json);