Updated Payment APIs

- Updated SDK Models to latest Payment APIs
- Updated Unit Tests
This commit is contained in:
Jay Patel
2015-02-26 15:03:59 -06:00
parent 241d80cd17
commit 3e43f93f9b
93 changed files with 6079 additions and 1735 deletions

View File

@@ -3,14 +3,13 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
use PayPal\Validation\NumericValidator;
use PayPal\Converter\FormatConverter;
use PayPal\Validation\NumericValidator;
/**
* Class Amount
*
* Let's you specify details of a payment amount.
* payment amount with break-ups.
*
* @package PayPal\Api
*
@@ -22,7 +21,6 @@ class Amount extends PayPalModel
{
/**
* 3 letter currency code
*
*
* @param string $currency
*
@@ -45,11 +43,11 @@ class Amount extends PayPalModel
}
/**
* Total amount charged from the Payer account (or card) to Payee. In case of a refund, this is the refunded amount to the original Payer from Payee account.
*
* Total amount charged as part of this payment.
*
*
* @param string|double $total
*
*
* @return $this
*/
public function setTotal($total)
@@ -61,7 +59,7 @@ class Amount extends PayPalModel
}
/**
* Total amount charged from the Payer account (or card) to Payee. In case of a refund, this is the refunded amount to the original Payer from Payee account.
* Total amount charged as part of this payment.
*
* @return string
*/
@@ -72,7 +70,6 @@ class Amount extends PayPalModel
/**
* Additional details of the payment amount.
*
*
* @param \PayPal\Api\Details $details
*

View File

@@ -2,12 +2,11 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
use PayPal\Rest\IResource;
use PayPal\Api\Capture;
use PayPal\Transport\PayPalRestCall;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\Capture;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PayPalRestCall;
/**
* Class Authorization
@@ -22,18 +21,20 @@ use PayPal\Validation\ArgumentValidator;
* @property \PayPal\Api\Amount amount
* @property string payment_mode
* @property string state
* @property string reason_code
* @property string pending_reason
* @property string protection_eligibility
* @property string protection_eligibility_type
* @property \PayPal\Api\FmfDetails fmf_details
* @property string parent_payment
* @property string clearing_time
* @property string valid_until
* @property \PayPal\Api\Links links
*/
class Authorization extends PayPalModel implements IResource
class Authorization extends PayPalResourceModel
{
/**
* Identifier of the authorization transaction.
*
*
* @param string $id
*
@@ -55,57 +56,8 @@ class Authorization extends PayPalModel implements IResource
return $this->id;
}
/**
* 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 last updated 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 last updated in UTC ISO8601 format.
*
* @return string
*/
public function getUpdateTime()
{
return $this->update_time;
}
/**
* Amount being authorized for.
*
*
* @param \PayPal\Api\Amount $amount
*
@@ -129,7 +81,7 @@ class Authorization extends PayPalModel implements IResource
/**
* specifies payment mode of the transaction
* Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"]
* Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"]
*
* @param string $payment_mode
*
@@ -153,7 +105,7 @@ class Authorization extends PayPalModel implements IResource
/**
* State of the authorization transaction.
* Valid Values: ["pending", "authorized", "partially_captured", "captured", "expired", "voided"]
* Valid Values: ["pending", "authorized", "partially_captured", "captured", "expired", "voided"]
*
* @param string $state
*
@@ -175,9 +127,57 @@ class Authorization extends PayPalModel implements IResource
return $this->state;
}
/**
* Reason code for the transaction state being Pending. This field will replace pending_reason field eventually
* Valid Values: ["AUTHORIZATION"]
*
* @param string $reason_code
*
* @return $this
*/
public function setReasonCode($reason_code)
{
$this->reason_code = $reason_code;
return $this;
}
/**
* Reason code for the transaction state being Pending. This field will replace pending_reason field eventually
*
* @return string
*/
public function getReasonCode()
{
return $this->reason_code;
}
/**
* [DEPRECATED] Reason code for the transaction state being Pending.Obsolete. use reason_code field instead.
* Valid Values: ["AUTHORIZATION"]
* @deprecated Plese Use setReasonCode instead
* @param string $pending_reason
*
* @return $this
*/
public function setPendingReason($pending_reason)
{
$this->pending_reason = $pending_reason;
return $this;
}
/**
* [DEPRECATED] Reason code for the transaction state being Pending.Obsolete. use reason_code field instead.
* @deprecated Plese Use setReasonCode instead
* @return string
*/
public function getPendingReason()
{
return $this->pending_reason;
}
/**
* Protection Eligibility of the Payer
* Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"]
* Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"]
*
* @param string $protection_eligibility
*
@@ -201,7 +201,7 @@ class Authorization extends PayPalModel implements IResource
/**
* Protection Eligibility Type of the Payer
* Valid Values: ["ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE", "INELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE"]
* Valid Values: ["ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE", "INELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE"]
*
* @param string $protection_eligibility_type
*
@@ -224,8 +224,30 @@ class Authorization extends PayPalModel implements IResource
}
/**
* ID of the Payment resource that this transaction is based on.
* Fraud Management Filter (FMF) details applied for the payment that could result in accept/deny/pending action.
*
* @param \PayPal\Api\FmfDetails $fmf_details
*
* @return $this
*/
public function setFmfDetails($fmf_details)
{
$this->fmf_details = $fmf_details;
return $this;
}
/**
* Fraud Management Filter (FMF) details applied for the payment that could result in accept/deny/pending action.
*
* @return \PayPal\Api\FmfDetails
*/
public function getFmfDetails()
{
return $this->fmf_details;
}
/**
* ID of the Payment resource that this transaction is based on.
*
* @param string $parent_payment
*
@@ -249,10 +271,10 @@ class Authorization extends PayPalModel implements IResource
/**
* Expected clearing time for eCheck Transactions
*
*
*
* @param string $clearing_time
*
*
* @return $this
*/
public function setClearingTime($clearing_time)
@@ -272,8 +294,7 @@ class Authorization extends PayPalModel implements IResource
}
/**
* Date/Time until which funds may be captured against this resource.
*
* Date/Time until which funds may be captured against this resource in UTC ISO8601 format.
*
* @param string $valid_until
*
@@ -286,7 +307,7 @@ class Authorization extends PayPalModel implements IResource
}
/**
* Date/Time until which funds may be captured against this resource.
* Date/Time until which funds may be captured against this resource in UTC ISO8601 format.
*
* @return string
*/
@@ -296,110 +317,144 @@ class Authorization extends PayPalModel implements IResource
}
/**
* Sets Links
*
* Time the resource was created in UTC ISO8601 format.
*
* @param \PayPal\Api\Links $links
* @param string $create_time
*
* @return $this
*/
public function setLinks($links)
public function setCreateTime($create_time)
{
$this->links = $links;
$this->create_time = $create_time;
return $this;
}
/**
* Gets Links
* Time the resource was created in UTC ISO8601 format.
*
* @return \PayPal\Api\Links[]
* @return string
*/
public function getLinks()
public function getCreateTime()
{
return $this->links;
return $this->create_time;
}
/**
* Obtain the Authorization transaction resource for the given identifier.
* 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;
}
/**
* Time the resource was last updated in UTC ISO8601 format.
*
* @return string
*/
public function getUpdateTime()
{
return $this->update_time;
}
/**
* Retrieve details about a previously created authorization by passing the authorization_id in the request URI.
*
* @param string $authorizationId
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Authorization
*/
public static function get($authorizationId, $apiContext = null)
public static function get($authorizationId, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($authorizationId, 'authorizationId');
$payLoad = "";
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PayPalRestCall($apiContext);
$json = $call->execute(array('PayPal\Handler\RestHandler'), "/v1/payments/authorization/$authorizationId", "GET", $payLoad);
$json = self::executeCall(
"/v1/payments/authorization/$authorizationId",
"GET",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new Authorization();
$ret->fromJson($json);
return $ret;
}
/**
* Creates (and processes) a new Capture Transaction added as a related resource.
* Capture and process a previously created authorization by passing the authorization_id in the request URI. To use this request, the original payment call must have the intent set to authorize.
*
* @param Capture $capture
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @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 Capture
*/
public function capture($capture, $apiContext = null)
public function capture($capture, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($capture, 'capture');
$payLoad = $capture->toJSON();
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PayPalRestCall($apiContext);
$json = $call->execute(array('PayPal\Handler\RestHandler'), "/v1/payments/authorization/{$this->getId()}/capture", "POST", $payLoad);
$json = self::executeCall(
"/v1/payments/authorization/{$this->getId()}/capture",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new Capture();
$ret->fromJson($json);
return $ret;
}
/**
* Voids (cancels) an Authorization.
* Void (cancel) a previously authorized payment by passing the authorization_id in the request URI. Note that a fully captured authorization cannot be voided.
*
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Authorization
*/
public function void($apiContext = null)
public function void($apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
$payLoad = "";
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PayPalRestCall($apiContext);
$json = $call->execute(array('PayPal\Handler\RestHandler'), "/v1/payments/authorization/{$this->getId()}/void", "POST", $payLoad);
$json = self::executeCall(
"/v1/payments/authorization/{$this->getId()}/void",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
$this->fromJson($json);
return $this;
}
/**
* Reauthorizes an expired Authorization.
* Reauthorize a PayPal account payment by passing the authorization_id in the request URI. You should reauthorize a payment after the initial 3-day honor period to ensure that funds are still available.
*
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Authorization
*/
public function reauthorize($apiContext = null)
public function reauthorize($apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
$payLoad = $this->toJSON();
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PayPalRestCall($apiContext);
$json = $call->execute(array('PayPal\Handler\RestHandler'), "/v1/payments/authorization/{$this->getId()}/reauthorize", "POST", $payLoad);
$json = self::executeCall(
"/v1/payments/authorization/{$this->getId()}/reauthorize",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
$this->fromJson($json);
return $this;
}

View File

@@ -17,6 +17,8 @@ use PayPal\Common\PayPalModel;
* @property string country_code
* @property string postal_code
* @property string state
* @property string normalization_status
* @property string status
*/
class BaseAddress extends PayPalModel
{
@@ -158,4 +160,52 @@ class BaseAddress extends PayPalModel
return $this->state;
}
/**
* Address normalization status
* Valid Values: ["UNKNOWN", "UNNORMALIZED_USER_PREFERRED", "NORMALIZED", "UNNORMALIZED"]
*
* @param string $normalization_status
*
* @return $this
*/
public function setNormalizationStatus($normalization_status)
{
$this->normalization_status = $normalization_status;
return $this;
}
/**
* Address normalization status
*
* @return string
*/
public function getNormalizationStatus()
{
return $this->normalization_status;
}
/**
* Address status
* Valid Values: ["CONFIRMED", "UNCONFIRMED"]
*
* @param string $status
*
* @return $this
*/
public function setStatus($status)
{
$this->status = $status;
return $this;
}
/**
* Address status
*
* @return string
*/
public function getStatus()
{
return $this->status;
}
}

View File

@@ -2,12 +2,11 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
use PayPal\Rest\IResource;
use PayPal\Api\Refund;
use PayPal\Transport\PayPalRestCall;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\Refund;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PayPalRestCall;
/**
* Class Capture
@@ -23,13 +22,13 @@ use PayPal\Validation\ArgumentValidator;
* @property bool is_final_capture
* @property string state
* @property string parent_payment
* @property \PayPal\Api\Links links
* @property \PayPal\Api\Currency transaction_fee
* @property \PayPal\Api\Links[] links
*/
class Capture extends PayPalModel implements IResource
class Capture extends PayPalResourceModel
{
/**
* Identifier of the Capture transaction.
*
*
* @param string $id
*
@@ -52,56 +51,7 @@ class Capture extends PayPalModel implements IResource
}
/**
* 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 last updated 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 last updated in UTC ISO8601 format.
*
* @return string
*/
public function getUpdateTime()
{
return $this->update_time;
}
/**
* Amount being captured. If no amount is specified, amount is used from the authorization being captured. If amount is same as the amount that's authorized for, the state of the authorization changes to captured. If not, the state of the authorization changes to partially_captured. Alternatively, you could indicate a final capture by seting the is_final_capture flag to true.
*
* Amount being captured. If no amount is specified, amount is used from the authorization being captured. If amount is same as the amount that's authorized for, the state of the authorization changes to captured. If not, the state of the authorization changes to partially_captured. Alternatively, you could indicate a final capture by setting the is_final_capture flag to true.
*
* @param \PayPal\Api\Amount $amount
*
@@ -114,7 +64,7 @@ class Capture extends PayPalModel implements IResource
}
/**
* Amount being captured. If no amount is specified, amount is used from the authorization being captured. If amount is same as the amount that's authorized for, the state of the authorization changes to captured. If not, the state of the authorization changes to partially_captured. Alternatively, you could indicate a final capture by seting the is_final_capture flag to true.
* Amount being captured. If no amount is specified, amount is used from the authorization being captured. If amount is same as the amount that's authorized for, the state of the authorization changes to captured. If not, the state of the authorization changes to partially_captured. Alternatively, you could indicate a final capture by setting the is_final_capture flag to true.
*
* @return \PayPal\Api\Amount
*/
@@ -125,7 +75,6 @@ class Capture extends PayPalModel implements IResource
/**
* whether this is a final capture for the given authorization or not. If it's final, all the remaining funds held by the authorization, will be released in the funding instrument.
*
*
* @param bool $is_final_capture
*
@@ -149,7 +98,7 @@ class Capture extends PayPalModel implements IResource
/**
* State of the capture transaction.
* Valid Values: ["pending", "completed", "refunded", "partially_refunded"]
* Valid Values: ["pending", "completed", "refunded", "partially_refunded"]
*
* @param string $state
*
@@ -173,7 +122,6 @@ class Capture extends PayPalModel implements IResource
/**
* ID of the Payment resource that this transaction is based on.
*
*
* @param string $parent_payment
*
@@ -196,69 +144,120 @@ class Capture extends PayPalModel implements IResource
}
/**
* Sets Links
*
* Transaction fee applicable for this payment.
*
* @param \PayPal\Api\Links $links
* @param \PayPal\Api\Currency $transaction_fee
*
* @return $this
*/
public function setLinks($links)
public function setTransactionFee($transaction_fee)
{
$this->links = $links;
$this->transaction_fee = $transaction_fee;
return $this;
}
/**
* Gets Links
* Transaction fee applicable for this payment.
*
* @return \PayPal\Api\Links[]
* @return \PayPal\Api\Currency
*/
public function getLinks()
public function getTransactionFee()
{
return $this->links;
return $this->transaction_fee;
}
/**
* Obtain the Capture transaction resource for the given identifier.
* 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 last updated 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 last updated in UTC ISO8601 format.
*
* @return string
*/
public function getUpdateTime()
{
return $this->update_time;
}
/**
* Retrieve details about a captured payment by passing the capture_id in the request URI.
*
* @param string $captureId
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @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 Capture
*/
public static function get($captureId, $apiContext = null)
public static function get($captureId, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($captureId, 'captureId');
$payLoad = "";
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PayPalRestCall($apiContext);
$json = $call->execute(array('PayPal\Handler\RestHandler'), "/v1/payments/capture/$captureId", "GET", $payLoad);
$json = self::executeCall(
"/v1/payments/capture/$captureId",
"GET",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new Capture();
$ret->fromJson($json);
return $ret;
}
/**
* Creates (and processes) a new Refund Transaction added as a related resource.
* Refund a captured payment by passing the capture_id in the request URI. In addition, include an amount object in the body of the request JSON.
*
* @param Refund $refund
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Refund
*/
public function refund($refund, $apiContext = null)
public function refund($refund, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($refund, 'refund');
$payLoad = $refund->toJSON();
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PayPalRestCall($apiContext);
$json = $call->execute(array('PayPal\Handler\RestHandler'), "/v1/payments/capture/{$this->getId()}/refund", "POST", $payLoad);
$json = self::executeCall(
"/v1/payments/capture/{$this->getId()}/refund",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new Refund();
$ret->fromJson($json);
return $ret;

View File

@@ -3,8 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
/**
* Class CarrierAccountToken
@@ -20,9 +18,9 @@ class CarrierAccountToken extends PayPalModel
{
/**
* ID of a previously saved carrier account resource.
*
*
* @param string $carrier_account_id
*
* @return $this
*/
public function setCarrierAccountId($carrier_account_id)
@@ -42,8 +40,8 @@ class CarrierAccountToken extends PayPalModel
}
/**
* The unique identifier of the payer used when saving this carrier account instrument.
*
* ID of a previously saved carrier account resource.
*
*
* @param string $external_customer_id
* @return $this

View File

@@ -3,7 +3,7 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
use PayPal\Validation\UrlValidator;
/**
* Class CartBase
@@ -21,12 +21,13 @@ use PayPal\Rest\ApiContext;
* @property string soft_descriptor
* @property \PayPal\Api\PaymentOptions payment_options
* @property \PayPal\Api\ItemList item_list
* @property string notify_url
* @property string order_url
*/
class CartBase extends PayPalModel
{
/**
* Amount being collected.
*
*
* @param \PayPal\Api\Amount $amount
*
@@ -50,7 +51,6 @@ class CartBase extends PayPalModel
/**
* Recipient of the funds in this transaction.
*
*
* @param \PayPal\Api\Payee $payee
*
@@ -74,7 +74,6 @@ class CartBase extends PayPalModel
/**
* Description of what is being paid for.
*
*
* @param string $description
*
@@ -98,7 +97,6 @@ class CartBase extends PayPalModel
/**
* Note to the recipient of the funds in this transaction.
*
*
* @param string $note_to_payee
*
@@ -121,8 +119,8 @@ class CartBase extends PayPalModel
}
/**
* free-form field for the use of clients
*
* Note to the recipient of the funds in this transaction.
*
*
* @param string $custom
*
@@ -146,7 +144,6 @@ class CartBase extends PayPalModel
/**
* invoice number to track this payment
*
*
* @param string $invoice_number
*
@@ -170,7 +167,7 @@ class CartBase extends PayPalModel
/**
* Soft descriptor used when charging this funding source.
*
*
*
* @param string $soft_descriptor
*
@@ -194,7 +191,7 @@ class CartBase extends PayPalModel
/**
* Payment options requested for this purchase unit
*
*
*
* @param \PayPal\Api\PaymentOptions $payment_options
*
@@ -218,7 +215,6 @@ class CartBase extends PayPalModel
/**
* List of items being paid for.
*
*
* @param \PayPal\Api\ItemList $item_list
*
@@ -240,4 +236,53 @@ class CartBase extends PayPalModel
return $this->item_list;
}
/**
* URL to send payment notifications
*
* @param string $notify_url
* @throws \InvalidArgumentException
* @return $this
*/
public function setNotifyUrl($notify_url)
{
UrlValidator::validate($notify_url, "NotifyUrl");
$this->notify_url = $notify_url;
return $this;
}
/**
* URL to send payment notifications
*
* @return string
*/
public function getNotifyUrl()
{
return $this->notify_url;
}
/**
* Url on merchant site pertaining to this payment.
*
* @param string $order_url
* @throws \InvalidArgumentException
* @return $this
*/
public function setOrderUrl($order_url)
{
UrlValidator::validate($order_url, "OrderUrl");
$this->order_url = $order_url;
return $this;
}
/**
* Url on merchant site pertaining to this payment.
*
* @return string
*/
public function getOrderUrl()
{
return $this->order_url;
}
}

View File

@@ -55,7 +55,7 @@ class Credit extends PayPalModel
}
/**
* Specifies the type of credit.
* Specifies the type of credit
*
* @return string
*/
@@ -68,7 +68,7 @@ class Credit extends PayPalModel
* URI to the associated terms.
*
* @param string $terms
*
*
* @return $this
*/
public function setTerms($terms)

View File

@@ -19,7 +19,7 @@ use PayPal\Transport\PayPalRestCall;
* @property string type
* @property int expire_month
* @property int expire_year
* @property int cvv2
* @property string cvv2
* @property string first_name
* @property string last_name
* @property \PayPal\Api\Address billing_address
@@ -149,7 +149,7 @@ class CreditCard extends PayPalResourceModel
/**
* Card validation code. Only supported when making a Payment but not when saving a credit card for future use.
*
* @param int $cvv2
* @param string $cvv2
*
* @return $this
*/
@@ -162,7 +162,7 @@ class CreditCard extends PayPalResourceModel
/**
* Card validation code. Only supported when making a Payment but not when saving a credit card for future use.
*
* @return int
* @return string
*/
public function getCvv2()
{
@@ -312,7 +312,7 @@ class CreditCard extends PayPalResourceModel
* Time the resource was created in UTC ISO8601 format.
*
* @param string $create_time
*
*
* @return $this
*/
public function setCreateTime($create_time)
@@ -335,7 +335,7 @@ class CreditCard extends PayPalResourceModel
* Time the resource was created in UTC ISO8601 format.
*
* @param string $update_time
*
*
* @return $this
*/
public function setUpdateTime($update_time)

View File

@@ -113,7 +113,7 @@ class CreditCardToken extends PayPalModel
}
/**
* Expiry month from the saved card, represented as 1 - 12.
* card expiry month from the saved card with value 1 - 12
*
* @param int $expire_month
*
@@ -126,7 +126,7 @@ class CreditCardToken extends PayPalModel
}
/**
* Expiry month from the saved card, represented as 1 - 12.
* card expiry month from the saved card with value 1 - 12
*
* @return int
*/
@@ -136,7 +136,7 @@ class CreditCardToken extends PayPalModel
}
/**
* Expiry year from the saved card, represented as YYYY format.
* 4 digit card expiry year from the saved card
*
* @param int $expire_year
*
@@ -149,7 +149,7 @@ class CreditCardToken extends PayPalModel
}
/**
* Expiry year from the saved card, represented as YYYY format.
* 4 digit card expiry year from the saved card
*
* @return int
*/

View File

@@ -0,0 +1,267 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Validation\UrlValidator;
/**
* Class CurrencyConversion
*
* Object used to store the currency conversion rate.
*
* @package PayPal\Api
*
* @property string conversion_date
* @property string from_currency
* @property string from_amount
* @property string to_currency
* @property string to_amount
* @property string conversion_type
* @property bool conversion_type_changeable
* @property string web_url
* @property \PayPal\Api\Links[] links
*/
class CurrencyConversion extends PayPalModel
{
/**
* Date of validity for the conversion rate.
*
* @param string $conversion_date
*
* @return $this
*/
public function setConversionDate($conversion_date)
{
$this->conversion_date = $conversion_date;
return $this;
}
/**
* Date of validity for the conversion rate.
*
* @return string
*/
public function getConversionDate()
{
return $this->conversion_date;
}
/**
* 3 letter currency code
*
* @param string $from_currency
*
* @return $this
*/
public function setFromCurrency($from_currency)
{
$this->from_currency = $from_currency;
return $this;
}
/**
* 3 letter currency code
*
* @return string
*/
public function getFromCurrency()
{
return $this->from_currency;
}
/**
* Amount participating in currency conversion, set to 1 as default
*
* @param string $from_amount
*
* @return $this
*/
public function setFromAmount($from_amount)
{
$this->from_amount = $from_amount;
return $this;
}
/**
* Amount participating in currency conversion, set to 1 as default
*
* @return string
*/
public function getFromAmount()
{
return $this->from_amount;
}
/**
* 3 letter currency code
*
* @param string $to_currency
*
* @return $this
*/
public function setToCurrency($to_currency)
{
$this->to_currency = $to_currency;
return $this;
}
/**
* 3 letter currency code
*
* @return string
*/
public function getToCurrency()
{
return $this->to_currency;
}
/**
* Amount resulting from currency conversion.
*
* @param string $to_amount
*
* @return $this
*/
public function setToAmount($to_amount)
{
$this->to_amount = $to_amount;
return $this;
}
/**
* Amount resulting from currency conversion.
*
* @return string
*/
public function getToAmount()
{
return $this->to_amount;
}
/**
* Field indicating conversion type applied.
* Valid Values: ["PAYPAL", "VENDOR"]
*
* @param string $conversion_type
*
* @return $this
*/
public function setConversionType($conversion_type)
{
$this->conversion_type = $conversion_type;
return $this;
}
/**
* Field indicating conversion type applied.
*
* @return string
*/
public function getConversionType()
{
return $this->conversion_type;
}
/**
* Allow Payer to change conversion type.
*
* @param bool $conversion_type_changeable
*
* @return $this
*/
public function setConversionTypeChangeable($conversion_type_changeable)
{
$this->conversion_type_changeable = $conversion_type_changeable;
return $this;
}
/**
* Allow Payer to change conversion type.
*
* @return bool
*/
public function getConversionTypeChangeable()
{
return $this->conversion_type_changeable;
}
/**
* Base URL to web applications endpoint
* Valid Values: ["https://www.paypal.com/{country_code}/webapps/xocspartaweb/webflow/sparta/proxwebflow", "https://www.paypal.com/{country_code}/proxflow"]
*
* @param string $web_url
* @throws \InvalidArgumentException
* @return $this
*/
public function setWebUrl($web_url)
{
UrlValidator::validate($web_url, "WebUrl");
$this->web_url = $web_url;
return $this;
}
/**
* Base URL to web applications endpoint
*
* @return string
*/
public function getWebUrl()
{
return $this->web_url;
}
/**
* Sets Links
*
* @param \PayPal\Api\Links[] $links
*
* @return $this
*/
public function setLinks($links)
{
$this->links = $links;
return $this;
}
/**
* Gets Links
*
* @return \PayPal\Api\Links[]
*/
public function getLinks()
{
return $this->links;
}
/**
* Append Links to the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function addLink($links)
{
if (!$this->getLinks()) {
return $this->setLinks(array($links));
} else {
return $this->setLinks(
array_merge($this->getLinks(), array($links))
);
}
}
/**
* Remove Links from the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function removeLink($links)
{
return $this->setLinks(
array_diff($this->getLinks(), array($links))
);
}
}

View File

@@ -3,9 +3,8 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
use PayPal\Validation\NumericValidator;
use PayPal\Converter\FormatConverter;
use PayPal\Validation\NumericValidator;
/**
* Class Details
@@ -14,20 +13,44 @@ use PayPal\Converter\FormatConverter;
*
* @package PayPal\Api
*
* @property string shipping
* @property string subtotal
* @property string shipping
* @property string tax
* @property string fee
* @property string handling_fee
* @property string shipping_discount
* @property string insurance
* @property string handling_fee
* @property string gift_wrap
* @property string fee
*/
class Details extends PayPalModel
{
/**
* Amount being charged for shipping.
* Sub-total (amount) of items being paid for.
*
* @param string|double $subtotal
*
* @return $this
*/
public function setSubtotal($subtotal)
{
NumericValidator::validate($subtotal, "Subtotal");
$subtotal = FormatConverter::formatToPrice($subtotal);
$this->subtotal = $subtotal;
return $this;
}
/**
* Sub-total (amount) of items being paid for.
*
* @return string
*/
public function getSubtotal()
{
return $this->subtotal;
}
/**
* Amount being charged for shipping.
*
* @param string|double $shipping
*
@@ -51,36 +74,8 @@ class Details extends PayPalModel
return $this->shipping;
}
/**
* Sub-total (amount) of items being paid for.
*
*
* @param string|double $subtotal
*
* @return $this
*/
public function setSubtotal($subtotal)
{
NumericValidator::validate($subtotal, "SubTotal");
$subtotal = FormatConverter::formatToPrice($subtotal);
$this->subtotal = $subtotal;
return $this;
}
/**
* Sub-total (amount) of items being paid for.
*
* @return string
*/
public function getSubtotal()
{
return $this->subtotal;
}
/**
* Amount being charged as tax.
*
*
* @param string|double $tax
*
@@ -105,36 +100,34 @@ class Details extends PayPalModel
}
/**
* Fee charged by PayPal. In case of a refund, this is the fee amount refunded to the original receipient of the payment.
*
* Amount being charged as handling fee.
*
* @param string|double $fee
* @param string $handling_fee
*
* @return $this
*/
public function setFee($fee)
public function setHandlingFee($handling_fee)
{
NumericValidator::validate($fee, "Fee");
$fee = FormatConverter::formatToPrice($fee);
$this->fee = $fee;
NumericValidator::validate($handling_fee, "Handling Fee");
$handling_fee = FormatConverter::formatToPrice($handling_fee);
$this->handling_fee = $handling_fee;
return $this;
}
/**
* Fee charged by PayPal. In case of a refund, this is the fee amount refunded to the original receipient of the payment.
* Amount being charged as handling fee.
*
* @return string
*/
public function getFee()
public function getHandlingFee()
{
return $this->fee;
return $this->handling_fee;
}
/**
* Amount being charged as shipping discount.
*
*
* @param string|double $shipping_discount
* @param string $shipping_discount
*
* @return $this
*/
@@ -158,7 +151,6 @@ class Details extends PayPalModel
/**
* Amount being charged as insurance.
*
*
* @param string|double $insurance
*
@@ -182,36 +174,10 @@ class Details extends PayPalModel
return $this->insurance;
}
/**
* Amount being charged as handling fee.
*
*
* @param string|double $handling_fee
*
* @return $this
*/
public function setHandlingFee($handling_fee)
{
NumericValidator::validate($handling_fee, "Handling Fee");
$handling_fee = FormatConverter::formatToPrice($handling_fee);
$this->handling_fee = $handling_fee;
return $this;
}
/**
* Amount being charged as handling fee.
*
* @return string
*/
public function getHandlingFee()
{
return $this->handling_fee;
}
/**
* Amount being charged as gift wrap fee.
*
* @param string|double $gift_wrap
* @param string $gift_wrap
*
* @return $this
*/
@@ -233,4 +199,29 @@ class Details extends PayPalModel
return $this->gift_wrap;
}
/**
* Fee charged by PayPal. In case of a refund, this is the fee amount refunded to the original receipient of the payment.
*
* @param string|double $fee
*
* @return $this
*/
public function setFee($fee)
{
NumericValidator::validate($fee, "Fee");
$fee = FormatConverter::formatToPrice($fee);
$this->fee = $fee;
return $this;
}
/**
* Fee charged by PayPal. In case of a refund, this is the fee amount refunded to the original receipient of the payment.
*
* @return string
*/
public function getFee()
{
return $this->fee;
}
}

View File

@@ -12,8 +12,10 @@ use PayPal\Common\PayPalModel;
* @package PayPal\Api
*
* @property string name
* @property string purchase_unit_reference_id
* @property string debug_id
* @property string message
* @property string code
* @property string information_link
* @property \PayPal\Api\ErrorDetails[] details
* @property \PayPal\Api\Links[] links
@@ -43,6 +45,29 @@ class Error extends PayPalModel
return $this->name;
}
/**
* Reference ID of the purchase_unit associated with this error
*
* @param string $purchase_unit_reference_id
*
* @return $this
*/
public function setPurchaseUnitReferenceId($purchase_unit_reference_id)
{
$this->purchase_unit_reference_id = $purchase_unit_reference_id;
return $this;
}
/**
* Reference ID of the purchase_unit associated with this error
*
* @return string
*/
public function getPurchaseUnitReferenceId()
{
return $this->purchase_unit_reference_id;
}
/**
* PayPal internal identifier used for correlation purposes.
*
@@ -89,6 +114,29 @@ class Error extends PayPalModel
return $this->message;
}
/**
* PayPal internal error code.
*
* @param string $code
*
* @return $this
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
/**
* PayPal internal error code.
*
* @return string
*/
public function getCode()
{
return $this->code;
}
/**
* URI for detailed information related to this error for the developer.
*

View File

@@ -13,6 +13,8 @@ use PayPal\Common\PayPalModel;
*
* @property string field
* @property string issue
* @property string purchase_unit_reference_id
* @property string code
*/
class ErrorDetails extends PayPalModel
{
@@ -62,4 +64,50 @@ class ErrorDetails extends PayPalModel
return $this->issue;
}
/**
* Reference ID of the purchase_unit associated with this error
*
* @param string $purchase_unit_reference_id
*
* @return $this
*/
public function setPurchaseUnitReferenceId($purchase_unit_reference_id)
{
$this->purchase_unit_reference_id = $purchase_unit_reference_id;
return $this;
}
/**
* Reference ID of the purchase_unit associated with this error
*
* @return string
*/
public function getPurchaseUnitReferenceId()
{
return $this->purchase_unit_reference_id;
}
/**
* PayPal internal error code.
*
* @param string $code
*
* @return $this
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
/**
* PayPal internal error code.
*
* @return string
*/
public function getCode()
{
return $this->code;
}
}

View File

@@ -2,8 +2,6 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
/**
* Class ExtendedBankAccount
*

View File

@@ -0,0 +1,115 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
/**
* Class FmfDetails
*
* Details of Fraud Management Filter (FMF).
*
* @package PayPal\Api
*
* @property string filter_type
* @property string filter_id
* @property string name
* @property string description
*/
class FmfDetails extends PayPalModel
{
/**
* Type of filter.
* Valid Values: ["ACCEPT", "PENDING", "DENY", "REPORT"]
*
* @param string $filter_type
*
* @return $this
*/
public function setFilterType($filter_type)
{
$this->filter_type = $filter_type;
return $this;
}
/**
* Type of filter.
*
* @return string
*/
public function getFilterType()
{
return $this->filter_type;
}
/**
* Filter Identifier.
* Valid Values: ["AVS_NO_MATCH", "AVS_PARTIAL_MATCH", "AVS_UNAVAILABLE_OR_UNSUPPORTED", "CARD_SECURITY_CODE_MISMATCH", "MAXIMUM_TRANSACTION_AMOUNT", "UNCONFIRMED_ADDRESS", "COUNTRY_MONITOR", "LARGE_ORDER_NUMBER", "BILLING_OR_SHIPPING_ADDRESS_MATCH", "RISKY_ZIP_CODE", "SUSPECTED_FREIGHT_FORWARDER_CHECK", "TOTAL_PURCHASE_PRICE_MINIMUM", "IP_ADDRESS_VELOCITY", "RISKY_EMAIL_ADDRESS_DOMAIN_CHECK", "RISKY_BANK_IDENTIFICATION_NUMBER_CHECK", "RISKY_IP_ADDRESS_RANGE", "PAYPAL_FRAUD_MODEL"]
*
* @param string $filter_id
*
* @return $this
*/
public function setFilterId($filter_id)
{
$this->filter_id = $filter_id;
return $this;
}
/**
* Filter Identifier.
*
* @return string
*/
public function getFilterId()
{
return $this->filter_id;
}
/**
* Name of the filter
*
* @param string $name
*
* @return $this
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Name of the filter
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Description of the filter.
*
* @param string $description
*
* @return $this
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Description of the filter.
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
}

View File

@@ -0,0 +1,65 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
/**
* Class FundingDetail
*
* Additional detail of the funding.
*
* @package PayPal\Api
*
* @property string clearing_time
* @property string payment_hold_date
*/
class FundingDetail extends PayPalModel
{
/**
* Expected clearing time
*
* @param string $clearing_time
*
* @return $this
*/
public function setClearingTime($clearing_time)
{
$this->clearing_time = $clearing_time;
return $this;
}
/**
* Expected clearing time
*
* @return string
*/
public function getClearingTime()
{
return $this->clearing_time;
}
/**
* Hold-off duration of the payment
*
* @param string $payment_hold_date
*
* @return $this
*/
public function setPaymentHoldDate($payment_hold_date)
{
$this->payment_hold_date = $payment_hold_date;
return $this;
}
/**
* Hold-off duration of the payment
*
* @return string
*/
public function getPaymentHoldDate()
{
return $this->payment_hold_date;
}
}

View File

@@ -12,12 +12,15 @@ use PayPal\Common\PayPalModel;
* @package PayPal\Api
*
* @property \PayPal\Api\CreditCard credit_card
* @property \PayPal\Api\ExtendedBankAccount bank_account
* @property \PayPal\Api\CreditCardToken credit_card_token
* @property \PayPal\Api\Incentive incentive
* @property \PayPal\Api\PaymentCard payment_card
* @property \PayPal\Api\PaymentCardToken payment_card_token
* @property \PayPal\Api\ExtendedBankAccount bank_account
* @property \PayPal\Api\BankToken bank_account_token
* @property \PayPal\Api\Credit credit
* @property \PayPal\Api\CarrierAccountToken carrier_account_token
*
*/
class FundingInstrument extends PayPalModel
{
@@ -182,4 +185,50 @@ class FundingInstrument extends PayPalModel
return $this->credit;
}
/**
* Incentive funding information.
*
* @param \PayPal\Api\Incentive $incentive
*
* @return $this
*/
public function setIncentive($incentive)
{
$this->incentive = $incentive;
return $this;
}
/**
* Incentive funding information.
*
* @return \PayPal\Api\Incentive
*/
public function getIncentive()
{
return $this->incentive;
}
/**
* Carrier account token information.
*
* @param \PayPal\Api\CarrierAccountToken $carrier_account_token
*
* @return $this
*/
public function setCarrierAccountToken($carrier_account_token)
{
$this->carrier_account_token = $carrier_account_token;
return $this;
}
/**
* Carrier account token information.
*
* @return \PayPal\Api\CarrierAccountToken
*/
public function getCarrierAccountToken()
{
return $this->carrier_account_token;
}
}

View File

@@ -0,0 +1,221 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
/**
* Class FundingOption
*
* specifies the funding option details.
*
* @package PayPal\Api
*
* @property string id
* @property \PayPal\Api\FundingSource[] funding_sources
* @property \PayPal\Api\FundingInstrument backup_funding_instrument
* @property \PayPal\Api\CurrencyConversion currency_conversion
* @property \PayPal\Api\InstallmentInfo installment_info
* @property \PayPal\Api\Links[] links
*/
class FundingOption extends PayPalModel
{
/**
* id of the funding option.
*
* @param string $id
*
* @return $this
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* id of the funding option.
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* List of funding sources that contributes to a payment.
*
* @param \PayPal\Api\FundingSource[] $funding_sources
*
* @return $this
*/
public function setFundingSources($funding_sources)
{
$this->funding_sources = $funding_sources;
return $this;
}
/**
* List of funding sources that contributes to a payment.
*
* @return \PayPal\Api\FundingSource[]
*/
public function getFundingSources()
{
return $this->funding_sources;
}
/**
* Append FundingSources to the list.
*
* @param \PayPal\Api\FundingSource $fundingSource
* @return $this
*/
public function addFundingSource($fundingSource)
{
if (!$this->getFundingSources()) {
return $this->setFundingSources(array($fundingSource));
} else {
return $this->setFundingSources(
array_merge($this->getFundingSources(), array($fundingSource))
);
}
}
/**
* Remove FundingSources from the list.
*
* @param \PayPal\Api\FundingSource $fundingSource
* @return $this
*/
public function removeFundingSource($fundingSource)
{
return $this->setFundingSources(
array_diff($this->getFundingSources(), array($fundingSource))
);
}
/**
* Backup funding instrument which will be used for payment if primary fails.
*
* @param \PayPal\Api\FundingInstrument $backup_funding_instrument
*
* @return $this
*/
public function setBackupFundingInstrument($backup_funding_instrument)
{
$this->backup_funding_instrument = $backup_funding_instrument;
return $this;
}
/**
* Backup funding instrument which will be used for payment if primary fails.
*
* @return \PayPal\Api\FundingInstrument
*/
public function getBackupFundingInstrument()
{
return $this->backup_funding_instrument;
}
/**
* Currency conversion applicable to this funding option.
*
* @param \PayPal\Api\CurrencyConversion $currency_conversion
*
* @return $this
*/
public function setCurrencyConversion($currency_conversion)
{
$this->currency_conversion = $currency_conversion;
return $this;
}
/**
* Currency conversion applicable to this funding option.
*
* @return \PayPal\Api\CurrencyConversion
*/
public function getCurrencyConversion()
{
return $this->currency_conversion;
}
/**
* Installment options available for a funding option.
*
* @param \PayPal\Api\InstallmentInfo $installment_info
*
* @return $this
*/
public function setInstallmentInfo($installment_info)
{
$this->installment_info = $installment_info;
return $this;
}
/**
* Installment options available for a funding option.
*
* @return \PayPal\Api\InstallmentInfo
*/
public function getInstallmentInfo()
{
return $this->installment_info;
}
/**
* Sets Links
*
* @param \PayPal\Api\Links[] $links
*
* @return $this
*/
public function setLinks($links)
{
$this->links = $links;
return $this;
}
/**
* Gets Links
*
* @return \PayPal\Api\Links[]
*/
public function getLinks()
{
return $this->links;
}
/**
* Append Links to the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function addLink($links)
{
if (!$this->getLinks()) {
return $this->setLinks(array($links));
} else {
return $this->setLinks(
array_merge($this->getLinks(), array($links))
);
}
}
/**
* Remove Links from the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function removeLink($links)
{
return $this->setLinks(
array_diff($this->getLinks(), array($links))
);
}
}

View File

@@ -0,0 +1,265 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
/**
* Class FundingSource
*
* specifies the funding source details.
*
* @package PayPal\Api
*
* @property string funding_mode
* @property string funding_instrument_type
* @property string soft_descriptor
* @property \PayPal\Api\Currency amount
* @property string legal_text
* @property \PayPal\Api\FundingDetail funding_detail
* @property string additional_text
* @property \PayPal\Api\FundingInstrument extends
* @property \PayPal\Api\Links[] links
*/
class FundingSource extends PayPalModel
{
/**
* specifies funding mode of the instrument
* Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"]
*
* @param string $funding_mode
*
* @return $this
*/
public function setFundingMode($funding_mode)
{
$this->funding_mode = $funding_mode;
return $this;
}
/**
* specifies funding mode of the instrument
*
* @return string
*/
public function getFundingMode()
{
return $this->funding_mode;
}
/**
* Instrument type for this funding source
* Valid Values: ["BALANCE", "PAYMENT_CARD", "BANK_ACCOUNT", "CREDIT", "INCENTIVE"]
*
* @param string $funding_instrument_type
*
* @return $this
*/
public function setFundingInstrumentType($funding_instrument_type)
{
$this->funding_instrument_type = $funding_instrument_type;
return $this;
}
/**
* Instrument type for this funding source
*
* @return string
*/
public function getFundingInstrumentType()
{
return $this->funding_instrument_type;
}
/**
* Soft descriptor used when charging this funding source.
*
* @param string $soft_descriptor
*
* @return $this
*/
public function setSoftDescriptor($soft_descriptor)
{
$this->soft_descriptor = $soft_descriptor;
return $this;
}
/**
* Soft descriptor used when charging this funding source.
*
* @return string
*/
public function getSoftDescriptor()
{
return $this->soft_descriptor;
}
/**
* Total anticipated amount of money to be pulled from instrument.
*
* @param \PayPal\Api\Currency $amount
*
* @return $this
*/
public function setAmount($amount)
{
$this->amount = $amount;
return $this;
}
/**
* Total anticipated amount of money to be pulled from instrument.
*
* @return \PayPal\Api\Currency
*/
public function getAmount()
{
return $this->amount;
}
/**
* Localized legal text relevant to funding source.
*
* @param string $legal_text
*
* @return $this
*/
public function setLegalText($legal_text)
{
$this->legal_text = $legal_text;
return $this;
}
/**
* Localized legal text relevant to funding source.
*
* @return string
*/
public function getLegalText()
{
return $this->legal_text;
}
/**
* Additional detail of the funding.
*
* @param \PayPal\Api\FundingDetail $funding_detail
*
* @return $this
*/
public function setFundingDetail($funding_detail)
{
$this->funding_detail = $funding_detail;
return $this;
}
/**
* Additional detail of the funding.
*
* @return \PayPal\Api\FundingDetail
*/
public function getFundingDetail()
{
return $this->funding_detail;
}
/**
* Additional text relevant to funding source.
*
* @param string $additional_text
*
* @return $this
*/
public function setAdditionalText($additional_text)
{
$this->additional_text = $additional_text;
return $this;
}
/**
* Additional text relevant to funding source.
*
* @return string
*/
public function getAdditionalText()
{
return $this->additional_text;
}
/**
* Sets Extends
*
* @param \PayPal\Api\FundingInstrument $extends
*
* @return $this
*/
public function setExtends($extends)
{
$this->extends = $extends;
return $this;
}
/**
* Gets Extends
*
* @return \PayPal\Api\FundingInstrument
*/
public function getExtends()
{
return $this->extends;
}
/**
* Sets Links
*
* @param \PayPal\Api\Links[] $links
*
* @return $this
*/
public function setLinks($links)
{
$this->links = $links;
return $this;
}
/**
* Gets Links
*
* @return \PayPal\Api\Links[]
*/
public function getLinks()
{
return $this->links;
}
/**
* Append Links to the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function addLink($links)
{
if (!$this->getLinks()) {
return $this->setLinks(array($links));
} else {
return $this->setLinks(
array_merge($this->getLinks(), array($links))
);
}
}
/**
* Remove Links from the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function removeLink($links)
{
return $this->setLinks(
array_diff($this->getLinks(), array($links))
);
}
}

View File

@@ -0,0 +1,236 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Validation\UrlValidator;
/**
* Class Incentive
*
* A resource representing a incentive.
*
* @package PayPal\Api
*
* @property string id
* @property string code
* @property string name
* @property string description
* @property \PayPal\Api\Currency minimum_purchase_amount
* @property string logo_image_url
* @property string expiry_date
* @property string type
* @property string terms
*/
class Incentive extends PayPalModel
{
/**
* Identifier of the instrument in PayPal Wallet
*
* @param string $id
*
* @return $this
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Identifier of the instrument in PayPal Wallet
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* Code that identifies the incentive.
*
* @param string $code
*
* @return $this
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
/**
* Code that identifies the incentive.
*
* @return string
*/
public function getCode()
{
return $this->code;
}
/**
* Name of the incentive.
*
* @param string $name
*
* @return $this
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Name of the incentive.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Description of the incentive.
*
* @param string $description
*
* @return $this
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Description of the incentive.
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Indicates incentive is applicable for this minimum purchase amount.
*
* @param \PayPal\Api\Currency $minimum_purchase_amount
*
* @return $this
*/
public function setMinimumPurchaseAmount($minimum_purchase_amount)
{
$this->minimum_purchase_amount = $minimum_purchase_amount;
return $this;
}
/**
* Indicates incentive is applicable for this minimum purchase amount.
*
* @return \PayPal\Api\Currency
*/
public function getMinimumPurchaseAmount()
{
return $this->minimum_purchase_amount;
}
/**
* Logo image url for the incentive.
*
* @param string $logo_image_url
* @throws \InvalidArgumentException
* @return $this
*/
public function setLogoImageUrl($logo_image_url)
{
UrlValidator::validate($logo_image_url, "LogoImageUrl");
$this->logo_image_url = $logo_image_url;
return $this;
}
/**
* Logo image url for the incentive.
*
* @return string
*/
public function getLogoImageUrl()
{
return $this->logo_image_url;
}
/**
* expiry date of the incentive.
*
* @param string $expiry_date
*
* @return $this
*/
public function setExpiryDate($expiry_date)
{
$this->expiry_date = $expiry_date;
return $this;
}
/**
* expiry date of the incentive.
*
* @return string
*/
public function getExpiryDate()
{
return $this->expiry_date;
}
/**
* Specifies type of incentive
* Valid Values: ["COUPON", "GIFT_CARD", "MERCHANT_SPECIFIC_BALANCE"]
*
* @param string $type
*
* @return $this
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Specifies type of incentive
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* URI to the associated terms
*
* @param string $terms
*
* @return $this
*/
public function setTerms($terms)
{
$this->terms = $terms;
return $this;
}
/**
* URI to the associated terms
*
* @return string
*/
public function getTerms()
{
return $this->terms;
}
}

View File

@@ -0,0 +1,144 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
/**
* Class InstallmentInfo
*
* A resource representing installment information available for a transaction
*
* @package PayPal\Api
*
* @property string installment_id
* @property string network
* @property string issuer
* @property \PayPal\Api\InstallmentOption[] installment_options
*/
class InstallmentInfo extends PayPalModel
{
/**
* Installment id.
*
* @param string $installment_id
*
* @return $this
*/
public function setInstallmentId($installment_id)
{
$this->installment_id = $installment_id;
return $this;
}
/**
* Installment id.
*
* @return string
*/
public function getInstallmentId()
{
return $this->installment_id;
}
/**
* Credit card network.
* Valid Values: ["VISA", "MASTERCARD"]
*
* @param string $network
*
* @return $this
*/
public function setNetwork($network)
{
$this->network = $network;
return $this;
}
/**
* Credit card network.
*
* @return string
*/
public function getNetwork()
{
return $this->network;
}
/**
* Credit card issuer.
*
* @param string $issuer
*
* @return $this
*/
public function setIssuer($issuer)
{
$this->issuer = $issuer;
return $this;
}
/**
* Credit card issuer.
*
* @return string
*/
public function getIssuer()
{
return $this->issuer;
}
/**
* List of available installment options and the cost associated with each one.
*
* @param \PayPal\Api\InstallmentOption[] $installment_options
*
* @return $this
*/
public function setInstallmentOptions($installment_options)
{
$this->installment_options = $installment_options;
return $this;
}
/**
* List of available installment options and the cost associated with each one.
*
* @return \PayPal\Api\InstallmentOption[]
*/
public function getInstallmentOptions()
{
return $this->installment_options;
}
/**
* Append InstallmentOptions to the list.
*
* @param \PayPal\Api\InstallmentOption $installmentOption
* @return $this
*/
public function addInstallmentOption($installmentOption)
{
if (!$this->getInstallmentOptions()) {
return $this->setInstallmentOptions(array($installmentOption));
} else {
return $this->setInstallmentOptions(
array_merge($this->getInstallmentOptions(), array($installmentOption))
);
}
}
/**
* Remove InstallmentOptions from the list.
*
* @param \PayPal\Api\InstallmentOption $installmentOption
* @return $this
*/
public function removeInstallmentOption($installmentOption)
{
return $this->setInstallmentOptions(
array_diff($this->getInstallmentOptions(), array($installmentOption))
);
}
}

View File

@@ -0,0 +1,118 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Converter\FormatConverter;
use PayPal\Validation\NumericValidator;
/**
* Class InstallmentOption
*
* A resource describing an installment
*
* @package PayPal\Api
*
* @property int term
* @property \PayPal\Api\Currency monthly_payment
* @property \PayPal\Api\Currency discount_amount
* @property string discount_percentage
*/
class InstallmentOption extends PayPalModel
{
/**
* Number of installments
*
* @param int $term
*
* @return $this
*/
public function setTerm($term)
{
$this->term = $term;
return $this;
}
/**
* Number of installments
*
* @return int
*/
public function getTerm()
{
return $this->term;
}
/**
* Monthly payment
*
* @param \PayPal\Api\Currency $monthly_payment
*
* @return $this
*/
public function setMonthlyPayment($monthly_payment)
{
$this->monthly_payment = $monthly_payment;
return $this;
}
/**
* Monthly payment
*
* @return \PayPal\Api\Currency
*/
public function getMonthlyPayment()
{
return $this->monthly_payment;
}
/**
* Discount amount applied to the payment, if any
*
* @param \PayPal\Api\Currency $discount_amount
*
* @return $this
*/
public function setDiscountAmount($discount_amount)
{
$this->discount_amount = $discount_amount;
return $this;
}
/**
* Discount amount applied to the payment, if any
*
* @return \PayPal\Api\Currency
*/
public function getDiscountAmount()
{
return $this->discount_amount;
}
/**
* Discount percentage applied to the payment, if any
*
* @param string $discount_percentage
*
* @return $this
*/
public function setDiscountPercentage($discount_percentage)
{
NumericValidator::validate($discount_percentage, "Discount Percentage");
$discount_percentage = FormatConverter::formatToPrice($discount_percentage);
$this->discount_percentage = $discount_percentage;
return $this;
}
/**
* Discount percentage applied to the payment, if any
*
* @return string
*/
public function getDiscountPercentage()
{
return $this->discount_percentage;
}
}

View File

@@ -3,10 +3,9 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
use PayPal\Validation\UrlValidator;
use PayPal\Validation\NumericValidator;
use PayPal\Converter\FormatConverter;
use PayPal\Validation\NumericValidator;
use PayPal\Validation\UrlValidator;
/**
* Class Item
@@ -24,14 +23,17 @@ use PayPal\Converter\FormatConverter;
* @property string sku
* @property string url
* @property string category
* @property \PayPal\Api\NameValuePair supplementary_data
* @property \PayPal\Api\NameValuePair postback_data
* @property \PayPal\Api\Measurement weight
* @property \PayPal\Api\Measurement length
* @property \PayPal\Api\Measurement height
* @property \PayPal\Api\Measurement width
* @property \PayPal\Api\NameValuePair[] supplementary_data
* @property \PayPal\Api\NameValuePair[] postback_data
*/
class Item extends PayPalModel
{
/**
* Number of items.
*
*
* @param string $quantity
*
@@ -55,7 +57,6 @@ class Item extends PayPalModel
/**
* Name of the item.
*
*
* @param string $name
*
@@ -79,7 +80,6 @@ class Item extends PayPalModel
/**
* Description of the item.
*
*
* @param string $description
*
@@ -103,15 +103,13 @@ class Item extends PayPalModel
/**
* Cost of the item.
*
*
* @param double $price
* @param string|double $price
*
* @return $this
*/
public function setPrice($price)
{
NumericValidator::validate($price, "Price");
$price = FormatConverter::formatToPrice($price, $this->getCurrency());
$this->price = $price;
@@ -130,9 +128,8 @@ class Item extends PayPalModel
/**
* tax of the item.
*
*
* @param double $tax
* @param string|double $tax
*
* @return $this
*/
@@ -156,7 +153,6 @@ class Item extends PayPalModel
/**
* 3-letter Currency Code
*
*
* @param string $currency
*
@@ -180,7 +176,6 @@ class Item extends PayPalModel
/**
* Number or code to identify the item in your catalog/records.
*
*
* @param string $sku
*
@@ -204,7 +199,6 @@ class Item extends PayPalModel
/**
* URL linking to item information. Available to payer in transaction history.
*
*
* @param string $url
* @throws \InvalidArgumentException
@@ -228,8 +222,8 @@ class Item extends PayPalModel
}
/**
* Category type of the item. This can be either Digital or Physical.
*
* Category type of the item.
* Valid Values: ["DIGITAL", "PHYSICAL"]
*
* @param string $category
*
@@ -242,7 +236,7 @@ class Item extends PayPalModel
}
/**
* Category type of the item. This can be either Digital or Physical.
* Category type of the item.
*
* @return string
*/
@@ -252,10 +246,101 @@ class Item extends PayPalModel
}
/**
* Set of optional data used for PayPal risk determination.
*
* Weight of the item.
*
* @param \PayPal\Api\NameValuePair $supplementary_data
* @param \PayPal\Api\Measurement $weight
*
* @return $this
*/
public function setWeight($weight)
{
$this->weight = $weight;
return $this;
}
/**
* Weight of the item.
*
* @return \PayPal\Api\Measurement
*/
public function getWeight()
{
return $this->weight;
}
/**
* Length of the item.
*
* @param \PayPal\Api\Measurement $length
*
* @return $this
*/
public function setLength($length)
{
$this->length = $length;
return $this;
}
/**
* Length of the item.
*
* @return \PayPal\Api\Measurement
*/
public function getLength()
{
return $this->length;
}
/**
* Height of the item.
*
* @param \PayPal\Api\Measurement $height
*
* @return $this
*/
public function setHeight($height)
{
$this->height = $height;
return $this;
}
/**
* Height of the item.
*
* @return \PayPal\Api\Measurement
*/
public function getHeight()
{
return $this->height;
}
/**
* Width of the item.
*
* @param \PayPal\Api\Measurement $width
*
* @return $this
*/
public function setWidth($width)
{
$this->width = $width;
return $this;
}
/**
* Width of the item.
*
* @return \PayPal\Api\Measurement
*/
public function getWidth()
{
return $this->width;
}
/**
* Set of optional data used for PayPal risk determination.
*
* @param \PayPal\Api\NameValuePair[] $supplementary_data
*
* @return $this
*/
@@ -276,10 +361,39 @@ class Item extends PayPalModel
}
/**
* Set of optional data used for PayPal post-transaction notifications.
*
* Append SupplementaryData to the list.
*
* @param \PayPal\Api\NameValuePair $postback_data
* @param \PayPal\Api\NameValuePair $nameValuePair
* @return $this
*/
public function addSupplementaryData($nameValuePair)
{
if (!$this->getSupplementaryData()) {
return $this->setSupplementaryData(array($nameValuePair));
} else {
return $this->setSupplementaryData(
array_merge($this->getSupplementaryData(), array($nameValuePair))
);
}
}
/**
* Remove SupplementaryData from the list.
*
* @param \PayPal\Api\NameValuePair $nameValuePair
* @return $this
*/
public function removeSupplementaryData($nameValuePair)
{
return $this->setSupplementaryData(
array_diff($this->getSupplementaryData(), array($nameValuePair))
);
}
/**
* Set of optional data used for PayPal post-transaction notifications.
*
* @param \PayPal\Api\NameValuePair[] $postback_data
*
* @return $this
*/
@@ -299,4 +413,34 @@ class Item extends PayPalModel
return $this->postback_data;
}
/**
* Append PostbackData to the list.
*
* @param \PayPal\Api\NameValuePair $nameValuePair
* @return $this
*/
public function addPostbackData($nameValuePair)
{
if (!$this->getPostbackData()) {
return $this->setPostbackData(array($nameValuePair));
} else {
return $this->setPostbackData(
array_merge($this->getPostbackData(), array($nameValuePair))
);
}
}
/**
* Remove PostbackData from the list.
*
* @param \PayPal\Api\NameValuePair $nameValuePair
* @return $this
*/
public function removePostbackData($nameValuePair)
{
return $this->setPostbackData(
array_diff($this->getPostbackData(), array($nameValuePair))
);
}
}

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
/**
* Class ItemList
@@ -12,8 +11,9 @@ use PayPal\Rest\ApiContext;
*
* @package PayPal\Api
*
* @property \PayPal\Api\Item[] items
* @property \PayPal\Api\Item[] items
* @property \PayPal\Api\ShippingAddress shipping_address
* @property string shipping_method
*/
class ItemList extends PayPalModel
{
@@ -28,9 +28,8 @@ class ItemList extends PayPalModel
/**
* List of items.
*
*
* @param \PayPal\Api\Item[] $items
*
*
* @return $this
*/
public function setItems($items)
@@ -49,12 +48,41 @@ class ItemList extends PayPalModel
return $this->items;
}
/**
* Append Items to the list.
*
* @param \PayPal\Api\Item $item
* @return $this
*/
public function addItem($item)
{
if (!$this->getItems()) {
return $this->setItems(array($item));
} else {
return $this->setItems(
array_merge($this->getItems(), array($item))
);
}
}
/**
* Remove Items from the list.
*
* @param \PayPal\Api\Item $item
* @return $this
*/
public function removeItem($item)
{
return $this->setItems(
array_diff($this->getItems(), array($item))
);
}
/**
* Shipping address.
*
*
* @param \PayPal\Api\ShippingAddress $shipping_address
*
*
* @return $this
*/
public function setShippingAddress($shipping_address)
@@ -64,34 +92,7 @@ class ItemList extends PayPalModel
}
/**
* Append an item to the list.
*
* @return \PayPal\Api\Item
*/
public function addItem($item)
{
if (!$this->items) {
return $this->setItems(array($item));
} else {
return $this->setItems(
array_merge($this->items, array($item))
);
}
}
/**
* Remove an item from the list.
* Items are compared using === comparision (PHP.net)
*
* @return \PayPal\Api\Item
*/
public function removeItem($item)
{
return $this->setItems(array_diff($this->getItems(), array($item)));
}
/**
* Get Shipping Address
* Shipping address.
*
* @return \PayPal\Api\ShippingAddress
*/
@@ -100,4 +101,27 @@ class ItemList extends PayPalModel
return $this->shipping_address;
}
/**
* Shipping method used for this payment like USPSParcel etc.
*
* @param string $shipping_method
*
* @return $this
*/
public function setShippingMethod($shipping_method)
{
$this->shipping_method = $shipping_method;
return $this;
}
/**
* Shipping method used for this payment like USPSParcel etc.
*
* @return string
*/
public function getShippingMethod()
{
return $this->shipping_method;
}
}

