Enabled Payout Cancel API for Unclaimed Payout Item

- PayoutItem supports [Cancel and Unclaimed Payout Item](https://developer.paypal.com/docs/api/#cancel-an-unclaimed-payout-item)
- Updated Unit and Functional Tests Accordingly
- Updated Samples accordingly
This commit is contained in:
japatel
2015-01-23 13:50:51 -06:00
parent d9a5baf202
commit d84ddf85c9
11 changed files with 274 additions and 132 deletions

View File

@@ -85,6 +85,26 @@ class PayoutItemTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($result);
}
/**
* @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);
}
public function mockProvider()
{
$obj = self::getObject();

View File

@@ -65,6 +65,11 @@ class PayoutsFunctionalTest extends \PHPUnit_Framework_TestCase
$result = $obj->create($params, null, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals(PayoutsFunctionalTest::$batchId, $result->getBatchHeader()->getSenderBatchHeader()->getSenderBatchId());
$this->assertEquals('SUCCESS', $result->getBatchHeader()->getBatchStatus());
$items = $result->getItems();
$this->assertTrue(sizeof($items) > 0);
$item = $items[0];
$this->assertEquals('UNCLAIMED', $item->getTransactionStatus());
return $result;
}
@@ -99,4 +104,26 @@ class PayoutsFunctionalTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($item->getPayoutItemFee(), $result->getPayoutItemFee());
}
/**
* @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(), 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());
$this->assertEquals('RETURNED', $result->getTransactionStatus());
}
}

View File

@@ -0,0 +1,76 @@
{
"description":"User initiates cancel on unlcaimed payouts item.",
"title":"Cancel item sample",
"runnable":true,
"operationId":"payouts.item.cancel",
"user":{
"scopes":[
]
},
"credentials":{
"oauth":{
"path":"/v1/oauth/token",
"clientId":"",
"clientSecret":""
}
},
"request":{
"path":"v1/payments/payouts-item/452345/cancel",
"method":"POST",
"headers":{
"Content-Type":"application/json",
"Content-Encoding":"gzip"
},
"body":{
}
},
"response":{
"status":"200 OK",
"headers":{
"Content-Type":"application/json",
"Content-Encoding":"gzip"
},
"body":{
"payout_item_id":"VHBFGN95AWV82",
"transaction_id":"0728664497487461D",
"transaction_status":"RETURNED",
"payout_item_fee":{
"currency":"USD",
"value":"0.02"
},
"payout_batch_id":"CDZEC5MJ8R5HY",
"sender_batch_id":"2014021801",
"payout_item":{
"recipient_type":"EMAIL",
"amount":{
"value":"1.00",
"currency":"USD"
},
"note":"Thanks for your patronage!",
"receiver":"anybody01@gmail.com",
"payouts_item_id":"1421342",
"sender_item_id":"14Feb_234"
},
"time_processed":"2014-01-27T10:17:41Z",
"errors":{
"name":"RECEIVER_UNREGISTERED",
"message":"Receiver is unregistered",
"information_link": "https://developer.paypal.com/webapps/developer/docs/api/#RECEIVER_UNREGISTERED"
},
"links":[
{
"rel":"self",
"href":"https://api.sandbox.paypal.com/v1/payments/payouts-item/1421342",
"method":"GET"
},
{
"rel":"batch",
"href":"https://api.sandbox.paypal.com/v1/payments/payouts/20140724",
"method":"GET"
}
]
}
}
}

View File

@@ -68,7 +68,7 @@
{
"payout_item_id": "VHBFGN95AWV82",
"transaction_id": "0728664497487461D",
"transaction_status": "SUCCESS",
"transaction_status": "UNCLAIMED",
"payout_item_fee": {
"currency": "USD",
"value": "0.02"