Enabled EC Parameters support

- Updated Api to enabled EC Parameters
- Updated Tests
- Updated Logging Manager
- Added a feature to do validation on accessors.
This commit is contained in:
japatel
2014-10-09 11:30:12 -05:00
parent 459293838e
commit 61a52e4623
99 changed files with 9148 additions and 3609 deletions

View File

@@ -7,33 +7,40 @@ use PayPal\Rest\ApiContext;
use PayPal\Rest\IResource;
use PayPal\Api\PaymentHistory;
use PayPal\Transport\PPRestCall;
use PayPal\Validation\ArgumentValidator;
/**
* Class Payment
*
* @property string id
* @property string create_time
* @property string update_time
* @property string intent
* @property \PayPal\Api\Payer payer
* @property array|\PayPal\Api\Transaction transactions
* @property string state
* @property \PayPal\Api\RedirectUrls redirect_urls
* @property \PayPal\Api\Links links
* Lets you create, process and manage payments.
*
* @package PayPal\Api
*
* @property string id
* @property string create_time
* @property string update_time
* @property string intent
* @property \PayPal\Api\Payer payer
* @property \PayPal\Api\object cart
* @property \PayPal\Api\Transaction transactions
* @property string state
* @property \PayPal\Api\RedirectUrls redirect_urls
* @property \PayPal\Api\Links links
*/
class Payment extends PPModel implements IResource
{
/**
* @var
* OAuth Credentials to use for this call
*
* @var \PayPal\Auth\OAuthTokenCredential $credential
*/
protected static $credential;
/**
* Set Credential
*
* @param $credential
* Sets Credential
*
* @deprecated Pass ApiContext to create/get methods instead
* @param \PayPal\Auth\OAuthTokenCredential $credential
*/
public static function setCredential($credential)
{
@@ -41,23 +48,21 @@ class Payment extends PPModel implements IResource
}
/**
* Set ID
* Identifier of the payment resource created
* Identifier of the payment resource created.
*
*
* @param string $id
*
*
* @return $this
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Get ID
* Identifier of the payment resource created
* Identifier of the payment resource created.
*
* @return string
*/
@@ -67,23 +72,21 @@ class Payment extends PPModel implements IResource
}
/**
* Set Create Time
* Time the resource was created
* Time the resource was created in UTC ISO8601 format.
*
*
* @param string $create_time
*
*
* @return $this
*/
public function setCreateTime($create_time)
{
$this->create_time = $create_time;
return $this;
}
/**
* Get Create Time
* Time the resource was created
* Time the resource was created in UTC ISO8601 format.
*
* @return string
*/
@@ -93,27 +96,22 @@ class Payment extends PPModel implements IResource
}
/**
* Set Create Time
* Time the resource was created
* Time the resource was created in UTC ISO8601 format.
*
* @deprecated Instead use setCreateTime
*
* @param string $create_time
*
* @deprecated Use setCreateTime
*
* @return $this
*/
public function setCreate_time($create_time)
{
$this->create_time = $create_time;
return $this;
}
/**
* Get Create Time
* Time the resource was created
*
* @deprecated Use getCreateTime
* Time the resource was created in UTC ISO8601 format.
* @deprecated Instead use getCreateTime
*
* @return string
*/
@@ -123,23 +121,21 @@ class Payment extends PPModel implements IResource
}
/**
* Set Update Time
* Time the resource was last updated
* Time the resource was last updated in UTC ISO8601 format.
*
*
* @param string $update_time
*
*
* @return $this
*/
public function setUpdateTime($update_time)
{
$this->update_time = $update_time;
return $this;
}
/**
* Get Update Time
* Time the resource was last updated
* Time the resource was last updated in UTC ISO8601 format.
*
* @return string
*/
@@ -149,27 +145,22 @@ class Payment extends PPModel implements IResource
}
/**
* Set Update Time
* Time the resource was last updated
* Time the resource was last updated in UTC ISO8601 format.
*
* @deprecated Instead use setUpdateTime
*
* @param string $update_time
*
* @deprecated Use setUpdateTime
*
* @return $this
*/
public function setUpdate_time($update_time)
{
$this->update_time = $update_time;
return $this;
}
/**
* Get Update Time
* Time the resource was last updated
*
* @deprecated Use getUpdateTime
* Time the resource was last updated in UTC ISO8601 format.
* @deprecated Instead use getUpdateTime
*
* @return string
*/
@@ -179,23 +170,21 @@ class Payment extends PPModel implements IResource
}
/**
* Set Intent
* Intent of the payment - Sale or Authorization or Order
* Intent of the payment - Sale or Authorization or Order.
* Valid Values: ["sale", "authorize", "order"]
*
* @param string $intent
*
*
* @return $this
*/
public function setIntent($intent)
{
$this->intent = $intent;
return $this;
}
/**
* Get Intent
* Intent of the payment - Sale or Authorization or Order
* Intent of the payment - Sale or Authorization or Order.
*
* @return string
*/
@@ -205,23 +194,21 @@ class Payment extends PPModel implements IResource
}
/**
* Set Payer
* Source of the funds for this payment represented by a PayPal account or a direct credit card
* Source of the funds for this payment represented by a PayPal account or a direct credit card.
*
*
* @param \PayPal\Api\Payer $payer
*
*
* @return $this
*/
public function setPayer($payer)
{
$this->payer = $payer;
return $this;
}
/**
* Get Payer
* Source of the funds for this payment represented by a PayPal account or a direct credit card
* Source of the funds for this payment represented by a PayPal account or a direct credit card.
*
* @return \PayPal\Api\Payer
*/
@@ -231,25 +218,47 @@ class Payment extends PPModel implements IResource
}
/**
* Set Transactions
* Cart for which the payment is done.
*
*
* @param \PayPal\Api\object $cart
*
* @return $this
*/
public function setCart($cart)
{
$this->cart = $cart;
return $this;
}
/**
* Cart for which the payment is done.
*
* @return \PayPal\Api\object
*/
public function getCart()
{
return $this->cart;
}
/**
* A payment can have more than one transaction, with each transaction establishing a contract between the payer and a payee
*
*
* @param array|\PayPal\Api\Transaction $transactions
*
* @param \PayPal\Api\Transaction $transactions
*
* @return $this
*/
public function setTransactions($transactions)
{
$this->transactions = $transactions;
return $this;
}
/**
* Get Transactions
* A payment can have more than one transaction, with each transaction establishing a contract between the payer and a payee
*
* @return \PayPal\Api\Transaction
* @return \PayPal\Api\Transaction[]
*/
public function getTransactions()
{
@@ -257,23 +266,21 @@ class Payment extends PPModel implements IResource
}
/**
* Set State
* State of the payment
* state of the payment
* Valid Values: ["created", "approved", "failed", "canceled", "expired"]
*
* @param string $state
*
*
* @return $this
*/
public function setState($state)
{
$this->state = $state;
return $this;
}
/**
* Get State
* State of the payment
* state of the payment
*
* @return string
*/
@@ -283,23 +290,21 @@ class Payment extends PPModel implements IResource
}
/**
* Set Redirect URLs
* Redirect urls required only when using payment_method as PayPal - the only settings supported are return and cancel urls
* Redirect urls required only when using payment_method as PayPal - the only settings supported are return and cancel urls.
*
*
* @param \PayPal\Api\RedirectUrls $redirect_urls
*
*
* @return $this
*/
public function setRedirectUrls($redirect_urls)
{
$this->redirect_urls = $redirect_urls;
return $this;
}
/**
* Get Redirect URLs
* Redirect urls required only when using payment_method as PayPal - the only settings supported are return and cancel urls
* Redirect urls required only when using payment_method as PayPal - the only settings supported are return and cancel urls.
*
* @return \PayPal\Api\RedirectUrls
*/
@@ -309,27 +314,22 @@ class Payment extends PPModel implements IResource
}
/**
* Set Redirect URLs
* Redirect urls required only when using payment_method as PayPal - the only settings supported are return and cancel urls
* Redirect urls required only when using payment_method as PayPal - the only settings supported are return and cancel urls.
*
* @deprecated Instead use setRedirectUrls
*
* @param \PayPal\Api\RedirectUrls $redirect_urls
*
* @deprecated Use setRedirectUrls
*
* @return $this
*/
public function setRedirect_urls($redirect_urls)
{
$this->redirect_urls = $redirect_urls;
return $this;
}
/**
* Get Redirect URLs
* Redirect urls required only when using payment_method as PayPal - the only settings supported are return and cancel urls
*
* @deprecated Use getRedirectUrls
* Redirect urls required only when using payment_method as PayPal - the only settings supported are return and cancel urls.
* @deprecated Instead use getRedirectUrls
*
* @return \PayPal\Api\RedirectUrls
*/
@@ -339,154 +339,122 @@ class Payment extends PPModel implements IResource
}
/**
* Set Links
* Sets Links
*
*
* @param \PayPal\Api\Links $links
*
*
* @return $this
*/
public function setLinks($links)
{
$this->links = $links;
return $this;
}
/**
* Get Links
* Gets Links
*
* @return \PayPal\Api\Links
* @return \PayPal\Api\Links[]
*/
public function getLinks()
{
return $this->links;
}
/**
* Create
* Creates (and processes) a new Payment Resource.
*
* @param \PayPal\Rest\ApiContext|null $apiContext
*
* @return $this
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @return Payment
*/
public function create($apiContext = null)
{
$payLoad = $this->toJSON();
$payLoad = $this->toJSON();
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/payment", "POST", $payLoad);
$this->fromJson($json);
return $this;
}
/**
* Get
*
* @param int $paymentId
* @param \PayPal\Rest\ApiContext|null $apiContext
* Obtain the Payment resource for the given identifier.
*
* @param string $paymentId
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @return Payment
* @throws \InvalidArgumentException
*/
public static function get($paymentId, $apiContext = null)
{
if (($paymentId == null) || (strlen($paymentId) <= 0)) {
throw new \InvalidArgumentException("paymentId cannot be null or empty");
}
ArgumentValidator::validate($paymentId, 'paymentId');
$payLoad = "";
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/payment/$paymentId", "GET", $payLoad);
$ret = new Payment();
$ret->fromJson($json);
return $ret;
}
/**
* Execute
*
* @param \Paypal\Api\PaymentExecution $paymentExecution
* @param \PayPal\Rest\ApiContext|null $apiContext
* Executes the payment (after approved by the Payer) associated with this resource when the payment method is PayPal.
*
* @param PaymentExecution $paymentExecution
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @return Payment
* @throws \InvalidArgumentException
*/
public function execute($paymentExecution, $apiContext = null)
{
if ($this->getId() == null) {
throw new \InvalidArgumentException("Id cannot be null");
}
if (($paymentExecution == null)) {
throw new \InvalidArgumentException("paymentExecution cannot be null or empty");
}
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($paymentExecution, 'paymentExecution');
$payLoad = $paymentExecution->toJSON();
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/payment/{$this->getId()}/execute", "POST", $payLoad);
$ret = new Payment();
$ret->fromJson($json);
return $ret;
$this->fromJson($json);
return $this;
}
/**
* All
*
* @param array $params
* @param \PayPal\Rest\ApiContext|null $apiContext
* Retrieves a list of Payment resources.
*
* @param array $params
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @return PaymentHistory
* @throws \InvalidArgumentException
*/
public static function all($params, $apiContext = null)
{
if (($params == null)) {
throw new \InvalidArgumentException("params cannot be null or empty");
}
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,
'count' => 1,
'start_id' => 1,
'start_index' => 1,
'start_time' => 1,
'end_time' => 1,
'payee_id' => 1,
'sort_by' => 1,
'sort_order' => 1,
);
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/payment?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad);
$ret = new PaymentHistory();
$ret->fromJson($json);
return $ret;
}
}