View File

@@ -0,0 +1,65 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
/**
* Class Measurement
*
* Measurement to represent item dimensions like length, width, height and weight etc.
*
* @package PayPal\Api
*
* @property string value
* @property string unit
*/
class Measurement extends PayPalModel
{
/**
* Value this measurement represents.
*
* @param string $value
*
* @return $this
*/
public function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* Value this measurement represents.
*
* @return string
*/
public function getValue()
{
return $this->value;
}
/**
* Unit in which the value is represented.
*
* @param string $unit
*
* @return $this
*/
public function setUnit($unit)
{
$this->unit = $unit;
return $this;
}
/**
* Unit in which the value is represented.
*
* @return string
*/
public function getUnit()
{
return $this->unit;
}
}

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
/**
* Class NameValuePair
@@ -19,7 +18,6 @@ class NameValuePair extends PayPalModel
{
/**
* Key for the name value pair. The value name types should be correlated
*
*
* @param string $name
*
@@ -43,7 +41,6 @@ class NameValuePair extends PayPalModel
/**
* Value for the name value pair.
*
*
* @param string $value
*

View File

@@ -3,9 +3,11 @@
namespace PayPal\Api;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\Capture;
use PayPal\Api\Authorization;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PayPalRestCall;
use PayPal\Validation\ArgumentValidator;
/**
* Class Order
@@ -17,12 +19,14 @@ use PayPal\Validation\ArgumentValidator;
* @property string id
* @property string purchase_unit_reference_id
* @property \PayPal\Api\Amount amount
* @property string payment_mode
* @property string state
* @property string reason_code
* @property string pending_reason
* @property string protection_eligibility
* @property string protection_eligibility_type
* @property string parent_payment
* @property \PayPal\Api\FmfDetails fmf_details
* @property string create_time
* @property string update_time
*/
@@ -97,10 +101,33 @@ class Order extends PayPalResourceModel
return $this->amount;
}
/**
* specifies payment mode of the transaction
* Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"]
*
* @param string $payment_mode
*
* @return $this
*/
public function setPaymentMode($payment_mode)
{
$this->payment_mode = $payment_mode;
return $this;
}
/**
* specifies payment mode of the transaction
*
* @return string
*/
public function getPaymentMode()
{
return $this->payment_mode;
}
/**
* State of the order transaction.
* Valid Values: ["pending", "completed", "refunded", "partially_refunded"]
* Valid Values: ["pending", "completed", "refunded", "partially_refunded", "voided"]
*
* @param string $state
*
@@ -221,7 +248,8 @@ class Order extends PayPalResourceModel
/**
* ID of the Payment resource that this transaction is based on.
*
* @param string $parent_payment
* @param string $parent_payment
*
* @return $this
*/
public function setParentPayment($parent_payment)
@@ -240,6 +268,28 @@ class Order extends PayPalResourceModel
return $this->parent_payment;
}
/**
* Fraud Management Filter (FMF) details applied for the payment that could result in accept/deny/pending action.
*
* @param \PayPal\Api\FmfDetails $fmf_details
*
* @return $this
*/
public function setFmfDetails($fmf_details)
{
$this->fmf_details = $fmf_details;
return $this;
}
/**
* Fraud Management Filter (FMF) details applied for the payment that could result in accept/deny/pending action.
*
* @return \PayPal\Api\FmfDetails
*/
public function getFmfDetails()
{
return $this->fmf_details;
}
/**
* Time the resource was created in UTC ISO8601 format.

View File

@@ -7,7 +7,7 @@ use PayPal\Common\PayPalModel;
/**
* Class Patch
*
* A JSON patch object used for applying partial updates to resources.
* A JSON Patch object used for doing partial updates to resources.
*
* @package PayPal\Api
*
@@ -19,8 +19,8 @@ use PayPal\Common\PayPalModel;
class Patch extends PayPalModel
{
/**
* The operation to perform.
* Valid Values: ["add", "remove", "replace", "move", "copy", "test"]
* Patch operation to perform.Value required for add & remove operation can be any JSON value.
* Valid Values: ["add", "remove", "replace"]
*
* @param string $op
*
@@ -33,7 +33,7 @@ class Patch extends PayPalModel
}
/**
* The operation to perform.
* Patch operation to perform.Value required for add & remove operation can be any JSON value.
*
* @return string
*/
@@ -43,7 +43,7 @@ class Patch extends PayPalModel
}
/**
* String containing a JSON-Pointer value that references a location within the target document where the operation is performed.
* string containing a JSON-Pointer value that references a location within the target document (the target location) 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 where the operation is performed.
* string containing a JSON-Pointer value that references a location within the target document (the target location) where the operation is performed.
*
* @return string
*/
@@ -66,7 +66,7 @@ class Patch extends PayPalModel
}
/**
* New value to apply based on the operation. op=remove does not require value.
* New value to apply based on the operation.
*
* @param mixed $value
*
@@ -79,7 +79,7 @@ class Patch extends PayPalModel
}
/**
* New value to apply based on the operation. op=remove does not require value.
* New value to apply based on the operation.
*
* @return mixed
*/
@@ -89,7 +89,7 @@ class Patch extends PayPalModel
}
/**
* 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.
* A string containing a JSON Pointer value that references the location in the target document to move the value from.
*
* @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 from which to move the value. Required for use where op=move.
* A string containing a JSON Pointer value that references the location in the target document to move the value from.
*
* @return string
*/

