diff --git a/lib/PayPal/Api/Payout.php b/lib/PayPal/Api/Payout.php new file mode 100644 index 0000000..3492e91 --- /dev/null +++ b/lib/PayPal/Api/Payout.php @@ -0,0 +1,191 @@ +sender_batch_header = $sender_batch_header; + return $this; + } + + /** + * The original batch header as provided by the payment sender. + * + * @return \PayPal\Api\PayoutSenderBatchHeader + */ + public function getSenderBatchHeader() + { + return $this->sender_batch_header; + } + + /** + * The original batch header as provided by the payment sender. + * + * @deprecated Instead use setSenderBatchHeader + * + * @param \PayPal\Api\PayoutSenderBatchHeader $sender_batch_header + * @return $this + */ + public function setSender_batch_header($sender_batch_header) + { + $this->sender_batch_header = $sender_batch_header; + return $this; + } + + /** + * The original batch header as provided by the payment sender. + * @deprecated Instead use getSenderBatchHeader + * + * @return \PayPal\Api\PayoutSenderBatchHeader + */ + public function getSender_batch_header() + { + return $this->sender_batch_header; + } + + /** + * An array of payout items (that is, a set of individual payouts). + * + * @param \PayPal\Api\PayoutItem[] $items + * + * @return $this + */ + public function setItems($items) + { + $this->items = $items; + return $this; + } + + /** + * An array of payout items (that is, a set of individual payouts). + * + * @return \PayPal\Api\PayoutItem[] + */ + public function getItems() + { + return $this->items; + } + + /** + * Append Items to the list. + * + * @param \PayPal\Api\PayoutItem $payoutItem + * @return $this + */ + public function addItem($payoutItem) + { + if (!$this->getItems()) { + return $this->setItems(array($payoutItem)); + } else { + return $this->setItems( + array_merge($this->getItems(), array($payoutItem)) + ); + } + } + + /** + * Remove Items from the list. + * + * @param \PayPal\Api\PayoutItem $payoutItem + * @return $this + */ + public function removeItem($payoutItem) + { + return $this->setItems( + array_diff($this->getItems(), array($payoutItem)) + ); + } + + /** + * Create a payout batch resource by passing a sender_batch_header and an items array to the request URI. The sender_batch_header contains payout parameters that describe the handling of a batch resource while the items array conatins payout items. + * + * @param array $params + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return PayoutBatch + */ + public function create($params = array(), $apiContext = null, $restCall = null) + { + $params = $params ? $params : array(); + ArgumentValidator::validate($params, 'params'); + $payLoad = $this->toJSON(); + $allowedParams = array( + 'sync_mode' => 1, + ); + $json = self::executeCall( + "/v1/payments/payouts" . "?" . http_build_query(array_intersect_key($params, $allowedParams)), + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new PayoutBatch(); + $ret->fromJson($json); + return $ret; + } + + /** + * You can submit a payout with a synchronous API call, which immediately returns the results of a PayPal payment. + * + * @param ApiContext $apiContext + * @param PayPalRestCall $restCall + * @return PayoutBatch + */ + public function createSynchronous($apiContext = null, $restCall = null) + { + $params = array('sync_mode' => 'true'); + return $this->create($params, $apiContext, $restCall); + } + + /** + * Obtain the status of a specific batch resource by passing the payout batch ID to the request URI. You can issue this call multiple times to get the current status. + * + * @param string $payoutBatchId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return PayoutBatch + */ + public static function get($payoutBatchId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($payoutBatchId, 'payoutBatchId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/payouts/$payoutBatchId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new PayoutBatch(); + $ret->fromJson($json); + return $ret; + } + +} diff --git a/lib/PayPal/Api/PayoutBatch.php b/lib/PayPal/Api/PayoutBatch.php new file mode 100644 index 0000000..2d01d1a --- /dev/null +++ b/lib/PayPal/Api/PayoutBatch.php @@ -0,0 +1,145 @@ +batch_header = $batch_header; + return $this; + } + + /** + * A batch header that includes the generated batch status. + * + * @return \PayPal\Api\PayoutBatchHeader + */ + public function getBatchHeader() + { + return $this->batch_header; + } + + /** + * A batch header that includes the generated batch status. + * + * @deprecated Instead use setBatchHeader + * + * @param \PayPal\Api\PayoutBatchHeader $batch_header + * @return $this + */ + public function setBatch_header($batch_header) + { + $this->batch_header = $batch_header; + return $this; + } + + /** + * A batch header that includes the generated batch status. + * @deprecated Instead use getBatchHeader + * + * @return \PayPal\Api\PayoutBatchHeader + */ + public function getBatch_header() + { + return $this->batch_header; + } + + /** + * Array of the items in a batch payout. + * + * @param \PayPal\Api\PayoutItemDetails[] $items + * + * @return $this + */ + public function setItems($items) + { + $this->items = $items; + return $this; + } + + /** + * Array of the items in a batch payout. + * + * @return \PayPal\Api\PayoutItemDetails[] + */ + public function getItems() + { + return $this->items; + } + + /** + * Append Items to the list. + * + * @param \PayPal\Api\PayoutItemDetails $payoutItemDetails + * @return $this + */ + public function addItem($payoutItemDetails) + { + if (!$this->getItems()) { + return $this->setItems(array($payoutItemDetails)); + } else { + return $this->setItems( + array_merge($this->getItems(), array($payoutItemDetails)) + ); + } + } + + /** + * Remove Items from the list. + * + * @param \PayPal\Api\PayoutItemDetails $payoutItemDetails + * @return $this + */ + public function removeItem($payoutItemDetails) + { + return $this->setItems( + array_diff($this->getItems(), array($payoutItemDetails)) + ); + } + + + /** + * 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; + } + +} diff --git a/lib/PayPal/Api/PayoutBatchHeader.php b/lib/PayPal/Api/PayoutBatchHeader.php new file mode 100644 index 0000000..ddcfdee --- /dev/null +++ b/lib/PayPal/Api/PayoutBatchHeader.php @@ -0,0 +1,388 @@ +payout_batch_id = $payout_batch_id; + return $this; + } + + /** + * An ID for the batch payout. Generated by PayPal. 30 characters max. + * + * @return string + */ + public function getPayoutBatchId() + { + return $this->payout_batch_id; + } + + /** + * An ID for the batch payout. Generated by PayPal. 30 characters max. + * + * @deprecated Instead use setPayoutBatchId + * + * @param string $payout_batch_id + * @return $this + */ + public function setPayout_batch_id($payout_batch_id) + { + $this->payout_batch_id = $payout_batch_id; + return $this; + } + + /** + * An ID for the batch payout. Generated by PayPal. 30 characters max. + * @deprecated Instead use getPayoutBatchId + * + * @return string + */ + public function getPayout_batch_id() + { + return $this->payout_batch_id; + } + + /** + * Generated batch status. + * + * @param string $batch_status + * + * @return $this + */ + public function setBatchStatus($batch_status) + { + $this->batch_status = $batch_status; + return $this; + } + + /** + * Generated batch status. + * + * @return string + */ + public function getBatchStatus() + { + return $this->batch_status; + } + + /** + * Generated batch status. + * + * @deprecated Instead use setBatchStatus + * + * @param string $batch_status + * @return $this + */ + public function setBatch_status($batch_status) + { + $this->batch_status = $batch_status; + return $this; + } + + /** + * Generated batch status. + * @deprecated Instead use getBatchStatus + * + * @return string + */ + public function getBatch_status() + { + return $this->batch_status; + } + + /** + * The time the batch entered processing. + * + * @param string $time_created + * + * @return $this + */ + public function setTimeCreated($time_created) + { + $this->time_created = $time_created; + return $this; + } + + /** + * The time the batch entered processing. + * + * @return string + */ + public function getTimeCreated() + { + return $this->time_created; + } + + /** + * The time the batch entered processing. + * + * @deprecated Instead use setTimeCreated + * + * @param string $time_created + * @return $this + */ + public function setTime_created($time_created) + { + $this->time_created = $time_created; + return $this; + } + + /** + * The time the batch entered processing. + * @deprecated Instead use getTimeCreated + * + * @return string + */ + public function getTime_created() + { + return $this->time_created; + } + + /** + * The time that processing for the batch was completed. + * + * @param string $time_completed + * + * @return $this + */ + public function setTimeCompleted($time_completed) + { + $this->time_completed = $time_completed; + return $this; + } + + /** + * The time that processing for the batch was completed. + * + * @return string + */ + public function getTimeCompleted() + { + return $this->time_completed; + } + + /** + * The time that processing for the batch was completed. + * + * @deprecated Instead use setTimeCompleted + * + * @param string $time_completed + * @return $this + */ + public function setTime_completed($time_completed) + { + $this->time_completed = $time_completed; + return $this; + } + + /** + * The time that processing for the batch was completed. + * @deprecated Instead use getTimeCompleted + * + * @return string + */ + public function getTime_completed() + { + return $this->time_completed; + } + + /** + * The original batch header as provided by the payment sender. + * + * @param \PayPal\Api\PayoutSenderBatchHeader $sender_batch_header + * + * @return $this + */ + public function setSenderBatchHeader($sender_batch_header) + { + $this->sender_batch_header = $sender_batch_header; + return $this; + } + + /** + * The original batch header as provided by the payment sender. + * + * @return \PayPal\Api\PayoutSenderBatchHeader + */ + public function getSenderBatchHeader() + { + return $this->sender_batch_header; + } + + /** + * The original batch header as provided by the payment sender. + * + * @deprecated Instead use setSenderBatchHeader + * + * @param \PayPal\Api\PayoutSenderBatchHeader $sender_batch_header + * @return $this + */ + public function setSender_batch_header($sender_batch_header) + { + $this->sender_batch_header = $sender_batch_header; + return $this; + } + + /** + * The original batch header as provided by the payment sender. + * @deprecated Instead use getSenderBatchHeader + * + * @return \PayPal\Api\PayoutSenderBatchHeader + */ + public function getSender_batch_header() + { + return $this->sender_batch_header; + } + + /** + * Total amount, in U.S. dollars, requested for the applicable payouts. + * + * @param \PayPal\Api\Currency $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * Total amount, in U.S. dollars, requested for the applicable payouts. + * + * @return \PayPal\Api\Currency + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Total estimate in U.S. dollars for the applicable payouts fees. + * + * @param \PayPal\Api\Currency $fees + * + * @return $this + */ + public function setFees($fees) + { + $this->fees = $fees; + return $this; + } + + /** + * Total estimate in U.S. dollars for the applicable payouts fees. + * + * @return \PayPal\Api\Currency + */ + public function getFees() + { + return $this->fees; + } + + /** + * Sets Errors + * + * @param \PayPal\Api\Error $errors + * + * @return $this + */ + public function setErrors($errors) + { + $this->errors = $errors; + return $this; + } + + /** + * Gets Errors + * + * @return \PayPal\Api\Error + */ + public function getErrors() + { + return $this->errors; + } + + /** + * 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)) + ); + } + +} diff --git a/lib/PayPal/Api/PayoutItem.php b/lib/PayPal/Api/PayoutItem.php new file mode 100644 index 0000000..88b91d4 --- /dev/null +++ b/lib/PayPal/Api/PayoutItem.php @@ -0,0 +1,215 @@ +recipient_type = $recipient_type; + return $this; + } + + /** + * The type of identification for the payment receiver. If this field is provided, the payout items without a `recipient_type` will use the provided value. If this field is not provided, each payout item must include a value for the `recipient_type`. + * + * @return string + */ + public function getRecipientType() + { + return $this->recipient_type; + } + + /** + * The type of identification for the payment receiver. If this field is provided, the payout items without a `recipient_type` will use the provided value. If this field is not provided, each payout item must include a value for the `recipient_type`. + * + * @deprecated Instead use setRecipientType + * + * @param string $recipient_type + * @return $this + */ + public function setRecipient_type($recipient_type) + { + $this->recipient_type = $recipient_type; + return $this; + } + + /** + * The type of identification for the payment receiver. If this field is provided, the payout items without a `recipient_type` will use the provided value. If this field is not provided, each payout item must include a value for the `recipient_type`. + * @deprecated Instead use getRecipientType + * + * @return string + */ + public function getRecipient_type() + { + return $this->recipient_type; + } + + /** + * The amount of money to pay a receiver. + * + * @param \PayPal\Api\Currency $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * The amount of money to pay a receiver. + * + * @return \PayPal\Api\Currency + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Note for notifications. The note is provided by the payment sender. This note can be any string. 4000 characters max. + * + * @param string $note + * + * @return $this + */ + public function setNote($note) + { + $this->note = $note; + return $this; + } + + /** + * Note for notifications. The note is provided by the payment sender. This note can be any string. 4000 characters max. + * + * @return string + */ + public function getNote() + { + return $this->note; + } + + /** + * The receiver of the payment. In a call response, the format of this value corresponds to the `recipient_type` specified in the request. 127 characters max. + * + * @param string $receiver + * + * @return $this + */ + public function setReceiver($receiver) + { + $this->receiver = $receiver; + return $this; + } + + /** + * The receiver of the payment. In a call response, the format of this value corresponds to the `recipient_type` specified in the request. 127 characters max. + * + * @return string + */ + public function getReceiver() + { + return $this->receiver; + } + + /** + * A sender-specific ID number, used in an accounting system for tracking purposes. 30 characters max. + * + * @param string $sender_item_id + * + * @return $this + */ + public function setSenderItemId($sender_item_id) + { + $this->sender_item_id = $sender_item_id; + return $this; + } + + /** + * A sender-specific ID number, used in an accounting system for tracking purposes. 30 characters max. + * + * @return string + */ + public function getSenderItemId() + { + return $this->sender_item_id; + } + + /** + * A sender-specific ID number, used in an accounting system for tracking purposes. 30 characters max. + * + * @deprecated Instead use setSenderItemId + * + * @param string $sender_item_id + * @return $this + */ + public function setSender_item_id($sender_item_id) + { + $this->sender_item_id = $sender_item_id; + return $this; + } + + /** + * A sender-specific ID number, used in an accounting system for tracking purposes. 30 characters max. + * @deprecated Instead use getSenderItemId + * + * @return string + */ + public function getSender_item_id() + { + return $this->sender_item_id; + } + + /** + * Obtain the status of a payout item by passing the item ID to the request URI. + * + * @param string $payoutItemId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return PayoutItemDetails + */ + public static function get($payoutItemId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($payoutItemId, 'payoutItemId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/payouts-item/$payoutItemId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new PayoutItemDetails(); + $ret->fromJson($json); + return $ret; + } + +} diff --git a/lib/PayPal/Api/PayoutItemDetails.php b/lib/PayPal/Api/PayoutItemDetails.php new file mode 100644 index 0000000..404e385 --- /dev/null +++ b/lib/PayPal/Api/PayoutItemDetails.php @@ -0,0 +1,487 @@ +payout_item_id = $payout_item_id; + return $this; + } + + /** + * An ID for an individual payout. Provided by PayPal, such as in the case of getting the status of a batch request. 30 characters max. + * + * @return string + */ + public function getPayoutItemId() + { + return $this->payout_item_id; + } + + /** + * An ID for an individual payout. Provided by PayPal, such as in the case of getting the status of a batch request. 30 characters max. + * + * @deprecated Instead use setPayoutItemId + * + * @param string $payout_item_id + * @return $this + */ + public function setPayout_item_id($payout_item_id) + { + $this->payout_item_id = $payout_item_id; + return $this; + } + + /** + * An ID for an individual payout. Provided by PayPal, such as in the case of getting the status of a batch request. 30 characters max. + * @deprecated Instead use getPayoutItemId + * + * @return string + */ + public function getPayout_item_id() + { + return $this->payout_item_id; + } + + /** + * Generated ID for the transaction. 30 characters max. + * + * @param string $transaction_id + * + * @return $this + */ + public function setTransactionId($transaction_id) + { + $this->transaction_id = $transaction_id; + return $this; + } + + /** + * Generated ID for the transaction. 30 characters max. + * + * @return string + */ + public function getTransactionId() + { + return $this->transaction_id; + } + + /** + * Generated ID for the transaction. 30 characters max. + * + * @deprecated Instead use setTransactionId + * + * @param string $transaction_id + * @return $this + */ + public function setTransaction_id($transaction_id) + { + $this->transaction_id = $transaction_id; + return $this; + } + + /** + * Generated ID for the transaction. 30 characters max. + * @deprecated Instead use getTransactionId + * + * @return string + */ + public function getTransaction_id() + { + return $this->transaction_id; + } + + /** + * Status of a transaction. + * + * @param string $transaction_status + * + * @return $this + */ + public function setTransactionStatus($transaction_status) + { + $this->transaction_status = $transaction_status; + return $this; + } + + /** + * Status of a transaction. + * + * @return string + */ + public function getTransactionStatus() + { + return $this->transaction_status; + } + + /** + * Status of a transaction. + * + * @deprecated Instead use setTransactionStatus + * + * @param string $transaction_status + * @return $this + */ + public function setTransaction_status($transaction_status) + { + $this->transaction_status = $transaction_status; + return $this; + } + + /** + * Status of a transaction. + * @deprecated Instead use getTransactionStatus + * + * @return string + */ + public function getTransaction_status() + { + return $this->transaction_status; + } + + /** + * Amount of money in U.S. dollars for fees. + * + * @param \PayPal\Api\Currency $payout_item_fee + * + * @return $this + */ + public function setPayoutItemFee($payout_item_fee) + { + $this->payout_item_fee = $payout_item_fee; + return $this; + } + + /** + * Amount of money in U.S. dollars for fees. + * + * @return \PayPal\Api\Currency + */ + public function getPayoutItemFee() + { + return $this->payout_item_fee; + } + + /** + * Amount of money in U.S. dollars for fees. + * + * @deprecated Instead use setPayoutItemFee + * + * @param \PayPal\Api\Currency $payout_item_fee + * @return $this + */ + public function setPayout_item_fee($payout_item_fee) + { + $this->payout_item_fee = $payout_item_fee; + return $this; + } + + /** + * Amount of money in U.S. dollars for fees. + * @deprecated Instead use getPayoutItemFee + * + * @return \PayPal\Api\Currency + */ + public function getPayout_item_fee() + { + return $this->payout_item_fee; + } + + /** + * An ID for the batch payout. Generated by PayPal. 30 characters max. + * + * @param string $payout_batch_id + * + * @return $this + */ + public function setPayoutBatchId($payout_batch_id) + { + $this->payout_batch_id = $payout_batch_id; + return $this; + } + + /** + * An ID for the batch payout. Generated by PayPal. 30 characters max. + * + * @return string + */ + public function getPayoutBatchId() + { + return $this->payout_batch_id; + } + + /** + * An ID for the batch payout. Generated by PayPal. 30 characters max. + * + * @deprecated Instead use setPayoutBatchId + * + * @param string $payout_batch_id + * @return $this + */ + public function setPayout_batch_id($payout_batch_id) + { + $this->payout_batch_id = $payout_batch_id; + return $this; + } + + /** + * An ID for the batch payout. Generated by PayPal. 30 characters max. + * @deprecated Instead use getPayoutBatchId + * + * @return string + */ + public function getPayout_batch_id() + { + return $this->payout_batch_id; + } + + /** + * Sender-created ID for tracking the batch in an accounting system. 30 characters max. + * + * @param string $sender_batch_id + * + * @return $this + */ + public function setSenderBatchId($sender_batch_id) + { + $this->sender_batch_id = $sender_batch_id; + return $this; + } + + /** + * Sender-created ID for tracking the batch in an accounting system. 30 characters max. + * + * @return string + */ + public function getSenderBatchId() + { + return $this->sender_batch_id; + } + + /** + * Sender-created ID for tracking the batch in an accounting system. 30 characters max. + * + * @deprecated Instead use setSenderBatchId + * + * @param string $sender_batch_id + * @return $this + */ + public function setSender_batch_id($sender_batch_id) + { + $this->sender_batch_id = $sender_batch_id; + return $this; + } + + /** + * Sender-created ID for tracking the batch in an accounting system. 30 characters max. + * @deprecated Instead use getSenderBatchId + * + * @return string + */ + public function getSender_batch_id() + { + return $this->sender_batch_id; + } + + /** + * The data for a payout item that the sender initially provided. + * + * @param \PayPal\Api\PayoutItem $payout_item + * + * @return $this + */ + public function setPayoutItem($payout_item) + { + $this->payout_item = $payout_item; + return $this; + } + + /** + * The data for a payout item that the sender initially provided. + * + * @return \PayPal\Api\PayoutItem + */ + public function getPayoutItem() + { + return $this->payout_item; + } + + /** + * The data for a payout item that the sender initially provided. + * + * @deprecated Instead use setPayoutItem + * + * @param \PayPal\Api\PayoutItem $payout_item + * @return $this + */ + public function setPayout_item($payout_item) + { + $this->payout_item = $payout_item; + return $this; + } + + /** + * The data for a payout item that the sender initially provided. + * @deprecated Instead use getPayoutItem + * + * @return \PayPal\Api\PayoutItem + */ + public function getPayout_item() + { + return $this->payout_item; + } + + /** + * Time of the last processing for this item. + * + * @param string $time_processed + * + * @return $this + */ + public function setTimeProcessed($time_processed) + { + $this->time_processed = $time_processed; + return $this; + } + + /** + * Time of the last processing for this item. + * + * @return string + */ + public function getTimeProcessed() + { + return $this->time_processed; + } + + /** + * Time of the last processing for this item. + * + * @deprecated Instead use setTimeProcessed + * + * @param string $time_processed + * @return $this + */ + public function setTime_processed($time_processed) + { + $this->time_processed = $time_processed; + return $this; + } + + /** + * Time of the last processing for this item. + * @deprecated Instead use getTimeProcessed + * + * @return string + */ + public function getTime_processed() + { + return $this->time_processed; + } + + /** + * Sets Error + * + * @param \PayPal\Api\Error $error + * + * @return $this + */ + public function setErrors($error) + { + $this->errors = $error; + return $this; + } + + /** + * Gets Error + * + * @return \PayPal\Api\Error + */ + public function getErrors() + { + return $this->errors; + } + + /** + * 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)) + ); + } + +} diff --git a/lib/PayPal/Api/PayoutSenderBatchHeader.php b/lib/PayPal/Api/PayoutSenderBatchHeader.php new file mode 100644 index 0000000..d9f5ac2 --- /dev/null +++ b/lib/PayPal/Api/PayoutSenderBatchHeader.php @@ -0,0 +1,164 @@ +sender_batch_id = $sender_batch_id; + return $this; + } + + /** + * Sender-created ID for tracking the batch payout in an accounting system. 30 characters max. + * + * @return string + */ + public function getSenderBatchId() + { + return $this->sender_batch_id; + } + + /** + * Sender-created ID for tracking the batch payout in an accounting system. 30 characters max. + * + * @deprecated Instead use setSenderBatchId + * + * @param string $sender_batch_id + * @return $this + */ + public function setSender_batch_id($sender_batch_id) + { + $this->sender_batch_id = $sender_batch_id; + return $this; + } + + /** + * Sender-created ID for tracking the batch payout in an accounting system. 30 characters max. + * @deprecated Instead use getSenderBatchId + * + * @return string + */ + public function getSender_batch_id() + { + return $this->sender_batch_id; + } + + /** + * The subject line text for the email that PayPal sends when a payout item is completed. (The subject line is the same for all recipients.) Maximum of 255 single-byte alphanumeric characters. + * + * @param string $email_subject + * + * @return $this + */ + public function setEmailSubject($email_subject) + { + $this->email_subject = $email_subject; + return $this; + } + + /** + * The subject line text for the email that PayPal sends when a payout item is completed. (The subject line is the same for all recipients.) Maximum of 255 single-byte alphanumeric characters. + * + * @return string + */ + public function getEmailSubject() + { + return $this->email_subject; + } + + /** + * The subject line text for the email that PayPal sends when a payout item is completed. (The subject line is the same for all recipients.) Maximum of 255 single-byte alphanumeric characters. + * + * @deprecated Instead use setEmailSubject + * + * @param string $email_subject + * @return $this + */ + public function setEmail_subject($email_subject) + { + $this->email_subject = $email_subject; + return $this; + } + + /** + * The subject line text for the email that PayPal sends when a payout item is completed. (The subject line is the same for all recipients.) Maximum of 255 single-byte alphanumeric characters. + * @deprecated Instead use getEmailSubject + * + * @return string + */ + public function getEmail_subject() + { + return $this->email_subject; + } + + /** + * The type of ID for a payment receiver. If this field is provided, the payout items without a `recipient_type` will use the provided value. If this field is not provided, each payout item must include a value for the `recipient_type`. + * + * @param string $recipient_type + * + * @return $this + */ + public function setRecipientType($recipient_type) + { + $this->recipient_type = $recipient_type; + return $this; + } + + /** + * The type of ID for a payment receiver. If this field is provided, the payout items without a `recipient_type` will use the provided value. If this field is not provided, each payout item must include a value for the `recipient_type`. + * + * @return string + */ + public function getRecipientType() + { + return $this->recipient_type; + } + + /** + * The type of ID for a payment receiver. If this field is provided, the payout items without a `recipient_type` will use the provided value. If this field is not provided, each payout item must include a value for the `recipient_type`. + * + * @deprecated Instead use setRecipientType + * + * @param string $recipient_type + * @return $this + */ + public function setRecipient_type($recipient_type) + { + $this->recipient_type = $recipient_type; + return $this; + } + + /** + * The type of ID for a payment receiver. If this field is provided, the payout items without a `recipient_type` will use the provided value. If this field is not provided, each payout item must include a value for the `recipient_type`. + * @deprecated Instead use getRecipientType + * + * @return string + */ + public function getRecipient_type() + { + return $this->recipient_type; + } + +} diff --git a/sample/doc/assets/behavior.js b/sample/doc/assets/behavior.js index fbc2bdb..041815d 100644 --- a/sample/doc/assets/behavior.js +++ b/sample/doc/assets/behavior.js @@ -1243,73 +1243,6 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3 "depth": 1, "children": [ { - "type": "file", - "data": { - "language": { - "nameMatchers": [{}, ".fbp"], - "pygmentsLexer": "php", - "singleLineComment": ["//"], - "ignorePrefix": "}", - "foldPrefix": "^", - "name": "PHP" - }, - "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/notifications/CreateWebhook.php", - "projectPath": "notifications/CreateWebhook.php", - "targetPath": "notifications/CreateWebhook", - "pageTitle": "notifications/CreateWebhook", - "title": "CreateWebhook" - }, - "depth": 2, - "outline": [ - { - "type": "heading", - "data": { - "level": 1, - "title": "Create Webhook Sample", - "slug": "create-webhook-sample" - }, - "depth": 1 - }, { - "type": "heading", - "data": { - "level": 1, - "title": "Basic Information", - "slug": "basic-information" - }, - "depth": 1, - "children": [ - { - "type": "heading", - "data": { - "level": 4, - "title": "NOTE: Please note that you need an https url for paypal webhooks. You can however override the url with https, and accept", - "slug": "note-please-note-that-you-need-an-https-url-for-paypal-webhooks-you-can-however-override-the-url-with-https-and-accept" - }, - "depth": 4 - } - ] - }, { - "type": "heading", - "data": { - "level": 1, - "title": "Event Types", - "slug": "event-types" - }, - "depth": 1, - "children": [ - { - "type": "heading", - "data": { - "level": 3, - "title": "Create Webhook", - "slug": "create-webhook" - }, - "depth": 3 - } - ] - } - ] - }, { "type": "file", "data": { "language": { @@ -1714,6 +1647,73 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3 ] } ] + }, { + "type": "file", + "data": { + "language": { + "nameMatchers": [{}, ".fbp"], + "pygmentsLexer": "php", + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "PHP" + }, + "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/notifications/createWebhook.php", + "projectPath": "notifications/createWebhook.php", + "targetPath": "notifications/createWebhook", + "pageTitle": "notifications/createWebhook", + "title": "createWebhook" + }, + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 1, + "title": "Create Webhook Sample", + "slug": "create-webhook-sample" + }, + "depth": 1 + }, { + "type": "heading", + "data": { + "level": 1, + "title": "Basic Information", + "slug": "basic-information" + }, + "depth": 1, + "children": [ + { + "type": "heading", + "data": { + "level": 4, + "title": "NOTE: Please note that you need an https url for paypal webhooks. You can however override the url with https, and accept", + "slug": "note-please-note-that-you-need-an-https-url-for-paypal-webhooks-you-can-however-override-the-url-with-https-and-accept" + }, + "depth": 4 + } + ] + }, { + "type": "heading", + "data": { + "level": 1, + "title": "Event Types", + "slug": "event-types" + }, + "depth": 1, + "children": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "Create Webhook", + "slug": "create-webhook" + }, + "depth": 3 + } + ] + } + ] } ] }, { @@ -2924,6 +2924,268 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3 ] } ] + }, { + "type": "folder", + "data": { + "path": "payouts", + "title": "payouts" + }, + "depth": 1, + "children": [ + { + "type": "file", + "data": { + "language": { + "nameMatchers": [{}, ".fbp"], + "pygmentsLexer": "php", + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "PHP" + }, + "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payouts/CreateBatchPayout.php", + "projectPath": "payouts/CreateBatchPayout.php", + "targetPath": "payouts/CreateBatchPayout", + "pageTitle": "payouts/CreateBatchPayout", + "title": "CreateBatchPayout" + }, + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 1, + "title": "Create Bulk Payout Sample", + "slug": "create-bulk-payout-sample" + }, + "depth": 1, + "children": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "NOTE:", + "slug": "note" + }, + "depth": 3, + "children": [ + { + "type": "heading", + "data": { + "level": 4, + "title": "Batch Header Instance", + "slug": "batch-header-instance" + }, + "depth": 4 + }, { + "type": "heading", + "data": { + "level": 4, + "title": "Sender Item", + "slug": "sender-item" + }, + "depth": 4 + }, { + "type": "heading", + "data": { + "level": 4, + "title": "Sender Item 2", + "slug": "sender-item-2" + }, + "depth": 4 + }, { + "type": "heading", + "data": { + "level": 4, + "title": "Sender Item 3", + "slug": "sender-item-3" + }, + "depth": 4 + } + ] + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Create Payout", + "slug": "create-payout" + }, + "depth": 3 + } + ] + } + ] + }, { + "type": "file", + "data": { + "language": { + "nameMatchers": [{}, ".fbp"], + "pygmentsLexer": "php", + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "PHP" + }, + "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payouts/CreateSinglePayout.php", + "projectPath": "payouts/CreateSinglePayout.php", + "targetPath": "payouts/CreateSinglePayout", + "pageTitle": "payouts/CreateSinglePayout", + "title": "CreateSinglePayout" + }, + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 1, + "title": "Create Single Synchronous Payout Sample", + "slug": "create-single-synchronous-payout-sample" + }, + "depth": 1, + "children": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "NOTE:", + "slug": "note" + }, + "depth": 3, + "children": [ + { + "type": "heading", + "data": { + "level": 4, + "title": "Batch Header Instance", + "slug": "batch-header-instance" + }, + "depth": 4 + }, { + "type": "heading", + "data": { + "level": 4, + "title": "Sender Item", + "slug": "sender-item" + }, + "depth": 4 + } + ] + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Create Payout", + "slug": "create-payout" + }, + "depth": 3 + } + ] + } + ] + }, { + "type": "file", + "data": { + "language": { + "nameMatchers": [{}, ".fbp"], + "pygmentsLexer": "php", + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "PHP" + }, + "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payouts/GetPayoutBatchStatus.php", + "projectPath": "payouts/GetPayoutBatchStatus.php", + "targetPath": "payouts/GetPayoutBatchStatus", + "pageTitle": "payouts/GetPayoutBatchStatus", + "title": "GetPayoutBatchStatus" + }, + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 1, + "title": "Get Payout Batch Status Sample", + "slug": "get-payout-batch-status-sample" + }, + "depth": 1, + "children": [ + { + "type": "heading", + "data": { + "level": 2, + "title": "Payout Batch ID", + "slug": "payout-batch-id" + }, + "depth": 2, + "children": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "Get Payout Batch Status", + "slug": "get-payout-batch-status" + }, + "depth": 3 + } + ] + } + ] + } + ] + }, { + "type": "file", + "data": { + "language": { + "nameMatchers": [{}, ".fbp"], + "pygmentsLexer": "php", + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "PHP" + }, + "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payouts/GetPayoutItemStatus.php", + "projectPath": "payouts/GetPayoutItemStatus.php", + "targetPath": "payouts/GetPayoutItemStatus", + "pageTitle": "payouts/GetPayoutItemStatus", + "title": "GetPayoutItemStatus" + }, + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 1, + "title": "Get Payout Item Status Sample", + "slug": "get-payout-item-status-sample" + }, + "depth": 1, + "children": [ + { + "type": "heading", + "data": { + "level": 2, + "title": "Payout Item ID", + "slug": "payout-item-id" + }, + "depth": 2, + "children": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "Get Payout Item Status", + "slug": "get-payout-item-status" + }, + "depth": 3 + } + ] + } + ] + } + ] + } + ] }, { "type": "folder", "data": { diff --git a/sample/doc/billing/CreateBillingAgreementWithPayPal.html b/sample/doc/billing/CreateBillingAgreementWithPayPal.html index 765aadd..1e07903 100644 --- a/sample/doc/billing/CreateBillingAgreementWithPayPal.html +++ b/sample/doc/billing/CreateBillingAgreementWithPayPal.html @@ -46,13 +46,8 @@ Please note that the plan Id should be only set in this case.

'US'); $agreement->setShippingAddress($shippingAddress);

For Sample Purposes Only.

$request = clone $agreement;

Create Agreement

try {

Please note that as the agreement has not yet activated, we wont be receiving the ID just yet.

$agreement = $agreement->create($apiContext);

Get redirect url

The API response provides the url that you must redirect -the buyer to. Retrieve the url from the $agreement->getLinks() -method

foreach ($agreement->getLinks() as $link) { - if ($link->getRel() == 'approval_url') { - $approvalUrl = $link->getHref(); - break; - } - } +the buyer to. Retrieve the url from the $agreement->getApprovalLink() +method

$approvalUrl = $agreement->getApprovalLink(); } catch (Exception $ex) { ResultPrinter::printError("Created Billing Agreement.", "Agreement", null, $request, $ex); diff --git a/sample/doc/notifications/createWebhook.html b/sample/doc/notifications/createWebhook.html index a63b581..059a74d 100644 --- a/sample/doc/notifications/createWebhook.html +++ b/sample/doc/notifications/createWebhook.html @@ -1,4 +1,4 @@ -notifications/CreateWebhook
notifications/CreateWebhook.php
<?php

Create Webhook Sample

+notifications/createWebhook
notifications/createWebhook.php
<?php

Create Webhook Sample

This sample code demonstrate how you can create a webhook, as documented here at: https://developer.paypal.com/webapps/developer/docs/api/#create-a-webhook API used: POST /v1/notifications/webhooks

require __DIR__ . '/../bootstrap.php';

Create a new instance of Webhook object

$webhook = new \PayPal\Api\Webhook();

Basic Information

diff --git a/sample/doc/payments/AuthorizePaymentUsingPayPal.html b/sample/doc/payments/AuthorizePaymentUsingPayPal.html index 892d214..d4da445 100644 --- a/sample/doc/payments/AuthorizePaymentUsingPayPal.html +++ b/sample/doc/payments/AuthorizePaymentUsingPayPal.html @@ -73,12 +73,7 @@ for payment approval

Get redirect url

The API response provides the url that you must redirect the buyer to. Retrieve the url from the $payment->getLinks() -method

foreach ($payment->getLinks() as $link) { - if ($link->getRel() == 'approval_url') { - $approvalUrl = $link->getHref(); - break; - } -} +method

$approvalUrl = $payment->getApprovalLink(); ResultPrinter::printResult("Created Payment Authorization Using PayPal. Please visit the URL to Authorize.", "Payment", "<a href='$approvalUrl' >$approvalUrl</a>", $request, $payment); diff --git a/sample/doc/payments/CreatePaymentUsingPayPal.html b/sample/doc/payments/CreatePaymentUsingPayPal.html index 1f604b8..cc2ff55 100644 --- a/sample/doc/payments/CreatePaymentUsingPayPal.html +++ b/sample/doc/payments/CreatePaymentUsingPayPal.html @@ -70,13 +70,8 @@ for payment approval

exit(1); }

Get redirect url

The API response provides the url that you must redirect -the buyer to. Retrieve the url from the $payment->getLinks() -method

foreach ($payment->getLinks() as $link) { - if ($link->getRel() == 'approval_url') { - $approvalUrl = $link->getHref(); - break; - } -} +the buyer to. Retrieve the url from the $payment->getApprovalLink() +method

$approvalUrl = $payment->getApprovalLink(); ResultPrinter::printResult("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", "<a href='$approvalUrl' >$approvalUrl</a>", $request, $payment); diff --git a/sample/doc/payouts/CreateBatchPayout.html b/sample/doc/payouts/CreateBatchPayout.html new file mode 100644 index 0000000..0762272 --- /dev/null +++ b/sample/doc/payouts/CreateBatchPayout.html @@ -0,0 +1,93 @@ +payouts/CreateBatchPayout
payouts/CreateBatchPayout.php
<?php

Create Bulk Payout Sample

+

This sample code demonstrate how you can create a synchronous payout sample, as documented here at: +https://developer.paypal.com/docs/integration/direct/create-batch-payout/ +API used: /v1/payments/payouts

require __DIR__ . '/../bootstrap.php';

Create a new instance of Payout object

$payouts = new \PayPal\Api\Payout();

This is how our body should look like:

/* + *{ + "sender_batch_header": { + "sender_batch_id": "random_uniq_id", + "email_subject": "You have a payment" + }, + "items": [ + { + "recipient_type": "EMAIL", + "amount": { + "value": 0.99, + "currency": "USD" + }, + "receiver": "shirt-supplier-one@mail.com", + "note": "Thank you.", + "sender_item_id": "item_1" + }, + { + "recipient_type": "EMAIL", + "amount": { + "value": 0.90, + "currency": "USD" + }, + "receiver": "shirt-supplier-two@mail.com", + "note": "Thank you.", + "sender_item_id": "item_2" + }, + { + "recipient_type": "EMAIL", + "amount": { + "value": 2.00, + "currency": "USD" + }, + "receiver": "shirt-supplier-three@mail.com", + "note": "Thank you.", + "sender_item_id": "item_3" + } + ] +} + */ + +$senderBatchHeader = new \PayPal\Api\PayoutSenderBatchHeader();

NOTE:

+

You can prevent duplicate batches from being processed. If you specify a sender_batch_id that was used in the last 30 days, the batch will not be processed. For items, you can specify a sender_item_id. If the value for the sender_item_id is a duplicate of a payout item that was processed in the last 30 days, the item will not be processed.

Batch Header Instance

$senderBatchHeader->setSenderBatchId(uniqid()) + ->setEmailSubject("You have a payment");

Sender Item

+

Please note that if you are using single payout with sync mode, you can only pass one Item in the request

$senderItem1 = new \PayPal\Api\PayoutItem(); +$senderItem1->setRecipientType('Email') + ->setNote('Thanks you.') + ->setReceiver('shirt-supplier-one@gmail.com') + ->setSenderItemId("item_1" . uniqid()) + ->setAmount(new \PayPal\Api\Currency('{ + "value":"0.99", + "currency":"USD" + }'));

Sender Item 2

+

There are many different ways of assigning values in PayPal SDK. Here is another way where you could directly inject json string.

$senderItem2 = new \PayPal\Api\PayoutItem( + '{ + "recipient_type": "EMAIL", + "amount": { + "value": 0.90, + "currency": "USD" + }, + "receiver": "shirt-supplier-two@mail.com", + "note": "Thank you.", + "sender_item_id": "item_2" + }' +);

Sender Item 3

+

One more way of assigning values in constructor when creating instance of PayPalModel object. Injecting array.

$senderItem3 = new \PayPal\Api\PayoutItem( + array( + "recipient_type" => "EMAIL", + "receiver" => "shirt-supplier-three@mail.com", + "note" => "Thank you.", + "sender_item_id" => uniqid(), + "amount" => array( + "value" => "0.90", + "currency" => "USD" + ) + + ) +); + +$payouts->setSenderBatchHeader($senderBatchHeader) + ->addItem($senderItem1)->addItem($senderItem2)->addItem($senderItem3);

For Sample Purposes Only.

$request = clone $payouts;

Create Payout

try { + $output = $payouts->create(null, $apiContext); +} catch (Exception $ex) { + ResultPrinter::printError("Created Batch Payout", "Payout", null, $request, $ex); + exit(1); +} + +ResultPrinter::printResult("Created Batch Payout", "Payout", $output->getBatchHeader()->getPayoutBatchId(), $request, $output); + +return $output;
\ No newline at end of file diff --git a/sample/doc/payouts/CreateSinglePayout.html b/sample/doc/payouts/CreateSinglePayout.html new file mode 100644 index 0000000..90764ae --- /dev/null +++ b/sample/doc/payouts/CreateSinglePayout.html @@ -0,0 +1,48 @@ +payouts/CreateSinglePayout
payouts/CreateSinglePayout.php
<?php

Create Single Synchronous Payout Sample

+

This sample code demonstrate how you can create a synchronous payout sample, as documented here at: +https://developer.paypal.com/docs/integration/direct/create-single-payout/ +API used: /v1/payments/payouts?sync_mode=true

require __DIR__ . '/../bootstrap.php';

Create a new instance of Payout object

$payouts = new \PayPal\Api\Payout();

This is how our body should look like:

/* + * { + "sender_batch_header":{ + "sender_batch_id":"2014021801", + "email_subject":"You have a Payout!" + }, + "items":[ + { + "recipient_type":"EMAIL", + "amount":{ + "value":"1.0", + "currency":"USD" + }, + "note":"Thanks for your patronage!", + "sender_item_id":"2014031400023", + "receiver":"shirt-supplier-one@mail.com" + } + ] + } + */ + +$senderBatchHeader = new \PayPal\Api\PayoutSenderBatchHeader();

NOTE:

+

You can prevent duplicate batches from being processed. If you specify a sender_batch_id that was used in the last 30 days, the batch will not be processed. For items, you can specify a sender_item_id. If the value for the sender_item_id is a duplicate of a payout item that was processed in the last 30 days, the item will not be processed.

Batch Header Instance

$senderBatchHeader->setSenderBatchId(uniqid()) + ->setEmailSubject("You have a Payout!");

Sender Item

+

Please note that if you are using single payout with sync mode, you can only pass one Item in the request

$senderItem = new \PayPal\Api\PayoutItem(); +$senderItem->setRecipientType('Email') + ->setNote('Thanks for your patronage!') + ->setReceiver('shirt-supplier-one@gmail.com') + ->setSenderItemId("2014031400023") + ->setAmount(new \PayPal\Api\Currency('{ + "value":"1.0", + "currency":"USD" + }')); + +$payouts->setSenderBatchHeader($senderBatchHeader) + ->addItem($senderItem);

For Sample Purposes Only.

$request = clone $payouts;

Create Payout

try { + $output = $payouts->createSynchronous($apiContext); +} catch (Exception $ex) { + ResultPrinter::printError("Created Single Synchronous Payout", "Payout", null, $request, $ex); + exit(1); +} + +ResultPrinter::printResult("Created Single Synchronous Payout", "Payout", $output->getBatchHeader()->getPayoutBatchId(), $request, $output); + +return $output;
\ No newline at end of file diff --git a/sample/doc/payouts/GetPayoutBatchStatus.html b/sample/doc/payouts/GetPayoutBatchStatus.html new file mode 100644 index 0000000..570477e --- /dev/null +++ b/sample/doc/payouts/GetPayoutBatchStatus.html @@ -0,0 +1,15 @@ +payouts/GetPayoutBatchStatus
payouts/GetPayoutBatchStatus.php
<?php

Get Payout Batch Status Sample

+

This sample code demonstrate how you can get the batch payout status of a created batch payout, as documented here at: +https://developer.paypal.com/docs/api/#get-the-status-of-a-batch-payout +API used: GET /v1/payments/payouts/

/** @var \PayPal\Api\PayoutBatch $payoutBatch */ +$payoutBatch = require 'CreateBatchPayout.php';

Payout Batch ID

+

You can replace this with your Payout Batch Id on already created Payout.

$payoutBatchId = $payoutBatch->getBatchHeader()->getPayoutBatchId();

Get Payout Batch Status

try { + $output = \PayPal\Api\Payout::get($payoutBatchId, $apiContext); +} catch (Exception $ex) { + ResultPrinter::printError("Get Payout Batch Status", "PayoutBatch", null, $payoutBatchId, $ex); + exit(1); +} + +ResultPrinter::printResult("Get Payout Batch Status", "PayoutBatch", $output->getBatchHeader()->getPayoutBatchId(), null, $output); + +return $output;
\ No newline at end of file diff --git a/sample/doc/payouts/GetPayoutItemStatus.html b/sample/doc/payouts/GetPayoutItemStatus.html new file mode 100644 index 0000000..3ae0f0a --- /dev/null +++ b/sample/doc/payouts/GetPayoutItemStatus.html @@ -0,0 +1,16 @@ +payouts/GetPayoutItemStatus
payouts/GetPayoutItemStatus.php
<?php

Get Payout Item Status Sample

+

Use this call to get data about a payout item, including the status, without retrieving an entire batch. You can get the status of an individual payout item in a batch in order to review the current status of a previously-unclaimed, or pending, payout item. +https://developer.paypal.com/docs/api/#get-the-status-of-a-payout-item +API used: GET /v1/payments/payouts-item/

/** @var \PayPal\Api\PayoutBatch $payoutBatch */ +$payoutBatch = require 'GetPayoutBatchStatus.php';

Payout Item ID

+

You can replace this with your Payout Batch Id on already created Payout.

$payoutItem = $payoutBatch->getItems()[0]; +$payoutItemId = $payoutItem->getPayoutItemId();

Get Payout Item Status

try { + $output = \PayPal\Api\PayoutItem::get($payoutItemId, $apiContext); +} catch (Exception $ex) { + ResultPrinter::printError("Get Payout Item Status", "PayoutItem", null, $payoutItemId, $ex); + exit(1); +} + +ResultPrinter::printResult("Get Payout Item Status", "PayoutItem", $output->getPayoutItemId(), null, $output); + +return $output;
\ No newline at end of file diff --git a/sample/index.php b/sample/index.php index be1ecf3..bacf6ad 100644 --- a/sample/index.php +++ b/sample/index.php @@ -26,1109 +26,1165 @@ if (PHP_SAPI == 'cli') { } } ?> --> - - - - - - - - - + + + + + + + + + - PayPal REST API Samples + PayPal REST API Samples - - - - - - + body { + /* Margin bottom by footer height */ + margin-bottom: 60px; + } - - -
-
-
-
- -
-
-

