Example #1
0
 /**
  * Refund
  *
  * @param \Paypal\Api\Refund           $refund
  * @param \PayPal\Rest\ApiContext|null $apiContext
  *
  * @return Refund
  * @throws \InvalidArgumentException
  */
 public function refund($refund, $apiContext = null)
 {
     if ($this->getId() == null) {
         throw new \InvalidArgumentException("Id cannot be null");
     }
     if ($refund == null) {
         throw new \InvalidArgumentException("refund cannot be null or empty");
     }
     $payLoad = $refund->toJSON();
     if ($apiContext == null) {
         $apiContext = new ApiContext(self::$credential);
     }
     $call = new PPRestCall($apiContext);
     $json = $call->execute(array('PayPal\\Rest\\RestHandler'), "/v1/payments/sale/{$this->getId()}/refund", "POST", $payLoad);
     $ret = new Refund();
     $ret->fromJson($json);
     return $ret;
 }
Example #2
0
 /**
  * @path /v1/payments/sale/:sale-id/refund
  * @method POST
  * @param Refund $refund	  
  * @param PayPal\Rest\ApiContext $apiContext optional	  	 
  */
 public function refund($refund, $apiContext = null)
 {
     if ($refund == null) {
         throw new \InvalidArgumentException("refund cannot be null");
     }
     if ($this->getId() == null) {
         throw new \InvalidArgumentException("Id cannot be null");
     }
     $payLoad = $refund->toJSON();
     if ($apiContext == null) {
         $apiContext = new ApiContext(self::$credential);
     }
     $call = new Call();
     $json = $call->execute("/v1/payments/sale/{$this->getId()}/refund", "POST", $payLoad, $apiContext);
     $this->fromJson($json);
     return $this;
 }