Enabled Payout API Support

- Includes Unit and Functional Tests
- Includes Samples
This commit is contained in:
japatel
2015-01-02 16:41:36 -06:00
parent 9e7cb951a6
commit 6f13399e47
32 changed files with 4752 additions and 1165 deletions

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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)
);
}
}

View 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);
}
}

View 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)
);
}
}

View 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());
}
}

View File

@@ -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') {

View 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"
}
]
}
}
}

View 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"
}
]
}
}
}

View File

@@ -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"
}
]
}
]
}
}
}