forked from LiveCarta/PayPal-PHP-SDK
Enabled Vault Credit Card List API
- Added Credit Card List API Operation - Updated Credit Card to include new properties - Updated Tests - Updated Samples - Fixed Billing Agreement Sample (Expired Set Date).
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
namespace PayPal\Api;
|
||||
|
||||
use PayPal\Common\PayPalResourceModel;
|
||||
use PayPal\Validation\ArgumentValidator;
|
||||
use PayPal\Rest\ApiContext;
|
||||
use PayPal\Transport\PayPalRestCall;
|
||||
use PayPal\Validation\ArgumentValidator;
|
||||
use PayPal\Api\CreditCardList;
|
||||
use PayPal\Rest\ApiContext;
|
||||
use PayPal\Transport\PPRestCall;
|
||||
|
||||
/**
|
||||
* Class CreditCard
|
||||
@@ -24,10 +26,14 @@ use PayPal\Transport\PayPalRestCall;
|
||||
* @property string last_name
|
||||
* @property \PayPal\Api\Address billing_address
|
||||
* @property string external_customer_id
|
||||
* @property string merchant_id
|
||||
* @property string payer_id
|
||||
* @property string external_card_id
|
||||
* @property string state
|
||||
* @property string valid_until
|
||||
* @property string create_time
|
||||
* @property string update_time
|
||||
* @property string valid_until
|
||||
* @property \PayPal\Api\Links[] links
|
||||
*/
|
||||
class CreditCard extends PayPalResourceModel
|
||||
{
|
||||
@@ -78,7 +84,8 @@ class CreditCard extends PayPalResourceModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Type of the Card (eg. Visa, Mastercard, etc.).
|
||||
* Type of the Card. Currently supporting Visa, Mastercard, Amex, Discover and Maestro
|
||||
* Valid Values: ["visa", "mastercard", "amex", "discover", "maestro"]
|
||||
*
|
||||
* @param string $type
|
||||
*
|
||||
@@ -91,7 +98,7 @@ class CreditCard extends PayPalResourceModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Type of the Card (eg. Visa, Mastercard, etc.).
|
||||
* Type of the Card. Currently supporting Visa, Mastercard, Amex, Discover and Maestro
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -261,6 +268,75 @@ class CreditCard extends PayPalResourceModel
|
||||
return $this->external_customer_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* A user provided, optional convenvience field that functions as a unique identifier for the merchant on behalf of whom this credit card is being stored for. Note that this has no relation to PayPal merchant id
|
||||
*
|
||||
* @param string $merchant_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMerchantId($merchant_id)
|
||||
{
|
||||
$this->merchant_id = $merchant_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A user provided, optional convenvience field that functions as a unique identifier for the merchant on behalf of whom this credit card is being stored for. Note that this has no relation to PayPal merchant id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMerchantId()
|
||||
{
|
||||
return $this->merchant_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* A unique identifier that you can assign and track when storing a credit card or using a stored credit card. This ID can help to avoid unintentional use or misuse of credit cards. This ID can be any value you would like to associate with the saved card, such as a UUID, username, or email address. Required when using a stored credit card if a payer_id was originally provided when storing the credit card in vault.
|
||||
* @deprecated This is being deprecated in favor of the `external_customer_id` property.
|
||||
* @param string $payer_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPayerId($payer_id)
|
||||
{
|
||||
$this->payer_id = $payer_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A unique identifier that you can assign and track when storing a credit card or using a stored credit card. This ID can help to avoid unintentional use or misuse of credit cards. This ID can be any value you would like to associate with the saved card, such as a UUID, username, or email address. Required when using a stored credit card if a payer_id was originally provided when storing the credit card in vault.
|
||||
* @deprecated This is being deprecated in favor of the `external_customer_id` property.
|
||||
* @return string
|
||||
*/
|
||||
public function getPayerId()
|
||||
{
|
||||
return $this->payer_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* A unique identifier of the bank account resource. Generated and provided by the facilitator so it can be used to restrict the usage of the bank account to the specific merchant.
|
||||
*
|
||||
* @param string $external_card_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setExternalCardId($external_card_id)
|
||||
{
|
||||
$this->external_card_id = $external_card_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A unique identifier of the bank account resource. Generated and provided by the facilitator so it can be used to restrict the usage of the bank account to the specific merchant.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExternalCardId()
|
||||
{
|
||||
return $this->external_card_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* State of the funding instrument.
|
||||
* Valid Values: ["expired", "ok"]
|
||||
@@ -285,6 +361,52 @@ class CreditCard extends PayPalResourceModel
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates creation time.
|
||||
*
|
||||
* @param string $create_time
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCreateTime($create_time)
|
||||
{
|
||||
$this->create_time = $create_time;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates creation time.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCreateTime()
|
||||
{
|
||||
return $this->create_time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates the updation time.
|
||||
*
|
||||
* @param string $update_time
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUpdateTime($update_time)
|
||||
{
|
||||
$this->update_time = $update_time;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates the updation time.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUpdateTime()
|
||||
{
|
||||
return $this->update_time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Date/Time until this resource can be used fund a payment.
|
||||
*
|
||||
@@ -308,52 +430,6 @@ class CreditCard extends PayPalResourceModel
|
||||
return $this->valid_until;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time the resource was created in UTC ISO8601 format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCreateTime()
|
||||
{
|
||||
return $this->create_time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time the resource was created in UTC ISO8601 format.
|
||||
*
|
||||
* @param string $update_time
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUpdateTime($update_time)
|
||||
{
|
||||
$this->update_time = $update_time;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time the resource was created in UTC ISO8601 format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUpdateTime()
|
||||
{
|
||||
return $this->update_time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Credit Card Resource (aka Tokenize).
|
||||
*
|
||||
@@ -448,4 +524,43 @@ class CreditCard extends PayPalResourceModel
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,
|
||||
);
|
||||
$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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace PayPal\Api;
|
||||
|
||||
use PayPal\Common\PayPalModel;
|
||||
use PayPal\Common\PayPalResourceModel;
|
||||
|
||||
/**
|
||||
* Class CreditCardList
|
||||
@@ -11,22 +11,23 @@ use PayPal\Common\PayPalModel;
|
||||
*
|
||||
* @package PayPal\Api
|
||||
*
|
||||
* @property \PayPal\Api\CreditCard[] credit_cards
|
||||
* @property int count
|
||||
* @property string next_id
|
||||
* @property \PayPal\Api\CreditCard[] items
|
||||
* @property \PayPal\Api\Links[] links
|
||||
* @property int total_items
|
||||
* @property int total_pages
|
||||
*/
|
||||
class CreditCardList extends PayPalModel
|
||||
class CreditCardList extends PayPalResourceModel
|
||||
{
|
||||
/**
|
||||
* A list of credit card resources
|
||||
*
|
||||
* @param \PayPal\Api\CreditCard[] $credit_cards
|
||||
* @param \PayPal\Api\CreditCard[] $items
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCreditCards($credit_cards)
|
||||
public function setItems($items)
|
||||
{
|
||||
$this->{"credit-cards"} = $credit_cards;
|
||||
$this->items = $items;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -35,85 +36,85 @@ class CreditCardList extends PayPalModel
|
||||
*
|
||||
* @return \PayPal\Api\CreditCard[]
|
||||
*/
|
||||
public function getCreditCards()
|
||||
public function getItems()
|
||||
{
|
||||
return $this->{"credit-cards"};
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append CreditCards to the list.
|
||||
* Append Items to the list.
|
||||
*
|
||||
* @param \PayPal\Api\CreditCard $creditCard
|
||||
* @return $this
|
||||
*/
|
||||
public function addCreditCard($creditCard)
|
||||
public function addItem($creditCard)
|
||||
{
|
||||
if (!$this->getCreditCards()) {
|
||||
return $this->setCreditCards(array($creditCard));
|
||||
if (!$this->getItems()) {
|
||||
return $this->setItems(array($creditCard));
|
||||
} else {
|
||||
return $this->setCreditCards(
|
||||
array_merge($this->getCreditCards(), array($creditCard))
|
||||
return $this->setItems(
|
||||
array_merge($this->getItems(), array($creditCard))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove CreditCards from the list.
|
||||
* Remove Items from the list.
|
||||
*
|
||||
* @param \PayPal\Api\CreditCard $creditCard
|
||||
* @return $this
|
||||
*/
|
||||
public function removeCreditCard($creditCard)
|
||||
public function removeItem($creditCard)
|
||||
{
|
||||
return $this->setCreditCards(
|
||||
array_diff($this->getCreditCards(), array($creditCard))
|
||||
return $this->setItems(
|
||||
array_diff($this->getItems(), array($creditCard))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
|
||||
* Total number of items present in the given list. Note that the number of items might be larger than the records in the current page.
|
||||
*
|
||||
* @param int $count
|
||||
* @param int $total_items
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCount($count)
|
||||
public function setTotalItems($total_items)
|
||||
{
|
||||
$this->count = $count;
|
||||
$this->total_items = $total_items;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
|
||||
* Total number of items present in the given list. Note that the number of items might be larger than the records in the current page.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCount()
|
||||
public function getTotalItems()
|
||||
{
|
||||
return $this->count;
|
||||
return $this->total_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier of the next element to get the next range of results.
|
||||
* Total number of pages that exist, for the total number of items, with the given page size.
|
||||
*
|
||||
* @param string $next_id
|
||||
* @param int $total_pages
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setNextId($next_id)
|
||||
public function setTotalPages($total_pages)
|
||||
{
|
||||
$this->next_id = $next_id;
|
||||
$this->total_pages = $total_pages;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier of the next element to get the next range of results.
|
||||
* Total number of pages that exist, for the total number of items, with the given page size.
|
||||
*
|
||||
* @return string
|
||||
* @return int
|
||||
*/
|
||||
public function getNextId()
|
||||
public function getTotalPages()
|
||||
{
|
||||
return $this->next_id;
|
||||
return $this->total_pages;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ use PayPal\Common\PayPalModel;
|
||||
class Patch extends PayPalModel
|
||||
{
|
||||
/**
|
||||
* Patch operation to perform.Value required for add & remove operation can be any JSON value.
|
||||
* Valid Values: ["add", "remove", "replace"]
|
||||
* The operation to perform.
|
||||
* Valid Values: ["add", "remove", "replace", "move", "copy", "test"]
|
||||
*
|
||||
* @param string $op
|
||||
*
|
||||
@@ -33,7 +33,7 @@ class Patch extends PayPalModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Patch operation to perform.Value required for add & remove operation can be any JSON value.
|
||||
* The operation to perform.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -43,7 +43,7 @@ class Patch extends PayPalModel
|
||||
}
|
||||
|
||||
/**
|
||||
* string containing a JSON-Pointer value that references a location within the target document (the target location) where the operation is performed.
|
||||
* String containing a JSON-Pointer value that references a location within the target document where the operation is performed.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
@@ -56,7 +56,7 @@ class Patch extends PayPalModel
|
||||
}
|
||||
|
||||
/**
|
||||
* string containing a JSON-Pointer value that references a location within the target document (the target location) where the operation is performed.
|
||||
* String containing a JSON-Pointer value that references a location within the target document where the operation is performed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -89,7 +89,7 @@ class Patch extends PayPalModel
|
||||
}
|
||||
|
||||
/**
|
||||
* A string containing a JSON Pointer value that references the location in the target document to move the value from.
|
||||
* A string containing a JSON Pointer value that references the location in the target document from which to move the value. Required for use where op=move.
|
||||
*
|
||||
* @param string $from
|
||||
*
|
||||
@@ -102,7 +102,7 @@ class Patch extends PayPalModel
|
||||
}
|
||||
|
||||
/**
|
||||
* A string containing a JSON Pointer value that references the location in the target document to move the value from.
|
||||
* A string containing a JSON Pointer value that references the location in the target document from which to move the value. Required for use where op=move.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user