public function testSerializeDeserialize() { $r1 = $this->refund; $r2 = new Refund(); $r2->fromJson($r1->toJson()); $this->assertEquals($r1, $r2); }
/** * Refund a captured payment by passing the capture_id in the request URI. In addition, include an amount object in the body of the request JSON. * * @param Refund $refund * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Refund */ public function refund($refund, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($refund, 'refund'); $payLoad = $refund->toJSON(); $json = self::executeCall("/v1/payments/capture/{$this->getId()}/refund", "POST", $payLoad, null, $apiContext, $restCall); $ret = new Refund(); $ret->fromJson($json); return $ret; }
/** * Retrieve details about a specific refund by passing the refund_id in the request URI. * * @param string $refundId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Refund */ public static function get($refundId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($refundId, 'refundId'); $payLoad = ""; $json = self::executeCall("/v1/payments/refund/{$refundId}", "GET", $payLoad, null, $apiContext, $restCall); $ret = new Refund(); $ret->fromJson($json); return $ret; }
public static function get($refundId, $apiContext = null) { if ($refundId == null || strlen($refundId) <= 0) { throw new \InvalidArgumentException("refundId cannot be null or empty"); } $payLoad = ""; if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } $call = new PPRestCall($apiContext); $json = $call->execute(array('PayPal\\Rest\\RestHandler'), "/v1/payments/refund/{$refundId}", "GET", $payLoad); $ret = new Refund(); $ret->fromJson($json); return $ret; }
/** * 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; }
/** * @path /v1/payments/refund/:refund-id * @method GET * @param string $refundid */ public static function get($refundid) { if ($refundid == null || strlen($refundid) <= 0) { throw new \InvalidArgumentException("refundid cannot be null or empty"); } $payLoad = ""; $apiContext = new ApiContext(self::$credential); $call = new Call(); $json = $call->execute("/v1/payments/refund/{$refundid}", "GET", $payLoad, $apiContext); $ret = new Refund(); $ret->fromJson($json); return $ret; }
/** * Creates (and processes) a new Refund Transaction added as a related resource. * * @param Refund $refund * @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @return Refund */ public function refund($refund, $apiContext = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($refund, 'refund'); $payLoad = $refund->toJSON(); if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } $call = new PayPalRestCall($apiContext); $json = $call->execute(array('PayPal\\Handler\\RestHandler'), "/v1/payments/capture/{$this->getId()}/refund", "POST", $payLoad); $ret = new Refund(); $ret->fromJson($json); return $ret; }
/** * Obtain the Refund transaction resource for the given identifier. * * @param string $refundId * @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @return Refund */ public static function get($refundId, $apiContext = null) { ArgumentValidator::validate($refundId, 'refundId'); $payLoad = ""; if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } $call = new PayPalRestCall($apiContext); $json = $call->execute(array('PayPal\\Handler\\RestHandler'), "/v1/payments/refund/{$refundId}", "GET", $payLoad); $ret = new Refund(); $ret->fromJson($json); return $ret; }