View File

@@ -13,15 +13,19 @@ use PayPal\Common\PayPalModel;
*
* @property string payment_method
* @property string status
* @property string account_type
* @property string account_age
* @property \PayPal\Api\FundingInstrument[] funding_instruments
* @property string funding_option_id
* @property \PayPal\Api\FundingOption funding_option
* @property \PayPal\Api\FundingOption related_funding_option
* @property \PayPal\Api\PayerInfo payer_info
*/
class Payer extends PayPalModel
{
/**
* Payment method being used - PayPal Wallet payment, Bank Direct Debit, or Direct Credit card.
* Valid Values: ["credit_card", "bank", "paypal"]
* Payment method being used - PayPal Wallet payment, Bank Direct Debit or Direct Credit card.
* Valid Values: ["credit_card", "bank", "paypal", "pay_upon_invoice", "carrier"]
*
* @param string $payment_method
*
@@ -34,7 +38,7 @@ class Payer extends PayPalModel
}
/**
* Payment method being used - PayPal Wallet payment, Bank Direct Debit, or Direct Credit card.
* Payment method being used - PayPal Wallet payment, Bank Direct Debit or Direct Credit card.
*
* @return string
*/
@@ -44,7 +48,7 @@ class Payer extends PayPalModel
}
/**
* Status of Payer PayPal Account.
* Status of payer's PayPal Account.
* Valid Values: ["VERIFIED", "UNVERIFIED"]
*
* @param string $status
@@ -58,7 +62,7 @@ class Payer extends PayPalModel
}
/**
* Status of Payer PayPal Account.
* Status of payer's PayPal Account.
*
* @return string
*/
@@ -68,7 +72,54 @@ class Payer extends PayPalModel
}
/**
* List of funding instruments from which the funds of the current payment come. Typically a credit card.
* Type of account relationship payer has with PayPal.
* Valid Values: ["BUSINESS", "PERSONAL", "PREMIER"]
*
* @param string $account_type
*
* @return $this
*/
public function setAccountType($account_type)
{
$this->account_type = $account_type;
return $this;
}
/**
* Type of account relationship payer has with PayPal.
*
* @return string
*/
public function getAccountType()
{
return $this->account_type;
}
/**
* Duration since the payer established account relationship with PayPal in days.
*
* @param string $account_age
*
* @return $this
*/
public function setAccountAge($account_age)
{
$this->account_age = $account_age;
return $this;
}
/**
* Duration since the payer established account relationship with PayPal in days.
*
* @return string
*/
public function getAccountAge()
{
return $this->account_age;
}
/**
* List of funding instruments to fund the payment.
*
* @param \PayPal\Api\FundingInstrument[] $funding_instruments
*
@@ -81,7 +132,7 @@ class Payer extends PayPalModel
}
/**
* List of funding instruments from which the funds of the current payment come. Typically a credit card.
* List of funding instruments to fund the payment.
*
* @return \PayPal\Api\FundingInstrument[]
*/
@@ -121,7 +172,7 @@ class Payer extends PayPalModel
}
/**
* Id of user selected funding option for the payment. 'OneOf' funding_instruments or funding_option_id to be present.
* Id of user selected funding option for the payment. 'OneOf' funding_instruments or funding_option_id to be present
*
* @param string $funding_option_id
*
@@ -134,7 +185,7 @@ class Payer extends PayPalModel
}
/**
* Id of user selected funding option for the payment. 'OneOf' funding_instruments or funding_option_id to be present.
* Id of user selected funding option for the payment. 'OneOf' funding_instruments or funding_option_id to be present
*
* @return string
*/
@@ -143,6 +194,52 @@ class Payer extends PayPalModel
return $this->funding_option_id;
}
/**
* Default funding option available for the payment
*
* @param \PayPal\Api\FundingOption $funding_option
*
* @return $this
*/
public function setFundingOption($funding_option)
{
$this->funding_option = $funding_option;
return $this;
}
/**
* Default funding option available for the payment
*
* @return \PayPal\Api\FundingOption
*/
public function getFundingOption()
{
return $this->funding_option;
}
/**
* Funding option related to default funding option.
*
* @param \PayPal\Api\FundingOption $related_funding_option
*
* @return $this
*/
public function setRelatedFundingOption($related_funding_option)
{
$this->related_funding_option = $related_funding_option;
return $this;
}
/**
* Funding option related to default funding option.
*
* @return \PayPal\Api\FundingOption
*/
public function getRelatedFundingOption()
{
return $this->related_funding_option;
}
/**
* Information related to the Payer.
*

View File

@@ -7,21 +7,25 @@ use PayPal\Common\PayPalModel;
/**
* Class PayerInfo
*
* A resource representing information about a Payer.
* A resource representing a information about Payer.
*
* @package PayPal\Api
*
* @property string email
* @property string external_remember_me_id
* @property string buyer_account_number
* @property string salutation
* @property string first_name
* @property string middle_name
* @property string last_name
* @property string suffix
* @property string payer_id
* @property string phone
* @property string phone_type
* @property string birth_date
* @property string tax_id
* @property string tax_id_type
* @property string country_code
* @property \PayPal\Api\Address billing_address
* @property \PayPal\Api\ShippingAddress shipping_address
*/
@@ -96,6 +100,29 @@ class PayerInfo extends PayPalModel
return $this->buyer_account_number;
}
/**
* Salutation of the Payer.
*
* @param string $salutation
*
* @return $this
*/
public function setSalutation($salutation)
{
$this->salutation = $salutation;
return $this;
}
/**
* Salutation of the Payer.
*
* @return string
*/
public function getSalutation()
{
return $this->salutation;
}
/**
* First Name of the Payer.
*
@@ -119,6 +146,29 @@ class PayerInfo extends PayPalModel
return $this->first_name;
}
/**
* Middle Name of the Payer.
*
* @param string $middle_name
*
* @return $this
*/
public function setMiddleName($middle_name)
{
$this->middle_name = $middle_name;
return $this;
}
/**
* Middle Name of the Payer.
*
* @return string
*/
public function getMiddleName()
{
return $this->middle_name;
}
/**
* Last Name of the Payer.
*
@@ -142,6 +192,29 @@ class PayerInfo extends PayPalModel
return $this->last_name;
}
/**
* Suffix of the Payer.
*
* @param string $suffix
*
* @return $this
*/
public function setSuffix($suffix)
{
$this->suffix = $suffix;
return $this;
}
/**
* Suffix of the Payer.
*
* @return string
*/
public function getSuffix()
{
return $this->suffix;
}
/**
* PayPal assigned Payer ID.
*
@@ -213,7 +286,7 @@ class PayerInfo extends PayPalModel
}
/**
* Birth date of the Payer in ISO8601 format (YYYY-MM-DD).
* Birth date of the Payer in ISO8601 format (yyyy-mm-dd).
*
* @param string $birth_date
*
@@ -226,7 +299,7 @@ class PayerInfo extends PayPalModel
}
/**
* Birth date of the Payer in ISO8601 format (YYYY-MM-DD).
* Birth date of the Payer in ISO8601 format (yyyy-mm-dd).
*
* @return string
*/
@@ -282,6 +355,29 @@ class PayerInfo extends PayPalModel
return $this->tax_id_type;
}
/**
* 2 letter registered country code of the payer to identify the buyer country
*
* @param string $country_code
*
* @return $this
*/
public function setCountryCode($country_code)
{
$this->country_code = $country_code;
return $this;
}
/**
* 2 letter registered country code of the payer to identify the buyer country
*
* @return string
*/
public function getCountryCode()
{
return $this->country_code;
}
/**
* Billing address of the Payer.
*

View File

@@ -2,14 +2,13 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Common\PayPalResourceModel;
use PayPal\Core\PayPalConstants;
use PayPal\Rest\ApiContext;
use PayPal\Rest\IResource;
use PayPal\Api\PaymentHistory;
use PayPal\Transport\PayPalRestCall;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\object;
use PayPal\Api\PaymentHistory;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PayPalRestCall;
/**
* Class Payment
@@ -23,8 +22,11 @@ use PayPal\Validation\ArgumentValidator;
* @property string update_time
* @property string intent
* @property \PayPal\Api\Payer payer
* @property \PayPal\Api\object cart
* @property \PayPal\Api\Payee payee
* @property string cart
* @property \PayPal\Api\Transaction[] transactions
* @property \PayPal\Api\Error[] failed_transactions
* @property \PayPal\Api\PaymentInstruction payment_instruction
* @property string state
* @property \PayPal\Api\RedirectUrls redirect_urls
* @property string experience_profile_id
@@ -34,9 +36,8 @@ class Payment extends PayPalResourceModel
/**
* Identifier of the payment resource created.
*
*
* @param string $id
*
*
* @return $this
*/
public function setId($id)
@@ -55,60 +56,12 @@ class Payment extends PayPalResourceModel
return $this->id;
}
/**
* 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 last updated 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 last updated in UTC ISO8601 format.
*
* @return string
*/
public function getUpdateTime()
{
return $this->update_time;
}
/**
* Intent of the payment - Sale or Authorization or Order.
* Valid Values: ["sale", "authorize", "order"]
*
* @param string $intent
*
*
* @return $this
*/
public function setIntent($intent)
@@ -130,9 +83,8 @@ class Payment extends PayPalResourceModel
/**
* 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)
@@ -152,11 +104,33 @@ class Payment extends PayPalResourceModel
}
/**
* Cart for which the payment is done.
* .
*
* @param \PayPal\Api\Payee $payee
*
* @return $this
*/
public function setPayee($payee)
{
$this->payee = $payee;
return $this;
}
/**
* .
*
* @param \PayPal\Api\object $cart
* @return \PayPal\Api\Payee
*/
public function getPayee()
{
return $this->payee;
}
/**
* ID of the cart to execute the payment.
*
* @param string $cart
*
* @return $this
*/
public function setCart($cart)
@@ -166,9 +140,9 @@ class Payment extends PayPalResourceModel
}
/**
* Cart for which the payment is done.
* ID of the cart to execute the payment.
*
* @return \PayPal\Api\object
* @return string
*/
public function getCart()
{
@@ -178,9 +152,8 @@ class Payment extends PayPalResourceModel
/**
* A payment can have more than one transaction, with each transaction establishing a contract between the payer and a payee
*
*
* @param \PayPal\Api\Transaction[] $transactions
*
*
* @return $this
*/
public function setTransactions($transactions)
@@ -199,12 +172,118 @@ class Payment extends PayPalResourceModel
return $this->transactions;
}
/**
* Append Transactions to the list.
*
* @param \PayPal\Api\Transaction $transaction
* @return $this
*/
public function addTransaction($transaction)
{
if (!$this->getTransactions()) {
return $this->setTransactions(array($transaction));
} else {
return $this->setTransactions(
array_merge($this->getTransactions(), array($transaction))
);
}
}
/**
* Remove Transactions from the list.
*
* @param \PayPal\Api\Transaction $transaction
* @return $this
*/
public function removeTransaction($transaction)
{
return $this->setTransactions(
array_diff($this->getTransactions(), array($transaction))
);
}
/**
* Applicable for advanced payments like multi seller payment (MSP) to support partial failures
*
* @param \PayPal\Api\Error[] $failed_transactions
*
* @return $this
*/
public function setFailedTransactions($failed_transactions)
{
$this->failed_transactions = $failed_transactions;
return $this;
}
/**
* Applicable for advanced payments like multi seller payment (MSP) to support partial failures
*
* @return \PayPal\Api\Error[]
*/
public function getFailedTransactions()
{
return $this->failed_transactions;
}
/**
* Append FailedTransactions to the list.
*
* @param \PayPal\Api\Error $error
* @return $this
*/
public function addFailedTransaction($error)
{
if (!$this->getFailedTransactions()) {
return $this->setFailedTransactions(array($error));
} else {
return $this->setFailedTransactions(
array_merge($this->getFailedTransactions(), array($error))
);
}
}
/**
* Remove FailedTransactions from the list.
*
* @param \PayPal\Api\Error $error
* @return $this
*/
public function removeFailedTransaction($error)
{
return $this->setFailedTransactions(
array_diff($this->getFailedTransactions(), array($error))
);
}
/**
* A payment instruction resource
*
* @param \PayPal\Api\PaymentInstruction $payment_instruction
*
* @return $this
*/
public function setPaymentInstruction($payment_instruction)
{
$this->payment_instruction = $payment_instruction;
return $this;
}
/**
* A payment instruction resource
*
* @return \PayPal\Api\PaymentInstruction
*/
public function getPaymentInstruction()
{
return $this->payment_instruction;
}
/**
* state of the payment
* Valid Values: ["created", "approved", "failed", "canceled", "expired"]
* Valid Values: ["created", "approved", "completed", "partially_completed", "failed", "canceled", "expired", "in_progress"]
*
* @param string $state
*
*
* @return $this
*/
public function setState($state)
@@ -223,12 +302,34 @@ class Payment extends PayPalResourceModel
return $this->state;
}
/**
* Identifier for the payment experience.
*
* @param string $experience_profile_id
*
* @return $this
*/
public function setExperienceProfileId($experience_profile_id)
{
$this->experience_profile_id = $experience_profile_id;
return $this;
}
/**
* Identifier for the payment experience.
*
* @return string
*/
public function getExperienceProfileId()
{
return $this->experience_profile_id;
}
/**
* 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)
@@ -248,28 +349,49 @@ class Payment extends PayPalResourceModel
}
/**
* Set Experience_profile_id
* experience_profile_id of the payment
*
* @param string $experience_profile_id
* Time the resource was created in UTC ISO8601 format.
*
* @param string $create_time
*
* @return $this
*/
public function setExperienceProfileId($experience_profile_id)
public function setCreateTime($create_time)
{
$this->experience_profile_id = $experience_profile_id;
$this->create_time = $create_time;
return $this;
}
/**
* Get Experience_profile_id
* Experience_profile_id of the payment
* Time the resource was created in UTC ISO8601 format.
*
* @return string
*/
public function getExperienceProfileId()
public function getCreateTime()
{
return $this->experience_profile_id;
return $this->create_time;
}
/**
* 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;
}
/**
* Time the resource was last updated in UTC ISO8601 format.
*
* @return string
*/
public function getUpdateTime()
{
return $this->update_time;
}
/**
@@ -281,17 +403,16 @@ class Payment extends PayPalResourceModel
{
return $this->getLink(PayPalConstants::APPROVAL_URL);
}
/**
* Creates (and processes) a new Payment Resource.
* Create and process a payment by passing a payment object that includes the intent, payer, and transactions in the body of the request JSON. For PayPal payments, include redirect URLs in the payment object.
*
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @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 Payment
*/
public function create($apiContext = null, $restCall = null)
{
$payLoad = $this->toJSON();
$json = self::executeCall(
"/v1/payments/payment",
@@ -306,17 +427,16 @@ class Payment extends PayPalResourceModel
}
/**
* Obtain the Payment resource for the given identifier.
* Look up a particular payment resource by passing the payment_id in the request URI.
*
* @param string $paymentId
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @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 Payment
*/
public static function get($paymentId, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($paymentId, 'paymentId');
$payLoad = "";
$json = self::executeCall(
"/v1/payments/payment/$paymentId",
@@ -356,10 +476,10 @@ class Payment extends PayPalResourceModel
}
/**
* Executes the payment (after approved by the Payer) associated with this resource when the payment method is PayPal.
* Execute (complete) a PayPal payment that has been approved by the payer by passing the payment_id in the request URI. This request only works after a buyer has approved the payment using the provided PayPal approval URL. Optionally update transaction information when executing the payment by passing in one or more transactions.
*
* @param PaymentExecution $paymentExecution
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @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 Payment
*/
@@ -367,7 +487,6 @@ class Payment extends PayPalResourceModel
{
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($paymentExecution, 'paymentExecution');
$payLoad = $paymentExecution->toJSON();
$json = self::executeCall(
"/v1/payments/payment/{$this->getId()}/execute",
@@ -382,17 +501,16 @@ class Payment extends PayPalResourceModel
}
/**
* Retrieves a list of Payment resources.
* List payments in any state (created, approved, failed, etc.). Payments returned are the payments made to the merchant issuing the request.
*
* @param array $params
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return PaymentHistory
*/
public static function all($params, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($params, 'params');
$payLoad = "";
$allowedParams = array(
'count' => 1,
@@ -417,5 +535,4 @@ class Payment extends PayPalResourceModel
return $ret;
}
}

View File

@@ -16,11 +16,12 @@ use PayPal\Common\PayPalModel;
* @property string type
* @property int expire_month
* @property int expire_year
* @property int start_month
* @property int start_year
* @property int cvv2
* @property string start_month
* @property string start_year
* @property string cvv2
* @property string first_name
* @property string last_name
* @property string billing_country
* @property \PayPal\Api\Address billing_address
* @property string external_customer_id
* @property string status
@@ -123,7 +124,7 @@ class PaymentCard extends PayPalModel
}
/**
* 4 digit card expiry year.
* 4 digit card expiry year
*
* @param int $expire_year
*
@@ -136,7 +137,7 @@ class PaymentCard extends PayPalModel
}
/**
* 4 digit card expiry year.
* 4 digit card expiry year
*
* @return int
*/
@@ -148,7 +149,7 @@ class PaymentCard extends PayPalModel
/**
* 2 digit card start month.
*
* @param int $start_month
* @param string $start_month
*
* @return $this
*/
@@ -161,7 +162,7 @@ class PaymentCard extends PayPalModel
/**
* 2 digit card start month.
*
* @return int
* @return string
*/
public function getStartMonth()
{
@@ -171,7 +172,7 @@ class PaymentCard extends PayPalModel
/**
* 4 digit card start year.
*
* @param int $start_year
* @param string $start_year
*
* @return $this
*/
@@ -184,7 +185,7 @@ class PaymentCard extends PayPalModel
/**
* 4 digit card start year.
*
* @return int
* @return string
*/
public function getStartYear()
{
@@ -192,9 +193,9 @@ class PaymentCard extends PayPalModel
}
/**
* Card validation code. Only supported when making a Payment, but not when saving a payment card for future use.
* Card validation code. Only supported when making a Payment but not when saving a payment card for future use.
*
* @param int $cvv2
* @param string $cvv2
*
* @return $this
*/
@@ -205,9 +206,9 @@ class PaymentCard extends PayPalModel
}
/**
* Card validation code. Only supported when making a Payment, but not when saving a payment card for future use.
* Card validation code. Only supported when making a Payment but not when saving a payment card for future use.
*
* @return int
* @return string
*/
public function getCvv2()
{
@@ -260,6 +261,29 @@ class PaymentCard extends PayPalModel
return $this->last_name;
}
/**
* 2 letter country code
*
* @param string $billing_country
*
* @return $this
*/
public function setBillingCountry($billing_country)
{
$this->billing_country = $billing_country;
return $this;
}
/**
* 2 letter country code
*
* @return string
*/
public function getBillingCountry()
{
return $this->billing_country;
}
/**
* Billing Address associated with this card.
*
@@ -284,7 +308,7 @@ class PaymentCard extends PayPalModel
}
/**
* A unique identifier of the customer to whom this card account belongs. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
* A unique identifier of the customer to whom this card account belongs to. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
*
* @param string $external_customer_id
*
@@ -297,7 +321,7 @@ class PaymentCard extends PayPalModel
}
/**
* A unique identifier of the customer to whom this card account belongs. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
* A unique identifier of the customer to whom this card account belongs to. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
*
* @return string
*/
@@ -331,7 +355,7 @@ class PaymentCard extends PayPalModel
}
/**
* Date/Time until this resource can be used to fund a payment.
* Date/Time until this resource can be used fund a payment.
*
* @param string $valid_until
*
@@ -344,7 +368,7 @@ class PaymentCard extends PayPalModel
}
/**
* Date/Time until this resource can be used to fund a payment.
* Date/Time until this resource can be used fund a payment.
*
* @return string
*/

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
/**
* Class PaymentExecution
@@ -13,13 +12,12 @@ use PayPal\Rest\ApiContext;
* @package PayPal\Api
*
* @property string payer_id
* @property \PayPal\Api\Transactions transactions
* @property \PayPal\Api\Transaction[] transactions
*/
class PaymentExecution extends PayPalModel
{
/**
* PayPal assigned Payer ID returned in the approval return url.
*
*
* @param string $payer_id
*
@@ -42,10 +40,9 @@ class PaymentExecution extends PayPalModel
}
/**
* If the amount needs to be updated after obtaining the PayPal Payer info (eg. shipping address), it can be updated using this element.
*
* Transaction information to be used at the time of execute payment. Only amount and shipping_address can be updated in execute payment
*
* @param \PayPal\Api\Transactions $transactions
* @param \PayPal\Api\Transaction[] $transactions
*
* @return $this
*/
@@ -56,13 +53,43 @@ class PaymentExecution extends PayPalModel
}
/**
* If the amount needs to be updated after obtaining the PayPal Payer info (eg. shipping address), it can be updated using this element.
* Transaction information to be used at the time of execute payment. Only amount and shipping_address can be updated in execute payment
*
* @return \PayPal\Api\Transactions[]
* @return \PayPal\Api\Transaction[]
*/
public function getTransactions()
{
return $this->transactions;
}
/**
* Append Transactions to the list.
*
* @param \PayPal\Api\Transaction $transaction
* @return $this
*/
public function addTransaction($transaction)
{
if (!$this->getTransactions()) {
return $this->setTransactions(array($transaction));
} else {
return $this->setTransactions(
array_merge($this->getTransactions(), array($transaction))
);
}
}
/**
* Remove Transactions from the list.
*
* @param \PayPal\Api\Transaction $transaction
* @return $this
*/
public function removeTransaction($transaction)
{
return $this->setTransactions(
array_diff($this->getTransactions(), array($transaction))
);
}
}

