forked from LiveCarta/PayPal-PHP-SDK
Updating model classes to use dynamic config - Moving common classes to sdk-core-php
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
"php": ">=5.3.0",
|
"php": ">=5.3.0",
|
||||||
"ext-curl": "*",
|
"ext-curl": "*",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"paypal/sdk-core-php": "1.2.*"
|
"paypal/sdk-core-php": "dev-openidconnect"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "3.7.*"
|
"phpunit/phpunit": "3.7.*"
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class Address extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for line1
|
* Getter for line1
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getLine1() {
|
public function getLine1() {
|
||||||
return $this->line1;
|
return $this->line1;
|
||||||
@@ -33,6 +34,7 @@ class Address extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for line2
|
* Getter for line2
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getLine2() {
|
public function getLine2() {
|
||||||
return $this->line2;
|
return $this->line2;
|
||||||
@@ -48,6 +50,7 @@ class Address extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for city
|
* Getter for city
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCity() {
|
public function getCity() {
|
||||||
return $this->city;
|
return $this->city;
|
||||||
@@ -63,6 +66,7 @@ class Address extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for state
|
* Getter for state
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getState() {
|
public function getState() {
|
||||||
return $this->state;
|
return $this->state;
|
||||||
@@ -78,6 +82,7 @@ class Address extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for postal_code
|
* Getter for postal_code
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPostal_code() {
|
public function getPostal_code() {
|
||||||
return $this->postal_code;
|
return $this->postal_code;
|
||||||
@@ -93,6 +98,7 @@ class Address extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for country_code
|
* Getter for country_code
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCountry_code() {
|
public function getCountry_code() {
|
||||||
return $this->country_code;
|
return $this->country_code;
|
||||||
@@ -108,6 +114,7 @@ class Address extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for type
|
* Getter for type
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getType() {
|
public function getType() {
|
||||||
return $this->type;
|
return $this->type;
|
||||||
@@ -123,6 +130,7 @@ class Address extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for phone
|
* Getter for phone
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPhone() {
|
public function getPhone() {
|
||||||
return $this->phone;
|
return $this->phone;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class Amount extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for total
|
* Getter for total
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTotal() {
|
public function getTotal() {
|
||||||
return $this->total;
|
return $this->total;
|
||||||
@@ -33,6 +34,7 @@ class Amount extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for currency
|
* Getter for currency
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCurrency() {
|
public function getCurrency() {
|
||||||
return $this->currency;
|
return $this->currency;
|
||||||
@@ -48,6 +50,7 @@ class Amount extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for details
|
* Getter for details
|
||||||
|
* @return PayPal\Api\AmountDetails
|
||||||
*/
|
*/
|
||||||
public function getDetails() {
|
public function getDetails() {
|
||||||
return $this->details;
|
return $this->details;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class AmountDetails extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for subtotal
|
* Getter for subtotal
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getSubtotal() {
|
public function getSubtotal() {
|
||||||
return $this->subtotal;
|
return $this->subtotal;
|
||||||
@@ -33,6 +34,7 @@ class AmountDetails extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for tax
|
* Getter for tax
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTax() {
|
public function getTax() {
|
||||||
return $this->tax;
|
return $this->tax;
|
||||||
@@ -48,6 +50,7 @@ class AmountDetails extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for shipping
|
* Getter for shipping
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getShipping() {
|
public function getShipping() {
|
||||||
return $this->shipping;
|
return $this->shipping;
|
||||||
@@ -63,6 +66,7 @@ class AmountDetails extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for fee
|
* Getter for fee
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getFee() {
|
public function getFee() {
|
||||||
return $this->fee;
|
return $this->fee;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class Authorization extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for id
|
* Getter for id
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getId() {
|
public function getId() {
|
||||||
return $this->id;
|
return $this->id;
|
||||||
@@ -33,6 +34,7 @@ class Authorization extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for create_time
|
* Getter for create_time
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCreate_time() {
|
public function getCreate_time() {
|
||||||
return $this->create_time;
|
return $this->create_time;
|
||||||
@@ -48,6 +50,7 @@ class Authorization extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for update_time
|
* Getter for update_time
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUpdate_time() {
|
public function getUpdate_time() {
|
||||||
return $this->update_time;
|
return $this->update_time;
|
||||||
@@ -63,6 +66,7 @@ class Authorization extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for state
|
* Getter for state
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getState() {
|
public function getState() {
|
||||||
return $this->state;
|
return $this->state;
|
||||||
@@ -78,6 +82,7 @@ class Authorization extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for amount
|
* Getter for amount
|
||||||
|
* @return PayPal\Api\Amount
|
||||||
*/
|
*/
|
||||||
public function getAmount() {
|
public function getAmount() {
|
||||||
return $this->amount;
|
return $this->amount;
|
||||||
@@ -93,6 +98,7 @@ class Authorization extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for parent_payment
|
* Getter for parent_payment
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getParent_payment() {
|
public function getParent_payment() {
|
||||||
return $this->parent_payment;
|
return $this->parent_payment;
|
||||||
@@ -108,6 +114,7 @@ class Authorization extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for links
|
* Getter for links
|
||||||
|
* @return PayPal\Api\Link
|
||||||
*/
|
*/
|
||||||
public function getLinks() {
|
public function getLinks() {
|
||||||
return $this->links;
|
return $this->links;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class Capture extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for id
|
* Getter for id
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getId() {
|
public function getId() {
|
||||||
return $this->id;
|
return $this->id;
|
||||||
@@ -33,6 +34,7 @@ class Capture extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for create_time
|
* Getter for create_time
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCreate_time() {
|
public function getCreate_time() {
|
||||||
return $this->create_time;
|
return $this->create_time;
|
||||||
@@ -48,6 +50,7 @@ class Capture extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for update_time
|
* Getter for update_time
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUpdate_time() {
|
public function getUpdate_time() {
|
||||||
return $this->update_time;
|
return $this->update_time;
|
||||||
@@ -63,6 +66,7 @@ class Capture extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for state
|
* Getter for state
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getState() {
|
public function getState() {
|
||||||
return $this->state;
|
return $this->state;
|
||||||
@@ -78,6 +82,7 @@ class Capture extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for amount
|
* Getter for amount
|
||||||
|
* @return PayPal\Api\Amount
|
||||||
*/
|
*/
|
||||||
public function getAmount() {
|
public function getAmount() {
|
||||||
return $this->amount;
|
return $this->amount;
|
||||||
@@ -93,6 +98,7 @@ class Capture extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for parent_payment
|
* Getter for parent_payment
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getParent_payment() {
|
public function getParent_payment() {
|
||||||
return $this->parent_payment;
|
return $this->parent_payment;
|
||||||
@@ -108,6 +114,7 @@ class Capture extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for authorization_id
|
* Getter for authorization_id
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getAuthorization_id() {
|
public function getAuthorization_id() {
|
||||||
return $this->authorization_id;
|
return $this->authorization_id;
|
||||||
@@ -123,6 +130,7 @@ class Capture extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for description
|
* Getter for description
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getDescription() {
|
public function getDescription() {
|
||||||
return $this->description;
|
return $this->description;
|
||||||
@@ -138,6 +146,7 @@ class Capture extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for links
|
* Getter for links
|
||||||
|
* @return PayPal\Api\Link
|
||||||
*/
|
*/
|
||||||
public function getLinks() {
|
public function getLinks() {
|
||||||
return $this->links;
|
return $this->links;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class CreditCard extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for id
|
* Getter for id
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getId() {
|
public function getId() {
|
||||||
return $this->id;
|
return $this->id;
|
||||||
@@ -41,6 +42,7 @@ class CreditCard extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for valid_until
|
* Getter for valid_until
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getValid_until() {
|
public function getValid_until() {
|
||||||
return $this->valid_until;
|
return $this->valid_until;
|
||||||
@@ -56,6 +58,7 @@ class CreditCard extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for state
|
* Getter for state
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getState() {
|
public function getState() {
|
||||||
return $this->state;
|
return $this->state;
|
||||||
@@ -71,6 +74,7 @@ class CreditCard extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for payer_id
|
* Getter for payer_id
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPayer_id() {
|
public function getPayer_id() {
|
||||||
return $this->payer_id;
|
return $this->payer_id;
|
||||||
@@ -86,6 +90,7 @@ class CreditCard extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for type
|
* Getter for type
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getType() {
|
public function getType() {
|
||||||
return $this->type;
|
return $this->type;
|
||||||
@@ -101,6 +106,7 @@ class CreditCard extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for number
|
* Getter for number
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getNumber() {
|
public function getNumber() {
|
||||||
return $this->number;
|
return $this->number;
|
||||||
@@ -116,6 +122,7 @@ class CreditCard extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for expire_month
|
* Getter for expire_month
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getExpire_month() {
|
public function getExpire_month() {
|
||||||
return $this->expire_month;
|
return $this->expire_month;
|
||||||
@@ -131,6 +138,7 @@ class CreditCard extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for expire_year
|
* Getter for expire_year
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getExpire_year() {
|
public function getExpire_year() {
|
||||||
return $this->expire_year;
|
return $this->expire_year;
|
||||||
@@ -146,6 +154,7 @@ class CreditCard extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for cvv2
|
* Getter for cvv2
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCvv2() {
|
public function getCvv2() {
|
||||||
return $this->cvv2;
|
return $this->cvv2;
|
||||||
@@ -161,6 +170,7 @@ class CreditCard extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for first_name
|
* Getter for first_name
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getFirst_name() {
|
public function getFirst_name() {
|
||||||
return $this->first_name;
|
return $this->first_name;
|
||||||
@@ -176,6 +186,7 @@ class CreditCard extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for last_name
|
* Getter for last_name
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getLast_name() {
|
public function getLast_name() {
|
||||||
return $this->last_name;
|
return $this->last_name;
|
||||||
@@ -191,6 +202,7 @@ class CreditCard extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for billing_address
|
* Getter for billing_address
|
||||||
|
* @return PayPal\Api\Address
|
||||||
*/
|
*/
|
||||||
public function getBilling_address() {
|
public function getBilling_address() {
|
||||||
return $this->billing_address;
|
return $this->billing_address;
|
||||||
@@ -206,6 +218,7 @@ class CreditCard extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for links
|
* Getter for links
|
||||||
|
* @return PayPal\Api\Link
|
||||||
*/
|
*/
|
||||||
public function getLinks() {
|
public function getLinks() {
|
||||||
return $this->links;
|
return $this->links;
|
||||||
@@ -224,8 +237,10 @@ class CreditCard extends Resource implements IResource {
|
|||||||
if($apiContext == null) {
|
if($apiContext == null) {
|
||||||
$apiContext = new ApiContext(self::$credential);
|
$apiContext = new ApiContext(self::$credential);
|
||||||
}
|
}
|
||||||
$call = new Call();
|
$call = new \PPRestCall();
|
||||||
$json = $call->execute("/v1/vault/credit-card", "POST", $payLoad, $apiContext);
|
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
|
||||||
|
"/v1/vault/credit-card",
|
||||||
|
"POST", $payLoad);
|
||||||
$this->fromJson($json);
|
$this->fromJson($json);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -241,8 +256,10 @@ class CreditCard extends Resource implements IResource {
|
|||||||
}
|
}
|
||||||
$payLoad = "";
|
$payLoad = "";
|
||||||
|
|
||||||
$apiContext = new ApiContext(self::$credential); $call = new Call();
|
$apiContext = new ApiContext(self::$credential); $call = new \PPRestCall();
|
||||||
$json = $call->execute("/v1/vault/credit-card/$creditcardid", "GET", $payLoad, $apiContext);
|
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
|
||||||
|
"/v1/vault/credit-card/$creditcardid",
|
||||||
|
"GET", $payLoad);
|
||||||
$ret = new CreditCard();
|
$ret = new CreditCard();
|
||||||
$ret->fromJson($json);
|
$ret->fromJson($json);
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class CreditCardToken extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for credit_card_id
|
* Getter for credit_card_id
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCredit_card_id() {
|
public function getCredit_card_id() {
|
||||||
return $this->credit_card_id;
|
return $this->credit_card_id;
|
||||||
@@ -33,6 +34,7 @@ class CreditCardToken extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for payer_id
|
* Getter for payer_id
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPayer_id() {
|
public function getPayer_id() {
|
||||||
return $this->payer_id;
|
return $this->payer_id;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class FundingInstrument extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for credit_card
|
* Getter for credit_card
|
||||||
|
* @return PayPal\Api\CreditCard
|
||||||
*/
|
*/
|
||||||
public function getCredit_card() {
|
public function getCredit_card() {
|
||||||
return $this->credit_card;
|
return $this->credit_card;
|
||||||
@@ -33,6 +34,7 @@ class FundingInstrument extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for credit_card_token
|
* Getter for credit_card_token
|
||||||
|
* @return PayPal\Api\CreditCardToken
|
||||||
*/
|
*/
|
||||||
public function getCredit_card_token() {
|
public function getCredit_card_token() {
|
||||||
return $this->credit_card_token;
|
return $this->credit_card_token;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class Item extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for name
|
* Getter for name
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getName() {
|
public function getName() {
|
||||||
return $this->name;
|
return $this->name;
|
||||||
@@ -33,6 +34,7 @@ class Item extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for sku
|
* Getter for sku
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getSku() {
|
public function getSku() {
|
||||||
return $this->sku;
|
return $this->sku;
|
||||||
@@ -48,6 +50,7 @@ class Item extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for price
|
* Getter for price
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPrice() {
|
public function getPrice() {
|
||||||
return $this->price;
|
return $this->price;
|
||||||
@@ -63,6 +66,7 @@ class Item extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for currency
|
* Getter for currency
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCurrency() {
|
public function getCurrency() {
|
||||||
return $this->currency;
|
return $this->currency;
|
||||||
@@ -78,6 +82,7 @@ class Item extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for quantity
|
* Getter for quantity
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getQuantity() {
|
public function getQuantity() {
|
||||||
return $this->quantity;
|
return $this->quantity;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class ItemList extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for items
|
* Getter for items
|
||||||
|
* @return PayPal\Api\Item
|
||||||
*/
|
*/
|
||||||
public function getItems() {
|
public function getItems() {
|
||||||
return $this->items;
|
return $this->items;
|
||||||
@@ -33,6 +34,7 @@ class ItemList extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for shipping_address
|
* Getter for shipping_address
|
||||||
|
* @return PayPal\Api\ShippingAddress
|
||||||
*/
|
*/
|
||||||
public function getShipping_address() {
|
public function getShipping_address() {
|
||||||
return $this->shipping_address;
|
return $this->shipping_address;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class Link extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for href
|
* Getter for href
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getHref() {
|
public function getHref() {
|
||||||
return $this->href;
|
return $this->href;
|
||||||
@@ -33,6 +34,7 @@ class Link extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for rel
|
* Getter for rel
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getRel() {
|
public function getRel() {
|
||||||
return $this->rel;
|
return $this->rel;
|
||||||
@@ -48,6 +50,7 @@ class Link extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for method
|
* Getter for method
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getMethod() {
|
public function getMethod() {
|
||||||
return $this->method;
|
return $this->method;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class Payee extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for merchant_id
|
* Getter for merchant_id
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getMerchant_id() {
|
public function getMerchant_id() {
|
||||||
return $this->merchant_id;
|
return $this->merchant_id;
|
||||||
@@ -33,6 +34,7 @@ class Payee extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for email
|
* Getter for email
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getEmail() {
|
public function getEmail() {
|
||||||
return $this->email;
|
return $this->email;
|
||||||
@@ -48,6 +50,7 @@ class Payee extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for phone
|
* Getter for phone
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPhone() {
|
public function getPhone() {
|
||||||
return $this->phone;
|
return $this->phone;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class Payer extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for payment_method
|
* Getter for payment_method
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPayment_method() {
|
public function getPayment_method() {
|
||||||
return $this->payment_method;
|
return $this->payment_method;
|
||||||
@@ -33,6 +34,7 @@ class Payer extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for payer_info
|
* Getter for payer_info
|
||||||
|
* @return PayPal\Api\PayerInfo
|
||||||
*/
|
*/
|
||||||
public function getPayer_info() {
|
public function getPayer_info() {
|
||||||
return $this->payer_info;
|
return $this->payer_info;
|
||||||
@@ -48,6 +50,7 @@ class Payer extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for funding_instruments
|
* Getter for funding_instruments
|
||||||
|
* @return PayPal\Api\FundingInstrument
|
||||||
*/
|
*/
|
||||||
public function getFunding_instruments() {
|
public function getFunding_instruments() {
|
||||||
return $this->funding_instruments;
|
return $this->funding_instruments;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class PayerInfo extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for email
|
* Getter for email
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getEmail() {
|
public function getEmail() {
|
||||||
return $this->email;
|
return $this->email;
|
||||||
@@ -33,6 +34,7 @@ class PayerInfo extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for first_name
|
* Getter for first_name
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getFirst_name() {
|
public function getFirst_name() {
|
||||||
return $this->first_name;
|
return $this->first_name;
|
||||||
@@ -48,6 +50,7 @@ class PayerInfo extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for last_name
|
* Getter for last_name
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getLast_name() {
|
public function getLast_name() {
|
||||||
return $this->last_name;
|
return $this->last_name;
|
||||||
@@ -63,6 +66,7 @@ class PayerInfo extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for payer_id
|
* Getter for payer_id
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPayer_id() {
|
public function getPayer_id() {
|
||||||
return $this->payer_id;
|
return $this->payer_id;
|
||||||
@@ -78,6 +82,7 @@ class PayerInfo extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for shipping_address
|
* Getter for shipping_address
|
||||||
|
* @return PayPal\Api\Address
|
||||||
*/
|
*/
|
||||||
public function getShipping_address() {
|
public function getShipping_address() {
|
||||||
return $this->shipping_address;
|
return $this->shipping_address;
|
||||||
@@ -93,6 +98,7 @@ class PayerInfo extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for phone
|
* Getter for phone
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPhone() {
|
public function getPhone() {
|
||||||
return $this->phone;
|
return $this->phone;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class Payment extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for id
|
* Getter for id
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getId() {
|
public function getId() {
|
||||||
return $this->id;
|
return $this->id;
|
||||||
@@ -41,6 +42,7 @@ class Payment extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for create_time
|
* Getter for create_time
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCreate_time() {
|
public function getCreate_time() {
|
||||||
return $this->create_time;
|
return $this->create_time;
|
||||||
@@ -56,6 +58,7 @@ class Payment extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for update_time
|
* Getter for update_time
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUpdate_time() {
|
public function getUpdate_time() {
|
||||||
return $this->update_time;
|
return $this->update_time;
|
||||||
@@ -71,6 +74,7 @@ class Payment extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for state
|
* Getter for state
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getState() {
|
public function getState() {
|
||||||
return $this->state;
|
return $this->state;
|
||||||
@@ -86,6 +90,7 @@ class Payment extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for intent
|
* Getter for intent
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getIntent() {
|
public function getIntent() {
|
||||||
return $this->intent;
|
return $this->intent;
|
||||||
@@ -101,6 +106,7 @@ class Payment extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for payer
|
* Getter for payer
|
||||||
|
* @return PayPal\Api\Payer
|
||||||
*/
|
*/
|
||||||
public function getPayer() {
|
public function getPayer() {
|
||||||
return $this->payer;
|
return $this->payer;
|
||||||
@@ -116,6 +122,7 @@ class Payment extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for transactions
|
* Getter for transactions
|
||||||
|
* @return PayPal\Api\Transaction
|
||||||
*/
|
*/
|
||||||
public function getTransactions() {
|
public function getTransactions() {
|
||||||
return $this->transactions;
|
return $this->transactions;
|
||||||
@@ -131,6 +138,7 @@ class Payment extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for redirect_urls
|
* Getter for redirect_urls
|
||||||
|
* @return PayPal\Api\RedirectUrls
|
||||||
*/
|
*/
|
||||||
public function getRedirect_urls() {
|
public function getRedirect_urls() {
|
||||||
return $this->redirect_urls;
|
return $this->redirect_urls;
|
||||||
@@ -146,6 +154,7 @@ class Payment extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for links
|
* Getter for links
|
||||||
|
* @return PayPal\Api\Link
|
||||||
*/
|
*/
|
||||||
public function getLinks() {
|
public function getLinks() {
|
||||||
return $this->links;
|
return $this->links;
|
||||||
@@ -173,8 +182,10 @@ class Payment extends Resource implements IResource {
|
|||||||
$payLoad = "";
|
$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, );
|
$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, );
|
||||||
|
|
||||||
$apiContext = new ApiContext(self::$credential); $call = new Call();
|
$apiContext = new ApiContext(self::$credential); $call = new \PPRestCall();
|
||||||
$json = $call->execute("/v1/payments/payment?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, $apiContext);
|
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
|
||||||
|
"/v1/payments/payment?" . http_build_query(array_intersect_key($params, $allowedParams)),
|
||||||
|
"GET", $payLoad);
|
||||||
$ret = new PaymentHistory();
|
$ret = new PaymentHistory();
|
||||||
$ret->fromJson($json);
|
$ret->fromJson($json);
|
||||||
return $ret;
|
return $ret;
|
||||||
@@ -192,8 +203,10 @@ class Payment extends Resource implements IResource {
|
|||||||
if($apiContext == null) {
|
if($apiContext == null) {
|
||||||
$apiContext = new ApiContext(self::$credential);
|
$apiContext = new ApiContext(self::$credential);
|
||||||
}
|
}
|
||||||
$call = new Call();
|
$call = new \PPRestCall();
|
||||||
$json = $call->execute("/v1/payments/payment", "POST", $payLoad, $apiContext);
|
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
|
||||||
|
"/v1/payments/payment",
|
||||||
|
"POST", $payLoad);
|
||||||
$this->fromJson($json);
|
$this->fromJson($json);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -209,8 +222,10 @@ class Payment extends Resource implements IResource {
|
|||||||
}
|
}
|
||||||
$payLoad = "";
|
$payLoad = "";
|
||||||
|
|
||||||
$apiContext = new ApiContext(self::$credential); $call = new Call();
|
$apiContext = new ApiContext(self::$credential); $call = new \PPRestCall();
|
||||||
$json = $call->execute("/v1/payments/payment/$paymentid", "GET", $payLoad, $apiContext);
|
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
|
||||||
|
"/v1/payments/payment/$paymentid",
|
||||||
|
"GET", $payLoad);
|
||||||
$ret = new Payment();
|
$ret = new Payment();
|
||||||
$ret->fromJson($json);
|
$ret->fromJson($json);
|
||||||
return $ret;
|
return $ret;
|
||||||
@@ -234,8 +249,10 @@ class Payment extends Resource implements IResource {
|
|||||||
if($apiContext == null) {
|
if($apiContext == null) {
|
||||||
$apiContext = new ApiContext(self::$credential);
|
$apiContext = new ApiContext(self::$credential);
|
||||||
}
|
}
|
||||||
$call = new Call();
|
$call = new \PPRestCall();
|
||||||
$json = $call->execute("/v1/payments/payment/{$this->getId()}/execute", "POST", $payLoad, $apiContext);
|
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
|
||||||
|
"/v1/payments/payment/{$this->getId()}/execute",
|
||||||
|
"POST", $payLoad);
|
||||||
$this->fromJson($json);
|
$this->fromJson($json);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class PaymentExecution extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for payer_id
|
* Getter for payer_id
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPayer_id() {
|
public function getPayer_id() {
|
||||||
return $this->payer_id;
|
return $this->payer_id;
|
||||||
@@ -33,6 +34,7 @@ class PaymentExecution extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for transactions
|
* Getter for transactions
|
||||||
|
* @return PayPal\Api\Amount
|
||||||
*/
|
*/
|
||||||
public function getTransactions() {
|
public function getTransactions() {
|
||||||
return $this->transactions;
|
return $this->transactions;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class PaymentHistory extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for payments
|
* Getter for payments
|
||||||
|
* @return PayPal\Api\Payment
|
||||||
*/
|
*/
|
||||||
public function getPayments() {
|
public function getPayments() {
|
||||||
return $this->payments;
|
return $this->payments;
|
||||||
@@ -33,6 +34,7 @@ class PaymentHistory extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for count
|
* Getter for count
|
||||||
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getCount() {
|
public function getCount() {
|
||||||
return $this->count;
|
return $this->count;
|
||||||
@@ -48,6 +50,7 @@ class PaymentHistory extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for next_id
|
* Getter for next_id
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getNext_id() {
|
public function getNext_id() {
|
||||||
return $this->next_id;
|
return $this->next_id;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class RedirectUrls extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for return_url
|
* Getter for return_url
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getReturn_url() {
|
public function getReturn_url() {
|
||||||
return $this->return_url;
|
return $this->return_url;
|
||||||
@@ -33,6 +34,7 @@ class RedirectUrls extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for cancel_url
|
* Getter for cancel_url
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCancel_url() {
|
public function getCancel_url() {
|
||||||
return $this->cancel_url;
|
return $this->cancel_url;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class Refund extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for id
|
* Getter for id
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getId() {
|
public function getId() {
|
||||||
return $this->id;
|
return $this->id;
|
||||||
@@ -41,6 +42,7 @@ class Refund extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for create_time
|
* Getter for create_time
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCreate_time() {
|
public function getCreate_time() {
|
||||||
return $this->create_time;
|
return $this->create_time;
|
||||||
@@ -56,6 +58,7 @@ class Refund extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for update_time
|
* Getter for update_time
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUpdate_time() {
|
public function getUpdate_time() {
|
||||||
return $this->update_time;
|
return $this->update_time;
|
||||||
@@ -71,6 +74,7 @@ class Refund extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for state
|
* Getter for state
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getState() {
|
public function getState() {
|
||||||
return $this->state;
|
return $this->state;
|
||||||
@@ -86,6 +90,7 @@ class Refund extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for amount
|
* Getter for amount
|
||||||
|
* @return PayPal\Api\Amount
|
||||||
*/
|
*/
|
||||||
public function getAmount() {
|
public function getAmount() {
|
||||||
return $this->amount;
|
return $this->amount;
|
||||||
@@ -101,6 +106,7 @@ class Refund extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for sale_id
|
* Getter for sale_id
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getSale_id() {
|
public function getSale_id() {
|
||||||
return $this->sale_id;
|
return $this->sale_id;
|
||||||
@@ -116,6 +122,7 @@ class Refund extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for capture_id
|
* Getter for capture_id
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCapture_id() {
|
public function getCapture_id() {
|
||||||
return $this->capture_id;
|
return $this->capture_id;
|
||||||
@@ -131,6 +138,7 @@ class Refund extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for parent_payment
|
* Getter for parent_payment
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getParent_payment() {
|
public function getParent_payment() {
|
||||||
return $this->parent_payment;
|
return $this->parent_payment;
|
||||||
@@ -146,6 +154,7 @@ class Refund extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for description
|
* Getter for description
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getDescription() {
|
public function getDescription() {
|
||||||
return $this->description;
|
return $this->description;
|
||||||
@@ -161,6 +170,7 @@ class Refund extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for links
|
* Getter for links
|
||||||
|
* @return PayPal\Api\Link
|
||||||
*/
|
*/
|
||||||
public function getLinks() {
|
public function getLinks() {
|
||||||
return $this->links;
|
return $this->links;
|
||||||
@@ -179,8 +189,10 @@ class Refund extends Resource implements IResource {
|
|||||||
}
|
}
|
||||||
$payLoad = "";
|
$payLoad = "";
|
||||||
|
|
||||||
$apiContext = new ApiContext(self::$credential); $call = new Call();
|
$apiContext = new ApiContext(self::$credential); $call = new \PPRestCall();
|
||||||
$json = $call->execute("/v1/payments/refund/$refundid", "GET", $payLoad, $apiContext);
|
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
|
||||||
|
"/v1/payments/refund/$refundid",
|
||||||
|
"GET", $payLoad);
|
||||||
$ret = new Refund();
|
$ret = new Refund();
|
||||||
$ret->fromJson($json);
|
$ret->fromJson($json);
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace PayPal\Api;
|
namespace PayPal\Api;
|
||||||
use PayPal\Common\Model;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Resource extends Model {
|
class Resource extends \PPModel {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class Sale extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for id
|
* Getter for id
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getId() {
|
public function getId() {
|
||||||
return $this->id;
|
return $this->id;
|
||||||
@@ -41,6 +42,7 @@ class Sale extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for create_time
|
* Getter for create_time
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCreate_time() {
|
public function getCreate_time() {
|
||||||
return $this->create_time;
|
return $this->create_time;
|
||||||
@@ -56,6 +58,7 @@ class Sale extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for update_time
|
* Getter for update_time
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUpdate_time() {
|
public function getUpdate_time() {
|
||||||
return $this->update_time;
|
return $this->update_time;
|
||||||
@@ -71,6 +74,7 @@ class Sale extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for state
|
* Getter for state
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getState() {
|
public function getState() {
|
||||||
return $this->state;
|
return $this->state;
|
||||||
@@ -86,6 +90,7 @@ class Sale extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for amount
|
* Getter for amount
|
||||||
|
* @return PayPal\Api\Amount
|
||||||
*/
|
*/
|
||||||
public function getAmount() {
|
public function getAmount() {
|
||||||
return $this->amount;
|
return $this->amount;
|
||||||
@@ -101,6 +106,7 @@ class Sale extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for parent_payment
|
* Getter for parent_payment
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getParent_payment() {
|
public function getParent_payment() {
|
||||||
return $this->parent_payment;
|
return $this->parent_payment;
|
||||||
@@ -116,6 +122,7 @@ class Sale extends Resource implements IResource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for links
|
* Getter for links
|
||||||
|
* @return PayPal\Api\Link
|
||||||
*/
|
*/
|
||||||
public function getLinks() {
|
public function getLinks() {
|
||||||
return $this->links;
|
return $this->links;
|
||||||
@@ -134,8 +141,10 @@ class Sale extends Resource implements IResource {
|
|||||||
}
|
}
|
||||||
$payLoad = "";
|
$payLoad = "";
|
||||||
|
|
||||||
$apiContext = new ApiContext(self::$credential); $call = new Call();
|
$apiContext = new ApiContext(self::$credential); $call = new \PPRestCall();
|
||||||
$json = $call->execute("/v1/payments/sale/$saleid", "GET", $payLoad, $apiContext);
|
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
|
||||||
|
"/v1/payments/sale/$saleid",
|
||||||
|
"GET", $payLoad);
|
||||||
$ret = new Sale();
|
$ret = new Sale();
|
||||||
$ret->fromJson($json);
|
$ret->fromJson($json);
|
||||||
return $ret;
|
return $ret;
|
||||||
@@ -159,8 +168,10 @@ class Sale extends Resource implements IResource {
|
|||||||
if($apiContext == null) {
|
if($apiContext == null) {
|
||||||
$apiContext = new ApiContext(self::$credential);
|
$apiContext = new ApiContext(self::$credential);
|
||||||
}
|
}
|
||||||
$call = new Call();
|
$call = new \PPRestCall();
|
||||||
$json = $call->execute("/v1/payments/sale/{$this->getId()}/refund", "POST", $payLoad, $apiContext);
|
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
|
||||||
|
"/v1/payments/sale/{$this->getId()}/refund",
|
||||||
|
"POST", $payLoad);
|
||||||
$this->fromJson($json);
|
$this->fromJson($json);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class ShippingAddress extends Address {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for recipient_name
|
* Getter for recipient_name
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getRecipient_name() {
|
public function getRecipient_name() {
|
||||||
return $this->recipient_name;
|
return $this->recipient_name;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class SubTransaction extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for sale
|
* Getter for sale
|
||||||
|
* @return PayPal\Api\Sale
|
||||||
*/
|
*/
|
||||||
public function getSale() {
|
public function getSale() {
|
||||||
return $this->sale;
|
return $this->sale;
|
||||||
@@ -33,6 +34,7 @@ class SubTransaction extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for authorization
|
* Getter for authorization
|
||||||
|
* @return PayPal\Api\Authorization
|
||||||
*/
|
*/
|
||||||
public function getAuthorization() {
|
public function getAuthorization() {
|
||||||
return $this->authorization;
|
return $this->authorization;
|
||||||
@@ -48,6 +50,7 @@ class SubTransaction extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for refund
|
* Getter for refund
|
||||||
|
* @return PayPal\Api\Refund
|
||||||
*/
|
*/
|
||||||
public function getRefund() {
|
public function getRefund() {
|
||||||
return $this->refund;
|
return $this->refund;
|
||||||
@@ -63,6 +66,7 @@ class SubTransaction extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for capture
|
* Getter for capture
|
||||||
|
* @return PayPal\Api\Capture
|
||||||
*/
|
*/
|
||||||
public function getCapture() {
|
public function getCapture() {
|
||||||
return $this->capture;
|
return $this->capture;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class Transaction extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for amount
|
* Getter for amount
|
||||||
|
* @return PayPal\Api\Amount
|
||||||
*/
|
*/
|
||||||
public function getAmount() {
|
public function getAmount() {
|
||||||
return $this->amount;
|
return $this->amount;
|
||||||
@@ -33,6 +34,7 @@ class Transaction extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for payee
|
* Getter for payee
|
||||||
|
* @return PayPal\Api\Payee
|
||||||
*/
|
*/
|
||||||
public function getPayee() {
|
public function getPayee() {
|
||||||
return $this->payee;
|
return $this->payee;
|
||||||
@@ -48,6 +50,7 @@ class Transaction extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for description
|
* Getter for description
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getDescription() {
|
public function getDescription() {
|
||||||
return $this->description;
|
return $this->description;
|
||||||
@@ -63,6 +66,7 @@ class Transaction extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for item_list
|
* Getter for item_list
|
||||||
|
* @return PayPal\Api\ItemList
|
||||||
*/
|
*/
|
||||||
public function getItem_list() {
|
public function getItem_list() {
|
||||||
return $this->item_list;
|
return $this->item_list;
|
||||||
@@ -78,6 +82,7 @@ class Transaction extends Resource {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for related_resources
|
* Getter for related_resources
|
||||||
|
* @return PayPal\Api\SubTransaction
|
||||||
*/
|
*/
|
||||||
public function getRelated_resources() {
|
public function getRelated_resources() {
|
||||||
return $this->related_resources;
|
return $this->related_resources;
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ namespace PayPal\Auth;
|
|||||||
* Oauth Token credential
|
* Oauth Token credential
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
use PayPal\Rest\RestHandler;
|
||||||
|
|
||||||
|
use PayPal\Common\UserAgent;
|
||||||
|
|
||||||
class OAuthTokenCredential {
|
class OAuthTokenCredential {
|
||||||
|
|
||||||
private static $expiryBufferTime = 120;
|
private static $expiryBufferTime = 120;
|
||||||
@@ -52,7 +56,7 @@ class OAuthTokenCredential {
|
|||||||
/**
|
/**
|
||||||
* @return the accessToken
|
* @return the accessToken
|
||||||
*/
|
*/
|
||||||
public function getAccessToken() {
|
public function getAccessToken($config) {
|
||||||
// Check if Access Token is not null and has not expired.
|
// Check if Access Token is not null and has not expired.
|
||||||
// The API returns expiry time as a relative time unit
|
// The API returns expiry time as a relative time unit
|
||||||
// We use a buffer time when checking for token expiry to account
|
// We use a buffer time when checking for token expiry to account
|
||||||
@@ -64,7 +68,7 @@ class OAuthTokenCredential {
|
|||||||
}
|
}
|
||||||
// If accessToken is Null, obtain a new token
|
// If accessToken is Null, obtain a new token
|
||||||
if ($this->accessToken == null) {
|
if ($this->accessToken == null) {
|
||||||
$this->generateAccessToken();
|
$this->_generateAccessToken($config);
|
||||||
}
|
}
|
||||||
return $this->accessToken;
|
return $this->accessToken;
|
||||||
}
|
}
|
||||||
@@ -72,23 +76,18 @@ class OAuthTokenCredential {
|
|||||||
/**
|
/**
|
||||||
* Generates a new access token
|
* Generates a new access token
|
||||||
*/
|
*/
|
||||||
private function generateAccessToken() {
|
private function _generateAccessToken($config) {
|
||||||
return $this->generateOAuthToken(base64_encode($this->clientId . ":" . $this->clientSecret));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate OAuth type token from Base64Client ID
|
|
||||||
*/
|
|
||||||
private function generateOAuthToken($base64ClientID) {
|
|
||||||
|
|
||||||
|
$base64ClientID = base64_encode($this->clientId . ":" . $this->clientSecret);
|
||||||
$headers = array(
|
$headers = array(
|
||||||
|
"User-Agent" => \PPUserAgent::getValue(RestHandler::$sdkName, RestHandler::$sdkVersion),
|
||||||
"Authorization" => "Basic " . $base64ClientID,
|
"Authorization" => "Basic " . $base64ClientID,
|
||||||
"Accept" => "*/*"
|
"Accept" => "*/*"
|
||||||
);
|
);
|
||||||
$httpConfiguration = $this->getOAuthHttpConfiguration();
|
$httpConfiguration = $this->getOAuthHttpConfiguration($config);
|
||||||
$httpConfiguration->setHeaders($headers);
|
$httpConfiguration->setHeaders($headers);
|
||||||
|
|
||||||
$connection = \PPConnectionManager::getInstance()->getConnection($httpConfiguration);
|
$connection = \PPConnectionManager::getInstance()->getConnection($httpConfiguration, $config);
|
||||||
$res = $connection->execute("grant_type=client_credentials");
|
$res = $connection->execute("grant_type=client_credentials");
|
||||||
$jsonResponse = json_decode($res, true);
|
$jsonResponse = json_decode($res, true);
|
||||||
if($jsonResponse == NULL ||
|
if($jsonResponse == NULL ||
|
||||||
@@ -107,11 +106,26 @@ class OAuthTokenCredential {
|
|||||||
/*
|
/*
|
||||||
* Get HttpConfiguration object for OAuth API
|
* Get HttpConfiguration object for OAuth API
|
||||||
*/
|
*/
|
||||||
private function getOAuthHttpConfiguration() {
|
private function getOAuthHttpConfiguration($config) {
|
||||||
$configMgr = \PPConfigManager::getInstance();
|
if (isset($config['oauth.EndPoint'])) {
|
||||||
|
$baseEndpoint = $config['oauth.EndPoint'];
|
||||||
|
} else if (isset($config['service.EndPoint'])) {
|
||||||
|
$baseEndpoint = $config['service.EndPoint'];
|
||||||
|
} else if (isset($config['mode'])) {
|
||||||
|
switch (strtoupper($config['mode'])) {
|
||||||
|
case 'SANDBOX':
|
||||||
|
$baseEndpoint = \PPConstants::REST_SANDBOX_ENDPOINT;
|
||||||
|
break;
|
||||||
|
case 'LIVE':
|
||||||
|
$baseEndpoint = \PPConstants::REST_LIVE_ENDPOINT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new \PPConfigurationException('The mode config parameter must be set to either sandbox/live');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new PPConfigurationException('You must set one of service.endpoint or mode parameters in your configuration');
|
||||||
|
}
|
||||||
|
|
||||||
$baseEndpoint = ($configMgr->get("oauth.EndPoint") != '' && !is_array($configMgr->get("oauth.EndPoint"))) ?
|
|
||||||
$configMgr->get("oauth.EndPoint") : $configMgr->get("service.EndPoint");
|
|
||||||
$baseEndpoint = rtrim(trim($baseEndpoint), '/');
|
$baseEndpoint = rtrim(trim($baseEndpoint), '/');
|
||||||
return new \PPHttpConfig($baseEndpoint . "/v1/oauth2/token", "POST");
|
return new \PPHttpConfig($baseEndpoint . "/v1/oauth2/token", "POST");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace PayPal\Common;
|
|
||||||
|
|
||||||
class ArrayUtil {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param array $arr
|
|
||||||
* @return true if $arr is an associative array
|
|
||||||
*/
|
|
||||||
public static function isAssocArray(array $arr) {
|
|
||||||
foreach($arr as $k => $v) {
|
|
||||||
if(is_int($k)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace PayPal\Common;
|
|
||||||
|
|
||||||
use PayPal\Api\Payer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic Model class that all API domain classes extend
|
|
||||||
* Stores all member data in a hashmap that enables easy
|
|
||||||
* JSON encoding/decoding
|
|
||||||
*/
|
|
||||||
class Model {
|
|
||||||
|
|
||||||
private $_propMap = array();
|
|
||||||
|
|
||||||
public function __get($key) {
|
|
||||||
return $this->_propMap[$key];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __set($key, $value) {
|
|
||||||
$this->_propMap[$key] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __isset($key) {
|
|
||||||
return isset($this->_propMap[$key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __unset($key) {
|
|
||||||
unset($this->_propMap[$key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private function _convertToArray($param) {
|
|
||||||
$ret = array();
|
|
||||||
foreach($param as $k => $v) {
|
|
||||||
if($v instanceof Model ) {
|
|
||||||
$ret[$k] = $v->toArray();
|
|
||||||
} else if (is_array($v)) {
|
|
||||||
$ret[$k] = $this->_convertToArray($v);
|
|
||||||
} else {
|
|
||||||
$ret[$k] = $v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function fromArray($arr) {
|
|
||||||
|
|
||||||
foreach($arr as $k => $v) {
|
|
||||||
if(is_array($v)) {
|
|
||||||
$clazz = ReflectionUtil::getPropertyClass(get_class($this), $k);
|
|
||||||
if(ArrayUtil::isAssocArray($v)) {
|
|
||||||
$o = new $clazz();
|
|
||||||
$o->fromArray($v);
|
|
||||||
$setterFunc = "set".ucfirst($k);
|
|
||||||
$this->$setterFunc($o);
|
|
||||||
} else {
|
|
||||||
$setterFunc = "set".ucfirst($k);
|
|
||||||
$arr = array();
|
|
||||||
foreach($v as $nk => $nv) {
|
|
||||||
if(is_array($nv)) {
|
|
||||||
$o = new $clazz();
|
|
||||||
$o->fromArray($nv);
|
|
||||||
$arr[$nk] = $o;
|
|
||||||
} else {
|
|
||||||
$arr[$nk] = $nv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->$setterFunc($arr); //TODO: Cleaning up any current values in this case. Should be doing this allways
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
$this->$k = $v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function fromJson($json) {
|
|
||||||
$this->fromArray(json_decode($json, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toArray() {
|
|
||||||
return $this->_convertToArray($this->_propMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toJSON() {
|
|
||||||
return json_encode($this->toArray());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace PayPal\Common;
|
|
||||||
|
|
||||||
class ReflectionUtil {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array|ReflectionMethod[]
|
|
||||||
*/
|
|
||||||
private static $propertiesRefl = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array|string[]
|
|
||||||
*/
|
|
||||||
private static $propertiesType = array();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param string $class
|
|
||||||
* @param string $propertyName
|
|
||||||
*/
|
|
||||||
public static function getPropertyClass($class, $propertyName) {
|
|
||||||
|
|
||||||
if (($annotations = self::propertyAnnotations($class, $propertyName)) && isset($annotations['param'])) {
|
|
||||||
// if (substr($annotations['param'], -2) === '[]') {
|
|
||||||
// $param = substr($annotations['param'], 0, -2);
|
|
||||||
// }
|
|
||||||
$param = $annotations['param'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($param)) {
|
|
||||||
$anno = explode(' ', $param);
|
|
||||||
return $anno[0];
|
|
||||||
} else {
|
|
||||||
return 'string';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $class
|
|
||||||
* @param string $propertyName
|
|
||||||
* @throws RuntimeException
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function propertyAnnotations($class, $propertyName)
|
|
||||||
{
|
|
||||||
$class = is_object($class) ? get_class($class) : $class;
|
|
||||||
if (!class_exists('ReflectionProperty')) {
|
|
||||||
throw new RuntimeException("Property type of " . $class . "::{$propertyName} cannot be resolved");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($annotations =& self::$propertiesType[$class][$propertyName]) {
|
|
||||||
return $annotations;
|
|
||||||
}
|
|
||||||
|
|
||||||
$setterFunc = "set" . ucfirst($propertyName);
|
|
||||||
if (!($refl =& self::$propertiesRefl[$class][$propertyName])) {
|
|
||||||
$refl = new \ReflectionMethod($class, $setterFunc);
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo: smarter regexp
|
|
||||||
if (!preg_match_all('~\@([^\s@\(]+)[\t ]*(?:\(?([^\n@]+)\)?)?~i', $refl->getDocComment(), $annots, PREG_PATTERN_ORDER)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
foreach ($annots[1] as $i => $annot) {
|
|
||||||
$annotations[strtolower($annot)] = empty($annots[2][$i]) ? TRUE : rtrim($annots[2][$i], " \t\n\r)");
|
|
||||||
}
|
|
||||||
|
|
||||||
return $annotations;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace PayPal\Common;
|
|
||||||
|
|
||||||
define('SDK_NAME', 'rest-sdk-php');
|
|
||||||
define('SDK_VERSION', '0.5.0');
|
|
||||||
|
|
||||||
class UserAgent {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the value of the User-Agent header
|
|
||||||
* Add environment values and php version numbers
|
|
||||||
*/
|
|
||||||
public static function getValue() {
|
|
||||||
|
|
||||||
$featureList = array(
|
|
||||||
'lang=PHP',
|
|
||||||
'v=' . PHP_VERSION,
|
|
||||||
'bit=' . UserAgent::_getPHPBit(),
|
|
||||||
'os=' . str_replace(' ' , '_', php_uname('s') . ' ' . php_uname('r')),
|
|
||||||
'machine=' . php_uname('m')
|
|
||||||
);
|
|
||||||
if(defined('OPENSSL_VERSION_TEXT')) {
|
|
||||||
$opensslVersion = explode(' ', OPENSSL_VERSION_TEXT);
|
|
||||||
$featureList[] = 'openssl='. $opensslVersion[1];
|
|
||||||
}
|
|
||||||
if(function_exists('curl_version')) {
|
|
||||||
$curlVersion = curl_version();
|
|
||||||
$featureList[] = 'curl=' . $curlVersion['version'];
|
|
||||||
}
|
|
||||||
return sprintf("PayPalSDK/%s %s (%s)", SDK_NAME, SDK_VERSION, implode(';', $featureList));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function _getPHPBit() {
|
|
||||||
switch(PHP_INT_SIZE) {
|
|
||||||
case 4:
|
|
||||||
return '32';
|
|
||||||
case 8:
|
|
||||||
return '64';
|
|
||||||
default:
|
|
||||||
return PHP_INT_SIZE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,7 @@ namespace PayPal\Rest;
|
|||||||
* Call level parameters such as
|
* Call level parameters such as
|
||||||
* request id, credentials etc
|
* request id, credentials etc
|
||||||
*/
|
*/
|
||||||
class ApiContext {
|
class ApiContext extends \PPApiContext {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OAuth Credentials to use for this call
|
* OAuth Credentials to use for this call
|
||||||
@@ -22,7 +22,6 @@ class ApiContext {
|
|||||||
*/
|
*/
|
||||||
private $requestId;
|
private $requestId;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -32,11 +31,12 @@ class ApiContext {
|
|||||||
|
|
||||||
public function getrequestId() {
|
public function getrequestId() {
|
||||||
if($this->requestId == null) {
|
if($this->requestId == null) {
|
||||||
$this->requestId = $this->generaterequestId();
|
$this->requestId = $this->generateRequestId();
|
||||||
}
|
}
|
||||||
return $this->requestId;
|
return $this->requestId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param PayPal/Api/OAuthTokenCredential $credential
|
* @param PayPal/Api/OAuthTokenCredential $credential
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace PayPal\Rest;
|
|
||||||
|
|
||||||
use PayPal\Auth\OAuthTokenCredential;
|
|
||||||
|
|
||||||
use PayPal\Common\UserAgent;
|
|
||||||
|
|
||||||
class Call {
|
|
||||||
|
|
||||||
private $logger;
|
|
||||||
|
|
||||||
public function __construct() {
|
|
||||||
$this->logger = new \PPLoggingManager(__CLASS__);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param string $path
|
|
||||||
* @param string $data
|
|
||||||
* @param PayPal/Rest/ApiContext $apiContext
|
|
||||||
* @param array $headers
|
|
||||||
*/
|
|
||||||
public function execute($path, $method, $data='', $apiContext, $headers=array()) {
|
|
||||||
$configMgr = \PPConfigManager::getInstance();
|
|
||||||
|
|
||||||
$credential = $apiContext->getCredential();
|
|
||||||
if($credential == NULL) {
|
|
||||||
// Try picking credentials from the config file
|
|
||||||
$credMgr = \PPCredentialManager::getInstance();
|
|
||||||
$credValues = $credMgr->getCredentialObject();
|
|
||||||
if(!is_array($credValues)) {
|
|
||||||
throw new \PPMissingCredentialException("Empty or invalid credentials passed");
|
|
||||||
}
|
|
||||||
$credential = new OAuthTokenCredential($credValues['clientId'], $credValues['clientSecret']);
|
|
||||||
}
|
|
||||||
if($credential == NULL || ! ($credential instanceof OAuthTokenCredential) ) {
|
|
||||||
throw new \PPInvalidCredentialException("Invalid credentials passed");
|
|
||||||
}
|
|
||||||
|
|
||||||
$resourceUrl = rtrim( trim($configMgr->get('service.EndPoint')), '/') . $path;
|
|
||||||
$config = new \PPHttpConfig($resourceUrl, $method);
|
|
||||||
$headers += array(
|
|
||||||
'Content-Type' => 'application/json',
|
|
||||||
'User-Agent' => UserAgent::getValue()
|
|
||||||
);
|
|
||||||
if(!is_null($credential) && $credential instanceof OAuthTokenCredential) {
|
|
||||||
$headers['Authorization'] = "Bearer " . $credential->getAccessToken();
|
|
||||||
}
|
|
||||||
if($method == 'POST' || $method == 'PUT') {
|
|
||||||
$headers['PayPal-Request-Id'] = $apiContext->getRequestId();
|
|
||||||
}
|
|
||||||
$config->setHeaders($headers);
|
|
||||||
$connection = new \PPHttpConnection($config);
|
|
||||||
$response = $connection->execute($data);
|
|
||||||
$this->logger->fine($response);
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
77
lib/PayPal/Rest/RestHandler.php
Normal file
77
lib/PayPal/Rest/RestHandler.php
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
namespace PayPal\Rest;
|
||||||
|
|
||||||
|
use PayPal\Auth\OAuthTokenCredential;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* API handler for all REST API calls
|
||||||
|
*/
|
||||||
|
class RestHandler implements \IPPHandler {
|
||||||
|
|
||||||
|
private $apiContext;
|
||||||
|
|
||||||
|
public static $sdkName = "rest-sdk-php";
|
||||||
|
public static $sdkVersion = "0.5.0";
|
||||||
|
|
||||||
|
public function __construct($apiContext) {
|
||||||
|
$this->apiContext = $apiContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle($httpConfig, $request, $options) {
|
||||||
|
|
||||||
|
$credential = $this->apiContext->getCredential();
|
||||||
|
$config = $this->apiContext->getConfig();
|
||||||
|
|
||||||
|
if($credential == NULL) {
|
||||||
|
// Try picking credentials from the config file
|
||||||
|
$credMgr = \PPCredentialManager::getInstance($config);
|
||||||
|
$credValues = $credMgr->getCredentialObject();
|
||||||
|
if(!is_array($credValues)) {
|
||||||
|
throw new \PPMissingCredentialException("Empty or invalid credentials passed");
|
||||||
|
}
|
||||||
|
$credential = new OAuthTokenCredential($credValues['clientId'], $credValues['clientSecret']);
|
||||||
|
}
|
||||||
|
if($credential == NULL || ! ($credential instanceof OAuthTokenCredential) ) {
|
||||||
|
throw new \PPInvalidCredentialException("Invalid credentials passed");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$httpConfig->setUrl(
|
||||||
|
rtrim( trim($this->_getEndpoint($config)), '/') .
|
||||||
|
(isset($options['path']) ? $options['path'] : '')
|
||||||
|
);
|
||||||
|
|
||||||
|
if(!array_key_exists("User-Agent", $httpConfig->getHeaders())) {
|
||||||
|
$httpConfig->addHeader("User-Agent", \PPUserAgent::getValue(self::$sdkName, self::$sdkVersion));
|
||||||
|
}
|
||||||
|
if(!is_null($credential) && $credential instanceof OAuthTokenCredential) {
|
||||||
|
$httpConfig->addHeader('Authorization', "Bearer " . $credential->getAccessToken($config));
|
||||||
|
}
|
||||||
|
if($httpConfig->getMethod() == 'POST' || $httpConfig->getMethod() == 'PUT') {
|
||||||
|
$httpConfig->addHeader('PayPal-Request-Id', $this->apiContext->getRequestId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _getEndpoint($config) {
|
||||||
|
if (isset($config['service.EndPoint'])) {
|
||||||
|
return $config['service.EndPoint'];
|
||||||
|
} else if (isset($config['mode'])) {
|
||||||
|
switch (strtoupper($config['mode'])) {
|
||||||
|
case 'SANDBOX':
|
||||||
|
return \PPConstants::REST_SANDBOX_ENDPOINT;
|
||||||
|
break;
|
||||||
|
case 'LIVE':
|
||||||
|
return \PPConstants::REST_LIVE_ENDPOINT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new PPConfigurationException('The mode config parameter must be set to either sandbox/live');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new PPConfigurationException('You must set one of service.endpoint or mode parameters in your configuration');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,12 +9,13 @@ class OAuthTokenCredentialTest extends PHPUnit_Framework_TestCase {
|
|||||||
|
|
||||||
public function testGetAccessToken() {
|
public function testGetAccessToken() {
|
||||||
$cred = new OAuthTokenCredential(Constants::CLIENT_ID, Constants::CLIENT_SECRET);
|
$cred = new OAuthTokenCredential(Constants::CLIENT_ID, Constants::CLIENT_SECRET);
|
||||||
|
$config = \PPConfigManager::getInstance()->getConfigHashmap();
|
||||||
|
|
||||||
$token = $cred->getAccessToken();
|
$token = $cred->getAccessToken($config);
|
||||||
$this->assertNotNull($token);
|
$this->assertNotNull($token);
|
||||||
|
|
||||||
// Check that we get the same token when issuing a new call before token expiry
|
// Check that we get the same token when issuing a new call before token expiry
|
||||||
$newToken = $cred->getAccessToken();
|
$newToken = $cred->getAccessToken($config);
|
||||||
$this->assertNotNull($newToken);
|
$this->assertNotNull($newToken);
|
||||||
$this->assertEquals($token, $newToken);
|
$this->assertEquals($token, $newToken);
|
||||||
|
|
||||||
@@ -28,6 +29,6 @@ class OAuthTokenCredentialTest extends PHPUnit_Framework_TestCase {
|
|||||||
public function testInvalidCredentials() {
|
public function testInvalidCredentials() {
|
||||||
$this->setExpectedException('\PPConnectionException');
|
$this->setExpectedException('\PPConnectionException');
|
||||||
$cred = new OAuthTokenCredential('dummy', 'secret');
|
$cred = new OAuthTokenCredential('dummy', 'secret');
|
||||||
$this->assertNull($cred->getAccessToken());
|
$this->assertNull($cred->getAccessToken(\PPConfigManager::getInstance()->getConfigHashmap()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
// namespace PayPal\Test\Common;
|
// namespace PayPal\Test\Common;
|
||||||
|
|
||||||
use PayPal\Common\ArrayUtil;
|
|
||||||
|
|
||||||
class ArrayUtilTest extends PHPUnit_Framework_TestCase {
|
class ArrayUtilTest extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
public function testIsAssocArray() {
|
public function testIsAssocArray() {
|
||||||
|
|
||||||
$arr = array(1, 2, 3);
|
$arr = array(1, 2, 3);
|
||||||
$this->assertEquals(false, ArrayUtil::isAssocArray($arr));
|
$this->assertEquals(false, PPArrayUtil::isAssocArray($arr));
|
||||||
|
|
||||||
$arr = array(
|
$arr = array(
|
||||||
'name' => 'John Doe',
|
'name' => 'John Doe',
|
||||||
'City' => 'San Jose'
|
'City' => 'San Jose'
|
||||||
);
|
);
|
||||||
$this->assertEquals(true, ArrayUtil::isAssocArray($arr));
|
$this->assertEquals(true, PPArrayUtil::isAssocArray($arr));
|
||||||
|
|
||||||
$arr[] = 'CA';
|
$arr[] = 'CA';
|
||||||
$this->assertEquals(false, ArrayUtil::isAssocArray($arr));
|
$this->assertEquals(false, PPArrayUtil::isAssocArray($arr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
// namespace PayPal\Test\Common;
|
// namespace PayPal\Test\Common;
|
||||||
|
|
||||||
use PayPal\Common\Model;
|
|
||||||
|
|
||||||
class SimpleClass extends Model {
|
class SimpleClass extends \PPModel {
|
||||||
|
|
||||||
public function setName($name) {
|
public function setName($name) {
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
@@ -21,7 +20,7 @@ class SimpleClass extends Model {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArrayClass extends Model {
|
class ArrayClass extends \PPModel {
|
||||||
|
|
||||||
public function setName($name) {
|
public function setName($name) {
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
@@ -48,7 +47,7 @@ class ArrayClass extends Model {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NestedClass extends Model {
|
class NestedClass extends \PPModel {
|
||||||
|
|
||||||
public function setId($id) {
|
public function setId($id) {
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
@@ -64,6 +63,10 @@ class NestedClass extends Model {
|
|||||||
public function setInfo($info) {
|
public function setInfo($info) {
|
||||||
$this->info = $info;
|
$this->info = $info;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return ArrayClass
|
||||||
|
*/
|
||||||
public function getInfo() {
|
public function getInfo() {
|
||||||
return $this->info;
|
return $this->info;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use PayPal\Common\UserAgent;
|
|||||||
class UserAgentTest extends PHPUnit_Framework_TestCase {
|
class UserAgentTest extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
public function testGetValue() {
|
public function testGetValue() {
|
||||||
$ua = UserAgent::getValue();
|
$ua = PPUserAgent::getValue("name", "version");
|
||||||
list($id, $version, $features) = sscanf($ua, "PayPalSDK/%s %s (%s)");
|
list($id, $version, $features) = sscanf($ua, "PayPalSDK/%s %s (%s)");
|
||||||
|
|
||||||
// Check that we pass the useragent in the expected format
|
// Check that we pass the useragent in the expected format
|
||||||
@@ -13,6 +13,9 @@ class UserAgentTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->assertNotNull($version);
|
$this->assertNotNull($version);
|
||||||
$this->assertNotNull($features);
|
$this->assertNotNull($features);
|
||||||
|
|
||||||
|
$this->assertEquals("name", $id);
|
||||||
|
$this->assertEquals("version", $version);
|
||||||
|
|
||||||
// Check that we pass in these mininal features
|
// Check that we pass in these mininal features
|
||||||
$this->assertThat($features, $this->stringContains("OS="));
|
$this->assertThat($features, $this->stringContains("OS="));
|
||||||
$this->assertThat($features, $this->stringContains("Bit="));
|
$this->assertThat($features, $this->stringContains("Bit="));
|
||||||
|
|||||||
Reference in New Issue
Block a user