REST API Samples

+ .footer { + position: absolute; + bottom: 0; + width: 100%; + min-height: 60px; + background: -webkit-linear-gradient(-9deg, #428bca 70%, white 25%); + } -

These examples are created to experiment with the PayPal-PHP-SDK capabilities. Each examples - are - designed to demonstrate the default use-cases in each segment. - Many examples should be executable, and should allow you to experience the default behavior - of our - sdk, to expedite your integration experience.

+ .footer-links, .footer-links li { + display: inline-block; + font-size: 110%; + padding-left: 0px; + padding-right: 0px; + } - + .fixed { + position: fixed; + } + + .nav a { + font-weight: bold; + } + + + + + + + + +
+
+
+
+ +
+
+

REST API Samples

+ +

These examples are created to experiment with the PayPal-PHP-SDK capabilities. Each examples + are + designed to demonstrate the default use-cases in each segment. + Many examples should be executable, and should allow you to experience the default behavior + of our + sdk, to expedite your integration experience.

+ +
-
+
+
-
- -
-
-
-

Payments

-
- - +
+ +
+
+

Payouts

+
+ + +
+ +
+ + + +
+ +
+
+

Sale

+
+ + +
+ +
+ + + +
+ +
+
+

Vault

+
+ + +
+ +
+ + + +
+ +
+ + + +
+ +
+
+

Invoice

+
+ + +
+ +
+ + +
- - - - - - +
+
+ +
+
+ +
+
+ + + + + + + + + diff --git a/sample/invoice/images/sample.png b/sample/invoice/images/sample.png index 2192f3e..4d0799e 100644 Binary files a/sample/invoice/images/sample.png and b/sample/invoice/images/sample.png differ diff --git a/sample/payouts/CreateBatchPayout.php b/sample/payouts/CreateBatchPayout.php new file mode 100644 index 0000000..7e77800 --- /dev/null +++ b/sample/payouts/CreateBatchPayout.php @@ -0,0 +1,124 @@ +setSenderBatchId(uniqid()) + ->setEmailSubject("You have a payment"); + +// #### Sender Item +// Please note that if you are using single payout with sync mode, you can only pass one Item in the request +$senderItem1 = new \PayPal\Api\PayoutItem(); +$senderItem1->setRecipientType('Email') + ->setNote('Thanks you.') + ->setReceiver('shirt-supplier-one@gmail.com') + ->setSenderItemId("item_1" . uniqid()) + ->setAmount(new \PayPal\Api\Currency('{ + "value":"0.99", + "currency":"USD" + }')); + +// #### Sender Item 2 +// There are many different ways of assigning values in PayPal SDK. Here is another way where you could directly inject json string. +$senderItem2 = new \PayPal\Api\PayoutItem( + '{ + "recipient_type": "EMAIL", + "amount": { + "value": 0.90, + "currency": "USD" + }, + "receiver": "shirt-supplier-two@mail.com", + "note": "Thank you.", + "sender_item_id": "item_2" + }' +); + +// #### Sender Item 3 +// One more way of assigning values in constructor when creating instance of PayPalModel object. Injecting array. +$senderItem3 = new \PayPal\Api\PayoutItem( + array( + "recipient_type" => "EMAIL", + "receiver" => "shirt-supplier-three@mail.com", + "note" => "Thank you.", + "sender_item_id" => uniqid(), + "amount" => array( + "value" => "0.90", + "currency" => "USD" + ) + + ) +); + +$payouts->setSenderBatchHeader($senderBatchHeader) + ->addItem($senderItem1)->addItem($senderItem2)->addItem($senderItem3); + + +// For Sample Purposes Only. +$request = clone $payouts; + +// ### Create Payout +try { + $output = $payouts->create(null, $apiContext); +} catch (Exception $ex) { + ResultPrinter::printError("Created Batch Payout", "Payout", null, $request, $ex); + exit(1); +} + +ResultPrinter::printResult("Created Batch Payout", "Payout", $output->getBatchHeader()->getPayoutBatchId(), $request, $output); + +return $output; diff --git a/sample/payouts/CreateSinglePayout.php b/sample/payouts/CreateSinglePayout.php new file mode 100644 index 0000000..b00f626 --- /dev/null +++ b/sample/payouts/CreateSinglePayout.php @@ -0,0 +1,73 @@ +setSenderBatchId(uniqid()) + ->setEmailSubject("You have a Payout!"); + +// #### Sender Item +// Please note that if you are using single payout with sync mode, you can only pass one Item in the request +$senderItem = new \PayPal\Api\PayoutItem(); +$senderItem->setRecipientType('Email') + ->setNote('Thanks for your patronage!') + ->setReceiver('shirt-supplier-one@gmail.com') + ->setSenderItemId("2014031400023") + ->setAmount(new \PayPal\Api\Currency('{ + "value":"1.0", + "currency":"USD" + }')); + +$payouts->setSenderBatchHeader($senderBatchHeader) + ->addItem($senderItem); + + +// For Sample Purposes Only. +$request = clone $payouts; + +// ### Create Payout +try { + $output = $payouts->createSynchronous($apiContext); +} catch (Exception $ex) { + ResultPrinter::printError("Created Single Synchronous Payout", "Payout", null, $request, $ex); + exit(1); +} + +ResultPrinter::printResult("Created Single Synchronous Payout", "Payout", $output->getBatchHeader()->getPayoutBatchId(), $request, $output); + +return $output; diff --git a/sample/payouts/GetPayoutBatchStatus.php b/sample/payouts/GetPayoutBatchStatus.php new file mode 100644 index 0000000..3044890 --- /dev/null +++ b/sample/payouts/GetPayoutBatchStatus.php @@ -0,0 +1,25 @@ + + +/** @var \PayPal\Api\PayoutBatch $payoutBatch */ +$payoutBatch = require 'CreateBatchPayout.php'; +// ## Payout Batch ID +// You can replace this with your Payout Batch Id on already created Payout. +$payoutBatchId = $payoutBatch->getBatchHeader()->getPayoutBatchId(); + +// ### Get Payout Batch Status +try { + $output = \PayPal\Api\Payout::get($payoutBatchId, $apiContext); +} catch (Exception $ex) { + ResultPrinter::printError("Get Payout Batch Status", "PayoutBatch", null, $payoutBatchId, $ex); + exit(1); +} + +ResultPrinter::printResult("Get Payout Batch Status", "PayoutBatch", $output->getBatchHeader()->getPayoutBatchId(), null, $output); + +return $output; diff --git a/sample/payouts/GetPayoutItemStatus.php b/sample/payouts/GetPayoutItemStatus.php new file mode 100644 index 0000000..bdd3414 --- /dev/null +++ b/sample/payouts/GetPayoutItemStatus.php @@ -0,0 +1,26 @@ + + +/** @var \PayPal\Api\PayoutBatch $payoutBatch */ +$payoutBatch = require 'GetPayoutBatchStatus.php'; +// ## Payout Item ID +// You can replace this with your Payout Batch Id on already created Payout. +$payoutItem = $payoutBatch->getItems()[0]; +$payoutItemId = $payoutItem->getPayoutItemId(); + +// ### Get Payout Item Status +try { + $output = \PayPal\Api\PayoutItem::get($payoutItemId, $apiContext); +} catch (Exception $ex) { + ResultPrinter::printError("Get Payout Item Status", "PayoutItem", null, $payoutItemId, $ex); + exit(1); +} + +ResultPrinter::printResult("Get Payout Item Status", "PayoutItem", $output->getPayoutItemId(), null, $output); + +return $output; diff --git a/tests/PayPal/Test/Api/PayoutBatchHeaderTest.php b/tests/PayPal/Test/Api/PayoutBatchHeaderTest.php new file mode 100644 index 0000000..e9d2acf --- /dev/null +++ b/tests/PayPal/Test/Api/PayoutBatchHeaderTest.php @@ -0,0 +1,139 @@ +assertNotNull($obj); + $this->assertNotNull($obj->getPayoutBatchId()); + $this->assertNotNull($obj->getBatchStatus()); + $this->assertNotNull($obj->getTimeCreated()); + $this->assertNotNull($obj->getTimeCompleted()); + $this->assertNotNull($obj->getSenderBatchHeader()); + $this->assertNotNull($obj->getAmount()); + $this->assertNotNull($obj->getFees()); + $this->assertNotNull($obj->getErrors()); + $this->assertNotNull($obj->getLinks()); + $this->assertEquals(self::getJson(), $obj->toJson()); + return $obj; + } + + /** + * @depends testSerializationDeserialization + * @param PayoutBatchHeader $obj + */ + public function testGetters($obj) + { + $this->assertEquals($obj->getPayoutBatchId(), "TestSample"); + $this->assertEquals($obj->getBatchStatus(), "TestSample"); + $this->assertEquals($obj->getTimeCreated(), "TestSample"); + $this->assertEquals($obj->getTimeCompleted(), "TestSample"); + $this->assertEquals($obj->getSenderBatchHeader(), PayoutSenderBatchHeaderTest::getObject()); + $this->assertEquals($obj->getAmount(), CurrencyTest::getObject()); + $this->assertEquals($obj->getFees(), CurrencyTest::getObject()); + $this->assertEquals($obj->getErrors(), ErrorTest::getObject()); + $this->assertEquals($obj->getLinks(), LinksTest::getObject()); + } + + /** + * @depends testSerializationDeserialization + * @param PayoutBatchHeader $obj + */ + public function testDeprecatedGetters($obj) + { + $this->assertEquals($obj->getPayout_batch_id(), "TestSample"); + $this->assertEquals($obj->getBatch_status(), "TestSample"); + $this->assertEquals($obj->getTime_created(), "TestSample"); + $this->assertEquals($obj->getTime_completed(), "TestSample"); + $this->assertEquals($obj->getSender_batch_header(), PayoutSenderBatchHeaderTest::getObject()); + } + + /** + * @depends testSerializationDeserialization + * @param PayoutBatchHeader $obj + */ + public function testDeprecatedSetterNormalGetter($obj) + { + + // Check for Payout_batch_id + $obj->setPayoutBatchId(null); + $this->assertNull($obj->getPayout_batch_id()); + $this->assertNull($obj->getPayoutBatchId()); + $this->assertSame($obj->getPayoutBatchId(), $obj->getPayout_batch_id()); + $obj->setPayout_batch_id("TestSample"); + $this->assertEquals($obj->getPayout_batch_id(), "TestSample"); + + // Check for Batch_status + $obj->setBatchStatus(null); + $this->assertNull($obj->getBatch_status()); + $this->assertNull($obj->getBatchStatus()); + $this->assertSame($obj->getBatchStatus(), $obj->getBatch_status()); + $obj->setBatch_status("TestSample"); + $this->assertEquals($obj->getBatch_status(), "TestSample"); + + // Check for Time_created + $obj->setTimeCreated(null); + $this->assertNull($obj->getTime_created()); + $this->assertNull($obj->getTimeCreated()); + $this->assertSame($obj->getTimeCreated(), $obj->getTime_created()); + $obj->setTime_created("TestSample"); + $this->assertEquals($obj->getTime_created(), "TestSample"); + + // Check for Time_completed + $obj->setTimeCompleted(null); + $this->assertNull($obj->getTime_completed()); + $this->assertNull($obj->getTimeCompleted()); + $this->assertSame($obj->getTimeCompleted(), $obj->getTime_completed()); + $obj->setTime_completed("TestSample"); + $this->assertEquals($obj->getTime_completed(), "TestSample"); + + // Check for Sender_batch_header + $obj->setSenderBatchHeader(null); + $this->assertNull($obj->getSender_batch_header()); + $this->assertNull($obj->getSenderBatchHeader()); + $this->assertSame($obj->getSenderBatchHeader(), $obj->getSender_batch_header()); + $obj->setSender_batch_header(PayoutSenderBatchHeaderTest::getObject()); + $this->assertEquals($obj->getSender_batch_header(), PayoutSenderBatchHeaderTest::getObject()); + + //Test All Deprecated Getters and Normal Getters + $this->testDeprecatedGetters($obj); + $this->testGetters($obj); + } + + + +} diff --git a/tests/PayPal/Test/Api/PayoutBatchTest.php b/tests/PayPal/Test/Api/PayoutBatchTest.php new file mode 100644 index 0000000..34804d5 --- /dev/null +++ b/tests/PayPal/Test/Api/PayoutBatchTest.php @@ -0,0 +1,89 @@ +assertNotNull($obj); + $this->assertNotNull($obj->getBatchHeader()); + $this->assertNotNull($obj->getItems()); + $this->assertEquals(self::getJson(), $obj->toJson()); + return $obj; + } + + /** + * @depends testSerializationDeserialization + * @param PayoutBatch $obj + */ + public function testGetters($obj) + { + $this->assertEquals($obj->getBatchHeader(), PayoutBatchHeaderTest::getObject()); + $this->assertEquals($obj->getItems(), PayoutItemDetailsTest::getObject()); + } + + /** + * @depends testSerializationDeserialization + * @param PayoutBatch $obj + */ + public function testDeprecatedGetters($obj) + { + $this->assertEquals($obj->getBatch_header(), PayoutBatchHeaderTest::getObject()); + } + + /** + * @depends testSerializationDeserialization + * @param PayoutBatch $obj + */ + public function testDeprecatedSetterNormalGetter($obj) + { + + // Check for Batch_header + $obj->setBatchHeader(null); + $this->assertNull($obj->getBatch_header()); + $this->assertNull($obj->getBatchHeader()); + $this->assertSame($obj->getBatchHeader(), $obj->getBatch_header()); + $obj->setBatch_header(PayoutBatchHeaderTest::getObject()); + $this->assertEquals($obj->getBatch_header(), PayoutBatchHeaderTest::getObject()); + + //Test All Deprecated Getters and Normal Getters + $this->testDeprecatedGetters($obj); + $this->testGetters($obj); + } + + + +} diff --git a/tests/PayPal/Test/Api/PayoutItemDetailsTest.php b/tests/PayPal/Test/Api/PayoutItemDetailsTest.php new file mode 100644 index 0000000..391e84c --- /dev/null +++ b/tests/PayPal/Test/Api/PayoutItemDetailsTest.php @@ -0,0 +1,168 @@ +assertNotNull($obj); + $this->assertNotNull($obj->getPayoutItemId()); + $this->assertNotNull($obj->getTransactionId()); + $this->assertNotNull($obj->getTransactionStatus()); + $this->assertNotNull($obj->getPayoutItemFee()); + $this->assertNotNull($obj->getPayoutBatchId()); + $this->assertNotNull($obj->getSenderBatchId()); + $this->assertNotNull($obj->getPayoutItem()); + $this->assertNotNull($obj->getTimeProcessed()); + $this->assertNotNull($obj->getErrors()); + $this->assertNotNull($obj->getLinks()); + $this->assertEquals(self::getJson(), $obj->toJson()); + return $obj; + } + + /** + * @depends testSerializationDeserialization + * @param PayoutItemDetails $obj + */ + public function testGetters($obj) + { + $this->assertEquals($obj->getPayoutItemId(), "TestSample"); + $this->assertEquals($obj->getTransactionId(), "TestSample"); + $this->assertEquals($obj->getTransactionStatus(), "TestSample"); + $this->assertEquals($obj->getPayoutItemFee(), CurrencyTest::getObject()); + $this->assertEquals($obj->getPayoutBatchId(), "TestSample"); + $this->assertEquals($obj->getSenderBatchId(), "TestSample"); + $this->assertEquals($obj->getPayoutItem(), PayoutItemTest::getObject()); + $this->assertEquals($obj->getTimeProcessed(), "TestSample"); + $this->assertEquals($obj->getErrors(), ErrorTest::getObject()); + $this->assertEquals($obj->getLinks(), LinksTest::getObject()); + } + + /** + * @depends testSerializationDeserialization + * @param PayoutItemDetails $obj + */ + public function testDeprecatedGetters($obj) + { + $this->assertEquals($obj->getPayout_item_id(), "TestSample"); + $this->assertEquals($obj->getTransaction_id(), "TestSample"); + $this->assertEquals($obj->getTransaction_status(), "TestSample"); + $this->assertEquals($obj->getPayout_item_fee(), CurrencyTest::getObject()); + $this->assertEquals($obj->getPayout_batch_id(), "TestSample"); + $this->assertEquals($obj->getSender_batch_id(), "TestSample"); + $this->assertEquals($obj->getPayout_item(), PayoutItemTest::getObject()); + $this->assertEquals($obj->getTime_processed(), "TestSample"); + } + + /** + * @depends testSerializationDeserialization + * @param PayoutItemDetails $obj + */ + public function testDeprecatedSetterNormalGetter($obj) + { + + // Check for Payout_item_id + $obj->setPayoutItemId(null); + $this->assertNull($obj->getPayout_item_id()); + $this->assertNull($obj->getPayoutItemId()); + $this->assertSame($obj->getPayoutItemId(), $obj->getPayout_item_id()); + $obj->setPayout_item_id("TestSample"); + $this->assertEquals($obj->getPayout_item_id(), "TestSample"); + + // Check for Transaction_id + $obj->setTransactionId(null); + $this->assertNull($obj->getTransaction_id()); + $this->assertNull($obj->getTransactionId()); + $this->assertSame($obj->getTransactionId(), $obj->getTransaction_id()); + $obj->setTransaction_id("TestSample"); + $this->assertEquals($obj->getTransaction_id(), "TestSample"); + + // Check for Transaction_status + $obj->setTransactionStatus(null); + $this->assertNull($obj->getTransaction_status()); + $this->assertNull($obj->getTransactionStatus()); + $this->assertSame($obj->getTransactionStatus(), $obj->getTransaction_status()); + $obj->setTransaction_status( "TestSample"); + $this->assertEquals($obj->getTransaction_status(), "TestSample"); + + // Check for Payout_item_fee + $obj->setPayoutItemFee(null); + $this->assertNull($obj->getPayout_item_fee()); + $this->assertNull($obj->getPayoutItemFee()); + $this->assertSame($obj->getPayoutItemFee(), $obj->getPayout_item_fee()); + $obj->setPayout_item_fee(CurrencyTest::getObject()); + $this->assertEquals($obj->getPayout_item_fee(), CurrencyTest::getObject()); + + // Check for Payout_batch_id + $obj->setPayoutBatchId(null); + $this->assertNull($obj->getPayout_batch_id()); + $this->assertNull($obj->getPayoutBatchId()); + $this->assertSame($obj->getPayoutBatchId(), $obj->getPayout_batch_id()); + $obj->setPayout_batch_id("TestSample"); + $this->assertEquals($obj->getPayout_batch_id(), "TestSample"); + + // Check for Sender_batch_id + $obj->setSenderBatchId(null); + $this->assertNull($obj->getSender_batch_id()); + $this->assertNull($obj->getSenderBatchId()); + $this->assertSame($obj->getSenderBatchId(), $obj->getSender_batch_id()); + $obj->setSender_batch_id("TestSample"); + $this->assertEquals($obj->getSender_batch_id(), "TestSample"); + + // Check for Payout_item + $obj->setPayoutItem(null); + $this->assertNull($obj->getPayout_item()); + $this->assertNull($obj->getPayoutItem()); + $this->assertSame($obj->getPayoutItem(), $obj->getPayout_item()); + $obj->setPayout_item(PayoutItemTest::getObject()); + $this->assertEquals($obj->getPayout_item(), PayoutItemTest::getObject()); + + // Check for Time_processed + $obj->setTimeProcessed(null); + $this->assertNull($obj->getTime_processed()); + $this->assertNull($obj->getTimeProcessed()); + $this->assertSame($obj->getTimeProcessed(), $obj->getTime_processed()); + $obj->setTime_processed("TestSample"); + $this->assertEquals($obj->getTime_processed(), "TestSample"); + + //Test All Deprecated Getters and Normal Getters + $this->testDeprecatedGetters($obj); + $this->testGetters($obj); + } + + + +} diff --git a/tests/PayPal/Test/Api/PayoutItemTest.php b/tests/PayPal/Test/Api/PayoutItemTest.php new file mode 100644 index 0000000..6496a31 --- /dev/null +++ b/tests/PayPal/Test/Api/PayoutItemTest.php @@ -0,0 +1,138 @@ +assertNotNull($obj); + $this->assertNotNull($obj->getRecipientType()); + $this->assertNotNull($obj->getAmount()); + $this->assertNotNull($obj->getNote()); + $this->assertNotNull($obj->getReceiver()); + $this->assertNotNull($obj->getSenderItemId()); + $this->assertEquals(self::getJson(), $obj->toJson()); + return $obj; + } + + /** + * @depends testSerializationDeserialization + * @param PayoutItem $obj + */ + public function testGetters($obj) + { + $this->assertEquals($obj->getRecipientType(), "TestSample"); + $this->assertEquals($obj->getAmount(), CurrencyTest::getObject()); + $this->assertEquals($obj->getNote(), "TestSample"); + $this->assertEquals($obj->getReceiver(), "TestSample"); + $this->assertEquals($obj->getSenderItemId(), "TestSample"); + } + + /** + * @depends testSerializationDeserialization + * @param PayoutItem $obj + */ + public function testDeprecatedGetters($obj) + { + $this->assertEquals($obj->getRecipient_type(), "TestSample"); + $this->assertEquals($obj->getSender_item_id(), "TestSample"); + } + + /** + * @depends testSerializationDeserialization + * @param PayoutItem $obj + */ + public function testDeprecatedSetterNormalGetter($obj) + { + + // Check for Recipient_type + $obj->setRecipientType(null); + $this->assertNull($obj->getRecipient_type()); + $this->assertNull($obj->getRecipientType()); + $this->assertSame($obj->getRecipientType(), $obj->getRecipient_type()); + $obj->setRecipient_type("TestSample"); + $this->assertEquals($obj->getRecipient_type(), "TestSample"); + + // Check for Sender_item_id + $obj->setSenderItemId(null); + $this->assertNull($obj->getSender_item_id()); + $this->assertNull($obj->getSenderItemId()); + $this->assertSame($obj->getSenderItemId(), $obj->getSender_item_id()); + $obj->setSender_item_id("TestSample"); + $this->assertEquals($obj->getSender_item_id(), "TestSample"); + + //Test All Deprecated Getters and Normal Getters + $this->testDeprecatedGetters($obj); + $this->testGetters($obj); + } + + + /** + * @dataProvider mockProvider + * @param PayoutItem $obj + */ + public function testGet($obj, $mockApiContext) + { + $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') + ->disableOriginalConstructor() + ->getMock(); + + $mockPPRestCall->expects($this->any()) + ->method('execute') + ->will($this->returnValue( + PayoutItemDetailsTest::getJson() + )); + + $result = $obj->get("payoutItemId", $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) + ); + } +} diff --git a/tests/PayPal/Test/Api/PayoutSenderBatchHeaderTest.php b/tests/PayPal/Test/Api/PayoutSenderBatchHeaderTest.php new file mode 100644 index 0000000..0d1d78e --- /dev/null +++ b/tests/PayPal/Test/Api/PayoutSenderBatchHeaderTest.php @@ -0,0 +1,109 @@ +assertNotNull($obj); + $this->assertNotNull($obj->getSenderBatchId()); + $this->assertNotNull($obj->getEmailSubject()); + $this->assertNotNull($obj->getRecipientType()); + $this->assertEquals(self::getJson(), $obj->toJson()); + return $obj; + } + + /** + * @depends testSerializationDeserialization + * @param PayoutSenderBatchHeader $obj + */ + public function testGetters($obj) + { + $this->assertEquals($obj->getSenderBatchId(), "TestSample"); + $this->assertEquals($obj->getEmailSubject(), "TestSample"); + $this->assertEquals($obj->getRecipientType(), "TestSample"); + } + + /** + * @depends testSerializationDeserialization + * @param PayoutSenderBatchHeader $obj + */ + public function testDeprecatedGetters($obj) + { + $this->assertEquals($obj->getSender_batch_id(), "TestSample"); + $this->assertEquals($obj->getEmail_subject(), "TestSample"); + $this->assertEquals($obj->getRecipient_type(), "TestSample"); + } + + /** + * @depends testSerializationDeserialization + * @param PayoutSenderBatchHeader $obj + */ + public function testDeprecatedSetterNormalGetter($obj) + { + + // Check for Sender_batch_id + $obj->setSenderBatchId(null); + $this->assertNull($obj->getSender_batch_id()); + $this->assertNull($obj->getSenderBatchId()); + $this->assertSame($obj->getSenderBatchId(), $obj->getSender_batch_id()); + $obj->setSender_batch_id("TestSample"); + $this->assertEquals($obj->getSender_batch_id(), "TestSample"); + + // Check for Email_subject + $obj->setEmailSubject(null); + $this->assertNull($obj->getEmail_subject()); + $this->assertNull($obj->getEmailSubject()); + $this->assertSame($obj->getEmailSubject(), $obj->getEmail_subject()); + $obj->setEmail_subject("TestSample"); + $this->assertEquals($obj->getEmail_subject(), "TestSample"); + + // Check for Recipient_type + $obj->setRecipientType(null); + $this->assertNull($obj->getRecipient_type()); + $this->assertNull($obj->getRecipientType()); + $this->assertSame($obj->getRecipientType(), $obj->getRecipient_type()); + $obj->setRecipient_type("TestSample"); + $this->assertEquals($obj->getRecipient_type(), "TestSample"); + + //Test All Deprecated Getters and Normal Getters + $this->testDeprecatedGetters($obj); + $this->testGetters($obj); + } + + + +} diff --git a/tests/PayPal/Test/Api/PayoutTest.php b/tests/PayPal/Test/Api/PayoutTest.php new file mode 100644 index 0000000..2d52f7e --- /dev/null +++ b/tests/PayPal/Test/Api/PayoutTest.php @@ -0,0 +1,140 @@ +assertNotNull($obj); + $this->assertNotNull($obj->getSenderBatchHeader()); + $this->assertNotNull($obj->getItems()); + $this->assertNotNull($obj->getLinks()); + $this->assertEquals(self::getJson(), $obj->toJson()); + return $obj; + } + + /** + * @depends testSerializationDeserialization + * @param Payout $obj + */ + public function testGetters($obj) + { + $this->assertEquals($obj->getSenderBatchHeader(), PayoutSenderBatchHeaderTest::getObject()); + $this->assertEquals($obj->getItems(), PayoutItemTest::getObject()); + $this->assertEquals($obj->getLinks(), LinksTest::getObject()); + } + + /** + * @depends testSerializationDeserialization + * @param Payout $obj + */ + public function testDeprecatedGetters($obj) + { + $this->assertEquals($obj->getSender_batch_header(), PayoutSenderBatchHeaderTest::getObject()); + } + + /** + * @depends testSerializationDeserialization + * @param Payout $obj + */ + public function testDeprecatedSetterNormalGetter($obj) + { + + // Check for Sender_batch_header + $obj->setSenderBatchHeader(null); + $this->assertNull($obj->getSender_batch_header()); + $this->assertNull($obj->getSenderBatchHeader()); + $this->assertSame($obj->getSenderBatchHeader(), $obj->getSender_batch_header()); + $obj->setSender_batch_header(PayoutSenderBatchHeaderTest::getObject()); + $this->assertEquals($obj->getSender_batch_header(), PayoutSenderBatchHeaderTest::getObject()); + + //Test All Deprecated Getters and Normal Getters + $this->testDeprecatedGetters($obj); + $this->testGetters($obj); + } + + + /** + * @dataProvider mockProvider + * @param Payout $obj + */ + public function testCreate($obj, $mockApiContext) + { + $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') + ->disableOriginalConstructor() + ->getMock(); + + $mockPPRestCall->expects($this->any()) + ->method('execute') + ->will($this->returnValue( + PayoutBatchTest::getJson() + )); + $params = array(); + + $result = $obj->create($params, $mockApiContext, $mockPPRestCall); + $this->assertNotNull($result); + } + /** + * @dataProvider mockProvider + * @param Payout $obj + */ + public function testGet($obj, $mockApiContext) + { + $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') + ->disableOriginalConstructor() + ->getMock(); + + $mockPPRestCall->expects($this->any()) + ->method('execute') + ->will($this->returnValue( + PayoutBatchTest::getJson() + )); + + $result = $obj->get("payoutBatchId", $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) + ); + } +} diff --git a/tests/PayPal/Test/Functional/Api/PayoutsFunctionalTest.php b/tests/PayPal/Test/Functional/Api/PayoutsFunctionalTest.php new file mode 100644 index 0000000..f4ed062 --- /dev/null +++ b/tests/PayPal/Test/Functional/Api/PayoutsFunctionalTest.php @@ -0,0 +1,102 @@ +getClassName(); + $testName = $this->getName(); + $operationString = file_get_contents(__DIR__ . "/../resources/$className/$testName.json"); + $this->operation = json_decode($operationString, true); + $this->response = true; + if (array_key_exists('body', $this->operation['response'])) { + $this->response = json_encode($this->operation['response']['body']); + } + + Setup::SetUpForFunctionalTests($this); + } + + /** + * Returns just the classname of the test you are executing. It removes the namespaces. + * @return string + */ + public function getClassName() + { + return join('', array_slice(explode('\\', get_class($this)), -1)); + } + + public function testCreate() + { + $request = $this->operation['request']['body']; + $obj = new Payout($request); + if (Setup::$mode != 'mock') { + $obj->getSenderBatchHeader()->setSenderBatchId(uniqid()); + } + PayoutsFunctionalTest::$batchId = $obj->getSenderBatchHeader()->getSenderBatchId(); + $params = array('sync_mode' => 'true'); + $result = $obj->create($params, null, $this->mockPayPalRestCall); + $this->assertNotNull($result); + $this->assertEquals(PayoutsFunctionalTest::$batchId, $result->getBatchHeader()->getSenderBatchHeader()->getSenderBatchId()); + return $result; + } + + /** + * @depends testCreate + * @param $payoutBatch PayoutBatch + * @return PayoutBatch + */ + public function testGet($payoutBatch) + { + $result = Payout::get($payoutBatch->getBatchHeader()->getPayoutBatchId(), null, $this->mockPayPalRestCall); + $this->assertNotNull($result); + $this->assertNotNull($result->getBatchHeader()->getBatchStatus()); + $this->assertEquals(PayoutsFunctionalTest::$batchId, $result->getBatchHeader()->getSenderBatchHeader()->getSenderBatchId()); + return $result; + } + + /** + * @depends testCreate + * @param $payoutBatch PayoutBatch + * @return PayoutBatch + */ + public function testGetItem($payoutBatch) + { + $items = $payoutBatch->getItems(); + $item = $items[0]; + $result = PayoutItem::get($item->getPayoutItemId(), null, $this->mockPayPalRestCall); + $this->assertNotNull($result); + $this->assertEquals($item->getPayoutItemId(), $result->getPayoutItemId()); + $this->assertEquals($item->getPayoutBatchId(), $result->getPayoutBatchId()); + $this->assertEquals($item->getTransactionId(), $result->getTransactionId()); + $this->assertEquals($item->getPayoutItemFee(), $result->getPayoutItemFee()); + } + +} diff --git a/tests/PayPal/Test/Functional/Setup.php b/tests/PayPal/Test/Functional/Setup.php index 5743b18..ab39a89 100644 --- a/tests/PayPal/Test/Functional/Setup.php +++ b/tests/PayPal/Test/Functional/Setup.php @@ -3,6 +3,7 @@ namespace PayPal\Test\Functional; use PayPal\Auth\OAuthTokenCredential; +use PayPal\Core\PayPalConfigManager; use PayPal\Core\PayPalCredentialManager; use PayPal\Rest\ApiContext; @@ -16,20 +17,14 @@ class Setup $context = new ApiContext(); $context->setConfig(array( 'mode' => 'sandbox', - 'acct1.ClientId' => 'AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS', - 'acct1.ClientSecret' => 'EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL', 'http.ConnectionTimeOut' => 30, 'log.LogEnabled' => true, 'log.FileName' => '../PayPal.log', 'log.LogLevel' => 'FINE', 'validation.level' => 'warning' )); - PayPalCredentialManager::getInstance()->setCredentialObject( - new OAuthTokenCredential( - "AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS", - "EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL" - ) - ); + + PayPalCredentialManager::getInstance()->setCredentialObject(PayPalCredentialManager::getInstance()->getCredentialObject('acct1')); self::$mode = getenv('REST_MODE') ? getenv('REST_MODE') : 'mock'; if (self::$mode != 'sandbox') { diff --git a/tests/PayPal/Test/Functional/resources/PayoutsFunctionalTest/testCreate.json b/tests/PayPal/Test/Functional/resources/PayoutsFunctionalTest/testCreate.json new file mode 100755 index 0000000..0640d3f --- /dev/null +++ b/tests/PayPal/Test/Functional/resources/PayoutsFunctionalTest/testCreate.json @@ -0,0 +1,106 @@ +{ + "description" : "Sender POSTs a batch with 1 payout request. This example is for sync_mode=true. This means an immediate response. For sync_mode=false, the output will be run in back ground and the repsonse will be different.", + "title" : "POST batch sample", + "runnable" : true, + "operationId" : "payouts", + "user" : { + "scopes" : [ ] + }, + "credentials" : { + "oauth": { + "path" : "/v1/oauth/token", + "clientId":"", + "clientSecret":"" + } + }, + "request":{ + "path":"v1/payments/payouts?sync_mode=true", + "method":"POST", + "headers": { + "Content-Type": "application/json", + "Content-Encoding": "gzip" + }, + "body":{ + "sender_batch_header":{ + "sender_batch_id":"2014021801", + "email_subject":"You have a Payout!" + }, + "items":[ + { + "recipient_type":"EMAIL", + "amount":{ + "value":"1.0", + "currency":"USD" + }, + "note":"Thanks for your patronage!", + "sender_item_id":"2014031400023", + "receiver":"shirt-supplier-one@mail.com" + } + ] + } + }, + "response" : { + "status" : "201 OK", + "headers" : { + "Content-Type": "application/json", + "Content-Encoding": "gzip" + }, + "body" : { + "batch_header": { + "payout_batch_id": "CDZEC5MJ8R5HY", + "batch_status": "SUCCESS", + "time_created": "2014-46-14T06:46:22Z", + "time_completed": "2014-46-14T06:46:23Z", + "sender_batch_header": { + "sender_batch_id":"2014021801", + "email_subject": "You have a Payout!" + }, + "amount": { + "currency": "USD", + "value": "1.0" + }, + "fees": { + "currency": "USD", + "value": "0.02" + } + }, + "items": [ + { + "payout_item_id": "VHBFGN95AWV82", + "transaction_id": "0728664497487461D", + "transaction_status": "SUCCESS", + "payout_item_fee": { + "currency": "USD", + "value": "0.02" + }, + "payout_batch_id": "CDZEC5MJ8R5HY", + "payout_item": { + "amount": { + "currency": "USD", + "value": "1.0" + }, + "note": "Thanks for your patronage!", + "receiver": "anybody01@gmail.com", + "recipient_type": "EMAIL", + "sender_item_id": "201403140001" + }, + "time_processed": "2014-46-14T06:46:23Z", + "links": [ + { + "href": "https://api.sandbox.paypal.com/v1/payments/payouts-item/VHBFGN95AWV82", + "rel": "item", + "method": "GET" + } + ] + } + ], + "links": [ + { + "href": "https://api.sandbox.paypal.com/v1/payments/payouts/CDZEC5MJ8R5HY", + "rel": "self", + "method": "GET" + } + ] + } + } +} diff --git a/tests/PayPal/Test/Functional/resources/PayoutsFunctionalTest/testGet.json b/tests/PayPal/Test/Functional/resources/PayoutsFunctionalTest/testGet.json new file mode 100755 index 0000000..47101b4 --- /dev/null +++ b/tests/PayPal/Test/Functional/resources/PayoutsFunctionalTest/testGet.json @@ -0,0 +1,223 @@ +{ + "description" : "GET of a batch with multiple items.", + "title" : "GET batch with multiple items", + "runnable" : true, + "operationId" : "payouts.get", + "user" : { + "scopes" : [ ] + }, + "credentials" : { + "oauth": { + "path" : "/v1/oauth/token", + "clientId":"", + "clientSecret":"" + }, + "login" : { }, + "openIdConnect" : { } + }, + "request" : { + "path" : "v1/payments/payouts/12345678", + "method" : "GET", + "headers" : { + "Content-Type": "application/json", + "Content-Encoding": "gzip" + }, + "body":{ + } + }, + "response" : { + "status" : "200 OK", + "headers" : { + "Content-Type": "application/json", + "Content-Encoding": "gzip" + }, + "body":{ + "batch_header":{ + "payout_batch_id":"12345678", + "batch_status":"PROCESSING", + "sender_batch_id":"2014021801123", + "time_created":"2014-01-27T10:17:00Z", + "time_completed":"2014-01-27T11:17:39.00Z", + "sender_batch_header":{ + "sender_batch_id":"2014021801", + "email_subject":"You have a Payout!" + }, + "amount":{ + "value":"435.85", + "currency":"USD" + }, + "fees":{ + "value":"5.84", + "currency":"USD" + } + }, + "items":[ + { + "payout_item_id":"452176", + "transaction_id":"434176", + "transaction_status":"SUCCESS", + "payout_batch_id":"12345678", + "sender_batch_id":"2014021887", + "payout_item_fee":{ + "currency":"USD", + "value":"1.00" + }, + "payout_item":{ + "recipient_type":"EMAIL", + "amount":{ + "value":"65.24", + "currency":"EUR" + }, + "note":"Thanks for your patronage!", + "receiver":"anybody77@gmail.com", + "payouts_item_id":"1421388", + "sender_item_id":"14Feb_978" + }, + "time_created":"2014-01-27T10:17:00:00Z", + "time_processed":"2014-01-27T10:18:32Z" + }, + { + "payout_item_id":"452123", + "transaction_id":"434123", + "transaction_status":"SUCCESS", + "payout_batch_id":"12345678", + "sender_batch_id":"2014021802", + "payout_item_fee":{ + "currency":"USD", + "value":"1.00" + }, + "payout_item":{ + "recipient_type":"EMAIL", + "amount":{ + "value":"59.87", + "currency":"EUR" + }, + "note":"Thanks for your patronage!", + "receiver":"anybody34@gmail.com", + "payouts_item_id":"1421345", + "sender_item_id":"14Feb_321" + }, + "time_created":"2014-01-27T10:17:00Z", + "time_processed":"2014-01-27T10:18:15Z" + }, + { + "payout_item_id":"452323", + "transaction_id":"434543", + "transaction_status":"SUCCESS", + "payout_batch_id":"12345678", + "sender_batch_id":"2014021802", + "payout_item_fee":{ + "currency":"USD", + "value":"1.00" + }, + "payout_item":{ + "recipient_type":"EMAIL", + "amount":{ + "value":"59.87", + "currency":"EUR" + }, + "note":"Thanks for your patronage!", + "receiver":"anybody03@gmail.com", + "payouts_item_id":"1421355", + "sender_item_id":"14Feb_239" + }, + "time_created":"2014-01-27T10:17:00Z", + "time_processed":"2014-01-27T10:17:15Z" + }, + { + "payout_item_id":"452350", + "transaction_id":"434543", + "transaction_status":"SUCCESS", + "payout_batch_id":"12345678", + "sender_batch_id":"2014021801", + "payout_item_fee":{ + "currency":"USD", + "value":"0.75" + }, + "payout_item":{ + "recipient_type":"EMAIL", + "amount":{ + "value":"19.87", + "currency":"USD" + }, + "note":"Thanks for your patronage!", + "receiver":"anybody02@gmail.com", + "payouts_item_id":"1421332", + "sender_item_id":"14Feb_235" + }, + "time_created":"2014-01-27T10:17:00Z", + "time_processed":"2014-01-27T10:17:25Z" + }, + { + "payout_item_id":"452345", + "transaction_id":"4345", + "transaction_status":"SUCCESS", + "payout_batch_id":"12345678", + "sender_batch_id":"2014021801", + "payout_item_fee":{ + "currency":"USD", + "value":"0.75" + }, + "payout_item":{ + "recipient_type":"EMAIL", + "amount":{ + "value":"9.87", + "currency":"USD" + }, + "note":"Thanks for your patronage!", + "receiver":"anybody01@gmail.com", + "payouts_item_id":"1421342", + "sender_item_id":"14Feb_234" + }, + "time_created":"2014-01-27T10:17:00Z", + "time_processed":"2014-01-27T10:17:37Z" + }, + { + "payout_item_id":"4782902", + "transaction_id":"6456456", + "transaction_status":"SUCCESS", + "payout_item_fee":{ + "currency":"USD", + "value":"2.35" + }, + "payout_batch_id":"12345678", + "sender_batch_id":"2014021801", + "payout_item":{ + "recipient_type":"PHONE", + "amount":{ + "value":"112.34", + "currency":"EUR" + }, + "note":"Thanks for your support!", + "receiver":"91-734-234-1234", + "payouts_item_id":"1421343", + "sender_item_id":"14Feb_235" + }, + "time_created":"2014-01-27T10:17:00Z", + "time_processed":"2014-01-27T10:17:52Z" + }, + { + "payout_item_id":"4782902", + "transaction_id":"", + "transaction_status":"PROCESSING", + "payout_batch_id":"12345678", + "sender_batch_id":"2014021801", + "payout_item":{ + "recipient_type":"PHONE", + "amount":{ + "value":"5.32", + "currency":"USD" + }, + "note":"Thanks for your patronage!", + "receiver":"408X234-1234", + "payouts_item_id":"1421344", + "sender_item_id":"14Feb_235" + }, + "time_created":"2014-01-27T10:17:00Z", + "time_processed":"2014-01-27T10:17:41Z" + } + ] + } + } +} + diff --git a/tests/PayPal/Test/Functional/resources/PayoutsFunctionalTest/testGetItem.json b/tests/PayPal/Test/Functional/resources/PayoutsFunctionalTest/testGetItem.json new file mode 100755 index 0000000..19adc71 --- /dev/null +++ b/tests/PayPal/Test/Functional/resources/PayoutsFunctionalTest/testGetItem.json @@ -0,0 +1,65 @@ +{ + "description": "Sender needs status of one item.", + "title": "GET item sample", + "runnable": true, + "operationId": "payouts.item", + "user": { + "scopes": [] + }, + "credentials": { + "oauth": { + "path": "/v1/oauth/token", + "clientId": "", + "clientSecret": "" + } + }, + "request": { + "path": "v1/payments/payouts-item/452345", + "method": "GET", + "headers": { + "Content-Type": "application/json", + "Content-Encoding": "gzip" + }, + "body": {} + }, + "response": { + "status": "200 OK", + "headers": { + "Content-Type": "application/json", + "Content-Encoding": "gzip" + }, + "body": { + "payout_item_id": "VHBFGN95AWV82", + "transaction_status": "PENDING", + "payout_item_fee": { + "currency": "USD", + "value": "0.02" + }, + "payout_batch_id": "CDZEC5MJ8R5HY", + "transaction_id": "0728664497487461D", + "sender_batch_id": "2014021887", + "payout_item": { + "amount": { + "currency": "USD", + "value": "0.99" + }, + "note": "Thanks you.", + "receiver": "shirt-supplier-one@gmail.com", + "recipient_type": "EMAIL", + "sender_item_id": "item_154a716f035001" + }, + "links": [ + { + "href": "https://api.sandbox.paypal.com/v1/payments/payouts-item/HUUQ5YASYLQFN", + "rel": "self", + "method": "GET" + }, + { + "href": "https://api.sandbox.paypal.com/v1/payments/payouts/LNLSEVGU4P85S", + "rel": "batch", + "method": "GET" + } + ] + } + } +}