A sender-created definition of a payout to a single recipient.
Inheritance: extends PayPal\Common\PayPalResourceModel
Example #1
0
 /**
  * @dataProvider mockProvider
  * @param PayoutItem $obj
  */
 public function testCancel($obj, $mockApiContext)
 {
     $mockPPRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock();
     $mockPPRestCall->expects($this->any())->method('execute')->will($this->returnValue(PayoutItemDetailsTest::getJson()));
     $result = $obj->cancel("payoutItemId", $mockApiContext, $mockPPRestCall);
     $this->assertNotNull($result);
 }
 /**
  * @depends testCreate
  * @param $payoutBatch PayoutBatch
  * @return PayoutBatch
  */
 public function testGetItem($payoutBatch)
 {
     $items = $payoutBatch->getItems();
     $item = $items[0];
     $result = PayoutItem::get($item->getPayoutItemId(), null, $this->mockPayPalRestCall);
     $this->assertNotNull($result);
     $this->assertEquals($item->getPayoutItemId(), $result->getPayoutItemId());
     $this->assertEquals($item->getPayoutBatchId(), $result->getPayoutBatchId());
     $this->assertEquals($item->getTransactionId(), $result->getTransactionId());
     $this->assertEquals($item->getPayoutItemFee(), $result->getPayoutItemFee());
 }
<?php

// # Cancel Payout Item Status Sample
//
// Use this call to cancel an existing, unclaimed transaction. If an unclaimed item is not claimed within 30 days, the funds will be automatically returned to the sender. This call can be used to cancel the unclaimed item prior to the automatic 30-day return.
// https://developer.paypal.com/docs/api/#cancel-an-unclaimed-payout-item
// API used: POST /v1/payments/payouts-item/<Payout-Item-Id>/cancel
/** @var \PayPal\Api\PayoutBatch $payoutBatch */
$payoutBatch = (require 'CreateSinglePayout.php');
// ## Payout Item ID
// You can replace this with your Payout Batch Id on already created Payout.
$payoutItems = $payoutBatch->getItems();
$payoutItem = $payoutItems[0];
$payoutItemId = $payoutItem->getPayoutItemId();
$output = null;
// ### Cancel Payout Item
// Check if Payout Item is UNCLAIMED, and if so, cancel it.
try {
    if ($payoutItem->getTransactionStatus() == 'UNCLAIMED') {
        // Cancel the Payout Item
        $output = \PayPal\Api\PayoutItem::cancel($payoutItemId, $apiContext);
        ResultPrinter::printResult("Cancel Unclaimed Payout Item", "PayoutItem", $output->getPayoutItemId(), null, $output);
    } else {
        // The item transaction status is not unclaimed. You can only cancel an unclaimed transaction.
        ResultPrinter::printError("Cancel Unclaimed Payout Item", "PayoutItem", null, $payoutItemId, new Exception("Payout Item Status is not UNCLAIMED"));
    }
} catch (Exception $ex) {
    ResultPrinter::printError("Cancel Unclaimed Payout Item", "PayoutItem", null, $payoutItemId, $ex);
    exit(1);
}
return $output;
<?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;
Example #5
0
 /**
  * @depends testCreate
  * @param $payoutBatch PayoutBatch
  * @return PayoutBatch
  */
 public function testCancel($payoutBatch)
 {
     $items = $payoutBatch->getItems();
     $item = $items[0];
     if ($item->getTransactionStatus() != 'UNCLAIMED') {
         $this->markTestSkipped('Transaction status needs to be Unclaimed for this test ');
         return;
     }
     $result = PayoutItem::cancel($item->getPayoutItemId(), $this->apiContext, $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());
     $this->assertEquals('RETURNED', $result->getTransactionStatus());
 }