public function testSerializeDeserialize()
 {
     $a1 = $this->authorizations['partial'];
     $a2 = new Authorization();
     $a2->fromJson($a1->toJson());
     $this->assertEquals($a1, $a2);
 }
Beispiel #2
0
 /**
  * Authorize an order by passing the order_id in the request URI. In addition, include an amount object in the body of the request JSON.
  *
  * @param Authorization $authorization Authorization Object with Amount value to be authorized
  * @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 Authorization
  */
 public function authorize($authorization, $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($this->getId(), "Id");
     ArgumentValidator::validate($authorization, 'Authorization');
     $payLoad = $authorization->toJSON();
     $json = self::executeCall("/v1/payments/orders/{$this->getId()}/authorize", "POST", $payLoad, null, $apiContext, $restCall);
     $ret = new Authorization();
     $ret->fromJson($json);
     return $ret;
 }
 /**
  * Shows details for an authorization, by ID.
  *
  * @param string $authorizationId
  * @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 Authorization
  */
 public static function get($authorizationId, $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($authorizationId, 'authorizationId');
     $payLoad = "";
     $json = self::executeCall("/v1/payments/authorization/{$authorizationId}", "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new Authorization();
     $ret->fromJson($json);
     return $ret;
 }
 /**
  * Obtain the Authorization transaction resource for the given identifier.
  *
  * @param string $authorizationId
  * @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
  * @return Authorization
  */
 public static function get($authorizationId, $apiContext = null)
 {
     ArgumentValidator::validate($authorizationId, 'authorizationId');
     $payLoad = "";
     if ($apiContext == null) {
         $apiContext = new ApiContext(self::$credential);
     }
     $call = new PayPalRestCall($apiContext);
     $json = $call->execute(array('PayPal\\Handler\\RestHandler'), "/v1/payments/authorization/{$authorizationId}", "GET", $payLoad);
     $ret = new Authorization();
     $ret->fromJson($json);
     return $ret;
 }
 /**
  * Void
  *
  * @param \PayPal\Rest\ApiContext|null $apiContext
  *
  * @return Authorization
  * @throws \InvalidArgumentException
  */
 public function void($apiContext = null)
 {
     if ($this->getId() == null) {
         throw new \InvalidArgumentException("Id cannot be null");
     }
     $payLoad = "";
     if ($apiContext == null) {
         $apiContext = new ApiContext(self::$credential);
     }
     $call = new PPRestCall($apiContext);
     $json = $call->execute(array('PayPal\\Rest\\RestHandler'), "/v1/payments/authorization/{$this->getId()}/void", "POST", $payLoad);
     $ret = new Authorization();
     $ret->fromJson($json);
     return $ret;
 }