View File

@@ -3,16 +3,15 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
/**
* Class PaymentHistory
*
* A list of Payment Resources
* List of Payments made by the seller.
*
* @package PayPal\Api
*
* @property \PayPal\Api\Payment payments
* @property \PayPal\Api\Payment[] payments
* @property int count
* @property string next_id
*/
@@ -20,9 +19,8 @@ class PaymentHistory extends PayPalModel
{
/**
* A list of Payment resources
*
*
* @param \PayPal\Api\Payment $payments
* @param \PayPal\Api\Payment[] $payments
*
* @return $this
*/
@@ -42,9 +40,38 @@ class PaymentHistory extends PayPalModel
return $this->payments;
}
/**
* Append Payments to the list.
*
* @param \PayPal\Api\Payment $payment
* @return $this
*/
public function addPayment($payment)
{
if (!$this->getPayments()) {
return $this->setPayments(array($payment));
} else {
return $this->setPayments(
array_merge($this->getPayments(), array($payment))
);
}
}
/**
* Remove Payments from the list.
*
* @param \PayPal\Api\Payment $payment
* @return $this
*/
public function removePayment($payment)
{
return $this->setPayments(
array_diff($this->getPayments(), array($payment))
);
}
/**
* 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.
*
*
* @param int $count
*
@@ -68,7 +95,6 @@ class PaymentHistory extends PayPalModel
/**
* Identifier of the next element to get the next range of results.
*
*
* @param string $next_id
*

View File

@@ -0,0 +1,190 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PayPalRestCall;
/**
* Class PaymentInstruction
*
* Object used to represent payment instruction.
*
* @package PayPal\Api
*
* @property string reference_number
* @property string instruction_type
* @property \PayPal\Api\RecipientBankingInstruction recipient_banking_instruction
* @property \PayPal\Api\Currency amount
* @property string payment_due_date
* @property string note
* @property \PayPal\Api\Links[] links
*/
class PaymentInstruction extends PayPalResourceModel
{
/**
* ID of payment instruction
*
* @param string $reference_number
*
* @return $this
*/
public function setReferenceNumber($reference_number)
{
$this->reference_number = $reference_number;
return $this;
}
/**
* ID of payment instruction
*
* @return string
*/
public function getReferenceNumber()
{
return $this->reference_number;
}
/**
* Type of payment instruction
* Valid Values: ["MANUAL_BANK_TRANSFER", "PAY_UPON_INVOICE"]
*
* @param string $instruction_type
*
* @return $this
*/
public function setInstructionType($instruction_type)
{
$this->instruction_type = $instruction_type;
return $this;
}
/**
* Type of payment instruction
*
* @return string
*/
public function getInstructionType()
{
return $this->instruction_type;
}
/**
* Recipient bank Details.
*
* @param \PayPal\Api\RecipientBankingInstruction $recipient_banking_instruction
*
* @return $this
*/
public function setRecipientBankingInstruction($recipient_banking_instruction)
{
$this->recipient_banking_instruction = $recipient_banking_instruction;
return $this;
}
/**
* Recipient bank Details.
*
* @return \PayPal\Api\RecipientBankingInstruction
*/
public function getRecipientBankingInstruction()
{
return $this->recipient_banking_instruction;
}
/**
* Amount to be transferred
*
* @param \PayPal\Api\Currency $amount
*
* @return $this
*/
public function setAmount($amount)
{
$this->amount = $amount;
return $this;
}
/**
* Amount to be transferred
*
* @return \PayPal\Api\Currency
*/
public function getAmount()
{
return $this->amount;
}
/**
* Date by which payment should be received
*
* @param string $payment_due_date
*
* @return $this
*/
public function setPaymentDueDate($payment_due_date)
{
$this->payment_due_date = $payment_due_date;
return $this;
}
/**
* Date by which payment should be received
*
* @return string
*/
public function getPaymentDueDate()
{
return $this->payment_due_date;
}
/**
* Additional text regarding payment handling
*
* @param string $note
*
* @return $this
*/
public function setNote($note)
{
$this->note = $note;
return $this;
}
/**
* Additional text regarding payment handling
*
* @return string
*/
public function getNote()
{
return $this->note;
}
/**
* Retrieve a payment instruction by passing the payment_id in the request URI. Use this request if you are implementing a solution that includes delayed payment like Pay Upon Invoice (PUI).
*
* @param string $paymentId
* @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 PaymentInstruction
*/
public static function get($paymentId, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($paymentId, 'paymentId');
$payLoad = "";
$json = self::executeCall(
"/v1/payments/payment/$paymentId/payment-instruction",
"GET",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new PaymentInstruction();
$ret->fromJson($json);
return $ret;
}
}

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
/**
* Class PaymentOptions
@@ -18,7 +17,7 @@ class PaymentOptions extends PayPalModel
{
/**
* Payment method requested for this purchase unit
* Valid Values: ["UNRESTRICTED", "INSTANT_FUNDING_SOURCE", "IMMEDIATE_PAY"]
* Valid Values: ["UNRESTRICTED", "INSTANT_FUNDING_SOURCE", "IMMEDIATE_PAY"]
*
* @param string $allowed_payment_method
*

View File

@@ -7,7 +7,7 @@ use PayPal\Common\PayPalModel;
/**
* Class Phone
*
* Representation of a phone number.
* Information related to the Payer. In case of PayPal Wallet payment, this information will be filled in by PayPal after the user approves the payment using their PayPal Wallet.
*
* @package PayPal\Api
*
@@ -18,7 +18,7 @@ use PayPal\Common\PayPalModel;
class Phone extends PayPalModel
{
/**
* Country code (in E.164 format). Assume length is n.
* Country code (from in E.164 format)
*
* @param string $country_code
*
@@ -31,7 +31,7 @@ class Phone extends PayPalModel
}
/**
* Country code (in E.164 format). Assume length is n.
* Country code (from in E.164 format)
*
* @return string
*/
@@ -41,7 +41,7 @@ class Phone extends PayPalModel
}
/**
* In-country phone number (in E.164 format). Maximum (15 - n) digits.
* In-country phone number (from in E.164 format)
*
* @param string $national_number
*
@@ -54,7 +54,7 @@ class Phone extends PayPalModel
}
/**
* In-country phone number (in E.164 format). Maximum (15 - n) digits.
* In-country phone number (from in E.164 format)
*
* @return string
*/
@@ -66,9 +66,8 @@ class Phone extends PayPalModel
/**
* Phone extension
*
*
* @param string $extension
*
*
* @return $this
*/
public function setExtension($extension)

View File

