9fc4b6dd363055b0898940fa3b5341f57b6a1066
[WP-Plugins/glm-member-db-registrations.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\Authorization;
9 use PayPal\Api\Capture;
10 use PayPal\Transport\PPRestCall;
11
12 class Authorization 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 authorization 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 authorization 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 authorized for.
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 authorized for.
123          * @return PayPal\Api\Amount
124          */
125         public function getAmount() {
126                 return $this->amount;
127         }
128
129
130         /**
131          * State of the authorization transaction.
132          * @param string $state
133          */
134         public function setState($state) {
135                 $this->state = $state;
136                 return $this;
137         }
138
139         /**
140          * State of the authorization transaction.
141          * @return string
142          */
143         public function getState() {
144                 return $this->state;
145         }
146
147
148         /**
149          * ID of the Payment resource that this transaction is based on.
150          * @param string $parent_payment
151          */
152         public function setParentPayment($parent_payment) {
153                 $this->parent_payment = $parent_payment;
154                 return $this;
155         }
156
157         /**
158          * ID of the Payment resource that this transaction is based on.
159          * @return string
160          */
161         public function getParentPayment() {
162                 return $this->parent_payment;
163         }
164
165         /**
166          * ID of the Payment resource that this transaction is based on.
167          * @param string $parent_payment
168          * @deprecated. Instead use setParentPayment
169          */
170         public function setParent_payment($parent_payment) {
171                 $this->parent_payment = $parent_payment;
172                 return $this;
173         }
174         /**
175          * ID of the Payment resource that this transaction is based on.
176          * @return string
177          * @deprecated. Instead use getParentPayment
178          */
179         public function getParent_payment() {
180                 return $this->parent_payment;
181         }
182
183         /**
184          * Date/Time until which funds may be captured against this resource.
185          * @param string $valid_until
186          */
187         public function setValidUntil($valid_until) {
188                 $this->valid_until = $valid_until;
189                 return $this;
190         }
191
192         /**
193          * Date/Time until which funds may be captured against this resource.
194          * @return string
195          */
196         public function getValidUntil() {
197                 return $this->valid_until;
198         }
199
200         /**
201          * Date/Time until which funds may be captured against this resource.
202          * @param string $valid_until
203          * @deprecated. Instead use setValidUntil
204          */
205         public function setValid_until($valid_until) {
206                 $this->valid_until = $valid_until;
207                 return $this;
208         }
209         /**
210          * Date/Time until which funds may be captured against this resource.
211          * @return string
212          * @deprecated. Instead use getValidUntil
213          */
214         public function getValid_until() {
215                 return $this->valid_until;
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($authorizationId, $apiContext = null) {
239                 if (($authorizationId == null) || (strlen($authorizationId) <= 0)) {
240                         throw new \InvalidArgumentException("authorizationId 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/authorization/$authorizationId", "GET", $payLoad);
248                 $ret = new Authorization();
249                 $ret->fromJson($json);
250                 return $ret;
251         }
252
253         public function capture($capture, $apiContext = null) {
254                 if ($this->getId() == null) {
255                         throw new \InvalidArgumentException("Id cannot be null");
256                 }
257                 if (($capture == null)) {
258                         throw new \InvalidArgumentException("capture cannot be null or empty");
259                 }
260                 $payLoad = $capture->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/authorization/{$this->getId()}/capture", "POST", $payLoad);
266                 $ret = new Capture();
267                 $ret->fromJson($json);
268                 return $ret;
269         }
270
271         public function void($apiContext = null) {
272                 if ($this->getId() == null) {
273                         throw new \InvalidArgumentException("Id cannot be null");
274                 }
275                 $payLoad = "";
276                 if ($apiContext == null) {
277                         $apiContext = new ApiContext(self::$credential);
278                 }
279                 $call = new PPRestCall($apiContext);
280                 $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/authorization/{$this->getId()}/void", "POST", $payLoad);
281                 $ret = new Authorization();
282                 $ret->fromJson($json);
283                 return $ret;
284         }
285
286         public function reauthorize($apiContext = null) {
287                 if ($this->getId() == null) {
288                         throw new \InvalidArgumentException("Id cannot be null");
289                 }
290                 $payLoad = $this->toJSON();
291                 if ($apiContext == null) {
292                         $apiContext = new ApiContext(self::$credential);
293                 }
294                 $call = new PPRestCall($apiContext);
295                 $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/authorization/{$this->getId()}/reauthorize", "POST", $payLoad);
296                 $this->fromJson($json);
297                 return $this;
298         }
299 }