4 use PayPal\Common\PPModel;
5 use PayPal\Rest\IResource;
7 use PayPal\Rest\ApiContext;
8 use PayPal\Api\Authorization;
9 use PayPal\Api\Capture;
10 use PayPal\Transport\PPRestCall;
12 class Authorization 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 authorized for.
114 * @param PayPal\Api\Amount $amount
116 public function setAmount($amount) {
117 $this->amount = $amount;
122 * Amount being authorized for.
123 * @return PayPal\Api\Amount
125 public function getAmount() {
126 return $this->amount;
131 * State of the authorization transaction.
132 * @param string $state
134 public function setState($state) {
135 $this->state = $state;
140 * State of the authorization 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;
184 * Date/Time until which funds may be captured against this resource.
185 * @param string $valid_until
187 public function setValidUntil($valid_until) {
188 $this->valid_until = $valid_until;
193 * Date/Time until which funds may be captured against this resource.
196 public function getValidUntil() {
197 return $this->valid_until;
201 * Date/Time until which funds may be captured against this resource.
202 * @param string $valid_until
203 * @deprecated. Instead use setValidUntil
205 public function setValid_until($valid_until) {
206 $this->valid_until = $valid_until;
210 * Date/Time until which funds may be captured against this resource.
212 * @deprecated. Instead use getValidUntil
214 public function getValid_until() {
215 return $this->valid_until;
221 * @param PayPal\Api\Links $links
223 public function setLinks($links) {
224 $this->links = $links;
230 * @return PayPal\Api\Links
232 public function getLinks() {
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");
243 if ($apiContext == null) {
244 $apiContext = new ApiContext(self::$credential);
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);
253 public function capture($capture, $apiContext = null) {
254 if ($this->getId() == null) {
255 throw new \InvalidArgumentException("Id cannot be null");
257 if (($capture == null)) {
258 throw new \InvalidArgumentException("capture cannot be null or empty");
260 $payLoad = $capture->toJSON();
261 if ($apiContext == null) {
262 $apiContext = new ApiContext(self::$credential);
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);
271 public function void($apiContext = null) {
272 if ($this->getId() == null) {
273 throw new \InvalidArgumentException("Id cannot be null");
276 if ($apiContext == null) {
277 $apiContext = new ApiContext(self::$credential);
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);
286 public function reauthorize($apiContext = null) {
287 if ($this->getId() == null) {
288 throw new \InvalidArgumentException("Id cannot be null");
290 $payLoad = $this->toJSON();
291 if ($apiContext == null) {
292 $apiContext = new ApiContext(self::$credential);
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);