@@ -0,0 +1,161 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
/**
* Class RecipientBankingInstruction
*
* Recipient bank Details.
*
* @package PayPal\Api
*
* @property string bank_name
* @property string account_holder_name
* @property string account_number
* @property string routing_number
* @property string international_bank_account_number
* @property string bank_identifier_code
*/
class RecipientBankingInstruction extends PayPalModel
{
/**
* Name of the financial institution.
*
* @param string $bank_name
*
* @return $this
*/
public function setBankName($bank_name)
{
$this->bank_name = $bank_name;
return $this;
}
/**
* Name of the financial institution.
*
* @return string
*/
public function getBankName()
{
return $this->bank_name;
}
/**
* Name of the account holder
*
* @param string $account_holder_name
*
* @return $this
*/
public function setAccountHolderName($account_holder_name)
{
$this->account_holder_name = $account_holder_name;
return $this;
}
/**
* Name of the account holder
*
* @return string
*/
public function getAccountHolderName()
{
return $this->account_holder_name;
}
/**
* bank account number
*
* @param string $account_number
*
* @return $this
*/
public function setAccountNumber($account_number)
{
$this->account_number = $account_number;
return $this;
}
/**
* bank account number
*
* @return string
*/
public function getAccountNumber()
{
return $this->account_number;
}
/**
* bank routing number
*
* @param string $routing_number
*
* @return $this
*/
public function setRoutingNumber($routing_number)
{
$this->routing_number = $routing_number;
return $this;
}
/**
* bank routing number
*
* @return string
*/
public function getRoutingNumber()
{
return $this->routing_number;
}
/**
* IBAN equivalent of the bank
*
* @param string $international_bank_account_number
*
* @return $this
*/
public function setInternationalBankAccountNumber($international_bank_account_number)
{
$this->international_bank_account_number = $international_bank_account_number;
return $this;
}
/**
* IBAN equivalent of the bank
*
* @return string
*/
public function getInternationalBankAccountNumber()
{
return $this->international_bank_account_number;
}
/**
* BIC identifier of the financial institution
*
* @param string $bank_identifier_code
*
* @return $this
*/
public function setBankIdentifierCode($bank_identifier_code)
{
$this->bank_identifier_code = $bank_identifier_code;
return $this;
}
/**
* BIC identifier of the financial institution
*
* @return string
*/
public function getBankIdentifierCode()
{
return $this->bank_identifier_code;
}
}

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
use PayPal\Validation\UrlValidator;
/**
@@ -20,10 +19,9 @@ class RedirectUrls extends PayPalModel
{
/**
* Url where the payer would be redirected to after approving the payment.
*
*
* @param string $return_url
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
* @return $this
*/
public function setReturnUrl($return_url)
@@ -45,7 +43,6 @@ class RedirectUrls extends PayPalModel
/**
* Url where the payer would be redirected to after canceling the payment.
*
*
* @param string $cancel_url
* @throws \InvalidArgumentException

View File

@@ -2,11 +2,10 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
use PayPal\Rest\IResource;
use PayPal\Transport\PayPalRestCall;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PayPalRestCall;
/**
* Class Refund
@@ -20,18 +19,17 @@ use PayPal\Validation\ArgumentValidator;
* @property string update_time
* @property \PayPal\Api\Amount amount
* @property string state
* @property string reason
* @property string sale_id
* @property string capture_id
* @property string parent_payment
* @property string description
* @property \PayPal\Api\Links links
* @property \PayPal\Api\Links[] links
*/
class Refund extends PayPalModel implements IResource
class Refund extends PayPalResourceModel
{
/**
* Identifier of the refund transaction in UTC ISO8601 format.
*
*
* @param string $id
*
@@ -53,57 +51,8 @@ class Refund extends PayPalModel implements IResource
return $this->id;
}
/**
* 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 last updated 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 last updated in UTC ISO8601 format.
*
* @return string
*/
public function getUpdateTime()
{
return $this->update_time;
}
/**
* Details including both refunded amount (to Payer) and refunded fee (to Payee).If amount is not specified, it's assumed to be full refund.
*
*
* @param \PayPal\Api\Amount $amount
*
@@ -127,7 +76,7 @@ class Refund extends PayPalModel implements IResource
/**
* State of the refund transaction.
* Valid Values: ["pending", "completed", "failed"]
* Valid Values: ["pending", "completed", "failed"]
*
* @param string $state
*
@@ -150,8 +99,30 @@ class Refund extends PayPalModel implements IResource
}
/**
* ID of the Sale transaction being refunded.
* Reason description for the Sale transaction being refunded.
*
* @param string $reason
*
* @return $this
*/
public function setReason($reason)
{
$this->reason = $reason;
return $this;
}
/**
* Reason description for the Sale transaction being refunded.
*
* @return string
*/
public function getReason()
{
return $this->reason;
}
/**
* ID of the Sale transaction being refunded.
*
* @param string $sale_id
*
@@ -175,7 +146,6 @@ class Refund extends PayPalModel implements IResource
/**
* ID of the Capture transaction being refunded.
*
*
* @param string $capture_id
*
@@ -199,7 +169,6 @@ class Refund extends PayPalModel implements IResource
/**
* ID of the Payment resource that this transaction is based on.
*
*
* @param string $parent_payment
*
@@ -223,7 +192,6 @@ class Refund extends PayPalModel implements IResource
/**
* Description of what is being refunded for.
*
*
* @param string $description
*
@@ -246,46 +214,71 @@ class Refund extends PayPalModel implements IResource
}
/**
* Sets Links
*
* Time the resource was created in UTC ISO8601 format.
*
* @param \PayPal\Api\Links $links
* @param string $create_time
*
* @return $this
*/
public function setLinks($links)
public function setCreateTime($create_time)
{
$this->links = $links;
$this->create_time = $create_time;
return $this;
}
/**
* Gets Links
* Time the resource was created in UTC ISO8601 format.
*
* @return \PayPal\Api\Links[]
* @return string
*/
public function getLinks()
public function getCreateTime()
{
return $this->links;
return $this->create_time;
}
/**
* Obtain the Refund transaction resource for the given identifier.
* 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;
}
/**
* Time the resource was last updated in UTC ISO8601 format.
*
* @return string
*/
public function getUpdateTime()
{
return $this->update_time;
}
/**
* Retrieve details about a specific refund by passing the refund_id in the request URI.
*
* @param string $refundId
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Refund
*/
public static function get($refundId, $apiContext = null)
public static function get($refundId, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($refundId, 'refundId');
$payLoad = "";
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PayPalRestCall($apiContext);
$json = $call->execute(array('PayPal\Handler\RestHandler'), "/v1/payments/refund/$refundId", "GET", $payLoad);
$json = self::executeCall(
"/v1/payments/refund/$refundId",
"GET",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new Refund();
$ret->fromJson($json);
return $ret;

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
/**
* Class RelatedResources
@@ -22,10 +21,10 @@ class RelatedResources extends PayPalModel
{
/**
* A sale transaction
*
*
*
* @param \PayPal\Api\Sale $sale
*
*
* @return $this
*/
public function setSale($sale)
@@ -46,10 +45,10 @@ class RelatedResources extends PayPalModel
/**
* An authorization transaction
*
*
*
* @param \PayPal\Api\Authorization $authorization
*
*
* @return $this
*/
public function setAuthorization($authorization)
@@ -70,10 +69,10 @@ class RelatedResources extends PayPalModel
/**
* An order transaction
*
*
*
* @param \PayPal\Api\Order $order
*
*
* @return $this
*/
public function setOrder($order)
@@ -94,10 +93,10 @@ class RelatedResources extends PayPalModel
/**
* A capture transaction
*
*
*
* @param \PayPal\Api\Capture $capture
*
*
* @return $this
*/
public function setCapture($capture)
@@ -118,10 +117,10 @@ class RelatedResources extends PayPalModel
/**
* A refund transaction
*
*
*
* @param \PayPal\Api\Refund $refund
*
*
* @return $this
*/
public function setRefund($refund)

View File

@@ -3,14 +3,16 @@
namespace PayPal\Api;
use PayPal\Common\PayPalResourceModel;
use PayPal\Transport\PayPalRestCall;
use PayPal\Validation\ArgumentValidator;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PayPalRestCall;
/**
* Class Sale
*
* A sale transaction.
*
* @package PayPal\Api
*
* @property string id
* @property string create_time
@@ -23,18 +25,23 @@ use PayPal\Validation\ArgumentValidator;
* @property string protection_eligibility
* @property string protection_eligibility_type
* @property string clearing_time
* @property string recipient_fund_status
* @property string hold_reason
* @property \PayPal\Api\Currency transaction_fee
* @property \PayPal\Api\Currency receivable_amount
* @property string exchange_rate
* @property \PayPal\Api\FmfDetails fmf_details
* @property string receipt_id
* @property string parent_payment
* @property \PayPal\Api\Currency $transaction_fee
* @package PayPal\Api
* @property \PayPal\Api\Links[] links
*/
class Sale extends PayPalResourceModel
{
/**
* Identifier of the authorization transaction.
* Identifier of the sale transaction.
*
*
*
* @param string $id
* @param string $id
*
* @return $this
*/
public function setId($id)
@@ -44,7 +51,7 @@ class Sale extends PayPalResourceModel
}
/**
* Identifier of the authorization transaction.
* Identifier of the sale transaction.
*
* @return string
*/
@@ -54,59 +61,33 @@ class Sale extends PayPalResourceModel
}
/**
* Time the resource was created.
* Identifier to the purchase unit corresponding to this sale transaction.
*
*
*
* @param string $create_time
* @param string $purchase_unit_reference_id
*
* @return $this
*/
public function setCreateTime($create_time)
public function setPurchaseUnitReferenceId($purchase_unit_reference_id)
{
$this->create_time = $create_time;
$this->purchase_unit_reference_id = $purchase_unit_reference_id;
return $this;
}
/**
* Time the resource was created.
* Identifier to the purchase unit corresponding to this sale transaction.
*
* @return string
*/
public function getCreateTime()
public function getPurchaseUnitReferenceId()
{
return $this->create_time;
}
/**
* Time the resource was last updated.
*
*
*
* @param string $update_time
* @return $this
*/
public function setUpdateTime($update_time)
{
$this->update_time = $update_time;
return $this;
}
/**
* Time the resource was last updated.
*
* @return string
*/
public function getUpdateTime()
{
return $this->update_time;
return $this->purchase_unit_reference_id;
}
/**
* Amount being collected.
*
*
*
* @param \PayPal\Api\Amount $amount
* @param \PayPal\Api\Amount $amount
*
* @return $this
*/
public function setAmount($amount)
@@ -129,8 +110,8 @@ class Sale extends PayPalResourceModel
* specifies payment mode of the transaction
* Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"]
*
*
* @param string $payment_mode
* @param string $payment_mode
*
* @return $this
*/
public function setPaymentMode($payment_mode)
@@ -175,10 +156,10 @@ class Sale extends PayPalResourceModel
/**
* State of the sale transaction.
* Valid Values: ["pending", "completed", "refunded", "partially_refunded"]
* Valid Values: ["completed", "partially_refunded", "pending", "refunded"]
*
*
* @param string $state
* @param string $state
*
* @return $this
*/
public function setState($state)
@@ -201,8 +182,8 @@ class Sale extends PayPalResourceModel
* Reason code for the transaction state being Pending or Reversed.
* Valid Values: ["CHARGEBACK", "GUARANTEE", "BUYER_COMPLAINT", "REFUND", "UNCONFIRMED_SHIPPING_ADDRESS", "ECHECK", "INTERNATIONAL_WITHDRAWAL", "RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION", "PAYMENT_REVIEW", "REGULATORY_REVIEW", "UNILATERAL", "VERIFICATION_REQUIRED"]
*
*
* @param string $reason_code
* @param string $reason_code
*
* @return $this
*/
public function setReasonCode($reason_code)
@@ -222,11 +203,11 @@ class Sale extends PayPalResourceModel
}
/**
* Protection Eligibility of the Payer
* Protection Eligibility of the Payer
* Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"]
*
*
* @param string $protection_eligibility
* @param string $protection_eligibility
*
* @return $this
*/
public function setProtectionEligibility($protection_eligibility)
@@ -236,7 +217,7 @@ class Sale extends PayPalResourceModel
}
/**
* Protection Eligibility of the Payer
* Protection Eligibility of the Payer
*
* @return string
*/
@@ -246,11 +227,11 @@ class Sale extends PayPalResourceModel
}
/**
* Protection Eligibility Type of the Payer
* Protection Eligibility Type of the Payer
* Valid Values: ["ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE", "INELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE"]
*
*
* @param string $protection_eligibility_type
* @param string $protection_eligibility_type
*
* @return $this
*/
public function setProtectionEligibilityType($protection_eligibility_type)
@@ -260,7 +241,7 @@ class Sale extends PayPalResourceModel
}
/**
* Protection Eligibility Type of the Payer
* Protection Eligibility Type of the Payer
*
* @return string
*/
@@ -269,35 +250,11 @@ class Sale extends PayPalResourceModel
return $this->protection_eligibility_type;
}
/**
* Transaction fee applicable for this payment.
*
* @param Currency $transaction_fee
* @return $this
*/
public function setTransactionFee($transaction_fee)
{
$this->transaction_fee = $transaction_fee;
return $this;
}
/**
* Transaction fee applicable for this payment.
*
* @return \PayPal\Api\Currency
*/
public function getTransactionFee()
{
return $this->transaction_fee;
}
/**
* Expected clearing time for eCheck Transactions
*
*
*
* @param string $clearing_time
* @param string $clearing_time
*
* @return $this
*/
public function setClearingTime($clearing_time)
@@ -316,12 +273,174 @@ class Sale extends PayPalResourceModel
return $this->clearing_time;
}
/**
* Indicates the credit status of fund to the recipient. It will be returned only when payment status is 'completed'
* Valid Values: ["COMPLETED", "HELD"]
*
* @param string $recipient_fund_status
*
* @return $this
*/
public function setRecipientFundStatus($recipient_fund_status)
{
$this->recipient_fund_status = $recipient_fund_status;
return $this;
}
/**
* Indicates the credit status of fund to the recipient. It will be returned only when payment status is 'completed'
*
* @return string
*/
public function getRecipientFundStatus()
{
return $this->recipient_fund_status;
}
/**
* Reason for holding the funds.
* Valid Values: ["NEW_SELLER_PAYMENT_HOLD", "PAYMENT_HOLD"]
*
* @param string $hold_reason
*
* @return $this
*/
public function setHoldReason($hold_reason)
{
$this->hold_reason = $hold_reason;
return $this;
}
/**
* Reason for holding the funds.
*
* @return string
*/
public function getHoldReason()
{
return $this->hold_reason;
}
/**
* Transaction fee applicable for this payment.
*
* @param \PayPal\Api\Currency $transaction_fee
*
* @return $this
*/
public function setTransactionFee($transaction_fee)
{
$this->transaction_fee = $transaction_fee;
return $this;
}
/**
* Transaction fee applicable for this payment.
*
* @return \PayPal\Api\Currency
*/
public function getTransactionFee()
{
return $this->transaction_fee;
}
/**
* Net amount payee receives for this transaction after deducting transaction fee.
*
* @param \PayPal\Api\Currency $receivable_amount
*
* @return $this
*/
public function setReceivableAmount($receivable_amount)
{
$this->receivable_amount = $receivable_amount;
return $this;
}
/**
* Net amount payee receives for this transaction after deducting transaction fee.
*
* @return \PayPal\Api\Currency
*/
public function getReceivableAmount()
{
return $this->receivable_amount;
}
/**
* Exchange rate applied for this transaction.
*
* @param string $exchange_rate
*
* @return $this
*/
public function setExchangeRate($exchange_rate)
{
$this->exchange_rate = $exchange_rate;
return $this;
}
/**
* Exchange rate applied for this transaction.
*
* @return string
*/
public function getExchangeRate()
{
return $this->exchange_rate;
}
/**
* Fraud Management Filter (FMF) details applied for the payment that could result in accept/deny/pending action.
*
* @param \PayPal\Api\FmfDetails $fmf_details
*
* @return $this
*/
public function setFmfDetails($fmf_details)
{
$this->fmf_details = $fmf_details;
return $this;
}
/**
* Fraud Management Filter (FMF) details applied for the payment that could result in accept/deny/pending action.
*
* @return \PayPal\Api\FmfDetails
*/
public function getFmfDetails()
{
return $this->fmf_details;
}
/**
* Receipt id is 16 digit number payment identification number returned for guest users to identify the payment.
*
* @param string $receipt_id
*
* @return $this
*/
public function setReceiptId($receipt_id)
{
$this->receipt_id = $receipt_id;
return $this;
}
/**
* Receipt id is 16 digit number payment identification number returned for guest users to identify the payment.
*
* @return string
*/
public function getReceiptId()
{
return $this->receipt_id;
}
/**
* ID of the Payment resource that this transaction is based on.
*
*
*
* @param string $parent_payment
* @param string $parent_payment
*
* @return $this
*/
public function setParentPayment($parent_payment)
@@ -341,17 +460,62 @@ class Sale extends PayPalResourceModel
}
/**
* Obtain the Sale transaction resource for the given identifier.
* Time the resource was created in UTC ISO8601 format.
*
* @param string $saleId
* @param \PayPal\Rest\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
* @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 last updated 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 last updated in UTC ISO8601 format.
*
* @return string
*/
public function getUpdateTime()
{
return $this->update_time;
}
/**
* Retrieve details about a sale transaction by passing the sale_id in the request URI. This request returns only the sales that were created via the REST API.
*
* @param string $saleId
* @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 Sale
*/
public static function get($saleId, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($saleId, 'saleId');
$payLoad = "";
$json = self::executeCall(
"/v1/payments/sale/$saleId",
@@ -367,18 +531,17 @@ class Sale extends PayPalResourceModel
}
/**
* Creates (and processes) a new Refund Transaction added as a related resource.
* Refund a completed payment by passing the sale_id in the request URI. In addition, include an empty JSON payload in the request body for a full refund. For a partial refund, include an amount object in the request body.
*
* @param Refund $refund
* @param \PayPal\Rest\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
* @param Refund $refund
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Refund
*/
public function refund($refund, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($refund, 'refund');
$payLoad = $refund->toJSON();
$json = self::executeCall(
"/v1/payments/sale/{$this->getId()}/refund",

View File

@@ -14,14 +14,15 @@ use PayPal\Common\PayPalModel;
* @property string id
* @property string recipient_name
* @property bool default_address
* @property bool preferred_address
*/
class ShippingAddress extends Address
class ShippingAddress extends Address
{
/**
* Address ID assigned in PayPal system.
*
* @param string $id
*
*
* @return $this
*/
public function setId($id)
@@ -44,7 +45,7 @@ class ShippingAddress extends Address
* Name of the recipient at this address.
*
* @param string $recipient_name
*
*
* @return $this
*/
public function setRecipientName($recipient_name)
@@ -67,7 +68,7 @@ class ShippingAddress extends Address
* Default shipping address of the Payer.
*
* @param bool $default_address
*
*
* @return $this
*/
public function setDefaultAddress($default_address)
@@ -86,4 +87,27 @@ class ShippingAddress extends Address
return $this->default_address;
}
/**
* Shipping Address marked as preferred by Payer.
*
* @param bool $preferred_address
*
* @return $this
*/
public function setPreferredAddress($preferred_address)
{
$this->preferred_address = $preferred_address;
return $this;
}
/**
* Shipping Address marked as preferred by Payer.
*
* @return bool
*/
public function getPreferredAddress()
{
return $this->preferred_address;
}
}

View File

@@ -2,9 +2,6 @@
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
/**
* Class Transaction
*
@@ -12,9 +9,10 @@ use PayPal\Rest\ApiContext;
*
* @package PayPal\Api
*
* @property string purchase_unit_reference_id
* @property Transaction transactions
*/
class Transaction extends TransactionBase
class Transaction extends TransactionBase
{
/**
* Additional transactions for complex payment scenarios.
@@ -40,4 +38,27 @@ class Transaction extends TransactionBase
return $this->transactions;
}
/**
* Identifier to the purchase unit corresponding to this sale transaction
*
* @param string $purchase_unit_reference_id
*
* @return $this
*/
public function setPurchaseUnitReferenceId($purchase_unit_reference_id)
{
$this->purchase_unit_reference_id = $purchase_unit_reference_id;
return $this;
}
/**
* Identifier to the purchase unit corresponding to this sale transaction
*
* @return string
*/
public function getPurchaseUnitReferenceId()
{
return $this->purchase_unit_reference_id;
}
}

View File

@@ -18,7 +18,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"line1":"TestSample","line2":"TestSample","city":"TestSample","country_code":"TestSample","postal_code":"TestSample","state":"TestSample","phone":"TestSample"}';
return '{"line1":"TestSample","line2":"TestSample","city":"TestSample","country_code":"TestSample","postal_code":"TestSample","state":"TestSample","phone":"TestSample","normalization_status":"TestSample","status":"TestSample"}';
}
/**
@@ -46,6 +46,8 @@ class AddressTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj->getPostalCode());
$this->assertNotNull($obj->getState());
$this->assertNotNull($obj->getPhone());
$this->assertNotNull($obj->getNormalizationStatus());
$this->assertNotNull($obj->getStatus());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
@@ -63,6 +65,8 @@ class AddressTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($obj->getPostalCode(), "TestSample");
$this->assertEquals($obj->getState(), "TestSample");
$this->assertEquals($obj->getPhone(), "TestSample");
$this->assertEquals($obj->getNormalizationStatus(), "TestSample");
$this->assertEquals($obj->getStatus(), "TestSample");
}
}

View File

@@ -2,49 +2,61 @@
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Converter\FormatConverter;
use PayPal\Validation\NumericValidator;
use PayPal\Api\Amount;
use PayPal\Test\Constants;
/**
* Class Amount
*
* @package PayPal\Test\Api
*/
class AmountTest extends \PHPUnit_Framework_TestCase
{
private $amounts;
public static $currency = "USD";
public static $total = "1.12";
public static function createAmount()
/**
* Gets Json String of Object Amount
* @return string
*/
public static function getJson()
{
$amount = new Amount();
$amount->setCurrency(self::$currency);
$amount->setTotal(self::$total);
return $amount;
return '{"currency":"TestSample","total":"12.34","details":' .DetailsTest::getJson() . '}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return Amount
*/
public static function getObject()
{
$this->amounts['partial'] = self::createAmount();
$amount = self::createAmount();
$amount->setDetails(DetailsTest::createAmountDetails());
$this->amounts['full'] = $amount;
return new Amount(self::getJson());
}
public function testGetterSetter()
/**
* Tests for Serialization and Deserialization Issues
* @return Amount
*/
public function testSerializationDeserialization()
{
$this->assertEquals(self::$currency, $this->amounts['partial']->getCurrency());
$this->assertEquals(self::$total, $this->amounts['partial']->getTotal());
$this->assertEquals(DetailsTest::$fee, $this->amounts['full']->getDetails()->getFee());
$obj = new Amount(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getCurrency());
$this->assertNotNull($obj->getTotal());
$this->assertNotNull($obj->getDetails());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param Amount $obj
*/
public function testGetters($obj)
{
$a1 = $this->amounts['partial'];
$a2 = new Amount();
$a2->fromJson($a1->toJson());
$this->assertEquals($a1, $a2);
$this->assertEquals($obj->getCurrency(), "TestSample");
$this->assertEquals($obj->getTotal(), "12.34");
$this->assertEquals($obj->getDetails(), DetailsTest::getObject());
}
}
}

View File

@@ -1,201 +1,176 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Api\Amount;
use PayPal\Api\Authorization;
use PayPal\Api\Links;
use PayPal\Api\PayerInfo;
use PayPal\Test\Constants;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Address;
use PayPal\Api\Payer;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\Capture;
use PayPal\Api\CreditCard;
use PayPal\Api\Payment;
use PayPal\Api\FundingInstrument;
use PayPal\Api\Transaction;
use PayPal\Exception\PayPalConnectionException;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
use PayPal\Api\Authorization;
/**
* Class Authorization
*
* @package PayPal\Test\Api
*/
class AuthorizationTest extends \PHPUnit_Framework_TestCase
{
private $authorizations = array();
public static $create_time = "2013-02-28T00:00:00Z";
public static $update_time = "2013-03-28T00:00:00Z";
public static $id = "AUTH-123";
public static $state = "Created";
public static $parent_payment = "PAY-12345";
public static $valid_until = "2013-04-28T00:00:00Z";
public static $clearing_time = "2013-04-28T00:00:00Z";
public static $currency = "USD";
public static $total = "1.12";
public static $href = "USD";
public static $rel = "1.12";
public static $method = "1.12";
public static function createAuthorization()
/**
* Gets Json String of Object Authorization
* @return string
*/
public static function getJson()
{
$authorization = new Authorization();
$authorization->setCreateTime(self::$create_time);
$authorization->setId(self::$id);
$authorization->setState(self::$state);
$authorization->setClearingTime(self::$clearing_time);
$authorization->setAmount(AmountTest::createAmount());
$authorization->setLinks(array(LinksTest::getObject()));
return $authorization;
}
public static function authorize()
{
$addr = new Address();
$addr->setLine1("3909 Witmer Road");
$addr->setLine2("Niagara Falls");
$addr->setCity("Niagara Falls");
$addr->setState("NY");
$addr->setPostalCode("14305");
$addr->setCountryCode("US");
$addr->setPhone("716-298-1822");
$card = new CreditCard();
$card->setType("visa");
$card->setNumber("4417119669820331");
$card->setExpireMonth("11");
$card->setExpireYear("2019");
$card->setCvv2("012");
$card->setFirstName("Joe");
$card->setLastName("Shopper");
$card->setBillingAddress($addr);
$fi = new FundingInstrument();
$fi->setCreditCard($card);
$payer = new Payer();
$payer->setPaymentMethod("credit_card");
$payer->setFundingInstruments(array($fi));
$amount = new Amount();
$amount->setCurrency("USD");
$amount->setTotal("1.00");
$transaction = new Transaction();
$transaction->setAmount($amount);
$transaction->setDescription("This is the payment description.");
$payment = new Payment();
$payment->setIntent("authorize");
$payment->setPayer($payer);
$payment->setTransactions(array($transaction));
$paymnt = $payment->create();
$resArray = $paymnt->toArray();
return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id'];
}
public function setup()
{
$authorization = new Authorization();
$authorization->setCreateTime(self::$create_time);
$authorization->setUpdateTime(self::$update_time);
$authorization->setId(self::$id);
$authorization->setState(self::$state);
$authorization->setParentPayment(self::$parent_payment);
$authorization->setValidUntil(self::$valid_until);
$authorization->setClearingTime(self::$clearing_time);
$this->authorizations['partial'] = $authorization;
$this->authorizations['full'] = self::createAuthorization();
}
public function testGetterSetter()
{
/** @var Authorization $authorization */
$authorization = $this->authorizations['partial'];
$this->assertEquals(self::$create_time, $authorization->getCreateTime());
$this->assertEquals(self::$update_time, $authorization->getUpdateTime());
$this->assertEquals(self::$id, $authorization->getId());
$this->assertEquals(self::$state, $authorization->getState());
$this->assertEquals(self::$parent_payment, $authorization->getParentPayment());
$this->assertEquals(self::$valid_until, $authorization->getValidUntil());
$this->assertEquals(self::$clearing_time, $authorization->getClearingTime());
$authorization = $this->authorizations['full'];
$this->assertEquals(AmountTest::$currency, $authorization->getAmount()->getCurrency());
$this->assertEquals(1, count($authorization->getLinks()));
}
public function testSerializeDeserialize()
{
$a1 = $this->authorizations['partial'];
$a2 = new Authorization();
$a2->fromJson($a1->toJson());
$this->assertEquals($a1, $a2);
return '{"id":"TestSample","amount":' .AmountTest::getJson() . ',"payment_mode":"TestSample","state":"TestSample","reason_code":"TestSample","pending_reason":"TestSample","protection_eligibility":"TestSample","protection_eligibility_type":"TestSample","fmf_details":' .FmfDetailsTest::getJson() . ',"parent_payment":"TestSample","valid_until":"TestSample","create_time":"TestSample","update_time":"TestSample","links":' .LinksTest::getJson() . '}';
}
/**
* @group integration
* Gets Object Instance with Json data filled in
* @return Authorization
*/
public function testOperations()
public static function getObject()
{
try {
$authId = self::authorize();
$auth = Authorization::get($authId);
$this->assertNotNull($auth->getId());
return new Authorization(self::getJson());
}
$amount = new Amount();
$amount->setCurrency("USD");
$amount->setTotal("1.00");
$captur = new Capture();
$captur->setId($authId);
$captur->setAmount($amount);
$capt = $auth->capture($captur);
$this->assertNotNull($capt->getId());
$authId = self::authorize();
$auth = Authorization::get($authId);
$void = $auth->void();
$this->assertNotNull($void->getId());
$auth->setId(null);
try {
$auth->void();
} catch (\InvalidArgumentException $ex) {
$this->assertEquals($ex->getMessage(), "Id cannot be null");
}
} catch (PayPalConnectionException $ex) {
$this->markTestSkipped(
'Tests failing because of intermittent failures in Paypal Sandbox environment.' . $ex->getMessage()
);
}
/**
* Tests for Serialization and Deserialization Issues
* @return Authorization
*/
public function testSerializationDeserialization()
{
$obj = new Authorization(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getAmount());
$this->assertNotNull($obj->getPaymentMode());
$this->assertNotNull($obj->getState());
$this->assertNotNull($obj->getReasonCode());
$this->assertNotNull($obj->getPendingReason());
$this->assertNotNull($obj->getProtectionEligibility());
$this->assertNotNull($obj->getProtectionEligibilityType());
$this->assertNotNull($obj->getFmfDetails());
$this->assertNotNull($obj->getParentPayment());
$this->assertNotNull($obj->getValidUntil());
$this->assertNotNull($obj->getCreateTime());
$this->assertNotNull($obj->getUpdateTime());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @group integration
* @depends testSerializationDeserialization
* @param Authorization $obj
*/
public function testReauthorize()
public function testGetters($obj)
{
$authorization = Authorization::get('7GH53639GA425732B');
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getAmount(), AmountTest::getObject());
$this->assertEquals($obj->getPaymentMode(), "TestSample");
$this->assertEquals($obj->getState(), "TestSample");
$this->assertEquals($obj->getReasonCode(), "TestSample");
$this->assertEquals($obj->getPendingReason(), "TestSample");
$this->assertEquals($obj->getProtectionEligibility(), "TestSample");
$this->assertEquals($obj->getProtectionEligibilityType(), "TestSample");
$this->assertEquals($obj->getFmfDetails(), FmfDetailsTest::getObject());
$this->assertEquals($obj->getParentPayment(), "TestSample");
$this->assertEquals($obj->getValidUntil(), "TestSample");
$this->assertEquals($obj->getCreateTime(), "TestSample");
$this->assertEquals($obj->getUpdateTime(), "TestSample");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
$amount = new Amount();
$amount->setCurrency("USD");
$amount->setTotal("1.00");
$authorization->setAmount($amount);
try {
$authorization->reauthorize();
} catch (PayPalConnectionException $ex) {
//var_dump($ex->getMessage());
$this->assertEquals(strpos($ex->getMessage(), "500"), false);
}
/**
* @dataProvider mockProvider
* @param Authorization $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$authorization->setId(null);
try {
$authorization->reauthorize();
} catch (\InvalidArgumentException $ex) {
$this->assertEquals($ex->getMessage(), "Id cannot be null");
}
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
AuthorizationTest::getJson()
));
$result = $obj->get("authorizationId", $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Authorization $obj
*/
public function testCapture($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
CaptureTest::getJson()
));
$capture = CaptureTest::getObject();
$result = $obj->capture($capture, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Authorization $obj
*/
public function testVoid($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
));
$result = $obj->void($mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Authorization $obj
*/
public function testReauthorize($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
));
$result = $obj->reauthorize($mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
public function mockProvider()
{
$obj = self::getObject();
$mockApiContext = $this->getMockBuilder('ApiContext')
->disableOriginalConstructor()
->getMock();
return array(
array($obj, $mockApiContext),
array($obj, null)
);
}
}

View File

@@ -1,101 +1,128 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Api\Capture;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\Refund;
use PayPal\Api\Authorization;
use PayPal\Api\Amount;
use PayPal\Exception\PayPalConnectionException;
use PayPal\Test\Constants;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
use PayPal\Api\Capture;
/**
* Class Capture
*
* @package PayPal\Test\Api
*/
class CaptureTest extends \PHPUnit_Framework_TestCase
{
private $captures;
public static $authorization_id = "AUTH-123";
public static $create_time = "2013-02-28T00:00:00Z";
public static $id = "C-5678";
public static $parent_payment = "PAY-123";
public static $state = "Created";
public static function createCapture()
/**
* Gets Json String of Object Capture
* @return string
*/
public static function getJson()
{
$capture = new Capture();
$capture->setCreateTime(self::$create_time);
$capture->setId(self::$id);
$capture->setParentPayment(self::$parent_payment);
$capture->setState(self::$state);
return $capture;
}
public function setup()
{
$this->captures['partial'] = self::createCapture();
$capture = self::createCapture();
$capture->setAmount(AmountTest::createAmount());
$capture->setLinks(array(LinksTest::getObject()));
$this->captures['full'] = $capture;
}
public function testGetterSetter()
{
$this->assertEquals(self::$create_time, $this->captures['partial']->getCreateTime());
$this->assertEquals(self::$id, $this->captures['partial']->getId());
$this->assertEquals(self::$parent_payment, $this->captures['partial']->getParentPayment());
$this->assertEquals(self::$state, $this->captures['partial']->getState());
$this->assertEquals(AmountTest::$currency, $this->captures['full']->getAmount()->getCurrency());
$links = $this->captures['full']->getLinks();
}
public function testSerializeDeserialize()
{
$c1 = $this->captures['partial'];
$c2 = new Capture();
$c2->fromJson($c1->toJson());
$this->assertEquals($c1, $c2);
return '{"id":"TestSample","amount":' .AmountTest::getJson() . ',"is_final_capture":true,"state":"TestSample","parent_payment":"TestSample","transaction_fee":' .CurrencyTest::getJson() . ',"create_time":"TestSample","update_time":"TestSample","links":' .LinksTest::getJson() . '}';
}
/**
* @group integration
* Gets Object Instance with Json data filled in
* @return Capture
*/
public function testOperations()
public static function getObject()
{
try {
$authId = AuthorizationTest::authorize();
$auth = Authorization::get($authId);
return new Capture(self::getJson());
}
$amount = new Amount();
$amount->setCurrency("USD");
$amount->setTotal("1.00");
$captr = new Capture();
$captr->setId($authId);
$captr->setAmount($amount);
/**
* Tests for Serialization and Deserialization Issues
* @return Capture
*/
public function testSerializationDeserialization()
{
$obj = new Capture(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getAmount());
$this->assertNotNull($obj->getIsFinalCapture());
$this->assertNotNull($obj->getState());
$this->assertNotNull($obj->getParentPayment());
$this->assertNotNull($obj->getTransactionFee());
$this->assertNotNull($obj->getCreateTime());
$this->assertNotNull($obj->getUpdateTime());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
$capt = $auth->capture($captr);
$captureId = $capt->getId();
$this->assertNotNull($captureId);
/**
* @depends testSerializationDeserialization
* @param Capture $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getAmount(), AmountTest::getObject());
$this->assertEquals($obj->getIsFinalCapture(), true);
$this->assertEquals($obj->getState(), "TestSample");
$this->assertEquals($obj->getParentPayment(), "TestSample");
$this->assertEquals($obj->getTransactionFee(), CurrencyTest::getObject());
$this->assertEquals($obj->getCreateTime(), "TestSample");
$this->assertEquals($obj->getUpdateTime(), "TestSample");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
$refund = new Refund();
$refund->setId($captureId);
$refund->setAmount($amount);
$capture = Capture::get($captureId);
$this->assertNotNull($capture->getId());
/**
* @dataProvider mockProvider
* @param Capture $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$retund = $capture->refund($refund);
$this->assertNotNull($retund->getId());
} catch (PayPalConnectionException $ex) {
$this->markTestSkipped(
'Tests failing because of intermittent failures in Paypal Sandbox environment.' . $ex->getMessage()
);
}
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
CaptureTest::getJson()
));
$result = $obj->get("captureId", $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Capture $obj
*/
public function testRefund($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
RefundTest::getJson()
));
$refund = RefundTest::getObject();
$result = $obj->refund($refund, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
public function mockProvider()
{
$obj = self::getObject();
$mockApiContext = $this->getMockBuilder('ApiContext')
->disableOriginalConstructor()
->getMock();
return array(
array($obj, $mockApiContext),
array($obj, null)
);
}
}

View File

@@ -0,0 +1,57 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\CarrierAccountToken;
/**
* Class CarrierAccountToken
*
* @package PayPal\Test\Api
*/
class CarrierAccountTokenTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object CarrierAccountToken
* @return string
*/
public static function getJson()
{
return '{"carrier_account_id":"TestSample","external_customer_id":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return CarrierAccountToken
*/
public static function getObject()
{
return new CarrierAccountToken(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return CarrierAccountToken
*/
public function testSerializationDeserialization()
{
$obj = new CarrierAccountToken(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getCarrierAccountId());
$this->assertNotNull($obj->getExternalCustomerId());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param CarrierAccountToken $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getCarrierAccountId(), "TestSample");
$this->assertEquals($obj->getExternalCustomerId(), "TestSample");
}
}

View File

@@ -0,0 +1,94 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\CartBase;
/**
* Class CartBase
*
* @package PayPal\Test\Api
*/
class CartBaseTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object CartBase
* @return string
*/
public static function getJson()
{
return '{"amount":' .AmountTest::getJson() . ',"payee":' .PayeeTest::getJson() . ',"description":"TestSample","note_to_payee":"TestSample","custom":"TestSample","invoice_number":"TestSample","soft_descriptor":"TestSample","payment_options":' .PaymentOptionsTest::getJson() . ',"item_list":' .ItemListTest::getJson() . ',"notify_url":"http://www.google.com","order_url":"http://www.google.com"}';
}
/**
* Gets Object Instance with Json data filled in
* @return CartBase
*/
public static function getObject()
{
return new CartBase(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return CartBase
*/
public function testSerializationDeserialization()
{
$obj = new CartBase(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getAmount());
$this->assertNotNull($obj->getPayee());
$this->assertNotNull($obj->getDescription());
$this->assertNotNull($obj->getNoteToPayee());
$this->assertNotNull($obj->getCustom());
$this->assertNotNull($obj->getInvoiceNumber());
$this->assertNotNull($obj->getSoftDescriptor());
$this->assertNotNull($obj->getPaymentOptions());
$this->assertNotNull($obj->getItemList());
$this->assertNotNull($obj->getNotifyUrl());
$this->assertNotNull($obj->getOrderUrl());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param CartBase $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getAmount(), AmountTest::getObject());
$this->assertEquals($obj->getPayee(), PayeeTest::getObject());
$this->assertEquals($obj->getDescription(), "TestSample");
$this->assertEquals($obj->getNoteToPayee(), "TestSample");
$this->assertEquals($obj->getCustom(), "TestSample");
$this->assertEquals($obj->getInvoiceNumber(), "TestSample");
$this->assertEquals($obj->getSoftDescriptor(), "TestSample");
$this->assertEquals($obj->getPaymentOptions(), PaymentOptionsTest::getObject());
$this->assertEquals($obj->getItemList(), ItemListTest::getObject());
$this->assertEquals($obj->getNotifyUrl(), "http://www.google.com");
$this->assertEquals($obj->getOrderUrl(), "http://www.google.com");
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage NotifyUrl is not a fully qualified URL
*/
public function testUrlValidationForNotifyUrl()
{
$obj = new CartBase();
$obj->setNotifyUrl(null);
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage OrderUrl is not a fully qualified URL
*/
public function testUrlValidationForOrderUrl()
{
$obj = new CartBase();
$obj->setOrderUrl(null);
}
}

View File

@@ -2,10 +2,7 @@
namespace PayPal\Test\Api;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PayPalRestCall;
use PayPal\Common\PayPalModel;
use PayPal\Api\CreditCard;
/**
@@ -21,7 +18,7 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"id":"TestSample","number":"TestSample","type":"TestSample","expire_month":123,"expire_year":123,"cvv2":123,"first_name":"TestSample","last_name":"TestSample","billing_address":' .AddressTest::getJson() . ',"external_customer_id":"TestSample","state":"TestSample","valid_until":"TestSample","create_time":"TestSample","update_time":"TestSample"}';
return '{"id":"TestSample","number":"TestSample","type":"TestSample","expire_month":123,"expire_year":123,"cvv2":"TestSample","first_name":"TestSample","last_name":"TestSample","billing_address":' .AddressTest::getJson() . ',"external_customer_id":"TestSample","state":"TestSample","valid_until":"TestSample","links":' .LinksTest::getJson() . '}';
}
/**
@@ -54,8 +51,6 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj->getExternalCustomerId());
$this->assertNotNull($obj->getState());
$this->assertNotNull($obj->getValidUntil());
$this->assertNotNull($obj->getCreateTime());
$this->assertNotNull($obj->getUpdateTime());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
@@ -72,104 +67,14 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($obj->getType(), "TestSample");
$this->assertEquals($obj->getExpireMonth(), 123);
$this->assertEquals($obj->getExpireYear(), 123);
$this->assertEquals($obj->getCvv2(), 123);
$this->assertEquals($obj->getCvv2(), "TestSample");
$this->assertEquals($obj->getFirstName(), "TestSample");
$this->assertEquals($obj->getLastName(), "TestSample");
$this->assertEquals($obj->getBillingAddress(), AddressTest::getObject());
$this->assertEquals($obj->getExternalCustomerId(), "TestSample");
$this->assertEquals($obj->getState(), "TestSample");
$this->assertEquals($obj->getValidUntil(), "TestSample");
$this->assertEquals($obj->getCreateTime(), "TestSample");
$this->assertEquals($obj->getUpdateTime(), "TestSample");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
/**
* @dataProvider mockProvider
* @param CreditCard $obj
*/
public function testCreate($obj, $mockApiContext)
{
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPayPalRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
));
$result = $obj->create($mockApiContext, $mockPayPalRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param CreditCard $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPayPalRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
CreditCardTest::getJson()
));
$result = $obj->get("creditCardId", $mockApiContext, $mockPayPalRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param CreditCard $obj
*/
public function testDelete($obj, $mockApiContext)
{
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPayPalRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
true
));
$result = $obj->delete($mockApiContext, $mockPayPalRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param CreditCard $obj
*/
public function testUpdate($obj, $mockApiContext)
{
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPayPalRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
));
$result = $obj->update($mockApiContext, $mockPayPalRestCall);
$this->assertNotNull($result);
}
public function mockProvider()
{
$obj = self::getObject();
$mockApiContext = $this->getMockBuilder('ApiContext')
->disableOriginalConstructor()
->getMock();
return array(
array($obj, $mockApiContext),
array($obj, null)
);
}
}

View File

@@ -18,7 +18,7 @@ class CreditTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"id":"TestSample","type":"TestSample","terms":"TestSample"}';
return '{"id":"TestSample","type":"TestSample"}';
}
/**
@@ -41,7 +41,6 @@ class CreditTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getType());
$this->assertNotNull($obj->getTerms());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
@@ -54,7 +53,6 @@ class CreditTest extends \PHPUnit_Framework_TestCase
{
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getType(), "TestSample");
$this->assertEquals($obj->getTerms(), "TestSample");
}
}

View File

@@ -0,0 +1,89 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\CurrencyConversion;
/**
* Class CurrencyConversion
*
* @package PayPal\Test\Api
*/
class CurrencyConversionTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object CurrencyConversion
* @return string
*/
public static function getJson()
{
return '{"conversion_date":"TestSample","from_currency":"TestSample","from_amount":"TestSample","to_currency":"TestSample","to_amount":"TestSample","conversion_type":"TestSample","conversion_type_changeable":true,"web_url":"http://www.google.com","links":' .LinksTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return CurrencyConversion
*/
public static function getObject()
{
return new CurrencyConversion(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return CurrencyConversion
*/
public function testSerializationDeserialization()
{
$obj = new CurrencyConversion(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getConversionDate());
$this->assertNotNull($obj->getFromCurrency());
$this->assertNotNull($obj->getFromAmount());
$this->assertNotNull($obj->getToCurrency());
$this->assertNotNull($obj->getToAmount());
$this->assertNotNull($obj->getConversionType());
$this->assertNotNull($obj->getConversionTypeChangeable());
$this->assertNotNull($obj->getWebUrl());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param CurrencyConversion $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getConversionDate(), "TestSample");
$this->assertEquals($obj->getFromCurrency(), "TestSample");
$this->assertEquals($obj->getFromAmount(), "TestSample");
$this->assertEquals($obj->getToCurrency(), "TestSample");
$this->assertEquals($obj->getToAmount(), "TestSample");
$this->assertEquals($obj->getConversionType(), "TestSample");
$this->assertEquals($obj->getConversionTypeChangeable(), true);
$this->assertEquals($obj->getWebUrl(), "http://www.google.com");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage WebUrl is not a fully qualified URL
*/
public function testUrlValidationForWebUrl()
{
$obj = new CurrencyConversion();
$obj->setWebUrl(null);
}
public function testUrlValidationForWebUrlDeprecated()
{
$obj = new CurrencyConversion();
$obj->setWebUrl(null);
$this->assertNull($obj->getWebUrl());
}
}

View File

@@ -54,7 +54,7 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase
public function testGetters($obj)
{
$this->assertEquals($obj->getCurrency(), "TestSample");
$this->assertEquals($obj->getValue(), "TestSample");
$this->assertEquals($obj->getValue(), "12.34");
}
}

View File

@@ -1,50 +1,71 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Converter\FormatConverter;
use PayPal\Validation\NumericValidator;
use PayPal\Api\Details;
use PayPal\Test\Constants;
/**
* Class Details
*
* @package PayPal\Test\Api
*/
class DetailsTest extends \PHPUnit_Framework_TestCase
{
private $amountDetails;
public static $subtotal = "2.00";
public static $tax = "1.12";
public static $shipping = "3.15";
public static $fee = "4.99";
public static function createAmountDetails()
/**
* Gets Json String of Object Details
* @return string
*/
public static function getJson()
{
$amountDetails = new Details();
$amountDetails->setSubtotal(self::$subtotal);
$amountDetails->setTax(self::$tax);
$amountDetails->setShipping(self::$shipping);
$amountDetails->setFee(self::$fee);
return $amountDetails;
return '{"subtotal":"12.34","shipping":"12.34","tax":"12.34","handling_fee":"12.34","shipping_discount":"12.34","insurance":"12.34","gift_wrap":"12.34","fee":"12.34"}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return Details
*/
public static function getObject()
{
$this->amountDetails = self::createAmountDetails();
return new Details(self::getJson());
}
public function testGetterSetters()
/**
* Tests for Serialization and Deserialization Issues
* @return Details
*/
public function testSerializationDeserialization()
{
$this->assertEquals(self::$subtotal, $this->amountDetails->getSubtotal());
$this->assertEquals(self::$tax, $this->amountDetails->getTax());
$this->assertEquals(self::$shipping, $this->amountDetails->getShipping());
$this->assertEquals(self::$fee, $this->amountDetails->getFee());
$obj = new Details(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getSubtotal());
$this->assertNotNull($obj->getShipping());
$this->assertNotNull($obj->getTax());
$this->assertNotNull($obj->getHandlingFee());
$this->assertNotNull($obj->getShippingDiscount());
$this->assertNotNull($obj->getInsurance());
$this->assertNotNull($obj->getGiftWrap());
$this->assertNotNull($obj->getFee());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param Details $obj
*/
public function testGetters($obj)
{
$a1 = $this->amountDetails;
$a2 = new Details();
$a2->fromJson($a1->toJson());
$this->assertEquals($a1, $a2);
$this->assertEquals($obj->getSubtotal(), "12.34");
$this->assertEquals($obj->getShipping(), "12.34");
$this->assertEquals($obj->getTax(), "12.34");
$this->assertEquals($obj->getHandlingFee(), "12.34");
$this->assertEquals($obj->getShippingDiscount(), "12.34");
$this->assertEquals($obj->getInsurance(), "12.34");
$this->assertEquals($obj->getGiftWrap(), "12.34");
$this->assertEquals($obj->getFee(), "12.34");
}
}
}

View File

@@ -18,7 +18,7 @@ class ErrorDetailsTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"field":"TestSample","issue":"TestSample"}';
return '{"field":"TestSample","issue":"TestSample","purchase_unit_reference_id":"TestSample","code":"TestSample"}';
}
/**
@@ -41,6 +41,8 @@ class ErrorDetailsTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj);
$this->assertNotNull($obj->getField());
$this->assertNotNull($obj->getIssue());
$this->assertNotNull($obj->getPurchaseUnitReferenceId());
$this->assertNotNull($obj->getCode());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
@@ -53,6 +55,8 @@ class ErrorDetailsTest extends \PHPUnit_Framework_TestCase
{
$this->assertEquals($obj->getField(), "TestSample");
$this->assertEquals($obj->getIssue(), "TestSample");
$this->assertEquals($obj->getPurchaseUnitReferenceId(), "TestSample");
$this->assertEquals($obj->getCode(), "TestSample");
}
}

View File

@@ -18,7 +18,7 @@ class ErrorTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"name":"TestSample","debug_id":"TestSample","message":"TestSample","information_link":"TestSample","details":' .ErrorDetailsTest::getJson() . ',"links":' .LinksTest::getJson() . '}';
return '{"name":"TestSample","purchase_unit_reference_id":"TestSample","debug_id":"TestSample","message":"TestSample","code":"TestSample","information_link":"TestSample","details":' .ErrorDetailsTest::getJson() . ',"links":' .LinksTest::getJson() . '}';
}
/**
@@ -40,8 +40,10 @@ class ErrorTest extends \PHPUnit_Framework_TestCase
$obj = new Error(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getName());
$this->assertNotNull($obj->getPurchaseUnitReferenceId());
$this->assertNotNull($obj->getDebugId());
$this->assertNotNull($obj->getMessage());
$this->assertNotNull($obj->getCode());
$this->assertNotNull($obj->getInformationLink());
$this->assertNotNull($obj->getDetails());
$this->assertNotNull($obj->getLinks());
@@ -56,8 +58,10 @@ class ErrorTest extends \PHPUnit_Framework_TestCase
public function testGetters($obj)
{
$this->assertEquals($obj->getName(), "TestSample");
$this->assertEquals($obj->getPurchaseUnitReferenceId(), "TestSample");
$this->assertEquals($obj->getDebugId(), "TestSample");
$this->assertEquals($obj->getMessage(), "TestSample");
$this->assertEquals($obj->getCode(), "TestSample");
$this->assertEquals($obj->getInformationLink(), "TestSample");
$this->assertEquals($obj->getDetails(), ErrorDetailsTest::getObject());
$this->assertEquals($obj->getLinks(), LinksTest::getObject());

View File

@@ -0,0 +1,62 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\FmfDetails;
/**
* Class FmfDetails
*
* @package PayPal\Test\Api
*/
class FmfDetailsTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object FmfDetails
* @return string
*/
public static function getJson()
{
return '{"filter_type":"TestSample","filter_id":"TestSample","name":"TestSample","description":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return FmfDetails
*/
public static function getObject()
{
return new FmfDetails(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return FmfDetails
*/
public function testSerializationDeserialization()
{
$obj = new FmfDetails(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getFilterType());
$this->assertNotNull($obj->getFilterId());
$this->assertNotNull($obj->getName());
$this->assertNotNull($obj->getDescription());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param FmfDetails $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getFilterType(), "TestSample");
$this->assertEquals($obj->getFilterId(), "TestSample");
$this->assertEquals($obj->getName(), "TestSample");
$this->assertEquals($obj->getDescription(), "TestSample");
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\FundingDetail;
/**
* Class FundingDetail
*
* @package PayPal\Test\Api
*/
class FundingDetailTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object FundingDetail
* @return string
*/
public static function getJson()
{
return '{"clearing_time":"TestSample","payment_hold_date":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return FundingDetail
*/
public static function getObject()
{
return new FundingDetail(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return FundingDetail
*/
public function testSerializationDeserialization()
{
$obj = new FundingDetail(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getClearingTime());
$this->assertNotNull($obj->getPaymentHoldDate());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param FundingDetail $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getClearingTime(), "TestSample");
$this->assertEquals($obj->getPaymentHoldDate(), "TestSample");
}
}

View File

@@ -0,0 +1,65 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\FundingOption;
/**
* Class FundingOption
*
* @package PayPal\Test\Api
*/
class FundingOptionTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object FundingOption
* @return string
*/
public static function getJson()
{
return '{"id":"TestSample","funding_sources":' .FundingSourceTest::getJson() . ',"backup_funding_instrument":' .FundingInstrumentTest::getJson() . ',"currency_conversion":' .CurrencyConversionTest::getJson() . ',"installment_info":' .InstallmentInfoTest::getJson() . ',"links":' .LinksTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return FundingOption
*/
public static function getObject()
{
return new FundingOption(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return FundingOption
*/
public function testSerializationDeserialization()
{
$obj = new FundingOption(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getFundingSources());
$this->assertNotNull($obj->getBackupFundingInstrument());
$this->assertNotNull($obj->getCurrencyConversion());
$this->assertNotNull($obj->getInstallmentInfo());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param FundingOption $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getFundingSources(), FundingSourceTest::getObject());
$this->assertEquals($obj->getBackupFundingInstrument(), FundingInstrumentTest::getObject());
$this->assertEquals($obj->getCurrencyConversion(), CurrencyConversionTest::getObject());
$this->assertEquals($obj->getInstallmentInfo(), InstallmentInfoTest::getObject());
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
}

View File

@@ -0,0 +1,71 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\FundingSource;
/**
* Class FundingSource
*
* @package PayPal\Test\Api
*/
class FundingSourceTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object FundingSource
* @return string
*/
public static function getJson()
{
return '{"funding_mode":"TestSample","funding_instrument_type":"TestSample","soft_descriptor":"TestSample","amount":' .CurrencyTest::getJson() . ',"legal_text":"TestSample","funding_detail":' .FundingDetailTest::getJson() . ',"additional_text":"TestSample","extends":' .FundingInstrumentTest::getJson() . ',"links":' .LinksTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return FundingSource
*/
public static function getObject()
{
return new FundingSource(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return FundingSource
*/
public function testSerializationDeserialization()
{
$obj = new FundingSource(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getFundingMode());
$this->assertNotNull($obj->getFundingInstrumentType());
$this->assertNotNull($obj->getSoftDescriptor());
$this->assertNotNull($obj->getAmount());
$this->assertNotNull($obj->getLegalText());
$this->assertNotNull($obj->getFundingDetail());
$this->assertNotNull($obj->getAdditionalText());
$this->assertNotNull($obj->getExtends());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param FundingSource $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getFundingMode(), "TestSample");
$this->assertEquals($obj->getFundingInstrumentType(), "TestSample");
$this->assertEquals($obj->getSoftDescriptor(), "TestSample");
$this->assertEquals($obj->getAmount(), CurrencyTest::getObject());
$this->assertEquals($obj->getLegalText(), "TestSample");
$this->assertEquals($obj->getFundingDetail(), FundingDetailTest::getObject());
$this->assertEquals($obj->getAdditionalText(), "TestSample");
$this->assertEquals($obj->getExtends(), FundingInstrumentTest::getObject());
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
}

View File

@@ -0,0 +1,81 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\Incentive;
/**
* Class Incentive
*
* @package PayPal\Test\Api
*/
class IncentiveTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object Incentive
* @return string
*/
public static function getJson()
{
return '{"id":"TestSample","code":"TestSample","name":"TestSample","description":"TestSample","minimum_purchase_amount":' .CurrencyTest::getJson() . ',"logo_image_url":"http://www.google.com","expiry_date":"TestSample","type":"TestSample","terms":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return Incentive
*/
public static function getObject()
{
return new Incentive(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return Incentive
*/
public function testSerializationDeserialization()
{
$obj = new Incentive(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getCode());
$this->assertNotNull($obj->getName());
$this->assertNotNull($obj->getDescription());
$this->assertNotNull($obj->getMinimumPurchaseAmount());
$this->assertNotNull($obj->getLogoImageUrl());
$this->assertNotNull($obj->getExpiryDate());
$this->assertNotNull($obj->getType());
$this->assertNotNull($obj->getTerms());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Incentive $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getCode(), "TestSample");
$this->assertEquals($obj->getName(), "TestSample");
$this->assertEquals($obj->getDescription(), "TestSample");
$this->assertEquals($obj->getMinimumPurchaseAmount(), CurrencyTest::getObject());
$this->assertEquals($obj->getLogoImageUrl(), "http://www.google.com");
$this->assertEquals($obj->getExpiryDate(), "TestSample");
$this->assertEquals($obj->getType(), "TestSample");
$this->assertEquals($obj->getTerms(), "TestSample");
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage LogoImageUrl is not a fully qualified URL
*/
public function testUrlValidationForLogoImageUrl()
{
$obj = new Incentive();
$obj->setLogoImageUrl(null);
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\InstallmentInfo;
/**
* Class InstallmentInfo
*
* @package PayPal\Test\Api
*/
class InstallmentInfoTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object InstallmentInfo
* @return string
*/
public static function getJson()
{
return '{"installment_id":"TestSample","network":"TestSample","issuer":"TestSample","installment_options":' .InstallmentOptionTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return InstallmentInfo
*/
public static function getObject()
{
return new InstallmentInfo(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return InstallmentInfo
*/
public function testSerializationDeserialization()
{
$obj = new InstallmentInfo(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getInstallmentId());
$this->assertNotNull($obj->getNetwork());
$this->assertNotNull($obj->getIssuer());
$this->assertNotNull($obj->getInstallmentOptions());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param InstallmentInfo $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getInstallmentId(), "TestSample");
$this->assertEquals($obj->getNetwork(), "TestSample");
$this->assertEquals($obj->getIssuer(), "TestSample");
$this->assertEquals($obj->getInstallmentOptions(), InstallmentOptionTest::getObject());
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\InstallmentOption;
/**
* Class InstallmentOption
*
* @package PayPal\Test\Api
*/
class InstallmentOptionTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object InstallmentOption
* @return string
*/
public static function getJson()
{
return '{"term":123,"monthly_payment":' .CurrencyTest::getJson() . ',"discount_amount":' .CurrencyTest::getJson() . ',"discount_percentage":"12.34"}';
}
/**
* Gets Object Instance with Json data filled in
* @return InstallmentOption
*/
public static function getObject()
{
return new InstallmentOption(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return InstallmentOption
*/
public function testSerializationDeserialization()
{
$obj = new InstallmentOption(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getTerm());
$this->assertNotNull($obj->getMonthlyPayment());
$this->assertNotNull($obj->getDiscountAmount());
$this->assertNotNull($obj->getDiscountPercentage());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param InstallmentOption $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getTerm(), 123);
$this->assertEquals($obj->getMonthlyPayment(), CurrencyTest::getObject());
$this->assertEquals($obj->getDiscountAmount(), CurrencyTest::getObject());
$this->assertEquals($obj->getDiscountPercentage(), "12.34");
}
}

View File

@@ -1,83 +1,60 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Api\Item;
use PayPal\Common\PayPalModel;
use PayPal\Api\ItemList;
use PayPal\Test\Constants;
/**
* Class ItemList
*
* @package PayPal\Test\Api
*/
class ItemListTest extends \PHPUnit_Framework_TestCase
{
/** @var ItemList */
private $items;
private static $name = "item name";
private static $price = "1.12";
private static $quantity = "10";
private static $sku = "AXVTY123";
private static $currency = "USD";
public static function createItemList()
/**
* Gets Json String of Object ItemList
* @return string
*/
public static function getJson()
{
/** @var Item $item */
$item = ItemTest::createItem();
$itemList = new ItemList();
$itemList->setItems(array($item));
$itemList->setShippingAddress(ShippingAddressTest::getObject());
return $itemList;
return '{"items":' .ItemTest::getJson() . ',"shipping_address":' .ShippingAddressTest::getJson() . ',"shipping_method":"TestSample"}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return ItemList
*/
public static function getObject()
{
$this->items = self::createItemList();
return new ItemList(self::getJson());
}
public function testGetterSetters()
/**
* Tests for Serialization and Deserialization Issues
* @return ItemList
*/
public function testSerializationDeserialization()
{
$items = $this->items->getItems();
$this->assertEquals(ItemTest::createItem(), $items[0]);
$this->assertEquals(ShippingAddressTest::getObject(), $this->items->getShippingAddress());
$obj = new ItemList(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getItems());
$this->assertNotNull($obj->getShippingAddress());
$this->assertNotNull($obj->getShippingMethod());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param ItemList $obj
*/
public function testGetters($obj)
{
$itemList = new ItemList();
$itemList->fromJson($this->items->toJSON());
$this->assertEquals($itemList, $this->items);
$this->assertEquals($obj->getItems(), ItemTest::getObject());
$this->assertEquals($obj->getShippingAddress(), ShippingAddressTest::getObject());
$this->assertEquals($obj->getShippingMethod(), "TestSample");
}
public function testAddItemMethod()
{
$item2 = ItemTest::createItem();
$item2->setName("Item2");
$this->items->addItem($item2);
$found = false;
foreach ($this->items->getItems() as $item) {
if ($item->getName() == $item2->getName()) {
$found = true;
}
}
$this->assertTrue($found);
}
public function testRemoveItemMethod()
{
$itemList = new ItemList();
$item1 = ItemTest::createItem();
$item1->setName("Name1");
$item2 = ItemTest::createItem();
$itemList->addItem($item1);
$itemList->addItem($item2);
$itemList->removeItem($item2);
$this->assertEquals(sizeof($itemList->getItems()), 1);
$remainingElements = $itemList->getItems();
$this->assertEquals($remainingElements[0]->getName(), "Name1");
}
}

View File

@@ -1,52 +1,96 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Converter\FormatConverter;
use PayPal\Validation\NumericValidator;
use PayPal\Api\Item;
use PayPal\Test\Constants;
/**
* Class Item
*
* @package PayPal\Test\Api
*/
class ItemTest extends \PHPUnit_Framework_TestCase
{
private $item;
public static $name = "item name";
public static $price = "1.12";
public static $quantity = "10";
public static $sku = "AXVTY123";
public static $currency = "USD";
public static function createItem()
/**
* Gets Json String of Object Item
* @return string
*/
public static function getJson()
{
$item = new Item();
$item->setName(self::$name);
$item->setPrice(self::$price);
$item->setQuantity(self::$quantity);
$item->setSku(self::$sku);
$item->setCurrency(self::$currency);
return $item;
return '{"quantity":"TestSample","name":"TestSample","description":"TestSample","price":"12.34","tax":"12.34","currency":"TestSample","sku":"TestSample","url":"http://www.google.com","category":"TestSample","weight":' .MeasurementTest::getJson() . ',"length":' .MeasurementTest::getJson() . ',"height":' .MeasurementTest::getJson() . ',"width":' .MeasurementTest::getJson() . ',"supplementary_data":' .NameValuePairTest::getJson() . ',"postback_data":' .NameValuePairTest::getJson() . '}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return Item
*/
public static function getObject()
{
$this->item = ItemTest::createItem();
return new Item(self::getJson());
}
public function testGetterSetters()
/**
* Tests for Serialization and Deserialization Issues
* @return Item
*/
public function testSerializationDeserialization()
{
$this->assertEquals(self::$name, $this->item->getName());
$this->assertEquals(self::$price, $this->item->getPrice());
$this->assertEquals(self::$sku, $this->item->getSku());
$this->assertEquals(self::$quantity, $this->item->getQuantity());
$this->assertEquals(self::$currency, $this->item->getCurrency());
$obj = new Item(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getQuantity());
$this->assertNotNull($obj->getName());
$this->assertNotNull($obj->getDescription());
$this->assertNotNull($obj->getPrice());
$this->assertNotNull($obj->getTax());
$this->assertNotNull($obj->getCurrency());
$this->assertNotNull($obj->getSku());
$this->assertNotNull($obj->getUrl());
$this->assertNotNull($obj->getCategory());
$this->assertNotNull($obj->getWeight());
$this->assertNotNull($obj->getLength());
$this->assertNotNull($obj->getHeight());
$this->assertNotNull($obj->getWidth());
$this->assertNotNull($obj->getSupplementaryData());
$this->assertNotNull($obj->getPostbackData());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param Item $obj
*/
public function testGetters($obj)
{
$item = new Item();
$item->fromJson($this->item->toJSON());
$this->assertEquals($obj->getQuantity(), "TestSample");
$this->assertEquals($obj->getName(), "TestSample");
$this->assertEquals($obj->getDescription(), "TestSample");
$this->assertEquals($obj->getPrice(), "12.34");
$this->assertEquals($obj->getTax(), "12.34");
$this->assertEquals($obj->getCurrency(), "TestSample");
$this->assertEquals($obj->getSku(), "TestSample");
$this->assertEquals($obj->getUrl(), "http://www.google.com");
$this->assertEquals($obj->getCategory(), "TestSample");
$this->assertEquals($obj->getWeight(), MeasurementTest::getObject());
$this->assertEquals($obj->getLength(), MeasurementTest::getObject());
$this->assertEquals($obj->getHeight(), MeasurementTest::getObject());
$this->assertEquals($obj->getWidth(), MeasurementTest::getObject());
$this->assertEquals($obj->getSupplementaryData(), NameValuePairTest::getObject());
$this->assertEquals($obj->getPostbackData(), NameValuePairTest::getObject());
}
$this->assertEquals($item, $this->item);
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Url is not a fully qualified URL
*/
public function testUrlValidationForUrl()
{
$obj = new Item();
$obj->setUrl(null);
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\Measurement;
/**
* Class Measurement
*
* @package PayPal\Test\Api
*/
class MeasurementTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object Measurement
* @return string
*/
public static function getJson()
{
return '{"value":"TestSample","unit":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return Measurement
*/
public static function getObject()
{
return new Measurement(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return Measurement
*/
public function testSerializationDeserialization()
{
$obj = new Measurement(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getValue());
$this->assertNotNull($obj->getUnit());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Measurement $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getValue(), "TestSample");
$this->assertEquals($obj->getUnit(), "TestSample");
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\NameValuePair;
/**
* Class NameValuePair
*
* @package PayPal\Test\Api
*/
class NameValuePairTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object NameValuePair
* @return string
*/
public static function getJson()
{
return '{"name":"TestSample","value":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return NameValuePair
*/
public static function getObject()
{
return new NameValuePair(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return NameValuePair
*/
public function testSerializationDeserialization()
{
$obj = new NameValuePair(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getName());
$this->assertNotNull($obj->getValue());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param NameValuePair $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getName(), "TestSample");
$this->assertEquals($obj->getValue(), "TestSample");
}
}

View File

@@ -1,59 +1,178 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\Capture;
use PayPal\Api\Authorization;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
use PayPal\Api\Order;
use PayPal\Api\Amount;
use PayPal\Api\Details;
use PayPal\Api\Links;
use PayPal\Test\Constants;
/**
* Class Order
*
* @package PayPal\Test\Api
*/
class OrderTest extends \PHPUnit_Framework_TestCase
{
/** @var Order */
private $order;
public static $id = 'O-0AA8876533760860M';
public static $createTime = '2014-08-25T19:24:04Z';
public static $updateTime = '2014-08-25T19:24:51Z';
public static $state = 'pending';
public static $parentPayment = 'PAY-0AL32935UM2331537KP5Y2VA';
public static $reasonCode = 'order';
public static function createOrder()
/**
* Gets Json String of Object Order
* @return string
*/
public static function getJson()
{
$order = new Order();
$order->setId(self::$id);
$order->setCreateTime(self::$createTime);
$order->setUpdateTime(self::$updateTime);
$order->setState(self::$state);
$order->setAmount(AmountTest::createAmount());
return $order;
return '{"id":"TestSample","purchase_unit_reference_id":"TestSample","amount":' .AmountTest::getJson() . ',"payment_mode":"TestSample","state":"TestSample","reason_code":"TestSample","pending_reason":"TestSample","protection-eligibility":"TestSample","protection-eligibility_type":"TestSample","parent_payment":"TestSample","fmf_details":' .FmfDetailsTest::getJson() . ',"create_time":"TestSample","update_time":"TestSample","links":' .LinksTest::getJson() . '}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return Order
*/
public static function getObject()
{
$this->order = self::createOrder();
return new Order(self::getJson());
}
public function testGetterSetter()
{
$this->assertEquals(self::$id, $this->order->getId());
$this->assertEquals(self::$createTime, $this->order->getCreateTime());
$this->assertEquals(self::$updateTime, $this->order->getUpdateTime());
$this->assertEquals(self::$state, $this->order->getState());
$this->assertEquals(AmountTest::$currency, $this->order->getAmount()->getCurrency());
/**
* Tests for Serialization and Deserialization Issues
* @return Order
*/
public function testSerializationDeserialization()
{
$obj = new Order(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getPurchaseUnitReferenceId());
$this->assertNotNull($obj->getAmount());
$this->assertNotNull($obj->getPaymentMode());
$this->assertNotNull($obj->getState());
$this->assertNotNull($obj->getReasonCode());
$this->assertNotNull($obj->getPendingReason());
$this->assertNotNull($obj->getProtectionEligibility());
$this->assertNotNull($obj->getProtectionEligibilityType());
$this->assertNotNull($obj->getParentPayment());
$this->assertNotNull($obj->getFmfDetails());
$this->assertNotNull($obj->getCreateTime());
$this->assertNotNull($obj->getUpdateTime());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param Order $obj
*/
public function testGetters($obj)
{
$o1 = $this->order;
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getPurchaseUnitReferenceId(), "TestSample");
$this->assertEquals($obj->getAmount(), AmountTest::getObject());
$this->assertEquals($obj->getPaymentMode(), "TestSample");
$this->assertEquals($obj->getState(), "TestSample");
$this->assertEquals($obj->getReasonCode(), "TestSample");
$this->assertEquals($obj->getPendingReason(), "TestSample");
$this->assertEquals($obj->getProtectionEligibility(), "TestSample");
$this->assertEquals($obj->getProtectionEligibilityType(), "TestSample");
$this->assertEquals($obj->getParentPayment(), "TestSample");
$this->assertEquals($obj->getFmfDetails(), FmfDetailsTest::getObject());
$this->assertEquals($obj->getCreateTime(), "TestSample");
$this->assertEquals($obj->getUpdateTime(), "TestSample");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
$o2 = new Order();
$o2->fromJson($o1->toJson());
$this->assertEquals($o1, $o2);
/**
* @dataProvider mockProvider
* @param Order $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
OrderTest::getJson()
));
$result = $obj->get("orderId", $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Order $obj
*/
public function testCapture($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
CaptureTest::getJson()
));
$capture = CaptureTest::getObject();
$result = $obj->capture($capture, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Order $obj
*/
public function testVoid($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
));
$result = $obj->void($mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Order $obj
*/
public function testAuthorize($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
AuthorizationTest::getJson()
));
$authorization = new Authorization();
$result = $obj->authorize($authorization, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
public function mockProvider()
{
$obj = self::getObject();
$mockApiContext = $this->getMockBuilder('ApiContext')
->disableOriginalConstructor()
->getMock();
return array(
array($obj, $mockApiContext),
array($obj, null)
);
}
}

View File

@@ -2,48 +2,56 @@
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\Payee;
use PayPal\Test\Constants;
/**
* Class Payee
*
* @package PayPal\Test\Api
*/
class PayeeTest extends \PHPUnit_Framework_TestCase
{
private $payee;
public static $email = "test@paypal.com";
public static $merchant_id = "1XY12121";
public static $phone = "+14081234566";
public static function createPayee()
/**
* Gets Json String of Object Payee
* @return string
*/
public static function getJson()
{
$payee = new Payee();
$payee->setEmail(self::$email);
$payee->setMerchantId(self::$merchant_id);
$payee->setPhone(self::$phone);
return $payee;
return '{"email":"TestSample","merchant_id":"TestSample"}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return Payee
*/
public static function getObject()
{
$this->payee = self::createPayee();
return new Payee(self::getJson());
}
public function testGetterSetter()
/**
* Tests for Serialization and Deserialization Issues
* @return Payee
*/
public function testSerializationDeserialization()
{
$this->assertEquals(self::$email, $this->payee->getEmail());
$this->assertEquals(self::$merchant_id, $this->payee->getMerchantId());
$this->assertEquals(self::$phone, $this->payee->getPhone());
$obj = new Payee(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getEmail());
$this->assertNotNull($obj->getMerchantId());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param Payee $obj
*/
public function testGetters($obj)
{
$p1 = $this->payee;
$p2 = new Payee();
$p2->fromJson($p1->toJson());
$this->assertEquals($p1, $p2);
$this->assertEquals($obj->getEmail(), "TestSample");
$this->assertEquals($obj->getMerchantId(), "TestSample");
}
}
}

View File

@@ -18,7 +18,7 @@ class PayerInfoTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"email":"TestSample","external_remember_me_id":"TestSample","buyer_account_number":"TestSample","first_name":"TestSample","last_name":"TestSample","payer_id":"TestSample","phone":"TestSample","phone_type":"TestSample","birth_date":"TestSample","tax_id":"TestSample","tax_id_type":"TestSample","billing_address":' .AddressTest::getJson() . ',"shipping_address":' .ShippingAddressTest::getJson() . '}';
return '{"email":"TestSample","external_remember_me_id":"TestSample","buyer_account_number":"TestSample","salutation":"TestSample","first_name":"TestSample","middle_name":"TestSample","last_name":"TestSample","suffix":"TestSample","payer_id":"TestSample","phone":"TestSample","phone_type":"TestSample","birth_date":"TestSample","tax_id":"TestSample","tax_id_type":"TestSample","country_code":"TestSample","billing_address":' .AddressTest::getJson() . ',"shipping_address":' .ShippingAddressTest::getJson() . '}';
}
/**
@@ -42,14 +42,18 @@ class PayerInfoTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj->getEmail());
$this->assertNotNull($obj->getExternalRememberMeId());
$this->assertNotNull($obj->getBuyerAccountNumber());
$this->assertNotNull($obj->getSalutation());
$this->assertNotNull($obj->getFirstName());
$this->assertNotNull($obj->getMiddleName());
$this->assertNotNull($obj->getLastName());
$this->assertNotNull($obj->getSuffix());
$this->assertNotNull($obj->getPayerId());
$this->assertNotNull($obj->getPhone());
$this->assertNotNull($obj->getPhoneType());
$this->assertNotNull($obj->getBirthDate());
$this->assertNotNull($obj->getTaxId());
$this->assertNotNull($obj->getTaxIdType());
$this->assertNotNull($obj->getCountryCode());
$this->assertNotNull($obj->getBillingAddress());
$this->assertNotNull($obj->getShippingAddress());
$this->assertEquals(self::getJson(), $obj->toJson());
@@ -65,14 +69,18 @@ class PayerInfoTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($obj->getEmail(), "TestSample");
$this->assertEquals($obj->getExternalRememberMeId(), "TestSample");
$this->assertEquals($obj->getBuyerAccountNumber(), "TestSample");
$this->assertEquals($obj->getSalutation(), "TestSample");
$this->assertEquals($obj->getFirstName(), "TestSample");
$this->assertEquals($obj->getMiddleName(), "TestSample");
$this->assertEquals($obj->getLastName(), "TestSample");
$this->assertEquals($obj->getSuffix(), "TestSample");
$this->assertEquals($obj->getPayerId(), "TestSample");
$this->assertEquals($obj->getPhone(), "TestSample");
$this->assertEquals($obj->getPhoneType(), "TestSample");
$this->assertEquals($obj->getBirthDate(), "TestSample");
$this->assertEquals($obj->getTaxId(), "TestSample");
$this->assertEquals($obj->getTaxIdType(), "TestSample");
$this->assertEquals($obj->getCountryCode(), "TestSample");
$this->assertEquals($obj->getBillingAddress(), AddressTest::getObject());
$this->assertEquals($obj->getShippingAddress(), ShippingAddressTest::getObject());
}

View File

@@ -18,7 +18,7 @@ class PayerTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"payment_method":"TestSample","status":"TestSample","funding_instruments":' .FundingInstrumentTest::getJson() . ',"funding_option_id":"TestSample","payer_info":' .PayerInfoTest::getJson() . '}';
return '{"payment_method":"TestSample","status":"TestSample","account_type":"TestSample","account_age":"TestSample","funding_instruments":' .FundingInstrumentTest::getJson() . ',"funding_option_id":"TestSample","funding_option":' .FundingOptionTest::getJson() . ',"related_funding_option":' .FundingOptionTest::getJson() . ',"payer_info":' .PayerInfoTest::getJson() . '}';
}
/**
@@ -41,8 +41,12 @@ class PayerTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj);
$this->assertNotNull($obj->getPaymentMethod());
$this->assertNotNull($obj->getStatus());
$this->assertNotNull($obj->getAccountType());
$this->assertNotNull($obj->getAccountAge());
$this->assertNotNull($obj->getFundingInstruments());
$this->assertNotNull($obj->getFundingOptionId());
$this->assertNotNull($obj->getFundingOption());
$this->assertNotNull($obj->getRelatedFundingOption());
$this->assertNotNull($obj->getPayerInfo());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
@@ -56,8 +60,12 @@ class PayerTest extends \PHPUnit_Framework_TestCase
{
$this->assertEquals($obj->getPaymentMethod(), "TestSample");
$this->assertEquals($obj->getStatus(), "TestSample");
$this->assertEquals($obj->getAccountType(), "TestSample");
$this->assertEquals($obj->getAccountAge(), "TestSample");
$this->assertEquals($obj->getFundingInstruments(), FundingInstrumentTest::getObject());
$this->assertEquals($obj->getFundingOptionId(), "TestSample");
$this->assertEquals($obj->getFundingOption(), FundingOptionTest::getObject());
$this->assertEquals($obj->getRelatedFundingOption(), FundingOptionTest::getObject());
$this->assertEquals($obj->getPayerInfo(), PayerInfoTest::getObject());
}

View File

@@ -18,7 +18,7 @@ class PaymentCardTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"id":"TestSample","number":"TestSample","type":"TestSample","expire_month":123,"expire_year":123,"start_month":123,"start_year":123,"cvv2":123,"first_name":"TestSample","last_name":"TestSample","billing_address":' .AddressTest::getJson() . ',"external_customer_id":"TestSample","status":"TestSample","valid_until":"TestSample","links":' .LinksTest::getJson() . '}';
return '{"id":"TestSample","number":"TestSample","type":"TestSample","expire_month":123,"expire_year":123,"start_month":"TestSample","start_year":"TestSample","cvv2":"TestSample","first_name":"TestSample","last_name":"TestSample","billing_country":"TestSample","billing_address":' .AddressTest::getJson() . ',"external_customer_id":"TestSample","status":"TestSample","valid_until":"TestSample","links":' .LinksTest::getJson() . '}';
}
/**
@@ -49,6 +49,7 @@ class PaymentCardTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj->getCvv2());
$this->assertNotNull($obj->getFirstName());
$this->assertNotNull($obj->getLastName());
$this->assertNotNull($obj->getBillingCountry());
$this->assertNotNull($obj->getBillingAddress());
$this->assertNotNull($obj->getExternalCustomerId());
$this->assertNotNull($obj->getStatus());
@@ -69,11 +70,12 @@ class PaymentCardTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($obj->getType(), "TestSample");
$this->assertEquals($obj->getExpireMonth(), 123);
$this->assertEquals($obj->getExpireYear(), 123);
$this->assertEquals($obj->getStartMonth(), 123);
$this->assertEquals($obj->getStartYear(), 123);
$this->assertEquals($obj->getCvv2(), 123);
$this->assertEquals($obj->getStartMonth(), "TestSample");
$this->assertEquals($obj->getStartYear(), "TestSample");
$this->assertEquals($obj->getCvv2(), "TestSample");
$this->assertEquals($obj->getFirstName(), "TestSample");
$this->assertEquals($obj->getLastName(), "TestSample");
$this->assertEquals($obj->getBillingCountry(), "TestSample");
$this->assertEquals($obj->getBillingAddress(), AddressTest::getObject());
$this->assertEquals($obj->getExternalCustomerId(), "TestSample");
$this->assertEquals($obj->getStatus(), "TestSample");

View File

@@ -0,0 +1,57 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\PaymentExecution;
/**
* Class PaymentExecution
*
* @package PayPal\Test\Api
*/
class PaymentExecutionTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object PaymentExecution
* @return string
*/
public static function getJson()
{
return '{"payer_id":"TestSample","transactions":' .TransactionTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return PaymentExecution
*/
public static function getObject()
{
return new PaymentExecution(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return PaymentExecution
*/
public function testSerializationDeserialization()
{
$obj = new PaymentExecution(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getPayerId());
$this->assertNotNull($obj->getTransactions());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param PaymentExecution $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getPayerId(), "TestSample");
$this->assertEquals($obj->getTransactions(), TransactionTest::getObject());
}
}

View File

@@ -2,45 +2,58 @@
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\PaymentHistory;
use PayPal\Test\Constants;
/**
* Class PaymentHistory
*
* @package PayPal\Test\Api
*/
class PaymentHistoryTest extends \PHPUnit_Framework_TestCase
{
/** @var PaymentHistory */
private $history;
public static $count = 10;
public static $nextId = "11";
public static function createPaymentHistory()
/**
* Gets Json String of Object PaymentHistory
* @return string
*/
public static function getJson()
{
$history = new PaymentHistory();
$history->setCount(self::$count);
$history->setNextId(self::$nextId);
$history->setPayments(array(PaymentTest::createPayment()));
return $history;
return '{"payments":' .PaymentTest::getJson() . ',"count":123,"next_id":"TestSample"}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return PaymentHistory
*/
public static function getObject()
{
$this->history = PaymentHistoryTest::createPaymentHistory();
return new PaymentHistory(self::getJson());
}
public function testGetterSetters()
{
$this->assertEquals(self::$count, $this->history->getCount());
$this->assertEquals(self::$nextId, $this->history->getNextId());
/**
* Tests for Serialization and Deserialization Issues
* @return PaymentHistory
*/
public function testSerializationDeserialization()
{
$obj = new PaymentHistory(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getPayments());
$this->assertNotNull($obj->getCount());
$this->assertNotNull($obj->getNextId());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param PaymentHistory $obj
*/
public function testGetters($obj)
{
$history = new PaymentHistory();
$history->fromJson($this->history->toJSON());
$this->assertEquals($history, $this->history);
$this->assertEquals($obj->getPayments(), PaymentTest::getObject());
$this->assertEquals($obj->getCount(), 123);
$this->assertEquals($obj->getNextId(), "TestSample");
}
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
use PayPal\Api\PaymentInstruction;
/**
* Class PaymentInstruction
*
* @package PayPal\Test\Api
*/
class PaymentInstructionTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object PaymentInstruction
* @return string
*/
public static function getJson()
{
return '{"reference_number":"TestSample","instruction_type":"TestSample","recipient_banking_instruction":' .RecipientBankingInstructionTest::getJson() . ',"amount":' .CurrencyTest::getJson() . ',"payment_due_date":"TestSample","note":"TestSample","links":' .LinksTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return PaymentInstruction
*/
public static function getObject()
{
return new PaymentInstruction(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return PaymentInstruction
*/
public function testSerializationDeserialization()
{
$obj = new PaymentInstruction(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getReferenceNumber());
$this->assertNotNull($obj->getInstructionType());
$this->assertNotNull($obj->getRecipientBankingInstruction());
$this->assertNotNull($obj->getAmount());
$this->assertNotNull($obj->getPaymentDueDate());
$this->assertNotNull($obj->getNote());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param PaymentInstruction $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getReferenceNumber(), "TestSample");
$this->assertEquals($obj->getInstructionType(), "TestSample");
$this->assertEquals($obj->getRecipientBankingInstruction(), RecipientBankingInstructionTest::getObject());
$this->assertEquals($obj->getAmount(), CurrencyTest::getObject());
$this->assertEquals($obj->getPaymentDueDate(), "TestSample");
$this->assertEquals($obj->getNote(), "TestSample");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
/**
* @dataProvider mockProvider
* @param PaymentInstruction $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
PaymentInstructionTest::getJson()
));
$result = $obj->get("paymentId", $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
public function mockProvider()
{
$obj = self::getObject();
$mockApiContext = $this->getMockBuilder('ApiContext')
->disableOriginalConstructor()
->getMock();
return array(
array($obj, $mockApiContext),
array($obj, null)
);
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\PaymentOptions;
/**
* Class PaymentOptions
*
* @package PayPal\Test\Api
*/
class PaymentOptionsTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object PaymentOptions
* @return string
*/
public static function getJson()
{
return '{"allowed_payment_method":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return PaymentOptions
*/
public static function getObject()
{
return new PaymentOptions(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return PaymentOptions
*/
public function testSerializationDeserialization()
{
$obj = new PaymentOptions(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getAllowedPaymentMethod());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param PaymentOptions $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getAllowedPaymentMethod(), "TestSample");
}
}

View File

@@ -1,162 +1,197 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Address;
use PayPal\Api\Amount;
use PayPal\Api\CreditCard;
use PayPal\Api\Payer;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\object;
use PayPal\Api\PaymentHistory;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
use PayPal\Api\Payment;
use PayPal\Api\FundingInstrument;
use PayPal\Api\Transaction;
use PayPal\Test\Constants;
/**
* Class Payment
*
* @package PayPal\Test\Api
*/
class PaymentTest extends \PHPUnit_Framework_TestCase
{
private $payments;
public static function createPayment()
/**
* Gets Json String of Object Payment
* @return string
*/
public static function getJson()
{
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl("http://localhost/return");
$redirectUrls->setCancelUrl("http://localhost/cancel");
$payment = new Payment();
$payment->setIntent("sale");
$payment->setRedirectUrls($redirectUrls);
$payment->setPayer(PayerTest::getObject());
$payment->setTransactions(array(TransactionTest::createTransaction()));
return $payment;
}
public static function createNewPayment()
{
$funding = FundingInstrumentTest::getObject();
$funding->credit_card_token = null;
$payer = new Payer();
$payer->setPaymentMethod("credit_card");
$payer->setFundingInstruments(array($funding));
$transaction = new Transaction();
$transaction->setAmount(AmountTest::createAmount());
$transaction->setDescription("This is the payment description.");
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl("http://localhost/return");
$redirectUrls->setCancelUrl("http://localhost/cancel");
$payment = new Payment();
$payment->setIntent("sale");
$payment->setRedirectUrls($redirectUrls);
$payment->setPayer($payer);
$payment->setTransactions(array($transaction));
return $payment;
}
public function setup()
{
$this->payments['full'] = self::createPayment();
$this->payments['new'] = self::createNewPayment();
}
public function testSerializeDeserialize()
{
$p2 = new Payment();
$p2->fromJson($this->payments['full']->toJSON());
$this->assertEquals($p2, $this->payments['full']);
return '{"id":"TestSample","intent":"TestSample","payer":' .PayerTest::getJson() . ',"payee":' .PayeeTest::getJson() . ',"cart":"TestSample","transactions":' .TransactionTest::getJson() . ',"failed_transactions":' .ErrorTest::getJson() . ',"payment_instruction":' .PaymentInstructionTest::getJson() . ',"state":"TestSample","experience_profile_id":"TestSample","redirect_urls":' .RedirectUrlsTest::getJson() . ',"create_time":"TestSample","update_time":"TestSample","links":' .LinksTest::getJson() . '}';
}
/**
* @group integration
*
* Tests Additional_fields, shipping_discount and insurance information.
* Additional Information: https://developer.paypal.com/docs/integration/direct/explore-payment-capabilities/
* Gets Object Instance with Json data filled in
* @return Payment
*/
public function testECParameters()
public static function getObject()
{
$json = '{
"intent": "sale",
"redirect_urls": {
"return_url": "http://www.return.com",
"cancel_url": "http://www.cancel.com"
},
"payer": {
"payment_method": "paypal",
"payer_info": {
"tax_id_type": "BR_CPF",
"tax_id": "Fh618775690"
}
},
"transactions": [
{
"amount": {
"total": "34.07",
"currency": "USD",
"details": {
"subtotal": "30.00",
"tax": "0.07",
"shipping": "1.00",
"handling_fee": "1.00",
"shipping_discount": "1.00",
"insurance": "1.00"
}
},
"description": "This is the payment transaction description.",
"custom": "EBAY_EMS_90048630024435",
"invoice_number": "48787589677",
"payment_options": {
"allowed_payment_method": "INSTANT_FUNDING_SOURCE"
},
"soft_descriptor": "ECHI5786786",
"item_list": {
"items": [
{
"name": "bowling",
"description": "Bowling Team Shirt",
"quantity": "5",
"price": "3",
"tax": "0.01",
"sku": "1",
"currency": "USD"
},
{
"name": "mesh",
"description": "80s Mesh Sleeveless Shirt",
"quantity": "1",
"price": "15",
"tax": "0.02",
"sku": "product34",
"currency": "USD"
}
],
"shipping_address": {
"recipient_name": "Betsy Buyer",
"line1": "111 First Street",
"city": "Saratoga",
"country_code": "US",
"postal_code": "95070",
"state": "CA"
}
}
}
]
}';
$payment = new Payment();
$payment->fromJson($json);
return new Payment(self::getJson());
}
$payment->create();
$result = Payment::get($payment->getId());
$transactions = $result->getTransactions();
$transaction = $transactions[0];
$this->assertEquals($transaction->getAmount()->getDetails()->getShippingDiscount(), '1.00');
$this->assertEquals($transaction->getAmount()->getDetails()->getInsurance(), '1.00');
$this->assertEquals($transaction->getAmount()->getDetails()->getHandlingFee(), '1.00');
/**
* Tests for Serialization and Deserialization Issues
* @return Payment
*/
public function testSerializationDeserialization()
{
$obj = new Payment(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getIntent());
$this->assertNotNull($obj->getPayer());
$this->assertNotNull($obj->getPayee());
$this->assertNotNull($obj->getCart());
$this->assertNotNull($obj->getTransactions());
$this->assertNotNull($obj->getFailedTransactions());
$this->assertNotNull($obj->getPaymentInstruction());
$this->assertNotNull($obj->getState());
$this->assertNotNull($obj->getExperienceProfileId());
$this->assertNotNull($obj->getRedirectUrls());
$this->assertNotNull($obj->getCreateTime());
$this->assertNotNull($obj->getUpdateTime());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Payment $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getIntent(), "TestSample");
$this->assertEquals($obj->getPayer(), PayerTest::getObject());
$this->assertEquals($obj->getPayee(), PayeeTest::getObject());
$this->assertEquals($obj->getCart(), "TestSample");
$this->assertEquals($obj->getTransactions(), TransactionTest::getObject());
$this->assertEquals($obj->getFailedTransactions(), ErrorTest::getObject());
$this->assertEquals($obj->getPaymentInstruction(), PaymentInstructionTest::getObject());
$this->assertEquals($obj->getState(), "TestSample");
$this->assertEquals($obj->getExperienceProfileId(), "TestSample");
$this->assertEquals($obj->getRedirectUrls(), RedirectUrlsTest::getObject());
$this->assertEquals($obj->getCreateTime(), "TestSample");
$this->assertEquals($obj->getUpdateTime(), "TestSample");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
/**
* @dataProvider mockProvider
* @param Payment $obj
*/
public function testCreate($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
));
$result = $obj->create($mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Payment $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
PaymentTest::getJson()
));
$result = $obj->get("paymentId", $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Payment $obj
*/
public function testUpdate($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
true
));
$patchRequest = PatchRequestTest::getObject();
$result = $obj->update($patchRequest, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Payment $obj
*/
public function testExecute($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
));
$paymentExecution = PaymentExecutionTest::getObject();
$result = $obj->execute($paymentExecution, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Payment $obj
*/
public function testList($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
PaymentHistoryTest::getJson()
));
$params = array();
$result = $obj->all($params, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
public function mockProvider()
{
$obj = self::getObject();
$mockApiContext = $this->getMockBuilder('ApiContext')
->disableOriginalConstructor()
->getMock();
return array(
array($obj, $mockApiContext),
array($obj, null)
);
}
}

View File

@@ -18,7 +18,7 @@ class PhoneTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"country_code":"TestSample","national_number":"TestSample"}';
return '{"country_code":"TestSample","national_number":"TestSample","extension":"TestSample"}';
}
/**
@@ -41,6 +41,7 @@ class PhoneTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj);
$this->assertNotNull($obj->getCountryCode());
$this->assertNotNull($obj->getNationalNumber());
$this->assertNotNull($obj->getExtension());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
@@ -53,6 +54,7 @@ class PhoneTest extends \PHPUnit_Framework_TestCase
{
$this->assertEquals($obj->getCountryCode(), "TestSample");
$this->assertEquals($obj->getNationalNumber(), "TestSample");
$this->assertEquals($obj->getExtension(), "TestSample");
}
}

View File

@@ -0,0 +1,65 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\RecipientBankingInstruction;
/**
* Class RecipientBankingInstruction
*
* @package PayPal\Test\Api
*/
class RecipientBankingInstructionTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object RecipientBankingInstruction
* @return string
*/
public static function getJson()
{
return '{"bank_name":"TestSample","account_holder_name":"TestSample","account_number":"TestSample","routing_number":"TestSample","international_bank_account_number":"TestSample","bank_identifier_code":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return RecipientBankingInstruction
*/
public static function getObject()
{
return new RecipientBankingInstruction(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return RecipientBankingInstruction
*/
public function testSerializationDeserialization()
{
$obj = new RecipientBankingInstruction(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getBankName());
$this->assertNotNull($obj->getAccountHolderName());
$this->assertNotNull($obj->getAccountNumber());
$this->assertNotNull($obj->getRoutingNumber());
$this->assertNotNull($obj->getInternationalBankAccountNumber());
$this->assertNotNull($obj->getBankIdentifierCode());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param RecipientBankingInstruction $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getBankName(), "TestSample");
$this->assertEquals($obj->getAccountHolderName(), "TestSample");
$this->assertEquals($obj->getAccountNumber(), "TestSample");
$this->assertEquals($obj->getRoutingNumber(), "TestSample");
$this->assertEquals($obj->getInternationalBankAccountNumber(), "TestSample");
$this->assertEquals($obj->getBankIdentifierCode(), "TestSample");
}
}

View File

@@ -1,47 +1,57 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\RedirectUrls;
/**
* Class RedirectUrls
*
* @package PayPal\Test\Api
*/
class RedirectUrlsTest extends \PHPUnit_Framework_TestCase
{
public function validRedirectUrlsProvider()
/**
* Gets Json String of Object RedirectUrls
* @return string
*/
public static function getJson()
{
return array(
array('https://devtools-paypal.com/guide/pay_paypal/php?success=true', 'https://devtools-paypal.com/guide/pay_paypal/php?cancel=true')
);
}
public function invalidRedirectUrlsProvider()
{
return array(
array('devtools-paypal.com/guide/pay_paypal/php?success=true', 'devtools-paypal.com/guide/pay_paypal/php?cancel=true')
);
return '{"return_url":"http://www.google.com","cancel_url":"http://www.google.com"}';
}
/**
* @dataProvider validRedirectUrlsProvider
* Gets Object Instance with Json data filled in
* @return RedirectUrls
*/
public function testValidRedirectUrls($return_url, $cancel_url)
public static function getObject()
{
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl($return_url);
$redirectUrls->setCancelUrl($cancel_url);
return new RedirectUrls(self::getJson());
}
$this->assertEquals($return_url, $redirectUrls->getReturnUrl());
$this->assertEquals($cancel_url, $redirectUrls->getCancelUrl());
/**
* Tests for Serialization and Deserialization Issues
* @return RedirectUrls
*/
public function testSerializationDeserialization()
{
$obj = new RedirectUrls(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getReturnUrl());
$this->assertNotNull($obj->getCancelUrl());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @dataProvider invalidRedirectUrlsProvider
* @depends testSerializationDeserialization
* @param RedirectUrls $obj
*/
public function testInvalidRedirectUrls($return_url, $cancel_url)
public function testGetters($obj)
{
$redirectUrls = new RedirectUrls();
$this->setExpectedException('\InvalidArgumentException');
$redirectUrls->setReturnUrl($return_url);
$redirectUrls->setCancelUrl($cancel_url);
$this->assertEquals($obj->getReturnUrl(), "http://www.google.com");
$this->assertEquals($obj->getCancelUrl(), "http://www.google.com");
}
}
}

View File

@@ -1,59 +1,110 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
use PayPal\Api\Refund;
use PayPal\Test\Constants;
/**
* Class Refund
*
* @package PayPal\Test\Api
*/
class RefundTest extends \PHPUnit_Framework_TestCase
{
private $refund;
public static $captureId = "CAP-123";
public static $createTime = "2013-02-28T00:00:00Z";
public static $id = "R-5678";
public static $parentPayment = "PAY-123";
public static function createRefund()
/**
* Gets Json String of Object Refund
* @return string
*/
public static function getJson()
{
$refund = new Refund();
$refund->setCreateTime(self::$createTime);
$refund->setAmount(AmountTest::createAmount());
$refund->setCaptureId(self::$captureId);
$refund->setId(self::$id);
$refund->setLinks(array(LinksTest::getObject()));
$refund->setParentPayment(self::$parentPayment);
return $refund;
return '{"id":"TestSample","amount":' .AmountTest::getJson() . ',"state":"TestSample","reason":"TestSample","sale_id":"TestSample","capture_id":"TestSample","parent_payment":"TestSample","description":"TestSample","create_time":"TestSample","update_time":"TestSample","links":' .LinksTest::getJson() . '}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return Refund
*/
public static function getObject()
{
$this->refund = self::createRefund();
return new Refund(self::getJson());
}
public function testGetterSetter()
/**
* Tests for Serialization and Deserialization Issues
* @return Refund
*/
public function testSerializationDeserialization()
{
$this->assertEquals(self::$captureId, $this->refund->getCaptureId());
$this->assertEquals(self::$createTime, $this->refund->getCreateTime());
$this->assertEquals(self::$id, $this->refund->getId());
$this->assertEquals(self::$parentPayment, $this->refund->getParentPayment());
$this->assertEquals(AmountTest::$currency, $this->refund->getAmount()->getCurrency());
$links = $this->refund->getLinks();
$obj = new Refund(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getAmount());
$this->assertNotNull($obj->getState());
$this->assertNotNull($obj->getReason());
$this->assertNotNull($obj->getSaleId());
$this->assertNotNull($obj->getCaptureId());
$this->assertNotNull($obj->getParentPayment());
$this->assertNotNull($obj->getDescription());
$this->assertNotNull($obj->getCreateTime());
$this->assertNotNull($obj->getUpdateTime());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param Refund $obj
*/
public function testGetters($obj)
{
$r1 = $this->refund;
$r2 = new Refund();
$r2->fromJson($r1->toJson());
$this->assertEquals($r1, $r2);
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getAmount(), AmountTest::getObject());
$this->assertEquals($obj->getState(), "TestSample");
$this->assertEquals($obj->getReason(), "TestSample");
$this->assertEquals($obj->getSaleId(), "TestSample");
$this->assertEquals($obj->getCaptureId(), "TestSample");
$this->assertEquals($obj->getParentPayment(), "TestSample");
$this->assertEquals($obj->getDescription(), "TestSample");
$this->assertEquals($obj->getCreateTime(), "TestSample");
$this->assertEquals($obj->getUpdateTime(), "TestSample");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
public function testOperations()
/**
* @dataProvider mockProvider
* @param Refund $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
RefundTest::getJson()
));
$result = $obj->get("refundId", $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
public function mockProvider()
{
$obj = self::getObject();
$mockApiContext = $this->getMockBuilder('ApiContext')
->disableOriginalConstructor()
->getMock();
return array(
array($obj, $mockApiContext),
array($obj, null)
);
}
}

View File

@@ -1,42 +1,54 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\RelatedResources;
use PayPal\Test\Constants;
/**
* Class RelatedResources
*
* @package PayPal\Test\Api
*/
class RelatedResourcesTest extends \PHPUnit_Framework_TestCase
{
private $RelatedResources;
public static function createRelatedResources()
/**
* Gets Json String of Object RelatedResources
* @return string
*/
public static function getJson()
{
$relatedResources = new RelatedResources();
$relatedResources->setAuthorization(AuthorizationTest::createAuthorization());
$relatedResources->setCapture(CaptureTest::createCapture());
$relatedResources->setOrder(OrderTest::createOrder());
return $relatedResources;
return '{}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return RelatedResources
*/
public static function getObject()
{
$this->relatedResources = self::createRelatedResources();
return new RelatedResources(self::getJson());
}
public function testGetterSetter()
/**
* Tests for Serialization and Deserialization Issues
* @return RelatedResources
*/
public function testSerializationDeserialization()
{
$this->assertEquals(AuthorizationTest::$create_time, $this->relatedResources->getAuthorization()->getCreateTime());
$this->assertEquals(CaptureTest::$create_time, $this->relatedResources->getCapture()->getCreateTime());
$this->assertEquals(OrderTest::$id, $this->relatedResources->getOrder()->getId());
$obj = new RelatedResources(self::getJson());
$this->assertNotNull($obj);
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param RelatedResources $obj
*/
public function testGetters($obj)
{
$s1 = $this->relatedResources;
$s2 = new RelatedResources();
$s2->fromJson($s1->toJson());
$this->assertEquals($s1, $s2);
}
}

View File

@@ -1,63 +1,149 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Api\Currency;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\Refund;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
use PayPal\Api\Sale;
use PayPal\Test\Api\AmountTest;
/**
* Class Sale
*
* @package PayPal\Test\Api
*/
class SaleTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Sale
* Gets Json String of Object Sale
* @return string
*/
private $sale;
private $tFee;
public static $captureId = "CAP-123";
public static $createTime = "2013-02-28T00:00:00Z";
public static $id = "R-5678";
public static $parentPayment = "PAY-123";
public static $state = "Created";
private function createSale()
public static function getJson()
{
$sale = new Sale();
$sale->setAmount(AmountTest::createAmount());
$sale->setCreateTime(self::$createTime);
$sale->setId(self::$id);
$sale->setParentPayment(self::$parentPayment);
$sale->setState(self::$state);
$this->tFee = new Currency();
$this->tFee->setCurrency('AUD');
$this->tFee->setValue('0.10');
$sale->setTransactionFee($this->tFee);
return $sale;
return '{"id":"TestSample","purchase_unit_reference_id":"TestSample","amount":' .AmountTest::getJson() . ',"payment_mode":"TestSample","state":"TestSample","reason_code":"TestSample","protection_eligibility":"TestSample","protection_eligibility_type":"TestSample","clearing_time":"TestSample","recipient_fund_status":"TestSample","hold_reason":"TestSample","transaction_fee":' .CurrencyTest::getJson() . ',"receivable_amount":' .CurrencyTest::getJson() . ',"exchange_rate":"TestSample","fmf_details":' .FmfDetailsTest::getJson() . ',"receipt_id":"TestSample","parent_payment":"TestSample","create_time":"TestSample","update_time":"TestSample","links":' .LinksTest::getJson() . '}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return Sale
*/
public static function getObject()
{
$this->sale = $this->createSale();
return new Sale(self::getJson());
}
public function testGetterSetter()
/**
* Tests for Serialization and Deserialization Issues
* @return Sale
*/
public function testSerializationDeserialization()
{
$this->assertEquals(self::$createTime, $this->sale->getCreateTime());
$this->assertEquals(self::$id, $this->sale->getId());
$this->assertEquals(self::$parentPayment, $this->sale->getParentPayment());
$this->assertEquals(self::$state, $this->sale->getState());
$this->assertEquals(AmountTest::$currency, $this->sale->getAmount()->getCurrency());
$this->assertEquals($this->tFee, $this->sale->getTransactionFee());
$obj = new Sale(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getPurchaseUnitReferenceId());
$this->assertNotNull($obj->getAmount());
$this->assertNotNull($obj->getPaymentMode());
$this->assertNotNull($obj->getState());
$this->assertNotNull($obj->getReasonCode());
$this->assertNotNull($obj->getProtectionEligibility());
$this->assertNotNull($obj->getProtectionEligibilityType());
$this->assertNotNull($obj->getClearingTime());
$this->assertNotNull($obj->getRecipientFundStatus());
$this->assertNotNull($obj->getHoldReason());
$this->assertNotNull($obj->getTransactionFee());
$this->assertNotNull($obj->getReceivableAmount());
$this->assertNotNull($obj->getExchangeRate());
$this->assertNotNull($obj->getFmfDetails());
$this->assertNotNull($obj->getReceiptId());
$this->assertNotNull($obj->getParentPayment());
$this->assertNotNull($obj->getCreateTime());
$this->assertNotNull($obj->getUpdateTime());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param Sale $obj
*/
public function testGetters($obj)
{
$s1 = $this->sale;
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getPurchaseUnitReferenceId(), "TestSample");
$this->assertEquals($obj->getAmount(), AmountTest::getObject());
$this->assertEquals($obj->getPaymentMode(), "TestSample");
$this->assertEquals($obj->getState(), "TestSample");
$this->assertEquals($obj->getReasonCode(), "TestSample");
$this->assertEquals($obj->getProtectionEligibility(), "TestSample");
$this->assertEquals($obj->getProtectionEligibilityType(), "TestSample");
$this->assertEquals($obj->getClearingTime(), "TestSample");
$this->assertEquals($obj->getRecipientFundStatus(), "TestSample");
$this->assertEquals($obj->getHoldReason(), "TestSample");
$this->assertEquals($obj->getTransactionFee(), CurrencyTest::getObject());
$this->assertEquals($obj->getReceivableAmount(), CurrencyTest::getObject());
$this->assertEquals($obj->getExchangeRate(), "TestSample");
$this->assertEquals($obj->getFmfDetails(), FmfDetailsTest::getObject());
$this->assertEquals($obj->getReceiptId(), "TestSample");
$this->assertEquals($obj->getParentPayment(), "TestSample");
$this->assertEquals($obj->getCreateTime(), "TestSample");
$this->assertEquals($obj->getUpdateTime(), "TestSample");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
$s2 = new Sale();
$s2->fromJson($s1->toJson());
/**
* @dataProvider mockProvider
* @param Sale $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$this->assertEquals($s1, $s2);
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
SaleTest::getJson()
));
$result = $obj->get("saleId", $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Sale $obj
*/
public function testRefund($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
RefundTest::getJson()
));
$refund = RefundTest::getObject();
$result = $obj->refund($refund, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
public function mockProvider()
{
$obj = self::getObject();
$mockApiContext = $this->getMockBuilder('ApiContext')
->disableOriginalConstructor()
->getMock();
return array(
array($obj, $mockApiContext),
array($obj, null)
);
}
}

View File

@@ -2,60 +2,52 @@
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\Transaction;
/**
* Class Transaction
*
* @package PayPal\Test\Api
*/
class TransactionTest extends \PHPUnit_Framework_TestCase
{
/** @var Transaction */
private $transaction;
public static $description = "desc . . . ";
public static $invoiceNumber = "#123";
public static $custom = "custom";
public static $softDescriptor = "descriptor";
public static $total = "1.12";
public static function createTransaction()
/**
* Gets Json String of Object Transaction
* @return string
*/
public static function getJson()
{
$transaction = new Transaction();
$transaction->setAmount(AmountTest::createAmount());
$transaction->setDescription(self::$description);
$transaction->setInvoiceNumber(self::$invoiceNumber);
$transaction->setCustom(self::$custom);
$transaction->setSoftDescriptor(self::$softDescriptor);
$transaction->setItemList(ItemListTest::createItemList());
$transaction->setPayee(PayeeTest::createPayee());
$transaction->setRelatedResources(array(RelatedResourcesTest::createRelatedResources()));
return $transaction;
return '{}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return Transaction
*/
public static function getObject()
{
$this->transaction = self::createTransaction();
return new Transaction(self::getJson());
}
public function testGetterSetter()
/**
* Tests for Serialization and Deserialization Issues
* @return Transaction
*/
public function testSerializationDeserialization()
{
$this->assertEquals(AmountTest::$currency, $this->transaction->getAmount()->getCurrency());
$this->assertEquals(self::$description, $this->transaction->getDescription());
$this->assertEquals(self::$invoiceNumber, $this->transaction->getInvoiceNumber());
$this->assertEquals(self::$custom, $this->transaction->getCustom());
$this->assertEquals(self::$softDescriptor, $this->transaction->getSoftDescriptor());
$items = $this->transaction->getItemList()->getItems();
$this->assertEquals(ItemTest::$quantity, $items[0]->getQuantity());
$this->assertEquals(PayeeTest::$email, $this->transaction->getPayee()->getEmail());
$resources = $this->transaction->getRelatedResources();
$this->assertEquals(AuthorizationTest::$create_time, $resources[0]->getAuthorization()->getCreateTime());
$obj = new Transaction(self::getJson());
$this->assertNotNull($obj);
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param Transaction $obj
*/
public function testGetters($obj)
{
$t1 = $this->transaction;
$t2 = new Transaction();
$t2->fromJson($t1->toJson());
$this->assertEquals($t1, $t2);
}
}

View File

@@ -8,13 +8,7 @@ use PayPal\Api\Currency;
use PayPal\Api\Patch;
use PayPal\Api\PatchRequest;
use PayPal\Api\Plan;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
use PayPal\Rest\IResource;
use PayPal\Api\CreateProfileResponse;
use PayPal\Test\Functional\Setup;
use PayPal\Transport\PayPalRestCall;
use PayPal\Api\WebProfile;
/**
* Class Billing Agreements
@@ -28,6 +22,8 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
public $response;
public $apiContext;
public $mockPayPalRestCall;
public function setUp()
@@ -67,7 +63,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
$agreement = new Agreement($request);
// Update the Schema to use a working Plan
$agreement->getPlan()->setId($plan->getId());
$result = $agreement->create(null, $this->mockPayPalRestCall);
$result = $agreement->create($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $result;
}
@@ -88,7 +84,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
$paymentToken = $result['token'];
$this->assertNotNull($paymentToken);
$this->assertNotEmpty($paymentToken);
$result = $agreement->execute($paymentToken, null, $this->mockPayPalRestCall);
$result = $agreement->execute($paymentToken, $this->apiContext, $this->mockPayPalRestCall);
return $result;
}
@@ -102,7 +98,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
$agreement = new Agreement($request);
// Update the Schema to use a working Plan
$agreement->getPlan()->setId($plan->getId());
$result = $agreement->create(null, $this->mockPayPalRestCall);
$result = $agreement->create($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $result;
}
@@ -114,7 +110,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGet($agreement)
{
$result = Agreement::get($agreement->getId(), null, $this->mockPayPalRestCall);
$result = Agreement::get($agreement->getId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($agreement->getId(), $result->getId());
return $result;
@@ -136,7 +132,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
$patches[] = $patch;
$patchRequest = new PatchRequest();
$patchRequest->setPatches($patches);
$result = $agreement->update($patchRequest, null, $this->mockPayPalRestCall);
$result = $agreement->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
}
@@ -149,7 +145,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
{
$this->markTestSkipped('Skipped as the fix is on the way.');
$currency = new Currency($this->operation['request']['body']);
$result = $agreement->setBalance($currency, null, $this->mockPayPalRestCall);
$result = $agreement->setBalance($currency, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
return $agreement;
}
@@ -163,7 +159,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
{
$this->markTestSkipped('Skipped as the fix is on the way.');
$agreementStateDescriptor = new AgreementStateDescriptor($this->operation['request']['body']);
$result = $agreement->billBalance($agreementStateDescriptor, null, $this->mockPayPalRestCall);
$result = $agreement->billBalance($agreementStateDescriptor, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
return $agreement;
}
@@ -176,7 +172,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
public function testGetTransactions($agreement)
{
$params = array('start_date' => date('Y-m-d', strtotime('-15 years')), 'end_date' => date('Y-m-d', strtotime('+5 days')));
$result = Agreement::searchTransactions($agreement->getId(), $params, null, $this->mockPayPalRestCall);
$result = Agreement::searchTransactions($agreement->getId(), $params, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertTrue(is_array($result->getAgreementTransactionList()));
$this->assertTrue(sizeof($result->getAgreementTransactionList()) > 0);
@@ -193,7 +189,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
public function testSuspend($agreement)
{
$agreementStateDescriptor = new AgreementStateDescriptor($this->operation['request']['body']);
$result = $agreement->suspend($agreementStateDescriptor, null, $this->mockPayPalRestCall);
$result = $agreement->suspend($agreementStateDescriptor, $this->apiContext, $this->mockPayPalRestCall);
$this->setupTest($this->getClassName(), 'testGetSuspended');
$get = $this->testGet($agreement);
$this->assertTrue($result);
@@ -209,7 +205,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
public function testReactivate($agreement)
{
$agreementStateDescriptor = new AgreementStateDescriptor($this->operation['request']['body']);
$result = $agreement->reActivate($agreementStateDescriptor, null, $this->mockPayPalRestCall);
$result = $agreement->reActivate($agreementStateDescriptor, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
$this->setupTest($this->getClassName(), 'testGet');
$get = $this->testGet($agreement);
@@ -225,7 +221,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
public function testCancel($agreement)
{
$agreementStateDescriptor = new AgreementStateDescriptor($this->operation['request']['body']);
$result = $agreement->cancel($agreementStateDescriptor, null, $this->mockPayPalRestCall);
$result = $agreement->cancel($agreementStateDescriptor, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
$this->setupTest($this->getClassName(), 'testGetCancelled');
$get = $this->testGet($agreement);

View File

@@ -33,7 +33,7 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
public $mockPayPalRestCall;
public $context;
public $apiContext;
public function setUp()
{
@@ -86,7 +86,7 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$obj = new Plan($request);
$result = $obj->create(null, $this->mockPayPalRestCall);
$result = $obj->create($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
self::$obj = $result;
return $result;
@@ -96,7 +96,7 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$obj = new Plan($request);
$result = $obj->create(null, $this->mockPayPalRestCall);
$result = $obj->create($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $result;
}
@@ -108,7 +108,7 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGet($plan)
{
$result = Plan::get($plan->getId(), null, $this->mockPayPalRestCall);
$result = Plan::get($plan->getId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($plan->getId(), $result->getId());
$this->assertEquals($plan, $result, "", 0, 10, true);
@@ -121,7 +121,7 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGetList($plan)
{
$result = Plan::all(array('page_size' => '20', 'total_required' => 'yes'), null, $this->mockPayPalRestCall);
$result = Plan::all(array('page_size' => '20', 'total_required' => 'yes'), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$totalPages = $result->getTotalPages();
$found = false;
@@ -135,7 +135,7 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
}
}
if (!$found) {
$result = Plan::all(array('page' => --$totalPages, 'page_size' => '20', 'total_required' => 'yes'), null, $this->mockPayPalRestCall);
$result = Plan::all(array('page' => --$totalPages, 'page_size' => '20', 'total_required' => 'yes'), $this->apiContext, $this->mockPayPalRestCall);
}
} while ($totalPages > 0 && $found == false);
@@ -160,7 +160,7 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
$patches[] = $patch;
$patchRequest = new PatchRequest();
$patchRequest->setPatches($patches);
$result = $plan->update($patchRequest, null, $this->mockPayPalRestCall);
$result = $plan->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
}
@@ -181,7 +181,7 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
$patches[] = $patch;
$patchRequest = new PatchRequest();
$patchRequest->setPatches($patches);
$result = $plan->update($patchRequest, null, $this->mockPayPalRestCall);
$result = $plan->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
}
@@ -202,8 +202,8 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
$patches[] = $patch;
$patchRequest = new PatchRequest();
$patchRequest->setPatches($patches);
$result = $plan->update($patchRequest, null, $this->mockPayPalRestCall);
$result = $plan->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
return Plan::get($plan->getId(), null, $this->mockPayPalRestCall);
return Plan::get($plan->getId(), $this->apiContext, $this->mockPayPalRestCall);
}
}

View File

@@ -25,6 +25,8 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
public $mockPayPalRestCall;
public $apiContext;
public function setUp()
{
$className = $this->getClassName();
@@ -58,7 +60,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$obj = new Invoice($request);
$result = $obj->create(null, $this->mockPayPalRestCall);
$result = $obj->create($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
self::$obj = $result;
return $result;
@@ -71,7 +73,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGet($invoice)
{
$result = Invoice::get($invoice->getId(), null, $this->mockPayPalRestCall);
$result = Invoice::get($invoice->getId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($invoice->getId(), $result->getId());
return $result;
@@ -84,7 +86,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testSend($invoice)
{
$result = $invoice->send(null, $this->mockPayPalRestCall);
$result = $invoice->send($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $invoice;
}
@@ -97,7 +99,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
public function testUpdate($invoice)
{
$this->markTestSkipped('Skipped as the fix is on the way. #PPTIPS-1932');
$result = $invoice->update(null, $this->mockPayPalRestCall);
$result = $invoice->update($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($invoice->getId(), $result->getId());
}
@@ -109,7 +111,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGetAll($invoice)
{
$result = Invoice::getAll(array('page_size' => '20', 'total_count_required' => 'true'), null, $this->mockPayPalRestCall);
$result = Invoice::getAll(array('page_size' => '20', 'total_count_required' => 'true'), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertNotNull($result->getTotalCount());
$totalPages = ceil($result->getTotalCount()/20);
@@ -124,7 +126,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
}
}
if (!$found) {
$result = Invoice::getAll(array('page' => --$totalPages, 'page_size' => '20', 'total_required' => 'yes'), null, $this->mockPayPalRestCall);
$result = Invoice::getAll(array('page' => --$totalPages, 'page_size' => '20', 'total_required' => 'yes'), $this->apiContext, $this->mockPayPalRestCall);
}
} while ($totalPages > 0 && $found == false);
@@ -141,7 +143,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$search = new Search($request);
$result = Invoice::search($search, null, $this->mockPayPalRestCall);
$result = Invoice::search($search, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertNotNull($result->getTotalCount());
}
@@ -155,7 +157,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$notification = new Notification($request);
$result = $invoice->remind($notification, null, $this->mockPayPalRestCall);
$result = $invoice->remind($notification, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
}
@@ -168,7 +170,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$notification = new CancelNotification($request);
$result = $invoice->cancel($notification, null, $this->mockPayPalRestCall);
$result = $invoice->cancel($notification, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
}
@@ -179,7 +181,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testQRCode($invoice)
{
$result = Invoice::qrCode($invoice->getId(), array(), null, $this->mockPayPalRestCall);
$result = Invoice::qrCode($invoice->getId(), array(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertNotNull($result->getImage());
}
@@ -198,7 +200,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
$this->setupTest($this->getClassName(), 'testRecordPayment');
$request = $this->operation['request']['body'];
$paymentDetail = new PaymentDetail($request);
$result = $invoice->recordPayment($paymentDetail, null, $this->mockPayPalRestCall);
$result = $invoice->recordPayment($paymentDetail, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $invoice;
}
@@ -213,7 +215,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$refundDetail = new RefundDetail($request);
$result = $invoice->recordRefund($refundDetail, null, $this->mockPayPalRestCall);
$result = $invoice->recordRefund($refundDetail, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->setupTest($this->getClassName(), 'testDelete');
$invoice = $this->testDelete($invoice);
@@ -230,7 +232,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
$this->setupTest($this->getClassName(), 'testCreate');
$invoice = $this->testCreate($invoice);
$this->setupTest($this->getClassName(), 'testDelete');
$result = $invoice->delete(null, $this->mockPayPalRestCall);
$result = $invoice->delete($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
}

View File

@@ -31,6 +31,8 @@ class PaymentsFunctionalTest extends \PHPUnit_Framework_TestCase
public $mockPayPalRestCall;
public $apiContext;
public function setUp()
{
$className = $this->getClassName();
@@ -57,7 +59,7 @@ class PaymentsFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$obj = new Payment($request);
$result = $obj->create(null, $this->mockPayPalRestCall);
$result = $obj->create($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $result;
}
@@ -66,7 +68,7 @@ class PaymentsFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$obj = new Payment($request);
$result = $obj->create(null, $this->mockPayPalRestCall);
$result = $obj->create($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $result;
}
@@ -78,7 +80,7 @@ class PaymentsFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGet($payment)
{
$result = Payment::get($payment->getId(), null, $this->mockPayPalRestCall);
$result = Payment::get($payment->getId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($payment->getId(), $result->getId());
$this->assertEquals($payment, $result, "", 0, 10, true);
@@ -96,7 +98,7 @@ class PaymentsFunctionalTest extends \PHPUnit_Framework_TestCase
$transaction = $transactions[0];
$relatedResources = $transaction->getRelatedResources();
$resource = $relatedResources[0];
$result = Sale::get($resource->getSale()->getId(), null, $this->mockPayPalRestCall);
$result = Sale::get($resource->getSale()->getId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($resource->getSale()->getId(), $result->getId());
return $result;
@@ -110,7 +112,7 @@ class PaymentsFunctionalTest extends \PHPUnit_Framework_TestCase
public function testRefundSale($sale)
{
$refund = new Refund($this->operation['request']['body']);
$result = $sale->refund($refund, null, $this->mockPayPalRestCall);
$result = $sale->refund($refund, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals('completed', $result->getState());
$this->assertEquals($sale->getId(), $result->getSaleId());

View File

@@ -28,6 +28,8 @@ class PayoutsFunctionalTest extends \PHPUnit_Framework_TestCase
public $mockPayPalRestCall;
public $apiContext;
public static $batchId;
public function setUp()
@@ -62,7 +64,7 @@ class PayoutsFunctionalTest extends \PHPUnit_Framework_TestCase
}
PayoutsFunctionalTest::$batchId = $obj->getSenderBatchHeader()->getSenderBatchId();
$params = array('sync_mode' => 'true');
$result = $obj->create($params, null, $this->mockPayPalRestCall);
$result = $obj->create($params, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals(PayoutsFunctionalTest::$batchId, $result->getBatchHeader()->getSenderBatchHeader()->getSenderBatchId());
$this->assertEquals('SUCCESS', $result->getBatchHeader()->getBatchStatus());
@@ -80,7 +82,7 @@ class PayoutsFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGet($payoutBatch)
{
$result = Payout::get($payoutBatch->getBatchHeader()->getPayoutBatchId(), null, $this->mockPayPalRestCall);
$result = Payout::get($payoutBatch->getBatchHeader()->getPayoutBatchId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertNotNull($result->getBatchHeader()->getBatchStatus());
$this->assertEquals(PayoutsFunctionalTest::$batchId, $result->getBatchHeader()->getSenderBatchHeader()->getSenderBatchId());
@@ -96,7 +98,7 @@ class PayoutsFunctionalTest extends \PHPUnit_Framework_TestCase
{
$items = $payoutBatch->getItems();
$item = $items[0];
$result = PayoutItem::get($item->getPayoutItemId(), null, $this->mockPayPalRestCall);
$result = PayoutItem::get($item->getPayoutItemId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($item->getPayoutItemId(), $result->getPayoutItemId());
$this->assertEquals($item->getPayoutBatchId(), $result->getPayoutBatchId());
@@ -117,7 +119,7 @@ class PayoutsFunctionalTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Transaction status needs to be Unclaimed for this test ');
return;
}
$result = PayoutItem::cancel($item->getPayoutItemId(), null, $this->mockPayPalRestCall);
$result = PayoutItem::cancel($item->getPayoutItemId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($item->getPayoutItemId(), $result->getPayoutItemId());
$this->assertEquals($item->getPayoutBatchId(), $result->getPayoutBatchId());

View File

@@ -25,6 +25,8 @@ class WebProfileFunctionalTest extends \PHPUnit_Framework_TestCase
public $mockPayPalRestCall;
public $apiContext;
public function setUp()
{
$className = $this->getClassName();
@@ -53,7 +55,7 @@ class WebProfileFunctionalTest extends \PHPUnit_Framework_TestCase
$request = $this->operation['request']['body'];
$obj = new WebProfile($request);
$obj->setName(uniqid());
$result = $obj->create(null, $this->mockPayPalRestCall);
$result = $obj->create($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $result;
}
@@ -65,7 +67,7 @@ class WebProfileFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGet($createProfileResponse)
{
$result = WebProfile::get($createProfileResponse->getId(), null, $this->mockPayPalRestCall);
$result = WebProfile::get($createProfileResponse->getId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($createProfileResponse->getId(), $result->getId());
$this->assertEquals($this->operation['response']['body']['presentation']['logo_image'], $result->getPresentation()->getLogoImage());
@@ -82,7 +84,7 @@ class WebProfileFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGetList($webProfile)
{
$result = WebProfile::get_list(null, $this->mockPayPalRestCall);
$result = WebProfile::get_list($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$found = false;
$foundObject = null;
@@ -110,7 +112,7 @@ class WebProfileFunctionalTest extends \PHPUnit_Framework_TestCase
$boolValue = $webProfile->getInputFields()->getNoShipping();
$newValue = ($boolValue + 1) % 2;
$webProfile->getInputFields()->setNoShipping($newValue);
$result = $webProfile->update(null, $this->mockPayPalRestCall);
$result = $webProfile->update($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($webProfile->getInputFields()->getNoShipping(), $newValue);
}
@@ -132,7 +134,7 @@ class WebProfileFunctionalTest extends \PHPUnit_Framework_TestCase
"path": "/flow_config/landing_page_type"
}');
$result = $webProfile->partial_update($patches, null, $this->mockPayPalRestCall);
$result = $webProfile->partial_update($patches, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
}
@@ -144,7 +146,7 @@ class WebProfileFunctionalTest extends \PHPUnit_Framework_TestCase
{
$webProfile = new WebProfile();
$webProfile->setId($createProfileResponse->getId());
$result = $webProfile->delete(null, $this->mockPayPalRestCall);
$result = $webProfile->delete($this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
}

View File

@@ -38,6 +38,8 @@ class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase
public $mockPayPalRestCall;
public $apiContext;
public function setUp()
{
$className = $this->getClassName();
@@ -68,12 +70,12 @@ class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase
$obj->setUrl($obj->getUrl() . '?rand=' . uniqid());
$result = null;
try {
$result = $obj->create(null, $this->mockPayPalRestCall);
$result = $obj->create($this->apiContext, $this->mockPayPalRestCall);
} catch (PayPalConnectionException $ex) {
$data = $ex->getData();
if (strpos($data,'WEBHOOK_NUMBER_LIMIT_EXCEEDED') !== false) {
$this->deleteAll();
$result = $obj->create(null, $this->mockPayPalRestCall);
$result = $obj->create($this->apiContext, $this->mockPayPalRestCall);
} else {
$this->fail($ex->getMessage());
}
@@ -84,9 +86,9 @@ class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase
public function deleteAll()
{
$result = Webhook::getAll(null, $this->mockPayPalRestCall);
$result = Webhook::getAll($this->apiContext, $this->mockPayPalRestCall);
foreach ($result->getWebhooks() as $webhookObject) {
$webhookObject->delete(null, $this->mockPayPalRestCall);
$webhookObject->delete($this->apiContext, $this->mockPayPalRestCall);
}
}
@@ -97,7 +99,7 @@ class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGet($webhook)
{
$result = Webhook::get($webhook->getId(), null, $this->mockPayPalRestCall);
$result = Webhook::get($webhook->getId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($webhook->getId(), $result->getId());
$this->assertEquals($webhook, $result, "", 0, 10, true);
@@ -111,7 +113,7 @@ class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGetSubscribedEventTypes($webhook)
{
$result = WebhookEventType::subscribedEventTypes($webhook->getId(), null, $this->mockPayPalRestCall);
$result = WebhookEventType::subscribedEventTypes($webhook->getId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals(2, sizeof($result->getEventTypes()));
return $result;
@@ -124,7 +126,7 @@ class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGetAll($webhook)
{
$result = Webhook::getAll(null, $this->mockPayPalRestCall);
$result = Webhook::getAll($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$found = false;
$foundObject = null;
@@ -162,7 +164,7 @@ class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase
$patchRequest = new PatchRequest();
$patchRequest->setPatches($patches);
$result = $webhook->update($patchRequest, null, $this->mockPayPalRestCall);
$result = $webhook->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$found = false;
$foundObject = null;
@@ -181,13 +183,13 @@ class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testDelete($webhook)
{
$result = $webhook->delete(null, $this->mockPayPalRestCall);
$result = $webhook->delete($this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
}
public function testEventSearch()
{
$result = WebhookEvent::all(array(),null, $this->mockPayPalRestCall);
$result = WebhookEvent::all(array(),$this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $result;
}

View File

@@ -14,16 +14,21 @@ class Setup
public static function SetUpForFunctionalTests(\PHPUnit_Framework_TestCase &$test)
{
$context = new ApiContext();
$context->setConfig(array(
$configs = array(
'mode' => 'sandbox',
'http.ConnectionTimeOut' => 30,
'log.LogEnabled' => true,
'log.FileName' => '../PayPal.log',
'log.LogLevel' => 'FINE',
'validation.level' => 'warning'
));
'validation.level' => 'log'
);
$test->apiContext = new ApiContext(
new OAuthTokenCredential('AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS', 'EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL')
);
$test->apiContext->setConfig($configs);
//PayPalConfigManager::getInstance()->addConfigFromIni(__DIR__. '/../../../sdk_config.ini');
//PayPalConfigManager::getInstance()->addConfigs($configs);
PayPalCredentialManager::getInstance()->setCredentialObject(PayPalCredentialManager::getInstance()->getCredentialObject('acct1'));
self::$mode = getenv('REST_MODE') ? getenv('REST_MODE') : 'mock';