Unit Tests and Functional Tests for Invoicing

- Updated Unit Tests for PPModels used by Invoicing
- Updated Functional Tests
- Updated Samples for quick changes.
This commit is contained in:
japatel
2014-11-19 15:21:18 -06:00
parent ef4797a94c
commit 026802443d
41 changed files with 3795 additions and 7 deletions

View File

@@ -3,6 +3,8 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Validation\NumericValidator;
use PayPal\Common\FormatConverter;
/**
* Class Cost
@@ -11,7 +13,7 @@ use PayPal\Common\PPModel;
*
* @package PayPal\Api
*
* @property \PayPal\Api\number percent
* @property string percent
* @property \PayPal\Api\Currency amount
*/
class Cost extends PPModel
@@ -19,12 +21,14 @@ class Cost extends PPModel
/**
* Cost in percent. Range of 0 to 100.
*
* @param \PayPal\Api\number $percent
* @param string $percent
*
* @return $this
*/
public function setPercent($percent)
{
NumericValidator::validate($percent, "Percent");
$percent = FormatConverter::formatToTwoDecimalPlaces($percent);
$this->percent = $percent;
return $this;
}
@@ -32,7 +36,7 @@ class Cost extends PPModel
/**
* Cost in percent. Range of 0 to 100.
*
* @return \PayPal\Api\number
* @return string
*/
public function getPercent()
{

View File

@@ -208,4 +208,24 @@ class ShippingInfo extends PPModel
return $this->address;
}
/**
* @deprecated This will not be supported soon. Kept for backward Compatibility
*
* @param string $email
*/
public function setEmail($email)
{
$this->email = $email;
}
/**
* @deprecated This will not be supported soon. Kept for backward Compatibility
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
}

View File

@@ -21,7 +21,7 @@ on the Invoice class by passing a valid
notification object
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$recordStatus</span> = <span class="hljs-variable">$invoice</span>-&gt;recordPayment(<span class="hljs-variable">$record</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">"Payment for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$recordStatus</span>, <span class="hljs-variable">$ex</span>);
ResultPrinter::printError(<span class="hljs-string">"Payment for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}

View File

@@ -20,7 +20,7 @@ on the Invoice class by passing a valid
notification object
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$refundStatus</span> = <span class="hljs-variable">$invoice</span>-&gt;recordRefund(<span class="hljs-variable">$refund</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">"Refund for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$refundStatus</span>, <span class="hljs-variable">$ex</span>);
ResultPrinter::printError(<span class="hljs-string">"Refund for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}

View File

@@ -30,7 +30,7 @@ try {
// (See bootstrap.php for more on `ApiContext`)
$recordStatus = $invoice->recordPayment($record, $apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Payment for Invoice", "Invoice", null, $recordStatus, $ex);
ResultPrinter::printError("Payment for Invoice", "Invoice", null, null, $ex);
exit(1);
}

View File

@@ -29,7 +29,7 @@ try {
// (See bootstrap.php for more on `ApiContext`)
$refundStatus = $invoice->recordRefund($refund, $apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Refund for Invoice", "Invoice", null, $refundStatus, $ex);
ResultPrinter::printError("Refund for Invoice", "Invoice", null, null, $ex);
exit(1);
}

View File

@@ -0,0 +1,139 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\BillingInfo;
/**
* Class BillingInfo
*
* @package PayPal\Test\Api
*/
class BillingInfoTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object BillingInfo
* @return string
*/
public static function getJson()
{
return '{"email":"TestSample","first_name":"TestSample","last_name":"TestSample","business_name":"TestSample","address":' .AddressTest::getJson() . ',"language":"TestSample","additional_info":"TestSample","notification_channel":"TestSample","phone":' .PhoneTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return BillingInfo
*/
public static function getObject()
{
return new BillingInfo(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return BillingInfo
*/
public function testSerializationDeserialization()
{
$obj = new BillingInfo(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getEmail());
$this->assertNotNull($obj->getFirstName());
$this->assertNotNull($obj->getLastName());
$this->assertNotNull($obj->getBusinessName());
$this->assertNotNull($obj->getAddress());
$this->assertNotNull($obj->getLanguage());
$this->assertNotNull($obj->getAdditionalInfo());
$this->assertNotNull($obj->getNotificationChannel());
$this->assertNotNull($obj->getPhone());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param BillingInfo $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getEmail(), "TestSample");
$this->assertEquals($obj->getFirstName(), "TestSample");
$this->assertEquals($obj->getLastName(), "TestSample");
$this->assertEquals($obj->getBusinessName(), "TestSample");
$this->assertEquals($obj->getAddress(), AddressTest::getObject());
$this->assertEquals($obj->getLanguage(), "TestSample");
$this->assertEquals($obj->getAdditionalInfo(), "TestSample");
$this->assertEquals($obj->getNotificationChannel(), "TestSample");
$this->assertEquals($obj->getPhone(), PhoneTest::getObject());
}
/**
* @depends testSerializationDeserialization
* @param BillingInfo $obj
*/
public function testDeprecatedGetters($obj)
{
$this->assertEquals($obj->getFirst_name(), "TestSample");
$this->assertEquals($obj->getLast_name(), "TestSample");
$this->assertEquals($obj->getBusiness_name(), "TestSample");
$this->assertEquals($obj->getAdditional_info(), "TestSample");
$this->assertEquals($obj->getNotification_channel(), "TestSample");
}
/**
* @depends testSerializationDeserialization
* @param BillingInfo $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
// Check for First_name
$obj->setFirstName(null);
$this->assertNull($obj->getFirst_name());
$this->assertNull($obj->getFirstName());
$this->assertSame($obj->getFirstName(), $obj->getFirst_name());
$obj->setFirst_name("TestSample");
$this->assertEquals($obj->getFirst_name(), "TestSample");
// Check for Last_name
$obj->setLastName(null);
$this->assertNull($obj->getLast_name());
$this->assertNull($obj->getLastName());
$this->assertSame($obj->getLastName(), $obj->getLast_name());
$obj->setLast_name("TestSample");
$this->assertEquals($obj->getLast_name(), "TestSample");
// Check for Business_name
$obj->setBusinessName(null);
$this->assertNull($obj->getBusiness_name());
$this->assertNull($obj->getBusinessName());
$this->assertSame($obj->getBusinessName(), $obj->getBusiness_name());
$obj->setBusiness_name("TestSample");
$this->assertEquals($obj->getBusiness_name(), "TestSample");
// Check for Additional_info
$obj->setAdditionalInfo(null);
$this->assertNull($obj->getAdditional_info());
$this->assertNull($obj->getAdditionalInfo());
$this->assertSame($obj->getAdditionalInfo(), $obj->getAdditional_info());
$obj->setAdditional_info("TestSample");
$this->assertEquals($obj->getAdditional_info(), "TestSample");
// Check for Notification_channel
$obj->setNotificationChannel(null);
$this->assertNull($obj->getNotification_channel());
$this->assertNull($obj->getNotificationChannel());
$this->assertSame($obj->getNotificationChannel(), $obj->getNotification_channel());
$obj->setNotification_channel("TestSample");
$this->assertEquals($obj->getNotification_channel(), "TestSample");
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\CancelNotification;
/**
* Class CancelNotification
*
* @package PayPal\Test\Api
*/
class CancelNotificationTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object CancelNotification
* @return string
*/
public static function getJson()
{
return '{"subject":"TestSample","note":"TestSample","send_to_merchant":true,"send_to_payer":true}';
}
/**
* Gets Object Instance with Json data filled in
* @return CancelNotification
*/
public static function getObject()
{
return new CancelNotification(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return CancelNotification
*/
public function testSerializationDeserialization()
{
$obj = new CancelNotification(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getSubject());
$this->assertNotNull($obj->getNote());
$this->assertNotNull($obj->getSendToMerchant());
$this->assertNotNull($obj->getSendToPayer());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param CancelNotification $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getSubject(), "TestSample");
$this->assertEquals($obj->getNote(), "TestSample");
$this->assertEquals($obj->getSendToMerchant(), true);
$this->assertEquals($obj->getSendToPayer(), true);
}
/**
* @depends testSerializationDeserialization
* @param CancelNotification $obj
*/
public function testDeprecatedGetters($obj)
{
$this->assertEquals($obj->getSend_to_merchant(), true);
$this->assertEquals($obj->getSend_to_payer(), true);
}
/**
* @depends testSerializationDeserialization
* @param CancelNotification $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
// Check for Send_to_merchant
$obj->setSendToMerchant(null);
$this->assertNull($obj->getSend_to_merchant());
$this->assertNull($obj->getSendToMerchant());
$this->assertSame($obj->getSendToMerchant(), $obj->getSend_to_merchant());
$obj->setSend_to_merchant(true);
$this->assertEquals($obj->getSend_to_merchant(), true);
// Check for Send_to_payer
$obj->setSendToPayer(null);
$this->assertNull($obj->getSend_to_payer());
$this->assertNull($obj->getSendToPayer());
$this->assertSame($obj->getSendToPayer(), $obj->getSend_to_payer());
$obj->setSend_to_payer(true);
$this->assertEquals($obj->getSend_to_payer(), true);
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -0,0 +1,82 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Common\FormatConverter;
use PayPal\Validation\NumericValidator;
use PayPal\Api\Cost;
/**
* Class Cost
*
* @package PayPal\Test\Api
*/
class CostTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object Cost
* @return string
*/
public static function getJson()
{
return '{"percent":"12.34","amount":' .CurrencyTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return Cost
*/
public static function getObject()
{
return new Cost(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return Cost
*/
public function testSerializationDeserialization()
{
$obj = new Cost(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getPercent());
$this->assertNotNull($obj->getAmount());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Cost $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getPercent(), "12.34");
$this->assertEquals($obj->getAmount(), CurrencyTest::getObject());
}
/**
* @depends testSerializationDeserialization
* @param Cost $obj
*/
public function testDeprecatedGetters($obj)
{
}
/**
* @depends testSerializationDeserialization
* @param Cost $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -3,6 +3,8 @@
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Common\FormatConverter;
use PayPal\Validation\NumericValidator;
use PayPal\Api\Currency;
/**

View File

@@ -0,0 +1,80 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\CustomAmount;
/**
* Class CustomAmount
*
* @package PayPal\Test\Api
*/
class CustomAmountTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object CustomAmount
* @return string
*/
public static function getJson()
{
return '{"label":"TestSample","amount":' .CurrencyTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return CustomAmount
*/
public static function getObject()
{
return new CustomAmount(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return CustomAmount
*/
public function testSerializationDeserialization()
{
$obj = new CustomAmount(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getLabel());
$this->assertNotNull($obj->getAmount());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param CustomAmount $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getLabel(), "TestSample");
$this->assertEquals($obj->getAmount(), CurrencyTest::getObject());
}
/**
* @depends testSerializationDeserialization
* @param CustomAmount $obj
*/
public function testDeprecatedGetters($obj)
{
}
/**
* @depends testSerializationDeserialization
* @param CustomAmount $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -0,0 +1,80 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\ErrorDetails;
/**
* Class ErrorDetails
*
* @package PayPal\Test\Api
*/
class ErrorDetailsTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object ErrorDetails
* @return string
*/
public static function getJson()
{
return '{"field":"TestSample","issue":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return ErrorDetails
*/
public static function getObject()
{
return new ErrorDetails(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return ErrorDetails
*/
public function testSerializationDeserialization()
{
$obj = new ErrorDetails(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getField());
$this->assertNotNull($obj->getIssue());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param ErrorDetails $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getField(), "TestSample");
$this->assertEquals($obj->getIssue(), "TestSample");
}
/**
* @depends testSerializationDeserialization
* @param ErrorDetails $obj
*/
public function testDeprecatedGetters($obj)
{
}
/**
* @depends testSerializationDeserialization
* @param ErrorDetails $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\Error;
/**
* Class Error
*
* @package PayPal\Test\Api
*/
class ErrorTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object Error
* @return string
*/
public static function getJson()
{
return '{"name":"TestSample","debug_id":"TestSample","message":"TestSample","information_link":"TestSample","details":' .ErrorDetailsTest::getJson() . ',"links":' .LinksTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return Error
*/
public static function getObject()
{
return new Error(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return Error
*/
public function testSerializationDeserialization()
{
$obj = new Error(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getName());
$this->assertNotNull($obj->getDebugId());
$this->assertNotNull($obj->getMessage());
$this->assertNotNull($obj->getInformationLink());
$this->assertNotNull($obj->getDetails());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Error $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getName(), "TestSample");
$this->assertEquals($obj->getDebugId(), "TestSample");
$this->assertEquals($obj->getMessage(), "TestSample");
$this->assertEquals($obj->getInformationLink(), "TestSample");
$this->assertEquals($obj->getDetails(), ErrorDetailsTest::getObject());
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
/**
* @depends testSerializationDeserialization
* @param Error $obj
*/
public function testDeprecatedGetters($obj)
{
$this->assertEquals($obj->getDebug_id(), "TestSample");
$this->assertEquals($obj->getInformation_link(), "TestSample");
}
/**
* @depends testSerializationDeserialization
* @param Error $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
// Check for Debug_id
$obj->setDebugId(null);
$this->assertNull($obj->getDebug_id());
$this->assertNull($obj->getDebugId());
$this->assertSame($obj->getDebugId(), $obj->getDebug_id());
$obj->setDebug_id("TestSample");
$this->assertEquals($obj->getDebug_id(), "TestSample");
// Check for Information_link
$obj->setInformationLink(null);
$this->assertNull($obj->getInformation_link());
$this->assertNull($obj->getInformationLink());
$this->assertSame($obj->getInformationLink(), $obj->getInformation_link());
$obj->setInformation_link("TestSample");
$this->assertEquals($obj->getInformation_link(), "TestSample");
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -0,0 +1,78 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\Image;
/**
* Class Image
*
* @package PayPal\Test\Api
*/
class ImageTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object Patch
* @return string
*/
public static function getJson()
{
return '{"image":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return Image
*/
public static function getObject()
{
return new Image(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return Image
*/
public function testSerializationDeserialization()
{
$obj = new Image(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getImage());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Image $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getImage(), "TestSample");
}
/**
* @depends testSerializationDeserialization
* @param Image $obj
*/
public function testDeprecatedGetters($obj)
{
}
/**
* @depends testSerializationDeserialization
* @param Image $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -0,0 +1,99 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\InvoiceItem;
/**
* Class InvoiceItem
*
* @package PayPal\Test\Api
*/
class InvoiceItemTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object InvoiceItem
* @return string
*/
public static function getJson()
{
return '{"name":"TestSample","description":"TestSample","quantity":"12.34","unit_price":' .CurrencyTest::getJson() . ',"tax":' .TaxTest::getJson() . ',"date":"TestSample","discount":' .CostTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return InvoiceItem
*/
public static function getObject()
{
return new InvoiceItem(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return InvoiceItem
*/
public function testSerializationDeserialization()
{
$obj = new InvoiceItem(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getName());
$this->assertNotNull($obj->getDescription());
$this->assertNotNull($obj->getQuantity());
$this->assertNotNull($obj->getUnitPrice());
$this->assertNotNull($obj->getTax());
$this->assertNotNull($obj->getDate());
$this->assertNotNull($obj->getDiscount());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param InvoiceItem $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getName(), "TestSample");
$this->assertEquals($obj->getDescription(), "TestSample");
$this->assertEquals($obj->getQuantity(), "12.34");
$this->assertEquals($obj->getUnitPrice(), CurrencyTest::getObject());
$this->assertEquals($obj->getTax(), TaxTest::getObject());
$this->assertEquals($obj->getDate(), "TestSample");
$this->assertEquals($obj->getDiscount(), CostTest::getObject());
}
/**
* @depends testSerializationDeserialization
* @param InvoiceItem $obj
*/
public function testDeprecatedGetters($obj)
{
$this->assertEquals($obj->getUnit_price(), CurrencyTest::getObject());
}
/**
* @depends testSerializationDeserialization
* @param InvoiceItem $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
// Check for Unit_price
$obj->setUnitPrice(null);
$this->assertNull($obj->getUnit_price());
$this->assertNull($obj->getUnitPrice());
$this->assertSame($obj->getUnitPrice(), $obj->getUnit_price());
$obj->setUnit_price(CurrencyTest::getObject());
$this->assertEquals($obj->getUnit_price(), CurrencyTest::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\PPModel;
use PayPal\Api\InvoiceSearchResponse;
/**
* Class InvoiceSearchResponse
*
* @package PayPal\Test\Api
*/
class InvoiceSearchResponseTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object InvoiceSearchResponse
* @return string
*/
public static function getJson()
{
return '{"total_count":123,"invoices":' .InvoiceTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return InvoiceSearchResponse
*/
public static function getObject()
{
return new InvoiceSearchResponse(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return InvoiceSearchResponse
*/
public function testSerializationDeserialization()
{
$obj = new InvoiceSearchResponse(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getTotalCount());
$this->assertNotNull($obj->getInvoices());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param InvoiceSearchResponse $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getTotalCount(), 123);
$this->assertEquals($obj->getInvoices(), InvoiceTest::getObject());
}
/**
* @depends testSerializationDeserialization
* @param InvoiceSearchResponse $obj
*/
public function testDeprecatedGetters($obj)
{
$this->assertEquals($obj->getTotal_count(), 123);
}
/**
* @depends testSerializationDeserialization
* @param InvoiceSearchResponse $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
// Check for Total_count
$obj->setTotalCount(null);
$this->assertNull($obj->getTotal_count());
$this->assertNull($obj->getTotalCount());
$this->assertSame($obj->getTotalCount(), $obj->getTotal_count());
$obj->setTotal_count(123);
$this->assertEquals($obj->getTotal_count(), 123);
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -0,0 +1,505 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\ResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\InvoiceSearchResponse;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
use PayPal\Api\Invoice;
/**
* Class Invoice
*
* @package PayPal\Test\Api
*/
class InvoiceTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object Invoice
* @return string
*/
public static function getJson()
{
return '{"id":"TestSample","number":"TestSample","uri":"TestSample","status":"TestSample","merchant_info":' .MerchantInfoTest::getJson() . ',"billing_info":' .BillingInfoTest::getJson() . ',"shipping_info":' .ShippingInfoTest::getJson() . ',"items":' .InvoiceItemTest::getJson() . ',"invoice_date":"TestSample","payment_term":' .PaymentTermTest::getJson() . ',"discount":' .CostTest::getJson() . ',"shipping_cost":' .ShippingCostTest::getJson() . ',"custom":' .CustomAmountTest::getJson() . ',"tax_calculated_after_discount":true,"tax_inclusive":true,"terms":"TestSample","note":"TestSample","merchant_memo":"TestSample","logo_url":"http://www.google.com","total_amount":' .CurrencyTest::getJson() . ',"payment_details":' .PaymentDetailTest::getJson() . ',"refund_details":' .RefundDetailTest::getJson() . ',"metadata":' .MetadataTest::getJson() . ',"additional_data":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return Invoice
*/
public static function getObject()
{
return new Invoice(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return Invoice
*/
public function testSerializationDeserialization()
{
$obj = new Invoice(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getNumber());
$this->assertNotNull($obj->getUri());
$this->assertNotNull($obj->getStatus());
$this->assertNotNull($obj->getMerchantInfo());
$this->assertNotNull($obj->getBillingInfo());
$this->assertNotNull($obj->getShippingInfo());
$this->assertNotNull($obj->getItems());
$this->assertNotNull($obj->getInvoiceDate());
$this->assertNotNull($obj->getPaymentTerm());
$this->assertNotNull($obj->getDiscount());
$this->assertNotNull($obj->getShippingCost());
$this->assertNotNull($obj->getCustom());
$this->assertNotNull($obj->getTaxCalculatedAfterDiscount());
$this->assertNotNull($obj->getTaxInclusive());
$this->assertNotNull($obj->getTerms());
$this->assertNotNull($obj->getNote());
$this->assertNotNull($obj->getMerchantMemo());
$this->assertNotNull($obj->getLogoUrl());
$this->assertNotNull($obj->getTotalAmount());
$this->assertNotNull($obj->getPaymentDetails());
$this->assertNotNull($obj->getRefundDetails());
$this->assertNotNull($obj->getMetadata());
$this->assertNotNull($obj->getAdditionalData());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Invoice $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getNumber(), "TestSample");
$this->assertEquals($obj->getUri(), "TestSample");
$this->assertEquals($obj->getStatus(), "TestSample");
$this->assertEquals($obj->getMerchantInfo(), MerchantInfoTest::getObject());
$this->assertEquals($obj->getBillingInfo(), BillingInfoTest::getObject());
$this->assertEquals($obj->getShippingInfo(), ShippingInfoTest::getObject());
$this->assertEquals($obj->getItems(), InvoiceItemTest::getObject());
$this->assertEquals($obj->getInvoiceDate(), "TestSample");
$this->assertEquals($obj->getPaymentTerm(), PaymentTermTest::getObject());
$this->assertEquals($obj->getDiscount(), CostTest::getObject());
$this->assertEquals($obj->getShippingCost(), ShippingCostTest::getObject());
$this->assertEquals($obj->getCustom(), CustomAmountTest::getObject());
$this->assertEquals($obj->getTaxCalculatedAfterDiscount(), true);
$this->assertEquals($obj->getTaxInclusive(), true);
$this->assertEquals($obj->getTerms(), "TestSample");
$this->assertEquals($obj->getNote(), "TestSample");
$this->assertEquals($obj->getMerchantMemo(), "TestSample");
$this->assertEquals($obj->getLogoUrl(), "http://www.google.com");
$this->assertEquals($obj->getTotalAmount(), CurrencyTest::getObject());
$this->assertEquals($obj->getPaymentDetails(), PaymentDetailTest::getObject());
$this->assertEquals($obj->getRefundDetails(), RefundDetailTest::getObject());
$this->assertEquals($obj->getMetadata(), MetadataTest::getObject());
$this->assertEquals($obj->getAdditionalData(), "TestSample");
}
/**
* @depends testSerializationDeserialization
* @param Invoice $obj
*/
public function testDeprecatedGetters($obj)
{
$this->assertEquals($obj->getMerchant_info(), MerchantInfoTest::getObject());
$this->assertEquals($obj->getBilling_info(), BillingInfoTest::getObject());
$this->assertEquals($obj->getShipping_info(), ShippingInfoTest::getObject());
$this->assertEquals($obj->getInvoice_date(), "TestSample");
$this->assertEquals($obj->getPayment_term(), PaymentTermTest::getObject());
$this->assertEquals($obj->getShipping_cost(), ShippingCostTest::getObject());
$this->assertEquals($obj->getTax_calculated_after_discount(), true);
$this->assertEquals($obj->getTax_inclusive(), true);
$this->assertEquals($obj->getMerchant_memo(), "TestSample");
$this->assertEquals($obj->getLogo_url(), "http://www.google.com");
$this->assertEquals($obj->getTotal_amount(), CurrencyTest::getObject());
$this->assertEquals($obj->getPayment_details(), PaymentDetailTest::getObject());
$this->assertEquals($obj->getRefund_details(), RefundDetailTest::getObject());
$this->assertEquals($obj->getAdditional_data(), "TestSample");
}
/**
* @depends testSerializationDeserialization
* @param Invoice $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
// Check for Merchant_info
$obj->setMerchantInfo(null);
$this->assertNull($obj->getMerchant_info());
$this->assertNull($obj->getMerchantInfo());
$this->assertSame($obj->getMerchantInfo(), $obj->getMerchant_info());
$obj->setMerchant_info(MerchantInfoTest::getObject());
$this->assertEquals($obj->getMerchant_info(), MerchantInfoTest::getObject());
// Check for Billing_info
$obj->setBillingInfo(null);
$this->assertNull($obj->getBilling_info());
$this->assertNull($obj->getBillingInfo());
$this->assertSame($obj->getBillingInfo(), $obj->getBilling_info());
$obj->setBilling_info(BillingInfoTest::getObject());
$this->assertEquals($obj->getBilling_info(), BillingInfoTest::getObject());
// Check for Shipping_info
$obj->setShippingInfo(null);
$this->assertNull($obj->getShipping_info());
$this->assertNull($obj->getShippingInfo());
$this->assertSame($obj->getShippingInfo(), $obj->getShipping_info());
$obj->setShipping_info(ShippingInfoTest::getObject());
$this->assertEquals($obj->getShipping_info(), ShippingInfoTest::getObject());
// Check for Invoice_date
$obj->setInvoiceDate(null);
$this->assertNull($obj->getInvoice_date());
$this->assertNull($obj->getInvoiceDate());
$this->assertSame($obj->getInvoiceDate(), $obj->getInvoice_date());
$obj->setInvoice_date("TestSample");
$this->assertEquals($obj->getInvoice_date(), "TestSample");
// Check for Payment_term
$obj->setPaymentTerm(null);
$this->assertNull($obj->getPayment_term());
$this->assertNull($obj->getPaymentTerm());
$this->assertSame($obj->getPaymentTerm(), $obj->getPayment_term());
$obj->setPayment_term(PaymentTermTest::getObject());
$this->assertEquals($obj->getPayment_term(), PaymentTermTest::getObject());
// Check for Shipping_cost
$obj->setShippingCost(null);
$this->assertNull($obj->getShipping_cost());
$this->assertNull($obj->getShippingCost());
$this->assertSame($obj->getShippingCost(), $obj->getShipping_cost());
$obj->setShipping_cost(ShippingCostTest::getObject());
$this->assertEquals($obj->getShipping_cost(), ShippingCostTest::getObject());
// Check for Tax_calculated_after_discount
$obj->setTaxCalculatedAfterDiscount(null);
$this->assertNull($obj->getTax_calculated_after_discount());
$this->assertNull($obj->getTaxCalculatedAfterDiscount());
$this->assertSame($obj->getTaxCalculatedAfterDiscount(), $obj->getTax_calculated_after_discount());
$obj->setTax_calculated_after_discount(true);
$this->assertEquals($obj->getTax_calculated_after_discount(), true);
// Check for Tax_inclusive
$obj->setTaxInclusive(null);
$this->assertNull($obj->getTax_inclusive());
$this->assertNull($obj->getTaxInclusive());
$this->assertSame($obj->getTaxInclusive(), $obj->getTax_inclusive());
$obj->setTax_inclusive(true);
$this->assertEquals($obj->getTax_inclusive(), true);
// Check for Merchant_memo
$obj->setMerchantMemo(null);
$this->assertNull($obj->getMerchant_memo());
$this->assertNull($obj->getMerchantMemo());
$this->assertSame($obj->getMerchantMemo(), $obj->getMerchant_memo());
$obj->setMerchant_memo("TestSample");
$this->assertEquals($obj->getMerchant_memo(), "TestSample");
// Check for Total_amount
$obj->setTotalAmount(null);
$this->assertNull($obj->getTotal_amount());
$this->assertNull($obj->getTotalAmount());
$this->assertSame($obj->getTotalAmount(), $obj->getTotal_amount());
$obj->setTotal_amount(CurrencyTest::getObject());
$this->assertEquals($obj->getTotal_amount(), CurrencyTest::getObject());
// Check for Payment_details
$obj->setPaymentDetails(null);
$this->assertNull($obj->getPayment_details());
$this->assertNull($obj->getPaymentDetails());
$this->assertSame($obj->getPaymentDetails(), $obj->getPayment_details());
$obj->setPayment_details(PaymentDetailTest::getObject());
$this->assertEquals($obj->getPayment_details(), PaymentDetailTest::getObject());
// Check for Refund_details
$obj->setRefundDetails(null);
$this->assertNull($obj->getRefund_details());
$this->assertNull($obj->getRefundDetails());
$this->assertSame($obj->getRefundDetails(), $obj->getRefund_details());
$obj->setRefund_details(RefundDetailTest::getObject());
$this->assertEquals($obj->getRefund_details(), RefundDetailTest::getObject());
// Check for Additional_data
$obj->setAdditionalData(null);
$this->assertNull($obj->getAdditional_data());
$this->assertNull($obj->getAdditionalData());
$this->assertSame($obj->getAdditionalData(), $obj->getAdditional_data());
$obj->setAdditional_data("TestSample");
$this->assertEquals($obj->getAdditional_data(), "TestSample");
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage LogoUrl is not a fully qualified URL
*/
public function testUrlValidationForLogoUrl()
{
$obj = new Invoice();
$obj->setLogoUrl(null);
}
public function testUrlValidationForLogoUrlDeprecated()
{
$obj = new Invoice();
$obj->setLogo_url(null);
$this->assertNull($obj->getLogo_url());
}
/**
* @dataProvider mockProvider
* @param Invoice $obj
*/
public function testCreate($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
));
$result = $obj->create($mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Invoice $obj
*/
public function testSearch($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
InvoiceSearchResponseTest::getJson()
));
$search = SearchTest::getObject();
$result = $obj->search($search, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Invoice $obj
*/
public function testSend($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
true
));
$result = $obj->send($mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Invoice $obj
*/
public function testRemind($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
true
));
$notification = NotificationTest::getObject();
$result = $obj->remind($notification, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Invoice $obj
*/
public function testCancel($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
true
));
$cancelNotification = CancelNotificationTest::getObject();
$result = $obj->cancel($cancelNotification, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Invoice $obj
*/
public function testRecordPayment($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
true
));
$paymentDetail = PaymentDetailTest::getObject();
$result = $obj->recordPayment($paymentDetail, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Invoice $obj
*/
public function testRecordRefund($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
true
));
$refundDetail = RefundDetailTest::getObject();
$result = $obj->recordRefund($refundDetail, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Invoice $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
InvoiceTest::getJson()
));
$result = $obj->get("invoiceId", $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Invoice $obj
*/
public function testGetAll($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
InvoiceSearchResponseTest::getJson()
));
$result = $obj->getAll(array(), $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Invoice $obj
*/
public function testUpdate($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
));
$result = $obj->update($mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Invoice $obj
*/
public function testDelete($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
true
));
$result = $obj->delete($mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Invoice $obj
*/
public function testQrCode($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
ImageTest::getJson()
));
$result = $obj->qrCode("invoiceId", array(), $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,141 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\MerchantInfo;
/**
* Class MerchantInfo
*
* @package PayPal\Test\Api
*/
class MerchantInfoTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object MerchantInfo
* @return string
*/
public static function getJson()
{
return '{"email":"TestSample","first_name":"TestSample","last_name":"TestSample","address":' .AddressTest::getJson() . ',"business_name":"TestSample","phone":' .PhoneTest::getJson() . ',"fax":' .PhoneTest::getJson() . ',"website":"TestSample","tax_id":"TestSample","additional_info":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return MerchantInfo
*/
public static function getObject()
{
return new MerchantInfo(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return MerchantInfo
*/
public function testSerializationDeserialization()
{
$obj = new MerchantInfo(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getEmail());
$this->assertNotNull($obj->getFirstName());
$this->assertNotNull($obj->getLastName());
$this->assertNotNull($obj->getAddress());
$this->assertNotNull($obj->getBusinessName());
$this->assertNotNull($obj->getPhone());
$this->assertNotNull($obj->getFax());
$this->assertNotNull($obj->getWebsite());
$this->assertNotNull($obj->getTaxId());
$this->assertNotNull($obj->getAdditionalInfo());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param MerchantInfo $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getEmail(), "TestSample");
$this->assertEquals($obj->getFirstName(), "TestSample");
$this->assertEquals($obj->getLastName(), "TestSample");
$this->assertEquals($obj->getAddress(), AddressTest::getObject());
$this->assertEquals($obj->getBusinessName(), "TestSample");
$this->assertEquals($obj->getPhone(), PhoneTest::getObject());
$this->assertEquals($obj->getFax(), PhoneTest::getObject());
$this->assertEquals($obj->getWebsite(), "TestSample");
$this->assertEquals($obj->getTaxId(), "TestSample");
$this->assertEquals($obj->getAdditionalInfo(), "TestSample");
}
/**
* @depends testSerializationDeserialization
* @param MerchantInfo $obj
*/
public function testDeprecatedGetters($obj)
{
$this->assertEquals($obj->getFirst_name(), "TestSample");
$this->assertEquals($obj->getLast_name(), "TestSample");
$this->assertEquals($obj->getBusiness_name(), "TestSample");
$this->assertEquals($obj->getTax_id(), "TestSample");
$this->assertEquals($obj->getAdditional_info(), "TestSample");
}
/**
* @depends testSerializationDeserialization
* @param MerchantInfo $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
// Check for First_name
$obj->setFirstName(null);
$this->assertNull($obj->getFirst_name());
$this->assertNull($obj->getFirstName());
$this->assertSame($obj->getFirstName(), $obj->getFirst_name());
$obj->setFirst_name("TestSample");
$this->assertEquals($obj->getFirst_name(), "TestSample");
// Check for Last_name
$obj->setLastName(null);
$this->assertNull($obj->getLast_name());
$this->assertNull($obj->getLastName());
$this->assertSame($obj->getLastName(), $obj->getLast_name());
$obj->setLast_name("TestSample");
$this->assertEquals($obj->getLast_name(), "TestSample");
// Check for Business_name
$obj->setBusinessName(null);
$this->assertNull($obj->getBusiness_name());
$this->assertNull($obj->getBusinessName());
$this->assertSame($obj->getBusinessName(), $obj->getBusiness_name());
$obj->setBusiness_name("TestSample");
$this->assertEquals($obj->getBusiness_name(), "TestSample");
// Check for Tax_id
$obj->setTaxId(null);
$this->assertNull($obj->getTax_id());
$this->assertNull($obj->getTaxId());
$this->assertSame($obj->getTaxId(), $obj->getTax_id());
$obj->setTax_id("TestSample");
$this->assertEquals($obj->getTax_id(), "TestSample");
// Check for Additional_info
$obj->setAdditionalInfo(null);
$this->assertNull($obj->getAdditional_info());
$this->assertNull($obj->getAdditionalInfo());
$this->assertSame($obj->getAdditionalInfo(), $obj->getAdditional_info());
$obj->setAdditional_info("TestSample");
$this->assertEquals($obj->getAdditional_info(), "TestSample");
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -0,0 +1,193 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\Metadata;
/**
* Class Metadata
*
* @package PayPal\Test\Api
*/
class MetadataTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object Metadata
* @return string
*/
public static function getJson()
{
return '{"created_date":"TestSample","created_by":"TestSample","cancelled_date":"TestSample","cancelled_by":"TestSample","last_updated_date":"TestSample","last_updated_by":"TestSample","first_sent_date":"TestSample","last_sent_date":"TestSample","last_sent_by":"TestSample","payer_view_url":"http://www.google.com"}';
}
/**
* Gets Object Instance with Json data filled in
* @return Metadata
*/
public static function getObject()
{
return new Metadata(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return Metadata
*/
public function testSerializationDeserialization()
{
$obj = new Metadata(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getCreatedDate());
$this->assertNotNull($obj->getCreatedBy());
$this->assertNotNull($obj->getCancelledDate());
$this->assertNotNull($obj->getCancelledBy());
$this->assertNotNull($obj->getLastUpdatedDate());
$this->assertNotNull($obj->getLastUpdatedBy());
$this->assertNotNull($obj->getFirstSentDate());
$this->assertNotNull($obj->getLastSentDate());
$this->assertNotNull($obj->getLastSentBy());
$this->assertNotNull($obj->getPayerViewUrl());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Metadata $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getCreatedDate(), "TestSample");
$this->assertEquals($obj->getCreatedBy(), "TestSample");
$this->assertEquals($obj->getCancelledDate(), "TestSample");
$this->assertEquals($obj->getCancelledBy(), "TestSample");
$this->assertEquals($obj->getLastUpdatedDate(), "TestSample");
$this->assertEquals($obj->getLastUpdatedBy(), "TestSample");
$this->assertEquals($obj->getFirstSentDate(), "TestSample");
$this->assertEquals($obj->getLastSentDate(), "TestSample");
$this->assertEquals($obj->getLastSentBy(), "TestSample");
$this->assertEquals($obj->getPayerViewUrl(), "http://www.google.com");
}
/**
* @depends testSerializationDeserialization
* @param Metadata $obj
*/
public function testDeprecatedGetters($obj)
{
$this->assertEquals($obj->getCreated_date(), "TestSample");
$this->assertEquals($obj->getCreated_by(), "TestSample");
$this->assertEquals($obj->getCancelled_date(), "TestSample");
$this->assertEquals($obj->getCancelled_by(), "TestSample");
$this->assertEquals($obj->getLast_updated_date(), "TestSample");
$this->assertEquals($obj->getLast_updated_by(), "TestSample");
$this->assertEquals($obj->getFirst_sent_date(), "TestSample");
$this->assertEquals($obj->getLast_sent_date(), "TestSample");
$this->assertEquals($obj->getLast_sent_by(), "TestSample");
$this->assertEquals($obj->getPayer_view_url(), "http://www.google.com");
}
/**
* @depends testSerializationDeserialization
* @param Metadata $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
// Check for Created_date
$obj->setCreatedDate(null);
$this->assertNull($obj->getCreated_date());
$this->assertNull($obj->getCreatedDate());
$this->assertSame($obj->getCreatedDate(), $obj->getCreated_date());
$obj->setCreated_date("TestSample");
$this->assertEquals($obj->getCreated_date(), "TestSample");
// Check for Created_by
$obj->setCreatedBy(null);
$this->assertNull($obj->getCreated_by());
$this->assertNull($obj->getCreatedBy());
$this->assertSame($obj->getCreatedBy(), $obj->getCreated_by());
$obj->setCreated_by("TestSample");
$this->assertEquals($obj->getCreated_by(), "TestSample");
// Check for Cancelled_date
$obj->setCancelledDate(null);
$this->assertNull($obj->getCancelled_date());
$this->assertNull($obj->getCancelledDate());
$this->assertSame($obj->getCancelledDate(), $obj->getCancelled_date());
$obj->setCancelled_date("TestSample");
$this->assertEquals($obj->getCancelled_date(), "TestSample");
// Check for Cancelled_by
$obj->setCancelledBy(null);
$this->assertNull($obj->getCancelled_by());
$this->assertNull($obj->getCancelledBy());
$this->assertSame($obj->getCancelledBy(), $obj->getCancelled_by());
$obj->setCancelled_by("TestSample");
$this->assertEquals($obj->getCancelled_by(), "TestSample");
// Check for Last_updated_date
$obj->setLastUpdatedDate(null);
$this->assertNull($obj->getLast_updated_date());
$this->assertNull($obj->getLastUpdatedDate());
$this->assertSame($obj->getLastUpdatedDate(), $obj->getLast_updated_date());
$obj->setLast_updated_date("TestSample");
$this->assertEquals($obj->getLast_updated_date(), "TestSample");
// Check for Last_updated_by
$obj->setLastUpdatedBy(null);
$this->assertNull($obj->getLast_updated_by());
$this->assertNull($obj->getLastUpdatedBy());
$this->assertSame($obj->getLastUpdatedBy(), $obj->getLast_updated_by());
$obj->setLast_updated_by("TestSample");
$this->assertEquals($obj->getLast_updated_by(), "TestSample");
// Check for First_sent_date
$obj->setFirstSentDate(null);
$this->assertNull($obj->getFirst_sent_date());
$this->assertNull($obj->getFirstSentDate());
$this->assertSame($obj->getFirstSentDate(), $obj->getFirst_sent_date());
$obj->setFirst_sent_date("TestSample");
$this->assertEquals($obj->getFirst_sent_date(), "TestSample");
// Check for Last_sent_date
$obj->setLastSentDate(null);
$this->assertNull($obj->getLast_sent_date());
$this->assertNull($obj->getLastSentDate());
$this->assertSame($obj->getLastSentDate(), $obj->getLast_sent_date());
$obj->setLast_sent_date("TestSample");
$this->assertEquals($obj->getLast_sent_date(), "TestSample");
// Check for Last_sent_by
$obj->setLastSentBy(null);
$this->assertNull($obj->getLast_sent_by());
$this->assertNull($obj->getLastSentBy());
$this->assertSame($obj->getLastSentBy(), $obj->getLast_sent_by());
$obj->setLast_sent_by("TestSample");
$this->assertEquals($obj->getLast_sent_by(), "TestSample");
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage PayerViewUrl is not a fully qualified URL
*/
public function testUrlValidationForPayerViewUrl()
{
$obj = new Metadata();
$obj->setPayerViewUrl(null);
}
public function testUrlValidationForPayerViewUrlDeprecated()
{
$obj = new Metadata();
$obj->setPayer_view_url(null);
$this->assertNull($obj->getPayer_view_url());
}
}

View File

@@ -0,0 +1,91 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\Notification;
/**
* Class Notification
*
* @package PayPal\Test\Api
*/
class NotificationTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object Notification
* @return string
*/
public static function getJson()
{
return '{"subject":"TestSample","note":"TestSample","send_to_merchant":true}';
}
/**
* Gets Object Instance with Json data filled in
* @return Notification
*/
public static function getObject()
{
return new Notification(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return Notification
*/
public function testSerializationDeserialization()
{
$obj = new Notification(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getSubject());
$this->assertNotNull($obj->getNote());
$this->assertNotNull($obj->getSendToMerchant());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Notification $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getSubject(), "TestSample");
$this->assertEquals($obj->getNote(), "TestSample");
$this->assertEquals($obj->getSendToMerchant(), true);
}
/**
* @depends testSerializationDeserialization
* @param Notification $obj
*/
public function testDeprecatedGetters($obj)
{
$this->assertEquals($obj->getSend_to_merchant(), true);
}
/**
* @depends testSerializationDeserialization
* @param Notification $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
// Check for Send_to_merchant
$obj->setSendToMerchant(null);
$this->assertNull($obj->getSend_to_merchant());
$this->assertNull($obj->getSendToMerchant());
$this->assertSame($obj->getSendToMerchant(), $obj->getSend_to_merchant());
$obj->setSend_to_merchant(true);
$this->assertEquals($obj->getSend_to_merchant(), true);
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\PaymentDetail;
/**
* Class PaymentDetail
*
* @package PayPal\Test\Api
*/
class PaymentDetailTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object PaymentDetail
* @return string
*/
public static function getJson()
{
return '{"type":"TestSample","transaction_id":"TestSample","transaction_type":"TestSample","date":"TestSample","method":"TestSample","note":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return PaymentDetail
*/
public static function getObject()
{
return new PaymentDetail(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return PaymentDetail
*/
public function testSerializationDeserialization()
{
$obj = new PaymentDetail(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getType());
$this->assertNotNull($obj->getTransactionId());
$this->assertNotNull($obj->getTransactionType());
$this->assertNotNull($obj->getDate());
$this->assertNotNull($obj->getMethod());
$this->assertNotNull($obj->getNote());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param PaymentDetail $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getType(), "TestSample");
$this->assertEquals($obj->getTransactionId(), "TestSample");
$this->assertEquals($obj->getTransactionType(), "TestSample");
$this->assertEquals($obj->getDate(), "TestSample");
$this->assertEquals($obj->getMethod(), "TestSample");
$this->assertEquals($obj->getNote(), "TestSample");
}
/**
* @depends testSerializationDeserialization
* @param PaymentDetail $obj
*/
public function testDeprecatedGetters($obj)
{
$this->assertEquals($obj->getTransaction_id(), "TestSample");
$this->assertEquals($obj->getTransaction_type(), "TestSample");
}
/**
* @depends testSerializationDeserialization
* @param PaymentDetail $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
// 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_type
$obj->setTransactionType(null);
$this->assertNull($obj->getTransaction_type());
$this->assertNull($obj->getTransactionType());
$this->assertSame($obj->getTransactionType(), $obj->getTransaction_type());
$obj->setTransaction_type("TestSample");
$this->assertEquals($obj->getTransaction_type(), "TestSample");
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -0,0 +1,98 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\PaymentTerm;
/**
* Class PaymentTerm
*
* @package PayPal\Test\Api
*/
class PaymentTermTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object PaymentTerm
* @return string
*/
public static function getJson()
{
return '{"term_type":"TestSample","due_date":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return PaymentTerm
*/
public static function getObject()
{
return new PaymentTerm(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return PaymentTerm
*/
public function testSerializationDeserialization()
{
$obj = new PaymentTerm(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getTermType());
$this->assertNotNull($obj->getDueDate());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param PaymentTerm $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getTermType(), "TestSample");
$this->assertEquals($obj->getDueDate(), "TestSample");
}
/**
* @depends testSerializationDeserialization
* @param PaymentTerm $obj
*/
public function testDeprecatedGetters($obj)
{
$this->assertEquals($obj->getTerm_type(), "TestSample");
$this->assertEquals($obj->getDue_date(), "TestSample");
}
/**
* @depends testSerializationDeserialization
* @param PaymentTerm $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
// Check for Term_type
$obj->setTermType(null);
$this->assertNull($obj->getTerm_type());
$this->assertNull($obj->getTermType());
$this->assertSame($obj->getTermType(), $obj->getTerm_type());
$obj->setTerm_type("TestSample");
$this->assertEquals($obj->getTerm_type(), "TestSample");
// Check for Due_date
$obj->setDueDate(null);
$this->assertNull($obj->getDue_date());
$this->assertNull($obj->getDueDate());
$this->assertSame($obj->getDueDate(), $obj->getDue_date());
$obj->setDue_date("TestSample");
$this->assertEquals($obj->getDue_date(), "TestSample");
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -0,0 +1,98 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\Phone;
/**
* Class Phone
*
* @package PayPal\Test\Api
*/
class PhoneTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object Phone
* @return string
*/
public static function getJson()
{
return '{"country_code":"TestSample","national_number":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return Phone
*/
public static function getObject()
{
return new Phone(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return Phone
*/
public function testSerializationDeserialization()
{
$obj = new Phone(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getCountryCode());
$this->assertNotNull($obj->getNationalNumber());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Phone $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getCountryCode(), "TestSample");
$this->assertEquals($obj->getNationalNumber(), "TestSample");
}
/**
* @depends testSerializationDeserialization
* @param Phone $obj
*/
public function testDeprecatedGetters($obj)
{
$this->assertEquals($obj->getCountry_code(), "TestSample");
$this->assertEquals($obj->getNational_number(), "TestSample");
}
/**
* @depends testSerializationDeserialization
* @param Phone $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
// Check for Country_code
$obj->setCountryCode(null);
$this->assertNull($obj->getCountry_code());
$this->assertNull($obj->getCountryCode());
$this->assertSame($obj->getCountryCode(), $obj->getCountry_code());
$obj->setCountry_code("TestSample");
$this->assertEquals($obj->getCountry_code(), "TestSample");
// Check for National_number
$obj->setNationalNumber(null);
$this->assertNull($obj->getNational_number());
$this->assertNull($obj->getNationalNumber());
$this->assertSame($obj->getNationalNumber(), $obj->getNational_number());
$obj->setNational_number("TestSample");
$this->assertEquals($obj->getNational_number(), "TestSample");
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -0,0 +1,82 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\RefundDetail;
/**
* Class RefundDetail
*
* @package PayPal\Test\Api
*/
class RefundDetailTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object RefundDetail
* @return string
*/
public static function getJson()
{
return '{"type":"TestSample","date":"TestSample","note":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return RefundDetail
*/
public static function getObject()
{
return new RefundDetail(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return RefundDetail
*/
public function testSerializationDeserialization()
{
$obj = new RefundDetail(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getType());
$this->assertNotNull($obj->getDate());
$this->assertNotNull($obj->getNote());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param RefundDetail $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getType(), "TestSample");
$this->assertEquals($obj->getDate(), "TestSample");
$this->assertEquals($obj->getNote(), "TestSample");
}
/**
* @depends testSerializationDeserialization
* @param RefundDetail $obj
*/
public function testDeprecatedGetters($obj)
{
}
/**
* @depends testSerializationDeserialization
* @param RefundDetail $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -0,0 +1,249 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\Search;
/**
* Class Search
*
* @package PayPal\Test\Api
*/
class SearchTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object Search
* @return string
*/
public static function getJson()
{
return '{"email":"TestSample","recipient_first_name":"TestSample","recipient_last_name":"TestSample","recipient_business_name":"TestSample","number":"TestSample","status":"TestSample","lower_total_amount":' .CurrencyTest::getJson() . ',"upper_total_amount":' .CurrencyTest::getJson() . ',"start_invoice_date":"TestSample","end_invoice_date":"TestSample","start_due_date":"TestSample","end_due_date":"TestSample","start_payment_date":"TestSample","end_payment_date":"TestSample","start_creation_date":"TestSample","end_creation_date":"TestSample","page":"12.34","page_size":"12.34","total_count_required":true}';
}
/**
* Gets Object Instance with Json data filled in
* @return Search
*/
public static function getObject()
{
return new Search(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return Search
*/
public function testSerializationDeserialization()
{
$obj = new Search(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getEmail());
$this->assertNotNull($obj->getRecipientFirstName());
$this->assertNotNull($obj->getRecipientLastName());
$this->assertNotNull($obj->getRecipientBusinessName());
$this->assertNotNull($obj->getNumber());
$this->assertNotNull($obj->getStatus());
$this->assertNotNull($obj->getLowerTotalAmount());
$this->assertNotNull($obj->getUpperTotalAmount());
$this->assertNotNull($obj->getStartInvoiceDate());
$this->assertNotNull($obj->getEndInvoiceDate());
$this->assertNotNull($obj->getStartDueDate());
$this->assertNotNull($obj->getEndDueDate());
$this->assertNotNull($obj->getStartPaymentDate());
$this->assertNotNull($obj->getEndPaymentDate());
$this->assertNotNull($obj->getStartCreationDate());
$this->assertNotNull($obj->getEndCreationDate());
$this->assertNotNull($obj->getPage());
$this->assertNotNull($obj->getPageSize());
$this->assertNotNull($obj->getTotalCountRequired());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Search $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getEmail(), "TestSample");
$this->assertEquals($obj->getRecipientFirstName(), "TestSample");
$this->assertEquals($obj->getRecipientLastName(), "TestSample");
$this->assertEquals($obj->getRecipientBusinessName(), "TestSample");
$this->assertEquals($obj->getNumber(), "TestSample");
$this->assertEquals($obj->getStatus(), "TestSample");
$this->assertEquals($obj->getLowerTotalAmount(), CurrencyTest::getObject());
$this->assertEquals($obj->getUpperTotalAmount(), CurrencyTest::getObject());
$this->assertEquals($obj->getStartInvoiceDate(), "TestSample");
$this->assertEquals($obj->getEndInvoiceDate(), "TestSample");
$this->assertEquals($obj->getStartDueDate(), "TestSample");
$this->assertEquals($obj->getEndDueDate(), "TestSample");
$this->assertEquals($obj->getStartPaymentDate(), "TestSample");
$this->assertEquals($obj->getEndPaymentDate(), "TestSample");
$this->assertEquals($obj->getStartCreationDate(), "TestSample");
$this->assertEquals($obj->getEndCreationDate(), "TestSample");
$this->assertEquals($obj->getPage(), "12.34");
$this->assertEquals($obj->getPageSize(), "12.34");
$this->assertEquals($obj->getTotalCountRequired(), true);
}
/**
* @depends testSerializationDeserialization
* @param Search $obj
*/
public function testDeprecatedGetters($obj)
{
$this->assertEquals($obj->getRecipient_first_name(), "TestSample");
$this->assertEquals($obj->getRecipient_last_name(), "TestSample");
$this->assertEquals($obj->getRecipient_business_name(), "TestSample");
$this->assertEquals($obj->getLower_total_amount(), CurrencyTest::getObject());
$this->assertEquals($obj->getUpper_total_amount(), CurrencyTest::getObject());
$this->assertEquals($obj->getStart_invoice_date(), "TestSample");
$this->assertEquals($obj->getEnd_invoice_date(), "TestSample");
$this->assertEquals($obj->getStart_due_date(), "TestSample");
$this->assertEquals($obj->getEnd_due_date(), "TestSample");
$this->assertEquals($obj->getStart_payment_date(), "TestSample");
$this->assertEquals($obj->getEnd_payment_date(), "TestSample");
$this->assertEquals($obj->getStart_creation_date(), "TestSample");
$this->assertEquals($obj->getEnd_creation_date(), "TestSample");
$this->assertEquals($obj->getPage_size(), "12.34");
$this->assertEquals($obj->getTotal_count_required(), true);
}
/**
* @depends testSerializationDeserialization
* @param Search $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
// Check for Recipient_first_name
$obj->setRecipientFirstName(null);
$this->assertNull($obj->getRecipient_first_name());
$this->assertNull($obj->getRecipientFirstName());
$this->assertSame($obj->getRecipientFirstName(), $obj->getRecipient_first_name());
$obj->setRecipient_first_name("TestSample");
$this->assertEquals($obj->getRecipient_first_name(), "TestSample");
// Check for Recipient_last_name
$obj->setRecipientLastName(null);
$this->assertNull($obj->getRecipient_last_name());
$this->assertNull($obj->getRecipientLastName());
$this->assertSame($obj->getRecipientLastName(), $obj->getRecipient_last_name());
$obj->setRecipient_last_name("TestSample");
$this->assertEquals($obj->getRecipient_last_name(), "TestSample");
// Check for Recipient_business_name
$obj->setRecipientBusinessName(null);
$this->assertNull($obj->getRecipient_business_name());
$this->assertNull($obj->getRecipientBusinessName());
$this->assertSame($obj->getRecipientBusinessName(), $obj->getRecipient_business_name());
$obj->setRecipient_business_name("TestSample");
$this->assertEquals($obj->getRecipient_business_name(), "TestSample");
// Check for Lower_total_amount
$obj->setLowerTotalAmount(null);
$this->assertNull($obj->getLower_total_amount());
$this->assertNull($obj->getLowerTotalAmount());
$this->assertSame($obj->getLowerTotalAmount(), $obj->getLower_total_amount());
$obj->setLower_total_amount(CurrencyTest::getObject());
$this->assertEquals($obj->getLower_total_amount(), CurrencyTest::getObject());
// Check for Upper_total_amount
$obj->setUpperTotalAmount(null);
$this->assertNull($obj->getUpper_total_amount());
$this->assertNull($obj->getUpperTotalAmount());
$this->assertSame($obj->getUpperTotalAmount(), $obj->getUpper_total_amount());
$obj->setUpper_total_amount(CurrencyTest::getObject());
$this->assertEquals($obj->getUpper_total_amount(), CurrencyTest::getObject());
// Check for Start_invoice_date
$obj->setStartInvoiceDate(null);
$this->assertNull($obj->getStart_invoice_date());
$this->assertNull($obj->getStartInvoiceDate());
$this->assertSame($obj->getStartInvoiceDate(), $obj->getStart_invoice_date());
$obj->setStart_invoice_date("TestSample");
$this->assertEquals($obj->getStart_invoice_date(), "TestSample");
// Check for End_invoice_date
$obj->setEndInvoiceDate(null);
$this->assertNull($obj->getEnd_invoice_date());
$this->assertNull($obj->getEndInvoiceDate());
$this->assertSame($obj->getEndInvoiceDate(), $obj->getEnd_invoice_date());
$obj->setEnd_invoice_date("TestSample");
$this->assertEquals($obj->getEnd_invoice_date(), "TestSample");
// Check for Start_due_date
$obj->setStartDueDate(null);
$this->assertNull($obj->getStart_due_date());
$this->assertNull($obj->getStartDueDate());
$this->assertSame($obj->getStartDueDate(), $obj->getStart_due_date());
$obj->setStart_due_date("TestSample");
$this->assertEquals($obj->getStart_due_date(), "TestSample");
// Check for End_due_date
$obj->setEndDueDate(null);
$this->assertNull($obj->getEnd_due_date());
$this->assertNull($obj->getEndDueDate());
$this->assertSame($obj->getEndDueDate(), $obj->getEnd_due_date());
$obj->setEnd_due_date("TestSample");
$this->assertEquals($obj->getEnd_due_date(), "TestSample");
// Check for Start_payment_date
$obj->setStartPaymentDate(null);
$this->assertNull($obj->getStart_payment_date());
$this->assertNull($obj->getStartPaymentDate());
$this->assertSame($obj->getStartPaymentDate(), $obj->getStart_payment_date());
$obj->setStart_payment_date("TestSample");
$this->assertEquals($obj->getStart_payment_date(), "TestSample");
// Check for End_payment_date
$obj->setEndPaymentDate(null);
$this->assertNull($obj->getEnd_payment_date());
$this->assertNull($obj->getEndPaymentDate());
$this->assertSame($obj->getEndPaymentDate(), $obj->getEnd_payment_date());
$obj->setEnd_payment_date("TestSample");
$this->assertEquals($obj->getEnd_payment_date(), "TestSample");
// Check for Start_creation_date
$obj->setStartCreationDate(null);
$this->assertNull($obj->getStart_creation_date());
$this->assertNull($obj->getStartCreationDate());
$this->assertSame($obj->getStartCreationDate(), $obj->getStart_creation_date());
$obj->setStart_creation_date("TestSample");
$this->assertEquals($obj->getStart_creation_date(), "TestSample");
// Check for End_creation_date
$obj->setEndCreationDate(null);
$this->assertNull($obj->getEnd_creation_date());
$this->assertNull($obj->getEndCreationDate());
$this->assertSame($obj->getEndCreationDate(), $obj->getEnd_creation_date());
$obj->setEnd_creation_date("TestSample");
$this->assertEquals($obj->getEnd_creation_date(), "TestSample");
// Check for Page_size
$obj->setPageSize(null);
$this->assertNull($obj->getPage_size());
$this->assertNull($obj->getPageSize());
$this->assertSame($obj->getPageSize(), $obj->getPage_size());
$obj->setPage_size("12.34");
$this->assertEquals($obj->getPage_size(), "12.34");
// Check for Total_count_required
$obj->setTotalCountRequired(null);
$this->assertNull($obj->getTotal_count_required());
$this->assertNull($obj->getTotalCountRequired());
$this->assertSame($obj->getTotalCountRequired(), $obj->getTotal_count_required());
$obj->setTotal_count_required(true);
$this->assertEquals($obj->getTotal_count_required(), true);
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -0,0 +1,80 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\ShippingCost;
/**
* Class ShippingCost
*
* @package PayPal\Test\Api
*/
class ShippingCostTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object ShippingCost
* @return string
*/
public static function getJson()
{
return '{"amount":' .CurrencyTest::getJson() . ',"tax":' .TaxTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return ShippingCost
*/
public static function getObject()
{
return new ShippingCost(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return ShippingCost
*/
public function testSerializationDeserialization()
{
$obj = new ShippingCost(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getAmount());
$this->assertNotNull($obj->getTax());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param ShippingCost $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getAmount(), CurrencyTest::getObject());
$this->assertEquals($obj->getTax(), TaxTest::getObject());
}
/**
* @depends testSerializationDeserialization
* @param ShippingCost $obj
*/
public function testDeprecatedGetters($obj)
{
}
/**
* @depends testSerializationDeserialization
* @param ShippingCost $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -0,0 +1,111 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\ShippingInfo;
/**
* Class ShippingInfo
*
* @package PayPal\Test\Api
*/
class ShippingInfoTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object ShippingInfo
* @return string
*/
public static function getJson()
{
return '{"first_name":"TestSample","last_name":"TestSample","business_name":"TestSample","address":' .AddressTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return ShippingInfo
*/
public static function getObject()
{
return new ShippingInfo(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return ShippingInfo
*/
public function testSerializationDeserialization()
{
$obj = new ShippingInfo(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getFirstName());
$this->assertNotNull($obj->getLastName());
$this->assertNotNull($obj->getBusinessName());
$this->assertNotNull($obj->getAddress());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param ShippingInfo $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getFirstName(), "TestSample");
$this->assertEquals($obj->getLastName(), "TestSample");
$this->assertEquals($obj->getBusinessName(), "TestSample");
$this->assertEquals($obj->getAddress(), AddressTest::getObject());
}
/**
* @depends testSerializationDeserialization
* @param ShippingInfo $obj
*/
public function testDeprecatedGetters($obj)
{
$this->assertEquals($obj->getFirst_name(), "TestSample");
$this->assertEquals($obj->getLast_name(), "TestSample");
$this->assertEquals($obj->getBusiness_name(), "TestSample");
}
/**
* @depends testSerializationDeserialization
* @param ShippingInfo $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
// Check for First_name
$obj->setFirstName(null);
$this->assertNull($obj->getFirst_name());
$this->assertNull($obj->getFirstName());
$this->assertSame($obj->getFirstName(), $obj->getFirst_name());
$obj->setFirst_name("TestSample");
$this->assertEquals($obj->getFirst_name(), "TestSample");
// Check for Last_name
$obj->setLastName(null);
$this->assertNull($obj->getLast_name());
$this->assertNull($obj->getLastName());
$this->assertSame($obj->getLastName(), $obj->getLast_name());
$obj->setLast_name("TestSample");
$this->assertEquals($obj->getLast_name(), "TestSample");
// Check for Business_name
$obj->setBusinessName(null);
$this->assertNull($obj->getBusiness_name());
$this->assertNull($obj->getBusinessName());
$this->assertSame($obj->getBusinessName(), $obj->getBusiness_name());
$obj->setBusiness_name("TestSample");
$this->assertEquals($obj->getBusiness_name(), "TestSample");
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -0,0 +1,84 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PPModel;
use PayPal\Api\Tax;
/**
* Class Tax
*
* @package PayPal\Test\Api
*/
class TaxTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object Tax
* @return string
*/
public static function getJson()
{
return '{"id":"TestSample","name":"TestSample","percent":"12.34","amount":' .CurrencyTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return Tax
*/
public static function getObject()
{
return new Tax(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return Tax
*/
public function testSerializationDeserialization()
{
$obj = new Tax(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getName());
$this->assertNotNull($obj->getPercent());
$this->assertNotNull($obj->getAmount());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Tax $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getName(), "TestSample");
$this->assertEquals($obj->getPercent(), "12.34");
$this->assertEquals($obj->getAmount(), CurrencyTest::getObject());
}
/**
* @depends testSerializationDeserialization
* @param Tax $obj
*/
public function testDeprecatedGetters($obj)
{
}
/**
* @depends testSerializationDeserialization
* @param Tax $obj
*/
public function testDeprecatedSetterNormalGetter($obj)
{
//Test All Deprecated Getters and Normal Getters
$this->testDeprecatedGetters($obj);
$this->testGetters($obj);
}
}

View File

@@ -0,0 +1,252 @@
<?php
namespace PayPal\Test\Functional\Api;
use PayPal\Api\CancelNotification;
use PayPal\Api\Invoice;
use PayPal\Api\Notification;
use PayPal\Api\PaymentDetail;
use PayPal\Api\RefundDetail;
use PayPal\Api\Search;
/**
* Class Invoice
*
* @package PayPal\Test\Api
*/
class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
{
public static $obj;
public $operation;
public $response;
public $mode = 'mock';
public $mockPPRestCall;
public function setUp()
{
$className = $this->getClassName();
$testName = $this->getName();
$this->setupTest($className, $testName);
}
public function setupTest($className, $testName)
{
$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']);
}
$this->mode = getenv('REST_MODE') ? getenv('REST_MODE') : 'mock';
if ($this->mode != 'sandbox') {
// Mock PPRest Caller if mode set to mock
$this->mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
->disableOriginalConstructor()
->getMock();
$this->mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
$this->response
));
}
}
/**
* 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 Invoice($request);
$result = $obj->create(null, $this->mockPPRestCall);
$this->assertNotNull($result);
self::$obj = $result;
return $result;
}
/**
* @depends testCreate
* @param $invoice Invoice
* @return Invoice
*/
public function testGet($invoice)
{
$result = Invoice::get($invoice->getId(), null, $this->mockPPRestCall);
$this->assertNotNull($result);
$this->assertEquals($invoice->getId(), $result->getId());
return $result;
}
/**
* @depends testCreate
* @param $invoice Invoice
* @return Invoice
*/
public function testSend($invoice)
{
$result = $invoice->send(null, $this->mockPPRestCall);
$this->assertNotNull($result);
return $invoice;
}
/**
* @depends testSend
* @param $invoice Invoice
* @return Invoice
*/
public function testUpdate($invoice)
{
$this->markTestSkipped('Skipped as the fix is on the way. #PPTIPS-1932');
$result = $invoice->update(null, $this->mockPPRestCall);
$this->assertNotNull($result);
$this->assertEquals($invoice->getId(), $result->getId());
}
/**
* @depends testSend
* @param $invoice Invoice
* @return Invoice
*/
public function testGetAll($invoice)
{
$result = Invoice::getAll(array('page_size' => '20', 'total_count_required' => 'true'), null, $this->mockPPRestCall);
$this->assertNotNull($result);
$this->assertNotNull($result->getTotalCount());
$totalPages = ceil($result->getTotalCount()/20);
$found = false;
$foundObject = null;
do {
foreach ($result->getInvoices() as $obj) {
if ($obj->getId() == $invoice->getId()) {
$found = true;
$foundObject = $obj;
break;
}
}
if (!$found) {
$result = Invoice::getAll(array('page' => --$totalPages, 'page_size' => '20', 'total_required' => 'yes'), null, $this->mockPPRestCall);
}
} while ($totalPages > 0 && $found == false);
$this->assertTrue($found, "The Created Invoice was not found in the get list");
$this->assertEquals($invoice->getId(), $foundObject->getId());
}
/**
* @depends testSend
* @param $invoice Invoice
* @return Invoice
*/
public function testSearch($invoice)
{
$request = $this->operation['request']['body'];
$search = new Search($request);
$result = Invoice::search($search, null, $this->mockPPRestCall);
$this->assertNotNull($result);
$this->assertNotNull($result->getTotalCount());
}
/**
* @depends testSend
* @param $invoice Invoice
* @return Invoice
*/
public function testRemind($invoice)
{
$request = $this->operation['request']['body'];
$notification = new Notification($request);
$result = $invoice->remind($notification, null, $this->mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @depends testSend
* @param $invoice Invoice
* @return Invoice
*/
public function testCancel($invoice)
{
$request = $this->operation['request']['body'];
$notification = new CancelNotification($request);
$result = $invoice->cancel($notification, null, $this->mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @depends testSend
* @param $invoice Invoice
* @return Invoice
*/
public function testQRCode($invoice)
{
$result = Invoice::qrCode($invoice->getId(), array(), null, $this->mockPPRestCall);
$this->assertNotNull($result);
$this->assertNotNull($result->getImage());
}
/**
* @depends testSend
* @param $invoice Invoice
* @return Invoice
*/
public function testRecordPayment($invoice)
{
$this->setupTest($this->getClassName(), 'testCreate');
$invoice = $this->testCreate($invoice);
$this->setupTest($this->getClassName(), 'testSend');
$invoice = $this->testSend($invoice);
$this->setupTest($this->getClassName(), 'testRecordPayment');
$request = $this->operation['request']['body'];
$paymentDetail = new PaymentDetail($request);
$result = $invoice->recordPayment($paymentDetail, null, $this->mockPPRestCall);
$this->assertNotNull($result);
return $invoice;
}
/**
* @depends testRecordPayment
* @param $invoice Invoice
* @return Invoice
*/
public function testRecordRefund($invoice)
{
$request = $this->operation['request']['body'];
$refundDetail = new RefundDetail($request);
$result = $invoice->recordRefund($refundDetail, null, $this->mockPPRestCall);
$this->assertNotNull($result);
$this->setupTest($this->getClassName(), 'testDelete');
$invoice = $this->testDelete($invoice);
return $invoice;
}
/**
* @depends testGet
* @param $invoice Invoice
* @return Invoice
*/
public function testDelete($invoice)
{
$this->setupTest($this->getClassName(), 'testCreate');
$invoice = $this->testCreate($invoice);
$this->setupTest($this->getClassName(), 'testDelete');
$result = $invoice->delete(null, $this->mockPPRestCall);
$this->assertNotNull($result);
}
}

View File

@@ -0,0 +1,35 @@
{
"operationId": "invoice.cancel",
"title": "Cancel an invoice",
"description": "Cancel an invoice",
"runnable": true,
"user": {
"scopes": []
},
"credentials": {
"oauth": {
"clientId": "",
"clientSecret": "",
"path": ""
},
"login": {},
"openIdConnect": {}
},
"request": {
"path": "v1/invoicing/invoices/INV2-WW57-VFCD-X5H4-XTUP/cancel",
"method": "POST",
"headers": {
"X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}"
},
"body": {
"subject": "Past due",
"note": "Canceling invoice",
"send_to_merchant": true,
"send_to_payer": true
}
},
"response": {
"headers": {},
"status": ""
}
}

View File

@@ -0,0 +1,150 @@
{
"operationId": "invoice.create",
"title": "Create an invoice",
"description": "Create an invoice",
"runnable": true,
"user": {
"scopes": [
"https://uri.paypal.com/services/invoicing"
]
},
"credentials": {
"oauth": {
"clientId": "stage2managed",
"clientSecret": "secret",
"path": "/v1/oauth2/token"
},
"login": {},
"openIdConnect": {}
},
"request": {
"path": "v1/invoicing/invoices/",
"method": "POST",
"headers": {
"X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}"
},
"body": {"merchant_info": {
"email": "jaypatel512-facilitator@hotmail.com",
"first_name": "Dennis",
"last_name": "Doctor",
"business_name": "Medical Professionals, LLC",
"phone": {
"country_code": "001",
"national_number": "5032141716"
},
"address": {
"line1": "1234 Main St.",
"city": "Portland",
"state": "OR",
"postal_code": "97217",
"country_code": "US"
}
},
"billing_info": [
{
"email": "example@example.com"
}
],
"items": [
{
"name": "Sutures",
"quantity": 100,
"unit_price": {
"currency": "USD",
"value": "5.00"
}
}
],
"note": "Medical Invoice 16 Jul, 2013 PST",
"payment_term": {
"term_type": "NET_45"
},
"shipping_info": {
"first_name": "Sally",
"last_name": "Patient",
"business_name": "Not applicable",
"phone": {
"country_code": "001",
"national_number": "5039871234"
},
"address": {
"line1": "1234 Main St.",
"city": "Portland",
"state": "OR",
"postal_code": "97217",
"country_code": "US"
}
}
}
},
"response": {
"status": "201 Created",
"headers": {},
"body": {
"id": "INV2-RF6D-L66T-D7H2-CRU7",
"number": "ABCD4971",
"status": "DRAFT",
"merchant_info": {
"email": "ppaas_default@paypal.com",
"first_name": "Dennis",
"last_name": "Doctor",
"business_name": "Medical Professionals, LLC",
"phone": {
"country_code": "1",
"national_number": "5032141234"
},
"address": {
"line1": "1234 Main St.",
"city": "Portland",
"state": "OR",
"postal_code": "97217",
"country_code": "US"
}
},
"billing_info": [
{
"email": "email@example.com"
}
],
"shipping_info": {
"first_name": "Sally",
"last_name": "Patient",
"business_name": "Not applicable",
"phone": {
"country_code": "1",
"national_number": "5039871234"
},
"address": {
"line1": "1234 Broad St.",
"city": "Portland",
"state": "OR",
"postal_code": "97216",
"country_code": "US"
}
},
"items": [
{
"name": "Sutures",
"quantity": 100,
"unit_price": {
"currency": "USD",
"value": "5.00"
}
}
],
"invoice_date": "2014-02-27 PST",
"payment_term": {
"term_type": "NET_45",
"due_date": "2015-04-13 PDT"
},
"tax_calculated_after_discount": false,
"tax_inclusive": false,
"note": "Medical Invoice 16 Jul, 2013 PST",
"total_amount": {
"currency": "USD",
"value": "500.00"
}
}
}
}

View File

@@ -0,0 +1,31 @@
{
"description": "Delete an invoice",
"title": "Delete an invoice",
"runnable": true,
"operationId": "invoice.delete",
"user": {
"scopes": []
},
"credentials": {
"oauth": {
"clientId": "",
"clientSecret": "",
"path": ""
},
"login": {},
"openIdConnect": {}
},
"request": {
"path": "v1/invoicing/invoices/INV2-92MG-CNXV-ND7G-P3D2",
"method": "DELETE",
"headers": {
"X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}"
},
"body": {}
},
"response": {
"status": "",
"headers": {},
"body": {}
}
}

View File

@@ -0,0 +1,98 @@
{
"description": "Get the invoice resource for the given identifier.",
"title": "Get invoice details",
"runnable": true,
"operationId": "invoice.get",
"user": {
"scopes": []
},
"credentials": {
"oauth": {
"clientId": "",
"clientSecret": "",
"path": ""
},
"login": {},
"openIdConnect": {}
},
"request": {
"path": "v1/invoicing/invoices/INV2-RF6D-L66T-D7H2-CRU7",
"method": "GET",
"headers": {
"X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}"
},
"body": {}
},
"response": {
"status": "",
"headers": {},
"body": {
"id": "INV2-RF6D-L66T-D7H2-CRU7",
"number": "0002",
"status": "DRAFT",
"merchant_info": {
"email": "ppaas_default@paypal.com",
"first_name": "Dennis",
"last_name": "Doctor",
"business_name": "Medical Professionals, LLC",
"phone": {
"country_code": "1",
"national_number": "5032141716"
},
"address": {
"line1": "1234 Main St.",
"city": "Portland",
"state": "OR",
"postal_code": "97217",
"country_code": "US"
}
},
"billing_info": [
{
"email": "example@example.com"
}
],
"shipping_info": {
"first_name": "Sally",
"last_name": "Patient",
"business_name": "Not applicable",
"phone": {
"country_code": "1",
"national_number": "5039871234"
},
"address": {
"line1": "1234 Broad St.",
"city": "Portland",
"state": "OR",
"postal_code": "97216",
"country_code": "US"
}
},
"items": [
{
"name": "Sutures",
"quantity": 100,
"unit_price": {
"currency": "USD",
"value": "5.00"
}
}
],
"invoice_date": "2014-03-24 PDT",
"payment_term": {
"term_type": "NET_45",
"due_date": "2014-05-08 PDT"
},
"tax_calculated_after_discount": false,
"tax_inclusive": false,
"note": "Medical Invoice 16 Jul, 2013 PST",
"total_amount": {
"currency": "USD",
"value": "500.00"
},
"metadata": {
"created_date": "2014-03-24 12:11:52 PDT"
}
}
}
}

View File

@@ -0,0 +1,148 @@
{
"description": "get all invoices",
"title": "get all invoices",
"runnable": true,
"operationId": "invoice.get_all",
"user": {
"scopes": []
},
"credentials": {
"oauth": {
"clientId": "",
"clientSecret": "",
"path": ""
},
"login": {},
"openIdConnect": {}
},
"request": {
"path": "v1/invoicing/invoices?page=0&page_size=10&total_count_required=true",
"method": "GET",
"headers": {
"X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}"
},
"body": {}
},
"response": {
"status": "",
"headers": {},
"body": {
"total_count": 5,
"invoices": [
{
"id": "INV2-2NB5-UJ7A-YSUJ-ABCD",
"number": "9879878979003791",
"status": "DRAFT",
"merchant_info": {
"email": "sample@sample.com"
},
"billing_info": [
{
"email": "example@example.com"
}
],
"shipping_info": {
"email": "example@example.com",
"first_name": "Sally",
"last_name": "Patient",
"business_name": "Not applicable"
},
"invoice_date": "2014-02-27 PST",
"note": "Medical Invoice 16 Jul, 2013 PST",
"total_amount": {
"currency": "USD",
"value": "0.00"
},
"metadata": {
"created_date": "2014-02-27 23:55:58 PST"
}
},
{
"id": "INV2-5AYC-UE5K-XXEG-ABCD",
"number": "9879878979003790",
"status": "DRAFT",
"merchant_info": {
"email": "sample@sample.com"
},
"billing_info": [
{
"email": "example@example.com"
}
],
"shipping_info": {
"email": "example@example.com",
"first_name": "Sally",
"last_name": "Patient",
"business_name": "Not applicable"
},
"invoice_date": "2014-02-27 PST",
"note": "Medical Invoice 16 Jul, 2013 PST",
"total_amount": {
"currency": "USD",
"value": "0.00"
},
"metadata": {
"created_date": "2014-02-27 19:41:56 PST"
}
},
{
"id": "INV2-C4QH-KEKM-C5QE-ABCD",
"number": "9879878979003789",
"status": "DRAFT",
"merchant_info": {
"email": "sample@sample.com"
},
"billing_info": [
{
"email": "example@example.com"
}
],
"shipping_info": {
"email": "example@example.com",
"first_name": "Sally",
"last_name": "Patient",
"business_name": "Not applicable"
},
"invoice_date": "2014-02-27 PST",
"note": "Medical Invoice 16 Jul, 2013 PST",
"total_amount": {
"currency": "USD",
"value": "0.00"
},
"metadata": {
"created_date": "2014-02-27 15:34:11 PST"
}
},
{
"id": "INV2-RF6D-L66T-D7H2-CRU7",
"number": "9879878979003788",
"status": "DRAFT",
"merchant_info": {
"email": "sample@sample.com"
},
"billing_info": [
{
"email": "example@example.com"
}
],
"shipping_info": {
"email": "example@example.com",
"first_name": "Sally",
"last_name": "Patient",
"business_name": "Not applicable"
},
"invoice_date": "2014-02-27 PST",
"note": "Medical Invoice 16 Jul, 2013 PST",
"total_amount": {
"currency": "USD",
"value": "12.00"
},
"metadata": {
"created_date": "2014-02-27 15:34:01 PST"
}
}
]
}
}
}

View File

@@ -0,0 +1,33 @@
{
"description": "Generates QR code for the Invoice URL identified by invoice_id.",
"title": "Get QR code",
"runnable": true,
"operationId": "invoice.qr_code",
"user": {
"scopes": []
},
"credentials": {
"oauth": {
"clientId": "",
"clientSecret": "",
"path": ""
},
"login": {},
"openIdConnect": {}
},
"request": {
"path": "v1/invoicing/invoices/INV2-S6FG-ZZCK-VXMM-8KKP/qr-code",
"method": "GET",
"headers": {
"X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}"
},
"body": {}
},
"response": {
"status": "",
"headers": {},
"body": {
"image": "iVBORw0KGgoAA......XUDM"
}
}
}

View File

@@ -0,0 +1,21 @@
{
"description": "Record a payment for an invoice.",
"title": "Record a payment for an invoice.",
"runnable": true,
"operationId": "invoice.record-payment",
"request": {
"path": "v1/invoicing/invoices/INV2-T4UQ-VW4W-K7N7-XM2R/record-payment",
"method": "POST",
"headers": {},
"body": {
"method": "CASH",
"date": "2014-07-06 03:30:00 PST",
"note": "Cash received."
}
},
"response": {
"status": "",
"headers": {},
"body": {}
}
}

View File

@@ -0,0 +1,20 @@
{
"description": "Record a refund for an invoice.",
"title": "Record a refund for an invoice.",
"runnable": true,
"operationId": "invoice.record-refund",
"request": {
"path": "v1/invoicing/invoices/INV2-T4UQ-VW4W-K7N7-XM2R/record-refund",
"method": "POST",
"headers": {},
"body": {
"date" : "2013-11-10 14:00:00 PST",
"note" : "Refunded by cash!"
}
},
"response": {
"status": "",
"headers": {},
"body": {}
}
}

View File

@@ -0,0 +1,35 @@
{
"description": "Reminds the payer to pay the invoice.",
"title": "Reminds the payer to pay the invoice.",
"runnable": true,
"operationId": "invoice.remind",
"user": {
"scopes": []
},
"credentials": {
"oauth": {
"clientId": "",
"clientSecret": "",
"path": ""
},
"login": {},
"openIdConnect": {}
},
"request": {
"path": "v1/invoicing/invoices/INV2-T4UQ-VW4W-K7N7-XM2R/remind",
"method": "POST",
"headers": {
"X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}"
},
"body": {
"subject": "Past due",
"note": "Please pay soon",
"send_to_merchant": true
}
},
"response": {
"status": "",
"headers": {},
"body": {}
}
}

View File

@@ -0,0 +1,67 @@
{
"description": "Search for invoice resources.",
"title": "Search for invoice resources.",
"runnable": true,
"operationId": "invoice.search",
"user": {
"scopes": []
},
"credentials": {
"oauth": {
"clientId": "",
"clientSecret": "",
"path": ""
},
"login": {},
"openIdConnect": {}
},
"request": {
"path": "v1/invoicing/search/",
"method": "POST",
"headers": {
"X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}"
},
"body": {
"page": 0,
"page_size": 3,
"total_count_required": true
}
},
"response": {
"status": "",
"headers": {},
"body": {
"total_count": 1,
"invoices": [
{
"id": "INV2-RF6D-L66T-D7H2-CRU7",
"number": "0001",
"status": "SENT",
"merchant_info": {
"email": "dennis@sample.com"
},
"billing_info": [
{
"email": "sally-patient@example.com"
}
],
"shipping_info": {
"email": "sally-patient@example.com"
},
"invoice_date": "2012-05-09 PST",
"payment_term": {
"due_date": "2012-05-24 PST"
},
"total_amount": {
"currency": "USD",
"value": "250"
},
"metadata": {
"created_date": "2012-05-09 04:48:57 PST"
}
}
]
}
}
}

View File

@@ -0,0 +1,31 @@
{
"description": "Sends a legitimate invoice to the payer.",
"title": "Sends a legitimate invoice to the payer.",
"runnable": true,
"operationId": "invoice.send",
"user": {
"scopes": []
},
"credentials": {
"oauth": {
"clientId": "",
"clientSecret": "",
"path": ""
},
"login": {},
"openIdConnect": {}
},
"request": {
"path": "v1/invoicing/invoices/INV2-EHNV-LJ5S-A7DZ-V6NJ/send",
"method": "POST",
"headers": {
"X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}"
},
"body": {}
},
"response": {
"status": "",
"headers": {},
"body": {}
}
}

View File

@@ -0,0 +1,148 @@
{
"description": "Full update of the invoice resource for the given identifier.",
"title": "Full update of the invoice resource for the given identifier.",
"runnable": true,
"operationId": "invoice.update",
"user": {
"scopes": []
},
"credentials": {
"oauth": {
"clientId": "",
"clientSecret": "",
"path": ""
},
"login": {},
"openIdConnect": {}
},
"request": {
"path": "v1/invoicing/invoices/INV2-8UZ6-Q3DK-VZXV-SXQB",
"method": "PUT",
"headers": {
"X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}"
},
"body": {
"merchant_info": {
"email": "ppaas_default@paypal.com",
"first_name": "Dennis",
"last_name": "Doctor",
"business_name": "Medical Professionals, LLC",
"phone": {
"country_code": "001",
"national_number": "5032141716"
},
"address": {
"line1": "1234 Main St.",
"city": "Portland",
"state": "OR",
"postal_code": "97217",
"country_code": "US"
}
},
"billing_info": [
{
"email": "example@example.com"
}
],
"items": [
{
"name": "Sutures",
"quantity": 100,
"unit_price": {
"currency": "USD",
"value": "5"
}
}
],
"note": "Medical Invoice 16 Jul, 2013 PST",
"payment_term": {
"term_type": "NET_45"
},
"shipping_info": {
"first_name": "Sally",
"last_name": "Patient",
"business_name": "Not applicable",
"phone": {
"country_code": "001",
"national_number": "5039871234"
},
"address": {
"line1": "1234 Broad St.",
"city": "Portland",
"state": "OR",
"postal_code": "97216",
"country_code": "US"
}
}
}
},
"response": {
"status": "",
"headers": {},
"body": {
"id": "INV2-8UZ6-Q3DK-VZXV-SXQB",
"number": "0014",
"status": "DRAFT",
"merchant_info": {
"email": "ppaas_default@paypal.com",
"first_name": "Dennis",
"last_name": "Doctor",
"business_name": "Medical Professionals, LLC",
"phone": {
"country_code": "1",
"national_number": "5032141716"
},
"address": {
"line1": "1234 Main St.",
"city": "Portland",
"state": "OR",
"postal_code": "97217",
"country_code": "US"
}
},
"billing_info": [
{
"email": "example@example.com"
}
],
"shipping_info": {
"first_name": "Sally",
"last_name": "Patient",
"business_name": "Not applicable",
"phone": {
"country_code": "1",
"national_number": "5039871234"
},
"address": {
"line1": "1234 Broad St.",
"city": "Portland",
"state": "OR",
"postal_code": "97216",
"country_code": "US"
}
},
"items": [
{
"name": "Sutures",
"quantity": 100,
"unit_price": {
"currency": "USD",
"value": "5.00"
}
}
],
"invoice_date": "2014-03-24 PDT",
"payment_term": {
"term_type": "NET_45",
"due_date": "2014-05-08 PDT"
},
"tax_calculated_after_discount": false,
"tax_inclusive": false,
"note": "Medical Invoice 16 Jul, 2013 PST",
"total_amount": {
"currency": "USD",
"value": "500.00"
}
}
}
}