773f95260b23542187063f30d97e6d6f880d3055
[WP-Plugins/glm-member-db.git] /
1 <?php
2 namespace PayPal\Api;
3
4 use PayPal\Common\PPModel;
5 use PayPal\Rest\IResource;
6 use PayPal\Rest\Call;
7 use PayPal\Rest\ApiContext;
8 use PayPal\Api\Capture;
9 use PayPal\Api\Refund;
10 use PayPal\Transport\PPRestCall;
11
12 class Capture extends PPModel implements IResource {
13
14         private static $credential;
15
16         /**
17          *
18          * @deprecated. Pass ApiContext to create/get methods instead
19          */
20         public static function setCredential($credential) {
21                 self::$credential = $credential;
22         }
23
24         /**
25          * Identifier of the Capture transaction.
26          * @param string $id
27          */
28         public function setId($id) {
29                 $this->id = $id;
30                 return $this;
31         }
32
33         /**
34          * Identifier of the Capture transaction.
35          * @return string
36          */
37         public function getId() {
38                 return $this->id;
39         }
40
41
42         /**
43          * Time the resource was created.
44          * @param string $create_time
45          */
46         public function setCreateTime($create_time) {
47                 $this->create_time = $create_time;
48                 return $this;
49         }
50
51         /**
52          * Time the resource was created.
53          * @return string
54          */
55         public function getCreateTime() {
56                 return $this->create_time;
57         }
58
59         /**
60          * Time the resource was created.
61          * @param string $create_time
62          * @deprecated. Instead use setCreateTime
63          */
64         public function setCreate_time($create_time) {
65                 $this->create_time = $create_time;
66                 return $this;
67         }
68         /**
69          * Time the resource was created.
70          * @return string
71          * @deprecated. Instead use getCreateTime
72          */
73         public function getCreate_time() {
74                 return $this->create_time;
75         }
76
77         /**
78          * Time the resource was last updated.
79          * @param string $update_time
80          */
81         public function setUpdateTime($update_time) {
82                 $this->update_time = $update_time;
83                 return $this;
84         }
85
86         /**
87          * Time the resource was last updated.
88          * @return string
89          */
90         public function getUpdateTime() {
91                 return $this->update_time;
92         }
93
94         /**
95          * Time the resource was last updated.
96          * @param string $update_time
97          * @deprecated. Instead use setUpdateTime
98          */
99         public function setUpdate_time($update_time) {
100                 $this->update_time = $update_time;
101                 return $this;
102         }
103         /**
104          * Time the resource was last updated.
105          * @return string
106          * @deprecated. Instead use getUpdateTime
107          */
108         public function getUpdate_time() {
109                 return $this->update_time;
110         }
111
112         /**
113          * Amount being captured. If no amount is specified, amount is used from the authorization being captured. If amount is same as the amount that's authorized for, the state of the authorization changes to captured. If not, the state of the authorization changes to partially_captured. Alternatively, you could indicate a final capture by seting the is_final_capture flag to true.
114          * @param PayPal\Api\Amount $amount
115          */
116         public function setAmount($amount) {
117                 $this->amount = $amount;
118                 return $this;
119         }
120
121         /**
122          * Amount being captured. If no amount is specified, amount is used from the authorization being captured. If amount is same as the amount that's authorized for, the state of the authorization changes to captured. If not, the state of the authorization changes to partially_captured. Alternatively, you could indicate a final capture by seting the is_final_capture flag to true.
123          * @return PayPal\Api\Amount
124          */
125         public function getAmount() {
126                 return $this->amount;
127         }
128
129
130         /**
131          * whether this is a final capture for the given authorization or not. If it's final, all the remaining funds held by the authorization, will be released in the funding instrument.
132          * @param boolean $is_final_capture
133          */
134         public function setIsFinalCapture($is_final_capture) {
135                 $this->is_final_capture = $is_final_capture;
136                 return $this;
137         }
138
139         /**
140          * whether this is a final capture for the given authorization or not. If it's final, all the remaining funds held by the authorization, will be released in the funding instrument.
141          * @return boolean
142          */
143         public function getIsFinalCapture() {
144                 return $this->is_final_capture;
145         }
146
147         /**
148          * whether this is a final capture for the given authorization or not. If it's final, all the remaining funds held by the authorization, will be released in the funding instrument.
149          * @param boolean $is_final_capture
150          * @deprecated. Instead use setIsFinalCapture
151          */
152         public function setIs_final_capture($is_final_capture) {
153                 $this->is_final_capture = $is_final_capture;
154                 return $this;
155         }
156         /**
157          * whether this is a final capture for the given authorization or not. If it's final, all the remaining funds held by the authorization, will be released in the funding instrument.
158          * @return boolean
159          * @deprecated. Instead use getIsFinalCapture
160          */
161         public function getIs_final_capture() {
162                 return $this->is_final_capture;
163         }
164
165         /**
166          * State of the capture transaction.
167          * @param string $state
168          */
169         public function setState($state) {
170                 $this->state = $state;
171                 return $this;
172         }
173
174         /**
175          * State of the capture transaction.
176          * @return string
177          */
178         public function getState() {
179                 return $this->state;
180         }
181
182
183         /**
184          * ID of the Payment resource that this transaction is based on.
185          * @param string $parent_payment
186          */
187         public function setParentPayment($parent_payment) {
188                 $this->parent_payment = $parent_payment;
189                 return $this;
190         }
191
192         /**
193          * ID of the Payment resource that this transaction is based on.
194          * @return string
195          */
196         public function getParentPayment() {
197                 return $this->parent_payment;
198         }
199
200         /**
201          * ID of the Payment resource that this transaction is based on.
202          * @param string $parent_payment
203          * @deprecated. Instead use setParentPayment
204          */
205         public function setParent_payment($parent_payment) {
206                 $this->parent_payment = $parent_payment;
207                 return $this;
208         }
209         /**
210          * ID of the Payment resource that this transaction is based on.
211          * @return string
212          * @deprecated. Instead use getParentPayment
213          */
214         public function getParent_payment() {
215                 return $this->parent_payment;
216         }
217
218         /**
219          * 
220          * @array
221          * @param PayPal\Api\Links $links
222          */
223         public function setLinks($links) {
224                 $this->links = $links;
225                 return $this;
226         }
227
228         /**
229          * 
230          * @return PayPal\Api\Links
231          */
232         public function getLinks() {
233                 return $this->links;
234         }
235
236
237
238         public static function get($captureId, $apiContext = null) {
239                 if (($captureId == null) || (strlen($captureId) <= 0)) {
240                         throw new \InvalidArgumentException("captureId cannot be null or empty");
241                 }
242                 $payLoad = "";
243                 if ($apiContext == null) {
244                         $apiContext = new ApiContext(self::$credential);
245                 }
246                 $call = new PPRestCall($apiContext);
247                 $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/capture/$captureId", "GET", $payLoad);
248                 $ret = new Capture();
249                 $ret->fromJson($json);
250                 return $ret;
251         }
252
253         public function refund($refund, $apiContext = null) {
254                 if ($this->getId() == null) {
255                         throw new \InvalidArgumentException("Id cannot be null");
256                 }
257                 if (($refund == null)) {
258                         throw new \InvalidArgumentException("refund cannot be null or empty");
259                 }
260                 $payLoad = $refund->toJSON();
261                 if ($apiContext == null) {
262                         $apiContext = new ApiContext(self::$credential);
263                 }
264                 $call = new PPRestCall($apiContext);
265                 $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/capture/{$this->getId()}/refund", "POST", $payLoad);
266                 $ret = new Refund();
267                 $ret->fromJson($json);
268                 return $ret;
269         }
270 }