/**
  * Capture
  *
  * @param \Paypal\Api\Capture          $capture
  * @param \PayPal\Rest\ApiContext|null $apiContext
  *
  * @return Capture
  * @throws \InvalidArgumentException
  */
 public function capture($capture, $apiContext = null)
 {
     if ($this->getId() == null) {
         throw new \InvalidArgumentException("Id cannot be null");
     }
     if ($capture == null) {
         throw new \InvalidArgumentException("capture cannot be null or empty");
     }
     $payLoad = $capture->toJSON();
     if ($apiContext == null) {
         $apiContext = new ApiContext(self::$credential);
     }
     $call = new PPRestCall($apiContext);
     $json = $call->execute(array('PayPal\\Rest\\RestHandler'), "/v1/payments/authorization/{$this->getId()}/capture", "POST", $payLoad);
     $ret = new Capture();
     $ret->fromJson($json);
     return $ret;
 }