validate() public static method

Helper method for validating an argument that will be used by this API in any requests.
public static validate ( $argument, $argumentName = null ) : boolean
$argument mixed The object to be validated
$argumentName string|null The name of the argument. This will be placed in the exception message for easy reference
return boolean
 /**
  * Retrieves the list of events-types subscribed by the given Webhook.
  *
  * @param string $webhookId
  * @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 WebhookEventTypeList
  */
 public static function subscribedEventTypes($webhookId, $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($webhookId, 'webhookId');
     $payLoad = "";
     $json = self::executeCall("/v1/notifications/webhooks/{$webhookId}/event-types", "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new WebhookEventTypeList();
     $ret->fromJson($json);
     return $ret;
 }
Example #2
0
 /**
  * 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;
 }
Example #3
0
 /**
  * Retrieves a list of Credit Card resources.
  *
  * @param array          $params
  * @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 CreditCardList
  */
 public static function all($params, $apiContext = null, $restCall = null)
 {
     if (is_null($params)) {
         $params = array();
     }
     ArgumentValidator::validate($params, 'params');
     $payLoad = "";
     $allowedParams = array('page_size' => 1, 'page' => 1, 'start_time' => 1, 'end_time' => 1, 'sort_order' => 1, 'sort_by' => 1, 'merchant_id' => 1, 'external_card_id' => 1, 'external_customer_id' => 1, 'total_required' => 1);
     $json = self::executeCall("/v1/vault/credit-cards" . "?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new CreditCardList();
     $ret->fromJson($json);
     return $ret;
 }
Example #4
0
 /**
  * Cancels the unclaimed payment using the items id passed in the request URI. If an unclaimed item is not claimed within 30 days, the funds will be automatically returned to the sender. This call can be used to cancel the unclaimed item prior to the automatic 30-day return.
  *
  * @param string $payoutItemId
  * @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 PayoutItemDetails
  */
 public static function cancel($payoutItemId, $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($payoutItemId, 'payoutItemId');
     $payLoad = "";
     $json = self::executeCall("/v1/payments/payouts-item/{$payoutItemId}/cancel", "POST", $payLoad, null, $apiContext, $restCall);
     $ret = new PayoutItemDetails();
     $ret->fromJson($json);
     return $ret;
 }
Example #5
0
 /**
  * Update an existing template by passing the template ID to the request URI. In addition, pass a complete template object in the request JSON. Partial updates are not supported.
  *
  * @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 Template
  */
 public function update($apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($this->getTemplateId(), "Id");
     $payLoad = $this->toJSON();
     $json = self::executeCall("/v1/invoicing/templates/{$this->getTemplateId()}", "PUT", $payLoad, null, $apiContext, $restCall);
     $this->fromJson($json);
     return $this;
 }
Example #6
0
 /**
  * List payments in any state (created, approved, failed, etc.). Payments returned are the payments made to the merchant issuing the request.
  *
  * @param array          $params
  * @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 PaymentHistory
  */
 public static function all($params, $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($params, 'params');
     $payLoad = "";
     $allowedParams = array('count' => 1, 'start_id' => 1, 'start_index' => 1, 'start_time' => 1, 'end_time' => 1, 'payee_id' => 1, 'sort_by' => 1, 'sort_order' => 1);
     $json = self::executeCall("/v1/payments/payment?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new PaymentHistory();
     $ret->fromJson($json);
     return $ret;
 }
Example #7
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;
 }
Example #8
0
 /**
  * Generate a QR code for an invoice by passing the invoice ID to the request URI. The request generates a QR code that is 500 pixels in width and height. You can change the dimensions of the returned code by specifying optional query parameters.
  *
  * @param array $params
  * @param string $invoiceId
  * @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 Image
  */
 public static function qrCode($invoiceId, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($invoiceId, 'invoiceId');
     ArgumentValidator::validate($params, 'params');
     $allowedParams = array('width' => 1, 'height' => 1, 'action' => 1);
     $payLoad = "";
     $json = self::executeCall("/v1/invoicing/invoices/{$invoiceId}/qr-code?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new Image();
     $ret->fromJson($json);
     return $ret;
 }
Example #9
0
 /**
  * List transactions for a billing agreement by passing the ID of the agreement, as well as the start and end dates of the range of transactions to list, to the request URI.
  *
  * @param string $agreementId
  * @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 AgreementTransactions
  */
 public static function transactions($agreementId, $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($agreementId, 'agreementId');
     $payLoad = "";
     $json = self::executeCall("/v1/payments/billing-agreements/{$agreementId}/transactions", "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new AgreementTransactions();
     $ret->fromJson($json);
     return $ret;
 }
Example #10
0
 /**
  * Reauthorizes an expired Authorization.
  *
  * @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
  * @return Authorization
  */
 public function reauthorize($apiContext = null)
 {
     ArgumentValidator::validate($this->getId(), "Id");
     $payLoad = $this->toJSON();
     if ($apiContext == null) {
         $apiContext = new ApiContext(self::$credential);
     }
     $call = new PayPalRestCall($apiContext);
     $json = $call->execute(array('PayPal\\Handler\\RestHandler'), "/v1/payments/authorization/{$this->getId()}/reauthorize", "POST", $payLoad);
     $this->fromJson($json);
     return $this;
 }
Example #11
0
 /**
  *
  * @dataProvider invalidProvider
  * @expectedException \InvalidArgumentException
  */
 public function testInvalidDataValidate($input)
 {
     $this->assertTrue(ArgumentValidator::validate($input, "Name"));
 }
 /**
  * Look up a particular credit financing resource by passing the financing_code in the request URI.
  *
  * @param string         $financing_code
  * @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 CreditFinancing
  */
 public static function get($financing_code, $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($financing_code, 'financing_code');
     $payLoad = "";
     $json = self::executeCall("/v1/credit/credit-financing/{$financing_code}", "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new CreditFinancing();
     $ret->fromJson($json);
     return $ret;
 }
Example #13
0
 /**
  * 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;
 }
Example #14
0
 /**
  * Delete an existing web experience profile by passing the profile ID to the request URI.
  *
  * @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 bool
  */
 public function delete($apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($this->getId(), "Id");
     $payLoad = "";
     self::executeCall("/v1/payment-experience/web-profiles/{$this->getId()}", "DELETE", $payLoad, null, $apiContext, $restCall);
     return true;
 }
 /**
  * List transactions for a billing agreement by passing the ID of the agreement, as well as the start and end dates of the range of transactions to list, to the request URI.
  *
  * @param string $agreementId
  * @param array $params Parameters for search string. Options: start_date, and end_date
  * @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 AgreementTransactions
  */
 public static function searchTransactions($agreementId, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($agreementId, 'agreementId');
     ArgumentValidator::validate($params, 'params');
     $allowedParams = array('start_date' => 1, 'end_date' => 1);
     $payLoad = "";
     $json = self::executeCall("/v1/payments/billing-agreements/{$agreementId}/transactions?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new AgreementTransactions();
     $ret->fromJson($json);
     return $ret;
 }
Example #16
0
 /**
  * Retrieves the list of Webhooks events resources for the application associated with token. The developers can use it to see list of past webhooks events.
  *
  * @param array $params
  * @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 WebhookEventList
  */
 public static function all($params, $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($params, 'params');
     $payLoad = "";
     $allowedParams = array('page_size' => 1, 'start_time' => 1, 'end_time' => 1);
     $json = self::executeCall("/v1/notifications/webhooks-events" . "?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new WebhookEventList();
     $ret->fromJson($json);
     return $ret;
 }
Example #17
0
 /**
  * Update information in a previously saved card. Only the modified fields need to be passed in the request.
  *
  * @param PatchRequest $patchRequest
  * @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 CreditCard
  */
 public function update($patchRequest, $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($this->getId(), "Id");
     ArgumentValidator::validate($patchRequest, 'patch');
     $payload = $patchRequest->toJSON();
     $json = self::executeCall("/v1/vault/credit-cards/{$this->getId()}", "PATCH", $payload, null, $apiContext, $restCall);
     $this->fromJson($json);
     return $this;
 }
Example #18
0
 /**
  * Retrieves the template information of the merchant.
  *
  * @param array $params
  * @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 Templates
  */
 public static function getAll($params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($params, 'params');
     $payLoad = "";
     $allowedParams = array('fields' => 1);
     $json = self::executeCall("/v1/invoicing/templates/" . "?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new Templates();
     $ret->fromJson($json);
     return $ret;
 }
Example #19
0
 /**
  * List billing plans according to optional query string parameters specified.
  *
  * @param array $params
  * @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 PlanList
  */
 public static function all($params, $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($params, 'params');
     $payLoad = "";
     $allowedParams = array('page_size' => 1, 'status' => 1, 'page' => 1, 'total_required' => 1);
     $json = self::executeCall("/v1/payments/billing-plans/" . "?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new PlanList();
     $ret->fromJson($json);
     return $ret;
 }
Example #20
0
 /**
  * Obtain the status of a specific batch resource by passing the payout batch ID to the request URI. You can issue this call multiple times to get the current status.
  *
  * @param string $payoutBatchId
  * @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 PayoutBatch
  */
 public static function get($payoutBatchId, $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($payoutBatchId, 'payoutBatchId');
     $payLoad = "";
     $json = self::executeCall("/v1/payments/payouts/{$payoutBatchId}", "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new PayoutBatch();
     $ret->fromJson($json);
     return $ret;
 }
Example #21
0
 /**
  * Reauthorizes a PayPal account payment, by authorization ID. To ensure that funds are still available, reauthorize a payment after the initial three-day honor period. Supports only the `amount` request parameter.
  *
  * @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 reauthorize($apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($this->getId(), "Id");
     $payLoad = $this->toJSON();
     $json = self::executeCall("/v1/payments/authorization/{$this->getId()}/reauthorize", "POST", $payLoad, null, $apiContext, $restCall);
     $this->fromJson($json);
     return $this;
 }
Example #22
0
 /**
  * Deletes a webhook, by ID.
  *
  * @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 bool
  */
 public function delete($apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($this->getId(), "Id");
     $payLoad = "";
     self::executeCall("/v1/notifications/webhooks/{$this->getId()}", "DELETE", $payLoad, null, $apiContext, $restCall);
     return true;
 }
Example #23
0
 /**
  * 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;
 }