forked from LiveCarta/PayPal-PHP-SDK
Enabled Payout API Support
- Includes Unit and Functional Tests - Includes Samples
This commit is contained in:
191
lib/PayPal/Api/Payout.php
Normal file
191
lib/PayPal/Api/Payout.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Api;
|
||||
|
||||
use PayPal\Common\PayPalResourceModel;
|
||||
use PayPal\Transport\PayPalRestCall;
|
||||
use PayPal\Validation\ArgumentValidator;
|
||||
use PayPal\Rest\ApiContext;
|
||||
|
||||
/**
|
||||
* Class Payout
|
||||
*
|
||||
* This object represents a set of payouts that includes status data for the payouts. This object enables you to create a payout using a POST request.
|
||||
*
|
||||
* @package PayPal\Api
|
||||
*
|
||||
* @property \PayPal\Api\PayoutSenderBatchHeader sender_batch_header
|
||||
* @property \PayPal\Api\PayoutItem[] items
|
||||
* @property \PayPal\Api\Links[] links
|
||||
*/
|
||||
class Payout extends PayPalResourceModel
|
||||
{
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
||||
145
lib/PayPal/Api/PayoutBatch.php
Normal file
145
lib/PayPal/Api/PayoutBatch.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Api;
|
||||
|
||||
use PayPal\Common\PayPalModel;
|
||||
|
||||
/**
|
||||
* Class PayoutBatch
|
||||
*
|
||||
* The batch status as generated by PayPal.
|
||||
*
|
||||
* @package PayPal\Api
|
||||
*
|
||||
* @property \PayPal\Api\PayoutBatchHeader batch_header
|
||||
* @property \PayPal\Api\PayoutItemDetails[] items
|
||||
* @property \PayPal\Api\Links[] links
|
||||
*/
|
||||
class PayoutBatch extends PayPalModel
|
||||
{
|
||||
/**
|
||||
* A batch header that includes the generated batch status.
|
||||
*
|
||||
* @param \PayPal\Api\PayoutBatchHeader $batch_header
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBatchHeader($batch_header)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
|
||||
}
|
||||
388
lib/PayPal/Api/PayoutBatchHeader.php
Normal file
388
lib/PayPal/Api/PayoutBatchHeader.php
Normal file
@@ -0,0 +1,388 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Api;
|
||||
|
||||
use PayPal\Common\PayPalModel;
|
||||
|
||||
/**
|
||||
* Class PayoutBatchHeader
|
||||
*
|
||||
* This object enables you to get payout header information for an entire batch request. This object represents payout header data, and can be the response to a batch header request.
|
||||
*
|
||||
* @package PayPal\Api
|
||||
*
|
||||
* @property string payout_batch_id
|
||||
* @property string batch_status
|
||||
* @property string time_created
|
||||
* @property string time_completed
|
||||
* @property \PayPal\Api\PayoutSenderBatchHeader sender_batch_header
|
||||
* @property \PayPal\Api\Currency amount
|
||||
* @property \PayPal\Api\Currency fees
|
||||
* @property \PayPal\Api\Error errors
|
||||
* @property \PayPal\Api\Links[] links
|
||||
*/
|
||||
class PayoutBatchHeader extends PayPalModel
|
||||
{
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
215
lib/PayPal/Api/PayoutItem.php
Normal file
215
lib/PayPal/Api/PayoutItem.php
Normal file
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Api;
|
||||
|
||||
use PayPal\Common\PayPalResourceModel;
|
||||
use PayPal\Validation\ArgumentValidator;
|
||||
use PayPal\Rest\ApiContext;
|
||||
use PayPal\Transport\PayPalRestCall;
|
||||
|
||||
/**
|
||||
* Class PayoutItem
|
||||
*
|
||||
* Sender-created description of a payout to a single recipient.
|
||||
*
|
||||
* @package PayPal\Api
|
||||
*
|
||||
* @property string recipient_type
|
||||
* @property \PayPal\Api\Currency amount
|
||||
* @property string note
|
||||
* @property string receiver
|
||||
* @property string sender_item_id
|
||||
*/
|
||||
class PayoutItem extends PayPalResourceModel
|
||||
{
|
||||
/**
|
||||
* 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`.
|
||||
*
|
||||
* @param string $recipient_type
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setRecipientType($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`.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
487
lib/PayPal/Api/PayoutItemDetails.php
Normal file
487
lib/PayPal/Api/PayoutItemDetails.php
Normal file
@@ -0,0 +1,487 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Api;
|
||||
|
||||
use PayPal\Common\PayPalModel;
|
||||
|
||||
/**
|
||||
* Class PayoutItemDetails
|
||||
*
|
||||
* This object contains status and other data for an individual payout of a batch.
|
||||
*
|
||||
* @package PayPal\Api
|
||||
*
|
||||
* @property string payout_item_id
|
||||
* @property string transaction_id
|
||||
* @property string transaction_status
|
||||
* @property \PayPal\Api\Currency payout_item_fee
|
||||
* @property string payout_batch_id
|
||||
* @property string sender_batch_id
|
||||
* @property \PayPal\Api\PayoutItem payout_item
|
||||
* @property string time_processed
|
||||
* @property \PayPal\Api\Error error
|
||||
* @property \PayPal\Api\Links[] links
|
||||
*/
|
||||
class PayoutItemDetails extends PayPalModel
|
||||
{
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param string $payout_item_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPayoutItemId($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.
|
||||
*
|
||||
* @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))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
164
lib/PayPal/Api/PayoutSenderBatchHeader.php
Normal file
164
lib/PayPal/Api/PayoutSenderBatchHeader.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Api;
|
||||
|
||||
use PayPal\Common\PayPalModel;
|
||||
|
||||
/**
|
||||
* Class PayoutSenderBatchHeader
|
||||
*
|
||||
* This object represents sender-provided data about a batch header. The data is provided in a POST request. All batch submissions must have a batch header.
|
||||
*
|
||||
* @package PayPal\Api
|
||||
*
|
||||
* @property string sender_batch_id
|
||||
* @property string email_subject
|
||||
* @property string recipient_type
|
||||
*/
|
||||
class PayoutSenderBatchHeader extends PayPalModel
|
||||
{
|
||||
/**
|
||||
* Sender-created ID for tracking the batch payout 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 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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": {
|
||||
|
||||
@@ -46,13 +46,8 @@ Please note that the plan Id should be only set in this case.</p></div></div><di
|
||||
->setCountryCode(<span class="hljs-string">'US'</span>);
|
||||
<span class="hljs-variable">$agreement</span>->setShippingAddress(<span class="hljs-variable">$shippingAddress</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>For Sample Purposes Only.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$request</span> = <span class="hljs-keyword">clone</span> <span class="hljs-variable">$agreement</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-agreement">Create Agreement</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Please note that as the agreement has not yet activated, we wont be receiving the ID just yet.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$agreement</span> = <span class="hljs-variable">$agreement</span>->create(<span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-redirect-url">Get redirect url</h3>
|
||||
<p>The API response provides the url that you must redirect
|
||||
the buyer to. Retrieve the url from the $agreement->getLinks()
|
||||
method</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$agreement</span>->getLinks() <span class="hljs-keyword">as</span> <span class="hljs-variable">$link</span>) {
|
||||
<span class="hljs-keyword">if</span> (<span class="hljs-variable">$link</span>->getRel() == <span class="hljs-string">'approval_url'</span>) {
|
||||
<span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$link</span>->getHref();
|
||||
<span class="hljs-keyword">break</span>;
|
||||
}
|
||||
}
|
||||
the buyer to. Retrieve the url from the $agreement->getApprovalLink()
|
||||
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$agreement</span>->getApprovalLink();
|
||||
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Created Billing Agreement."</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>notifications/CreateWebhook</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="notifications/CreateWebhook"><meta name="groc-project-path" content="notifications/CreateWebhook.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">notifications/CreateWebhook.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-webhook-sample">Create Webhook Sample</h1>
|
||||
<!DOCTYPE html><html lang="en"><head><title>notifications/createWebhook</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="notifications/createWebhook"><meta name="groc-project-path" content="notifications/createWebhook.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">notifications/createWebhook.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-webhook-sample">Create Webhook Sample</h1>
|
||||
<p>This sample code demonstrate how you can create a webhook, as documented here at:
|
||||
<a href="https://developer.paypal.com/webapps/developer/docs/api/#create-a-webhook">https://developer.paypal.com/webapps/developer/docs/api/#create-a-webhook</a>
|
||||
API used: POST /v1/notifications/webhooks</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Create a new instance of Webhook object</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$webhook</span> = <span class="hljs-keyword">new</span> \PayPal\Api\Webhook();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="basic-information">Basic Information</h1>
|
||||
|
||||
@@ -73,12 +73,7 @@ for payment approval</p></div></div><div class="code"><div class="wrapper"><span
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-redirect-url">Get redirect url</h3>
|
||||
<p>The API response provides the url that you must redirect
|
||||
the buyer to. Retrieve the url from the $payment->getLinks()
|
||||
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$payment</span>->getLinks() <span class="hljs-keyword">as</span> <span class="hljs-variable">$link</span>) {
|
||||
<span class="hljs-keyword">if</span> (<span class="hljs-variable">$link</span>->getRel() == <span class="hljs-string">'approval_url'</span>) {
|
||||
<span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$link</span>->getHref();
|
||||
<span class="hljs-keyword">break</span>;
|
||||
}
|
||||
}
|
||||
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$payment</span>->getApprovalLink();
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Created Payment Authorization Using PayPal. Please visit the URL to Authorize."</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-string">"<a href='$approvalUrl' >$approvalUrl</a>"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
|
||||
|
||||
|
||||
@@ -70,13 +70,8 @@ for payment approval</p></div></div><div class="code"><div class="wrapper"><span
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-redirect-url">Get redirect url</h3>
|
||||
<p>The API response provides the url that you must redirect
|
||||
the buyer to. Retrieve the url from the $payment->getLinks()
|
||||
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$payment</span>->getLinks() <span class="hljs-keyword">as</span> <span class="hljs-variable">$link</span>) {
|
||||
<span class="hljs-keyword">if</span> (<span class="hljs-variable">$link</span>->getRel() == <span class="hljs-string">'approval_url'</span>) {
|
||||
<span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$link</span>->getHref();
|
||||
<span class="hljs-keyword">break</span>;
|
||||
}
|
||||
}
|
||||
the buyer to. Retrieve the url from the $payment->getApprovalLink()
|
||||
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$payment</span>->getApprovalLink();
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Created Payment Using PayPal. Please visit the URL to Approve."</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-string">"<a href='$approvalUrl' >$approvalUrl</a>"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
|
||||
|
||||
|
||||
93
sample/doc/payouts/CreateBatchPayout.html
Normal file
93
sample/doc/payouts/CreateBatchPayout.html
Normal file
@@ -0,0 +1,93 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>payouts/CreateBatchPayout</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="payouts/CreateBatchPayout"><meta name="groc-project-path" content="payouts/CreateBatchPayout.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">payouts/CreateBatchPayout.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-bulk-payout-sample">Create Bulk Payout Sample</h1>
|
||||
<p>This sample code demonstrate how you can create a synchronous payout sample, as documented here at:
|
||||
<a href="https://developer.paypal.com/docs/integration/direct/create-batch-payout/">https://developer.paypal.com/docs/integration/direct/create-batch-payout/</a>
|
||||
API used: /v1/payments/payouts</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Create a new instance of Payout object</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payouts</span> = <span class="hljs-keyword">new</span> \PayPal\Api\Payout();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>This is how our body should look like:</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/*
|
||||
*{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
*/</span>
|
||||
|
||||
<span class="hljs-variable">$senderBatchHeader</span> = <span class="hljs-keyword">new</span> \PayPal\Api\PayoutSenderBatchHeader();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="note">NOTE:</h3>
|
||||
<p>You can prevent duplicate batches from being processed. If you specify a <code>sender_batch_id</code> that was used in the last 30 days, the batch will not be processed. For items, you can specify a <code>sender_item_id</code>. If the value for the <code>sender_item_id</code> is a duplicate of a payout item that was processed in the last 30 days, the item will not be processed.</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h4 id="batch-header-instance">Batch Header Instance</h4></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-variable">$senderBatchHeader</span>->setSenderBatchId(uniqid())
|
||||
->setEmailSubject(<span class="hljs-string">"You have a payment"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h4 id="sender-item">Sender Item</h4>
|
||||
<p>Please note that if you are using single payout with sync mode, you can only pass one Item in the request</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$senderItem1</span> = <span class="hljs-keyword">new</span> \PayPal\Api\PayoutItem();
|
||||
<span class="hljs-variable">$senderItem1</span>->setRecipientType(<span class="hljs-string">'Email'</span>)
|
||||
->setNote(<span class="hljs-string">'Thanks you.'</span>)
|
||||
->setReceiver(<span class="hljs-string">'shirt-supplier-one@gmail.com'</span>)
|
||||
->setSenderItemId(<span class="hljs-string">"item_1"</span> . uniqid())
|
||||
->setAmount(<span class="hljs-keyword">new</span> \PayPal\Api\Currency(<span class="hljs-string">'{
|
||||
"value":"0.99",
|
||||
"currency":"USD"
|
||||
}'</span>));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h4 id="sender-item-2">Sender Item 2</h4>
|
||||
<p>There are many different ways of assigning values in PayPal SDK. Here is another way where you could directly inject json string.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$senderItem2</span> = <span class="hljs-keyword">new</span> \PayPal\Api\PayoutItem(
|
||||
<span class="hljs-string">'{
|
||||
"recipient_type": "EMAIL",
|
||||
"amount": {
|
||||
"value": 0.90,
|
||||
"currency": "USD"
|
||||
},
|
||||
"receiver": "shirt-supplier-two@mail.com",
|
||||
"note": "Thank you.",
|
||||
"sender_item_id": "item_2"
|
||||
}'</span>
|
||||
);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h4 id="sender-item-3">Sender Item 3</h4>
|
||||
<p>One more way of assigning values in constructor when creating instance of PayPalModel object. Injecting array.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$senderItem3</span> = <span class="hljs-keyword">new</span> \PayPal\Api\PayoutItem(
|
||||
<span class="hljs-keyword">array</span>(
|
||||
<span class="hljs-string">"recipient_type"</span> => <span class="hljs-string">"EMAIL"</span>,
|
||||
<span class="hljs-string">"receiver"</span> => <span class="hljs-string">"shirt-supplier-three@mail.com"</span>,
|
||||
<span class="hljs-string">"note"</span> => <span class="hljs-string">"Thank you."</span>,
|
||||
<span class="hljs-string">"sender_item_id"</span> => uniqid(),
|
||||
<span class="hljs-string">"amount"</span> => <span class="hljs-keyword">array</span>(
|
||||
<span class="hljs-string">"value"</span> => <span class="hljs-string">"0.90"</span>,
|
||||
<span class="hljs-string">"currency"</span> => <span class="hljs-string">"USD"</span>
|
||||
)
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
<span class="hljs-variable">$payouts</span>->setSenderBatchHeader(<span class="hljs-variable">$senderBatchHeader</span>)
|
||||
->addItem(<span class="hljs-variable">$senderItem1</span>)->addItem(<span class="hljs-variable">$senderItem2</span>)->addItem(<span class="hljs-variable">$senderItem3</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>For Sample Purposes Only.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$request</span> = <span class="hljs-keyword">clone</span> <span class="hljs-variable">$payouts</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-payout">Create Payout</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$output</span> = <span class="hljs-variable">$payouts</span>->create(<span class="hljs-keyword">null</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Created Batch Payout"</span>, <span class="hljs-string">"Payout"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Created Batch Payout"</span>, <span class="hljs-string">"Payout"</span>, <span class="hljs-variable">$output</span>->getBatchHeader()->getPayoutBatchId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$output</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>
|
||||
48
sample/doc/payouts/CreateSinglePayout.html
Normal file
48
sample/doc/payouts/CreateSinglePayout.html
Normal file
@@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>payouts/CreateSinglePayout</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="payouts/CreateSinglePayout"><meta name="groc-project-path" content="payouts/CreateSinglePayout.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">payouts/CreateSinglePayout.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-single-synchronous-payout-sample">Create Single Synchronous Payout Sample</h1>
|
||||
<p>This sample code demonstrate how you can create a synchronous payout sample, as documented here at:
|
||||
<a href="https://developer.paypal.com/docs/integration/direct/create-single-payout/">https://developer.paypal.com/docs/integration/direct/create-single-payout/</a>
|
||||
API used: /v1/payments/payouts?sync_mode=true</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Create a new instance of Payout object</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payouts</span> = <span class="hljs-keyword">new</span> \PayPal\Api\Payout();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>This is how our body should look like:</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/*
|
||||
* {
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
*/</span>
|
||||
|
||||
<span class="hljs-variable">$senderBatchHeader</span> = <span class="hljs-keyword">new</span> \PayPal\Api\PayoutSenderBatchHeader();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="note">NOTE:</h3>
|
||||
<p>You can prevent duplicate batches from being processed. If you specify a <code>sender_batch_id</code> that was used in the last 30 days, the batch will not be processed. For items, you can specify a <code>sender_item_id</code>. If the value for the <code>sender_item_id</code> is a duplicate of a payout item that was processed in the last 30 days, the item will not be processed.</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h4 id="batch-header-instance">Batch Header Instance</h4></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-variable">$senderBatchHeader</span>->setSenderBatchId(uniqid())
|
||||
->setEmailSubject(<span class="hljs-string">"You have a Payout!"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h4 id="sender-item">Sender Item</h4>
|
||||
<p>Please note that if you are using single payout with sync mode, you can only pass one Item in the request</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$senderItem</span> = <span class="hljs-keyword">new</span> \PayPal\Api\PayoutItem();
|
||||
<span class="hljs-variable">$senderItem</span>->setRecipientType(<span class="hljs-string">'Email'</span>)
|
||||
->setNote(<span class="hljs-string">'Thanks for your patronage!'</span>)
|
||||
->setReceiver(<span class="hljs-string">'shirt-supplier-one@gmail.com'</span>)
|
||||
->setSenderItemId(<span class="hljs-string">"2014031400023"</span>)
|
||||
->setAmount(<span class="hljs-keyword">new</span> \PayPal\Api\Currency(<span class="hljs-string">'{
|
||||
"value":"1.0",
|
||||
"currency":"USD"
|
||||
}'</span>));
|
||||
|
||||
<span class="hljs-variable">$payouts</span>->setSenderBatchHeader(<span class="hljs-variable">$senderBatchHeader</span>)
|
||||
->addItem(<span class="hljs-variable">$senderItem</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>For Sample Purposes Only.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$request</span> = <span class="hljs-keyword">clone</span> <span class="hljs-variable">$payouts</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-payout">Create Payout</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$output</span> = <span class="hljs-variable">$payouts</span>->createSynchronous(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Created Single Synchronous Payout"</span>, <span class="hljs-string">"Payout"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Created Single Synchronous Payout"</span>, <span class="hljs-string">"Payout"</span>, <span class="hljs-variable">$output</span>->getBatchHeader()->getPayoutBatchId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$output</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>
|
||||
15
sample/doc/payouts/GetPayoutBatchStatus.html
Normal file
15
sample/doc/payouts/GetPayoutBatchStatus.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>payouts/GetPayoutBatchStatus</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="payouts/GetPayoutBatchStatus"><meta name="groc-project-path" content="payouts/GetPayoutBatchStatus.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">payouts/GetPayoutBatchStatus.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="get-payout-batch-status-sample">Get Payout Batch Status Sample</h1>
|
||||
<p>This sample code demonstrate how you can get the batch payout status of a created batch payout, as documented here at:
|
||||
<a href="https://developer.paypal.com/docs/api/#get-the-status-of-a-batch-payout">https://developer.paypal.com/docs/api/#get-the-status-of-a-batch-payout</a>
|
||||
API used: GET /v1/payments/payouts/<Payout-Batch-Id></p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> \PayPal\Api\PayoutBatch $payoutBatch */</span>
|
||||
<span class="hljs-variable">$payoutBatch</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateBatchPayout.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h2 id="payout-batch-id">Payout Batch ID</h2>
|
||||
<p>You can replace this with your Payout Batch Id on already created Payout.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payoutBatchId</span> = <span class="hljs-variable">$payoutBatch</span>->getBatchHeader()->getPayoutBatchId();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-payout-batch-status">Get Payout Batch Status</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$output</span> = \PayPal\Api\Payout::get(<span class="hljs-variable">$payoutBatchId</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get Payout Batch Status"</span>, <span class="hljs-string">"PayoutBatch"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$payoutBatchId</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Payout Batch Status"</span>, <span class="hljs-string">"PayoutBatch"</span>, <span class="hljs-variable">$output</span>->getBatchHeader()->getPayoutBatchId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$output</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>
|
||||
16
sample/doc/payouts/GetPayoutItemStatus.html
Normal file
16
sample/doc/payouts/GetPayoutItemStatus.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>payouts/GetPayoutItemStatus</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="payouts/GetPayoutItemStatus"><meta name="groc-project-path" content="payouts/GetPayoutItemStatus.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">payouts/GetPayoutItemStatus.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="get-payout-item-status-sample">Get Payout Item Status Sample</h1>
|
||||
<p>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.
|
||||
<a href="https://developer.paypal.com/docs/api/#get-the-status-of-a-payout-item">https://developer.paypal.com/docs/api/#get-the-status-of-a-payout-item</a>
|
||||
API used: GET /v1/payments/payouts-item/<Payout-Item-Id></p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> \PayPal\Api\PayoutBatch $payoutBatch */</span>
|
||||
<span class="hljs-variable">$payoutBatch</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'GetPayoutBatchStatus.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h2 id="payout-item-id">Payout Item ID</h2>
|
||||
<p>You can replace this with your Payout Batch Id on already created Payout.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payoutItem</span> = <span class="hljs-variable">$payoutBatch</span>->getItems()[<span class="hljs-number">0</span>];
|
||||
<span class="hljs-variable">$payoutItemId</span> = <span class="hljs-variable">$payoutItem</span>->getPayoutItemId();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-payout-item-status">Get Payout Item Status</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$output</span> = \PayPal\Api\PayoutItem::get(<span class="hljs-variable">$payoutItemId</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get Payout Item Status"</span>, <span class="hljs-string">"PayoutItem"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$payoutItemId</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Payout Item Status"</span>, <span class="hljs-string">"PayoutItem"</span>, <span class="hljs-variable">$output</span>->getPayoutItemId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$output</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>
|
||||
2194
sample/index.php
2194
sample/index.php
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
124
sample/payouts/CreateBatchPayout.php
Normal file
124
sample/payouts/CreateBatchPayout.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?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;
|
||||
73
sample/payouts/CreateSinglePayout.php
Normal file
73
sample/payouts/CreateSinglePayout.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?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;
|
||||
25
sample/payouts/GetPayoutBatchStatus.php
Normal file
25
sample/payouts/GetPayoutBatchStatus.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?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/<Payout-Batch-Id>
|
||||
|
||||
/** @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;
|
||||
26
sample/payouts/GetPayoutItemStatus.php
Normal file
26
sample/payouts/GetPayoutItemStatus.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?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/<Payout-Item-Id>
|
||||
|
||||
/** @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;
|
||||
139
tests/PayPal/Test/Api/PayoutBatchHeaderTest.php
Normal file
139
tests/PayPal/Test/Api/PayoutBatchHeaderTest.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\PayPalModel;
|
||||
use PayPal\Api\PayoutBatchHeader;
|
||||
|
||||
/**
|
||||
* Class PayoutBatchHeader
|
||||
*
|
||||
* @package PayPal\Test\Api
|
||||
*/
|
||||
class PayoutBatchHeaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Gets Json String of Object PayoutBatchHeader
|
||||
* @return string
|
||||
*/
|
||||
public static function getJson()
|
||||
{
|
||||
return '{"payout_batch_id":"TestSample","batch_status":"TestSample","time_created":"TestSample","time_completed":"TestSample","sender_batch_header":' .PayoutSenderBatchHeaderTest::getJson() . ',"amount":' .CurrencyTest::getJson() . ',"fees":' .CurrencyTest::getJson() . ',"errors":' .ErrorTest::getJson() . ',"links":' .LinksTest::getJson() . '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Object Instance with Json data filled in
|
||||
* @return PayoutBatchHeader
|
||||
*/
|
||||
public static function getObject()
|
||||
{
|
||||
return new PayoutBatchHeader(self::getJson());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests for Serialization and Deserialization Issues
|
||||
* @return PayoutBatchHeader
|
||||
*/
|
||||
public function testSerializationDeserialization()
|
||||
{
|
||||
$obj = new PayoutBatchHeader(self::getJson());
|
||||
$this->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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
89
tests/PayPal/Test/Api/PayoutBatchTest.php
Normal file
89
tests/PayPal/Test/Api/PayoutBatchTest.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\PayPalModel;
|
||||
use PayPal\Api\PayoutBatch;
|
||||
|
||||
/**
|
||||
* Class PayoutBatch
|
||||
*
|
||||
* @package PayPal\Test\Api
|
||||
*/
|
||||
class PayoutBatchTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Gets Json String of Object PayoutBatch
|
||||
* @return string
|
||||
*/
|
||||
public static function getJson()
|
||||
{
|
||||
return '{"batch_header":' .PayoutBatchHeaderTest::getJson() . ',"items":' .PayoutItemDetailsTest::getJson() . '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Object Instance with Json data filled in
|
||||
* @return PayoutBatch
|
||||
*/
|
||||
public static function getObject()
|
||||
{
|
||||
return new PayoutBatch(self::getJson());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests for Serialization and Deserialization Issues
|
||||
* @return PayoutBatch
|
||||
*/
|
||||
public function testSerializationDeserialization()
|
||||
{
|
||||
$obj = new PayoutBatch(self::getJson());
|
||||
$this->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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
168
tests/PayPal/Test/Api/PayoutItemDetailsTest.php
Normal file
168
tests/PayPal/Test/Api/PayoutItemDetailsTest.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\PayPalModel;
|
||||
use PayPal\Api\PayoutItemDetails;
|
||||
|
||||
/**
|
||||
* Class PayoutItemDetails
|
||||
*
|
||||
* @package PayPal\Test\Api
|
||||
*/
|
||||
class PayoutItemDetailsTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Gets Json String of Object PayoutItemDetails
|
||||
* @return string
|
||||
*/
|
||||
public static function getJson()
|
||||
{
|
||||
return '{"payout_item_id":"TestSample","transaction_id":"TestSample","transaction_status":"TestSample","payout_item_fee":' .CurrencyTest::getJson() . ',"payout_batch_id":"TestSample","sender_batch_id":"TestSample","payout_item":' .PayoutItemTest::getJson() . ',"time_processed":"TestSample","error":' .ErrorTest::getJson() . ',"links":' .LinksTest::getJson() . '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Object Instance with Json data filled in
|
||||
* @return PayoutItemDetails
|
||||
*/
|
||||
public static function getObject()
|
||||
{
|
||||
return new PayoutItemDetails(self::getJson());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests for Serialization and Deserialization Issues
|
||||
* @return PayoutItemDetails
|
||||
*/
|
||||
public function testSerializationDeserialization()
|
||||
{
|
||||
$obj = new PayoutItemDetails(self::getJson());
|
||||
$this->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->getError());
|
||||
$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->getError(), 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
138
tests/PayPal/Test/Api/PayoutItemTest.php
Normal file
138
tests/PayPal/Test/Api/PayoutItemTest.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\PayPalResourceModel;
|
||||
use PayPal\Validation\ArgumentValidator;
|
||||
use PayPal\Api\ItemsArray;
|
||||
use PayPal\Rest\ApiContext;
|
||||
use PayPal\Transport\PPRestCall;
|
||||
use PayPal\Api\PayoutItem;
|
||||
|
||||
/**
|
||||
* Class PayoutItem
|
||||
*
|
||||
* @package PayPal\Test\Api
|
||||
*/
|
||||
class PayoutItemTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Gets Json String of Object PayoutItem
|
||||
* @return string
|
||||
*/
|
||||
public static function getJson()
|
||||
{
|
||||
return '{"recipient_type":"TestSample","amount":' .CurrencyTest::getJson() . ',"note":"TestSample","receiver":"TestSample","sender_item_id":"TestSample"}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Object Instance with Json data filled in
|
||||
* @return PayoutItem
|
||||
*/
|
||||
public static function getObject()
|
||||
{
|
||||
return new PayoutItem(self::getJson());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests for Serialization and Deserialization Issues
|
||||
* @return PayoutItem
|
||||
*/
|
||||
public function testSerializationDeserialization()
|
||||
{
|
||||
$obj = new PayoutItem(self::getJson());
|
||||
$this->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)
|
||||
);
|
||||
}
|
||||
}
|
||||
109
tests/PayPal/Test/Api/PayoutSenderBatchHeaderTest.php
Normal file
109
tests/PayPal/Test/Api/PayoutSenderBatchHeaderTest.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\PayPalModel;
|
||||
use PayPal\Api\PayoutSenderBatchHeader;
|
||||
|
||||
/**
|
||||
* Class PayoutSenderBatchHeader
|
||||
*
|
||||
* @package PayPal\Test\Api
|
||||
*/
|
||||
class PayoutSenderBatchHeaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Gets Json String of Object PayoutSenderBatchHeader
|
||||
* @return string
|
||||
*/
|
||||
public static function getJson()
|
||||
{
|
||||
return '{"sender_batch_id":"TestSample","email_subject":"TestSample","recipient_type":"TestSample"}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Object Instance with Json data filled in
|
||||
* @return PayoutSenderBatchHeader
|
||||
*/
|
||||
public static function getObject()
|
||||
{
|
||||
return new PayoutSenderBatchHeader(self::getJson());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests for Serialization and Deserialization Issues
|
||||
* @return PayoutSenderBatchHeader
|
||||
*/
|
||||
public function testSerializationDeserialization()
|
||||
{
|
||||
$obj = new PayoutSenderBatchHeader(self::getJson());
|
||||
$this->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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
140
tests/PayPal/Test/Api/PayoutTest.php
Normal file
140
tests/PayPal/Test/Api/PayoutTest.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Api\Payout;
|
||||
|
||||
/**
|
||||
* Class Payout
|
||||
*
|
||||
* @package PayPal\Test\Api
|
||||
*/
|
||||
class PayoutTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Gets Json String of Object Payout
|
||||
* @return string
|
||||
*/
|
||||
public static function getJson()
|
||||
{
|
||||
return '{"sender_batch_header":' .PayoutSenderBatchHeaderTest::getJson() . ',"items":' .PayoutItemTest::getJson() . ',"links":' .LinksTest::getJson() . '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Object Instance with Json data filled in
|
||||
* @return Payout
|
||||
*/
|
||||
public static function getObject()
|
||||
{
|
||||
return new Payout(self::getJson());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests for Serialization and Deserialization Issues
|
||||
* @return Payout
|
||||
*/
|
||||
public function testSerializationDeserialization()
|
||||
{
|
||||
$obj = new Payout(self::getJson());
|
||||
$this->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)
|
||||
);
|
||||
}
|
||||
}
|
||||
101
tests/PayPal/Test/Functional/Api/PayoutsFunctionalTest.php
Normal file
101
tests/PayPal/Test/Functional/Api/PayoutsFunctionalTest.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Functional\Api;
|
||||
|
||||
use PayPal\Api\Patch;
|
||||
use PayPal\Api\Payout;
|
||||
use PayPal\Api\PayoutBatch;
|
||||
use PayPal\Api\PayoutItem;
|
||||
use PayPal\Common\PayPalModel;
|
||||
use PayPal\Rest\ApiContext;
|
||||
use PayPal\Rest\IResource;
|
||||
use PayPal\Api\CreateProfileResponse;
|
||||
use PayPal\Test\Functional\Setup;
|
||||
use PayPal\Transport\PayPalRestCall;
|
||||
use PayPal\Api\WebProfile;
|
||||
|
||||
/**
|
||||
* Class Payouts
|
||||
*
|
||||
* @package PayPal\Test\Api
|
||||
*/
|
||||
class PayoutsFunctionalTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public $operation;
|
||||
|
||||
public $response;
|
||||
|
||||
public $mockPayPalRestCall;
|
||||
|
||||
public static $batchId;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$className = $this->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)
|
||||
{
|
||||
$item = $payoutBatch->getItems()[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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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') {
|
||||
|
||||
106
tests/PayPal/Test/Functional/resources/PayoutsFunctionalTest/testCreate.json
Executable file
106
tests/PayPal/Test/Functional/resources/PayoutsFunctionalTest/testCreate.json
Executable file
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
223
tests/PayPal/Test/Functional/resources/PayoutsFunctionalTest/testGet.json
Executable file
223
tests/PayPal/Test/Functional/resources/PayoutsFunctionalTest/testGet.json
Executable file
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"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" : {
|
||||
"items":[
|
||||
{
|
||||
"payout_item_id":"1421342",
|
||||
"transaction_id":"4345",
|
||||
"transaction_status":"SUCCESS",
|
||||
"payout_item_fee":{"currency":"USD","value":"0.35"},
|
||||
"payout_batch_id":"20140724",
|
||||
"sender_batch_id":"2014021801",
|
||||
"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:41Z",
|
||||
"links": [
|
||||
{
|
||||
"rel": "self",
|
||||
"href": "payouts-batch/{payout_batch_id}",
|
||||
"method": "GET"
|
||||
},
|
||||
{
|
||||
"rel": "self",
|
||||
"href": "payouts-item/{payout_item_id}",
|
||||
"method": "GET"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user