4 use PayPal\Common\PPModel;
5 use PayPal\Rest\IResource;
7 use PayPal\Rest\ApiContext;
8 use PayPal\Api\Capture;
10 use PayPal\Transport\PPRestCall;
12 class Capture 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 Capture transaction.
28 public function setId($id) {
34 * Identifier of the Capture 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 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
116 public function setAmount($amount) {
117 $this->amount = $amount;
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
125 public function getAmount() {
126 return $this->amount;
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
134 public function setIsFinalCapture($is_final_capture) {
135 $this->is_final_capture = $is_final_capture;
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.
143 public function getIsFinalCapture() {
144 return $this->is_final_capture;
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
152 public function setIs_final_capture($is_final_capture) {
153 $this->is_final_capture = $is_final_capture;
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.
159 * @deprecated. Instead use getIsFinalCapture
161 public function getIs_final_capture() {
162 return $this->is_final_capture;
166 * State of the capture transaction.
167 * @param string $state
169 public function setState($state) {
170 $this->state = $state;
175 * State of the capture transaction.
178 public function getState() {
184 * ID of the Payment resource that this transaction is based on.
185 * @param string $parent_payment
187 public function setParentPayment($parent_payment) {
188 $this->parent_payment = $parent_payment;
193 * ID of the Payment resource that this transaction is based on.
196 public function getParentPayment() {
197 return $this->parent_payment;
201 * ID of the Payment resource that this transaction is based on.
202 * @param string $parent_payment
203 * @deprecated. Instead use setParentPayment
205 public function setParent_payment($parent_payment) {
206 $this->parent_payment = $parent_payment;
210 * ID of the Payment resource that this transaction is based on.
212 * @deprecated. Instead use getParentPayment
214 public function getParent_payment() {
215 return $this->parent_payment;
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($captureId, $apiContext = null) {
239 if (($captureId == null) || (strlen($captureId) <= 0)) {
240 throw new \InvalidArgumentException("captureId 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/capture/$captureId", "GET", $payLoad);
248 $ret = new Capture();
249 $ret->fromJson($json);
253 public function refund($refund, $apiContext = null) {
254 if ($this->getId() == null) {
255 throw new \InvalidArgumentException("Id cannot be null");
257 if (($refund == null)) {
258 throw new \InvalidArgumentException("refund cannot be null or empty");
260 $payLoad = $refund->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/capture/{$this->getId()}/refund", "POST", $payLoad);
267 $ret->fromJson($json);