From 268b39b374f8349a8ade38ce94ffcf00c93fcae2 Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Tue, 28 May 2013 09:57:10 +0530 Subject: [PATCH 01/20] adding auth capture samples --- sample/payments/AuthorizationCapture.php | 48 ++++++++++++++++++++++++ sample/payments/GetAuthorization.php | 31 +++++++++++++++ sample/payments/GetCapture.php | 30 +++++++++++++++ sample/payments/RefundCapture.php | 45 ++++++++++++++++++++++ sample/payments/VoidAuthorization.php | 33 ++++++++++++++++ 5 files changed, 187 insertions(+) create mode 100644 sample/payments/AuthorizationCapture.php create mode 100644 sample/payments/GetAuthorization.php create mode 100644 sample/payments/GetCapture.php create mode 100644 sample/payments/RefundCapture.php create mode 100644 sample/payments/VoidAuthorization.php diff --git a/sample/payments/AuthorizationCapture.php b/sample/payments/AuthorizationCapture.php new file mode 100644 index 0000000..328b518 --- /dev/null +++ b/sample/payments/AuthorizationCapture.php @@ -0,0 +1,48 @@ +setCurrency("USD"); + $amount->setTotal("1.00"); + + +### Capture + +$captur = new Capture(); +$captur->setId('5RA45624N3531924N'); +$captur->setAmount($amount); + +// get the authorization +$authorization = Authorization::get('8UA90289RG279654G', $apiContext); + +// ### Capture Payment +// Capture Payment by posting to the APIService +// using a valid ApiContext (See bootstrap.php for more on `ApiContext`) +// The return object contains the status; +try { + $capt = $authorization->capture($captur, $apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> + + +
+ Capture payment: + getId();?> +
+
toArray());?>
+ Back + + diff --git a/sample/payments/GetAuthorization.php b/sample/payments/GetAuthorization.php new file mode 100644 index 0000000..1bf13a0 --- /dev/null +++ b/sample/payments/GetAuthorization.php @@ -0,0 +1,31 @@ + + +require __DIR__ . '/../bootstrap.php'; + +use PayPal\Api\Authorization; + +// ### GetAuthorization +// GetAuthorization by posting to the APIService +// using a valid ApiContext (See bootstrap.php for more on `ApiContext`) +// The return object contains the status; +try { + $authorization = Authorization::get('1FR49283DF589111P', $apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> + + +
+ Get Authorization: + getId();?> +
+
toArray());?>
+ Back + + diff --git a/sample/payments/GetCapture.php b/sample/payments/GetCapture.php new file mode 100644 index 0000000..73a7062 --- /dev/null +++ b/sample/payments/GetCapture.php @@ -0,0 +1,30 @@ + + +require __DIR__ . '/../bootstrap.php'; +use PayPal\Api\Capture; + +// ### Get Capture +// Get Capture by posting to the APIService +// using a valid ApiContext (See bootstrap.php for more on `ApiContext`) +// The return object contains the status; +try { + $capture = Capture::get('7BA08426L46375838', $apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> + + +
+ Get Capture : + getId();?> +
+
toArray());?>
+ Back + + diff --git a/sample/payments/RefundCapture.php b/sample/payments/RefundCapture.php new file mode 100644 index 0000000..447cd4c --- /dev/null +++ b/sample/payments/RefundCapture.php @@ -0,0 +1,45 @@ +}/refund + + +// ### Refund +// Create a refund object indicating +// refund amount + $amount = new Amount(); + $amount->setCurrency("USD"); + $amount->setTotal("1.00"); + + +$refund = new Refund(); +$refund->setId('7BA08426L46375838'); +$refund->setAmount($amount); + + +$capture = Capture::get('7BA08426L46375838', $apiContext); +try { + // (See bootstrap.php for more on `ApiContext`) + $captureRefund = $capture->refund($refund, $apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> + + + +
Refund Capture:
+
+ Back + + + diff --git a/sample/payments/VoidAuthorization.php b/sample/payments/VoidAuthorization.php new file mode 100644 index 0000000..dfeb051 --- /dev/null +++ b/sample/payments/VoidAuthorization.php @@ -0,0 +1,33 @@ +/void" + +require __DIR__ . '/../bootstrap.php'; + +use PayPal\Api\Authorization; + +$authorization = Authorization::get('87U86133WD4359724', $apiContext); + + +// ### VoidAuthorization +// VoidAuthorization by posting to the APIService +// using a valid ApiContext (See bootstrap.php for more on `ApiContext`) +// The return object contains the status; +try { + $void = $authorization->void($apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> + + +
+ Void Authorization: +
+
toArray());?>
+ Back + + From 125a7b66f39faf07c5e9b79a0ed6f63cad51f153 Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Tue, 28 May 2013 10:03:51 +0530 Subject: [PATCH 02/20] adding delete credit card sample --- sample/vault/DeleteCreditCard.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 sample/vault/DeleteCreditCard.php diff --git a/sample/vault/DeleteCreditCard.php b/sample/vault/DeleteCreditCard.php new file mode 100644 index 0000000..a815163 --- /dev/null +++ b/sample/vault/DeleteCreditCard.php @@ -0,0 +1,29 @@ +} +// NOTE: HTTP method used here is DELETE + +$creditCard = CreditCard::get('CARD-38K23067VS968933SKGPU66Q', $apiContext); + +try { + // (See bootstrap.php for more on `ApiContext`) + $creditCard->delete($apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + exit(1); +} +?> + + + +
Delete CreditCard:
+

Credit Card deleted Successfully

+ Back + + \ No newline at end of file From 50b09bdbdeb9881a50739656beb367f54a57e4cb Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Tue, 28 May 2013 10:08:34 +0530 Subject: [PATCH 03/20] testcases updated updated testcases to match new json schema and updates with camel case function names --- tests/PayPal/Test/Api/AddressTest.php | 10 ++--- tests/PayPal/Test/Api/AmountTest.php | 4 +- tests/PayPal/Test/Api/AuthorizationTest.php | 14 +++---- tests/PayPal/Test/Api/CaptureTest.php | 17 +++----- tests/PayPal/Test/Api/CreditCardTest.php | 34 ++++++++-------- tests/PayPal/Test/Api/CreditCardTokenTest.php | 8 ++-- ...{AmountDetailsTest.php => DetailsTest.php} | 8 ++-- .../PayPal/Test/Api/FundingInstrumentTest.php | 8 ++-- tests/PayPal/Test/Api/ItemListTest.php | 4 +- tests/PayPal/Test/Api/LinkTest.php | 40 ------------------- tests/PayPal/Test/Api/LinksTest.php | 40 +++++++++++++++++++ tests/PayPal/Test/Api/PayeeTest.php | 4 +- tests/PayPal/Test/Api/PayerInfoTest.php | 16 ++++---- tests/PayPal/Test/Api/PayerTest.php | 14 +++---- tests/PayPal/Test/Api/PaymentHistoryTest.php | 4 +- tests/PayPal/Test/Api/PaymentTest.php | 20 ++++------ tests/PayPal/Test/Api/RefundTest.php | 19 ++++----- .../PayPal/Test/Api/RelatedResourcesTest.php | 35 ++++++++++++++++ tests/PayPal/Test/Api/SaleTest.php | 17 ++++---- tests/PayPal/Test/Api/ShippingAddressTest.php | 15 +++---- tests/PayPal/Test/Api/SubTransactionTest.php | 35 ---------------- tests/PayPal/Test/Api/TransactionTest.php | 10 ++--- 22 files changed, 179 insertions(+), 197 deletions(-) rename tests/PayPal/Test/Api/{AmountDetailsTest.php => DetailsTest.php} (86%) delete mode 100644 tests/PayPal/Test/Api/LinkTest.php create mode 100644 tests/PayPal/Test/Api/LinksTest.php create mode 100644 tests/PayPal/Test/Api/RelatedResourcesTest.php delete mode 100644 tests/PayPal/Test/Api/SubTransactionTest.php diff --git a/tests/PayPal/Test/Api/AddressTest.php b/tests/PayPal/Test/Api/AddressTest.php index 3909d09..ec271c9 100644 --- a/tests/PayPal/Test/Api/AddressTest.php +++ b/tests/PayPal/Test/Api/AddressTest.php @@ -23,10 +23,9 @@ class AddressTest extends \PHPUnit_Framework_TestCase { $addr->setLine2(self::$line2); $addr->setCity(self::$city); $addr->setState(self::$state); - $addr->setPostal_code(self::$postalCode); - $addr->setCountry_code(self::$countryCode); + $addr->setPostalCode(self::$postalCode); + $addr->setCountryCode(self::$countryCode); $addr->setPhone(self::$phone); - $addr->setType(self::$type); return $addr; } @@ -39,10 +38,9 @@ class AddressTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(self::$line2, $this->address->getLine2()); $this->assertEquals(self::$city, $this->address->getCity()); $this->assertEquals(self::$state, $this->address->getState()); - $this->assertEquals(self::$postalCode, $this->address->getPostal_code()); - $this->assertEquals(self::$countryCode, $this->address->getCountry_code()); + $this->assertEquals(self::$postalCode, $this->address->getPostalCode()); + $this->assertEquals(self::$countryCode, $this->address->getCountryCode()); $this->assertEquals(self::$phone, $this->address->getPhone()); - $this->assertEquals(self::$type, $this->address->getType()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/AmountTest.php b/tests/PayPal/Test/Api/AmountTest.php index c1028c8..7f24e7b 100644 --- a/tests/PayPal/Test/Api/AmountTest.php +++ b/tests/PayPal/Test/Api/AmountTest.php @@ -24,14 +24,14 @@ class AmountTest extends \PHPUnit_Framework_TestCase { $this->amounts['partial'] = self::createAmount(); $amount = self::createAmount(); - $amount->setDetails(AmountDetailsTest::createAmountDetails()); + $amount->setDetails(DetailsTest::createAmountDetails()); $this->amounts['full'] = $amount; } public function testGetterSetter() { $this->assertEquals(self::$currency, $this->amounts['partial']->getCurrency()); $this->assertEquals(self::$total, $this->amounts['partial']->getTotal()); - $this->assertEquals(AmountDetailsTest::$fee, $this->amounts['full']->getDetails()->getFee()); + $this->assertEquals(DetailsTest::$fee, $this->amounts['full']->getDetails()->getFee()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/AuthorizationTest.php b/tests/PayPal/Test/Api/AuthorizationTest.php index baec44f..ba104f9 100644 --- a/tests/PayPal/Test/Api/AuthorizationTest.php +++ b/tests/PayPal/Test/Api/AuthorizationTest.php @@ -3,7 +3,7 @@ namespace PayPal\Test\Api; use PayPal\Api\Amount; use PayPal\Api\Authorization; -use PayPal\Api\Link; +use PayPal\Api\Links; use PayPal\Test\Constants; class AuthorizationTest extends \PHPUnit_Framework_TestCase { @@ -24,22 +24,22 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase { public static function createAuthorization() { $authorization = new Authorization(); - $authorization->setCreate_time(self::$create_time); + $authorization->setCreateTime(self::$create_time); $authorization->setId(self::$id); $authorization->setState(self::$state); $authorization->setAmount(AmountTest::createAmount()); - $authorization->setLinks(array(LinkTest::createLink())); + $authorization->setLinks(array(LinksTest::createLinks())); return $authorization; } public function setup() { $authorization = new Authorization(); - $authorization->setCreate_time(self::$create_time); + $authorization->setCreateTime(self::$create_time); $authorization->setId(self::$id); $authorization->setState(self::$state); - $authorization->setParent_payment(self::$parent_payment); + $authorization->setParentPayment(self::$parent_payment); $this->authorizations['partial'] = $authorization; @@ -48,10 +48,10 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase { public function testGetterSetter() { $authorization = $this->authorizations['partial']; - $this->assertEquals(self::$create_time, $authorization->getCreate_time()); + $this->assertEquals(self::$create_time, $authorization->getCreateTime()); $this->assertEquals(self::$id, $authorization->getId()); $this->assertEquals(self::$state, $authorization->getState()); - $this->assertEquals(self::$parent_payment, $authorization->getParent_payment()); + $this->assertEquals(self::$parent_payment, $authorization->getParentPayment()); $authorization = $this->authorizations['full']; $this->assertEquals(AmountTest::$currency, $authorization->getAmount()->getCurrency()); diff --git a/tests/PayPal/Test/Api/CaptureTest.php b/tests/PayPal/Test/Api/CaptureTest.php index 45a0a88..56000dc 100644 --- a/tests/PayPal/Test/Api/CaptureTest.php +++ b/tests/PayPal/Test/Api/CaptureTest.php @@ -10,18 +10,15 @@ class CaptureTest extends \PHPUnit_Framework_TestCase { public static $authorization_id = "AUTH-123"; public static $create_time = "2013-02-28T00:00:00Z"; - public static $description = "Test capture"; public static $id = "C-5678"; public static $parent_payment = "PAY-123"; public static $state = "Created"; public static function createCapture() { $capture = new Capture(); - $capture->setAuthorization_id(self::$authorization_id); - $capture->setCreate_time(self::$create_time); - $capture->setDescription(self::$description); + $capture->setCreateTime(self::$create_time); $capture->setId(self::$id); - $capture->setParent_payment(self::$parent_payment); + $capture->setParentPayment(self::$parent_payment); $capture->setState(self::$state); return $capture; @@ -32,21 +29,19 @@ class CaptureTest extends \PHPUnit_Framework_TestCase { $capture = self::createCapture(); $capture->setAmount(AmountTest::createAmount()); - $capture->setLinks(array(LinkTest::createLink())); + $capture->setLinks(array(LinksTest::createLinks())); $this->captures['full'] = $capture; } public function testGetterSetter() { - $this->assertEquals(self::$authorization_id, $this->captures['partial']->getAuthorization_id()); - $this->assertEquals(self::$create_time, $this->captures['partial']->getCreate_time()); - $this->assertEquals(self::$description, $this->captures['partial']->getDescription()); + $this->assertEquals(self::$create_time, $this->captures['partial']->getCreateTime()); $this->assertEquals(self::$id, $this->captures['partial']->getId()); - $this->assertEquals(self::$parent_payment, $this->captures['partial']->getParent_payment()); + $this->assertEquals(self::$parent_payment, $this->captures['partial']->getParentPayment()); $this->assertEquals(self::$state, $this->captures['partial']->getState()); $this->assertEquals(AmountTest::$currency, $this->captures['full']->getAmount()->getCurrency()); $links = $this->captures['full']->getLinks(); - $this->assertEquals(LinkTest::$href, $links[0]->getHref()); + $this->assertEquals(LinksTest::$href, $links[0]->getHref()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/CreditCardTest.php b/tests/PayPal/Test/Api/CreditCardTest.php index e442e70..c4ae466 100644 --- a/tests/PayPal/Test/Api/CreditCardTest.php +++ b/tests/PayPal/Test/Api/CreditCardTest.php @@ -26,23 +26,23 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase { $card = new CreditCard(); $card->setType(self::$cardType); $card->setNumber(self::$cardNumber); - $card->setExpire_month(self::$expireMonth); - $card->setExpire_year(self::$expireYear); + $card->setExpireMonth(self::$expireMonth); + $card->setExpireYear(self::$expireYear); $card->setCvv2(self::$cvv); - $card->setFirst_name(self::$firstName); - $card->setLast_name(self::$lastName); + $card->setFirstName(self::$firstName); + $card->setLastName(self::$lastName); $card->setId(self::$id); - $card->setValid_until(self::$validUntil); + $card->setValidUntil(self::$validUntil); $card->setState(self::$state); - $card->setPayer_id(self::$payerId); + $card->setPayerId(self::$payerId); return $card; } public function setup() { $card = self::createCreditCard(); - $card->setBilling_address(AddressTest::createAddress()); - $card->setLinks(array(LinkTest::createLink())); + $card->setBillingAddress(AddressTest::createAddress()); + $card->setLinks(array(LinksTest::createLinks())); $this->cards['full'] = $card; $card = self::createCreditCard(); @@ -53,20 +53,20 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase { $c = $this->cards['partial']; $this->assertEquals(self::$cardType, $c->getType()); $this->assertEquals(self::$cardNumber, $c->getNumber()); - $this->assertEquals(self::$expireMonth, $c->getExpire_month()); - $this->assertEquals(self::$expireYear, $c->getExpire_year()); + $this->assertEquals(self::$expireMonth, $c->getExpireMonth()); + $this->assertEquals(self::$expireYear, $c->getExpireYear()); $this->assertEquals(self::$cvv, $c->getCvv2()); - $this->assertEquals(self::$firstName, $c->getFirst_name()); - $this->assertEquals(self::$lastName, $c->getLast_name()); + $this->assertEquals(self::$firstName, $c->getFirstName()); + $this->assertEquals(self::$lastName, $c->getLastName()); $this->assertEquals(self::$id, $c->getId()); - $this->assertEquals(self::$validUntil, $c->getValid_until()); + $this->assertEquals(self::$validUntil, $c->getValidUntil()); $this->assertEquals(self::$state, $c->getState()); - $this->assertEquals(self::$payerId, $c->getPayer_id()); + $this->assertEquals(self::$payerId, $c->getPayerId()); $c = $this->cards['full']; - $this->assertEquals(AddressTest::$line1, $c->getBilling_address()->getLine1()); + $this->assertEquals(AddressTest::$line1, $c->getBillingAddress()->getLine1()); $link = $c->getLinks(); - $this->assertEquals(LinkTest::$href, $link[0]->getHref()); + $this->assertEquals(LinksTest::$href, $link[0]->getHref()); } public function testSerializeDeserialize() { @@ -87,7 +87,7 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase { $this->assertNotNull($c1->getId()); $c2 = CreditCard::get($c1->getId()); - $this->assertEquals($c1->getBilling_address(), $c2->getBilling_address()); + $this->assertEquals($c1->getBillingAddress(), $c2->getBillingAddress()); $this->assertGreaterThan(0, count($c2->getLinks())); $this->assertEquals(self::$cardType, $c2->getType()); $this->assertNotNull($c2->getState()); diff --git a/tests/PayPal/Test/Api/CreditCardTokenTest.php b/tests/PayPal/Test/Api/CreditCardTokenTest.php index 75de222..d1f8db9 100644 --- a/tests/PayPal/Test/Api/CreditCardTokenTest.php +++ b/tests/PayPal/Test/Api/CreditCardTokenTest.php @@ -13,8 +13,8 @@ class CreditCardTokenTest extends \PHPUnit_Framework_TestCase { public static function createCreditCardToken() { $ccToken = new CreditCardToken(); - $ccToken->setPayer_id(self::$payerId); - $ccToken->setCredit_card_id(self::$creditCardId); + $ccToken->setPayerId(self::$payerId); + $ccToken->setCreditCardId(self::$creditCardId); return $ccToken; } @@ -23,8 +23,8 @@ class CreditCardTokenTest extends \PHPUnit_Framework_TestCase { } public function testGetterSetter() { - $this->assertEquals(self::$payerId, $this->ccToken->getPayer_id()); - $this->assertEquals(self::$creditCardId, $this->ccToken->getCredit_card_id()); + $this->assertEquals(self::$payerId, $this->ccToken->getPayerId()); + $this->assertEquals(self::$creditCardId, $this->ccToken->getCreditCardId()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/AmountDetailsTest.php b/tests/PayPal/Test/Api/DetailsTest.php similarity index 86% rename from tests/PayPal/Test/Api/AmountDetailsTest.php rename to tests/PayPal/Test/Api/DetailsTest.php index 1456433..ae1cba9 100644 --- a/tests/PayPal/Test/Api/AmountDetailsTest.php +++ b/tests/PayPal/Test/Api/DetailsTest.php @@ -1,10 +1,10 @@ setSubtotal(self::$subtotal); $amountDetails->setTax(self::$tax); $amountDetails->setShipping(self::$shipping); @@ -37,7 +37,7 @@ class AmountDetailsTest extends \PHPUnit_Framework_TestCase { public function testSerializeDeserialize() { $a1 = $this->amountDetails; - $a2 = new AmountDetails(); + $a2 = new Details(); $a2->fromJson($a1->toJson()); $this->assertEquals($a1, $a2); diff --git a/tests/PayPal/Test/Api/FundingInstrumentTest.php b/tests/PayPal/Test/Api/FundingInstrumentTest.php index 5a93c36..cb420d6 100644 --- a/tests/PayPal/Test/Api/FundingInstrumentTest.php +++ b/tests/PayPal/Test/Api/FundingInstrumentTest.php @@ -11,8 +11,8 @@ class FundingInstrumentTest extends \PHPUnit_Framework_TestCase { public static function createFundingInstrument() { $fi = new FundingInstrument(); - $fi->setCredit_card(CreditCardTest::createCreditCard()); - $fi->setCredit_card_token(CreditCardTokenTest::createCreditCardToken()); + $fi->setCreditCard(CreditCardTest::createCreditCard()); + $fi->setCreditCardToken(CreditCardTokenTest::createCreditCardToken()); return $fi; } @@ -21,9 +21,9 @@ class FundingInstrumentTest extends \PHPUnit_Framework_TestCase { } public function testGetterSetter() { - $this->assertEquals(CreditCardTest::$cardNumber, $this->fi->getCredit_card()->getNumber()); + $this->assertEquals(CreditCardTest::$cardNumber, $this->fi->getCreditCard()->getNumber()); $this->assertEquals(CreditCardTokenTest::$creditCardId, - $this->fi->getCredit_card_token()->getCredit_card_id()); + $this->fi->getCreditCardToken()->getCreditCardId()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/ItemListTest.php b/tests/PayPal/Test/Api/ItemListTest.php index 96a6d2a..fe5f870 100644 --- a/tests/PayPal/Test/Api/ItemListTest.php +++ b/tests/PayPal/Test/Api/ItemListTest.php @@ -21,7 +21,7 @@ class ItemListTest extends \PHPUnit_Framework_TestCase { $itemList = new ItemList(); $itemList->setItems(array($item)); - $itemList->setShipping_address(ShippingAddressTest::createAddress()); + $itemList->setShippingAddress(ShippingAddressTest::createAddress()); return $itemList; } @@ -33,7 +33,7 @@ class ItemListTest extends \PHPUnit_Framework_TestCase { public function testGetterSetters() { $items = $this->items->getItems(); $this->assertEquals(ItemTest::createItem(), $items[0]); - $this->assertEquals(ShippingAddressTest::createAddress(), $this->items->getShipping_address()); + $this->assertEquals(ShippingAddressTest::createAddress(), $this->items->getShippingAddress()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/LinkTest.php b/tests/PayPal/Test/Api/LinkTest.php deleted file mode 100644 index 8deec92..0000000 --- a/tests/PayPal/Test/Api/LinkTest.php +++ /dev/null @@ -1,40 +0,0 @@ -setHref(self::$href); - $link->setRel(self::$rel); - $link->setMethod(self::$method); - - return $link; - } - - public function setup() { - $this->link = self::createLink(); - } - - public function testGetterSetters() { - $this->assertEquals(self::$href, $this->link->getHref()); - $this->assertEquals(self::$rel, $this->link->getRel()); - $this->assertEquals(self::$method, $this->link->getMethod()); - } - - public function testSerializeDeserialize() { - $link2 = new Link(); - $link2->fromJson($this->link->toJSON()); - $this->assertEquals($this->link, $link2); - } -} \ No newline at end of file diff --git a/tests/PayPal/Test/Api/LinksTest.php b/tests/PayPal/Test/Api/LinksTest.php new file mode 100644 index 0000000..68da69a --- /dev/null +++ b/tests/PayPal/Test/Api/LinksTest.php @@ -0,0 +1,40 @@ +setHref(self::$href); + $links->setRel(self::$rel); + $links->setMethod(self::$method); + + return $links; + } + + public function setup() { + $this->links = self::createLinks(); + } + + public function testGetterSetters() { + $this->assertEquals(self::$href, $this->links->getHref()); + $this->assertEquals(self::$rel, $this->links->getRel()); + $this->assertEquals(self::$method, $this->links->getMethod()); + } + + public function testSerializeDeserialize() { + $link2 = new Links(); + $link2->fromJson($this->links->toJSON()); + $this->assertEquals($this->links, $link2); + } +} \ No newline at end of file diff --git a/tests/PayPal/Test/Api/PayeeTest.php b/tests/PayPal/Test/Api/PayeeTest.php index 95687c9..ea9469f 100644 --- a/tests/PayPal/Test/Api/PayeeTest.php +++ b/tests/PayPal/Test/Api/PayeeTest.php @@ -17,7 +17,7 @@ class PayeeTest extends \PHPUnit_Framework_TestCase { public static function createPayee() { $payee = new Payee(); $payee->setEmail(self::$email); - $payee->setMerchant_id(self::$merchant_id); + $payee->setMerchantId(self::$merchant_id); $payee->setPhone(self::$phone); return $payee; @@ -29,7 +29,7 @@ class PayeeTest extends \PHPUnit_Framework_TestCase { public function testGetterSetter() { $this->assertEquals(self::$email, $this->payee->getEmail()); - $this->assertEquals(self::$merchant_id, $this->payee->getMerchant_id()); + $this->assertEquals(self::$merchant_id, $this->payee->getMerchantId()); $this->assertEquals(self::$phone, $this->payee->getPhone()); } diff --git a/tests/PayPal/Test/Api/PayerInfoTest.php b/tests/PayPal/Test/Api/PayerInfoTest.php index ddf584d..b1f5858 100644 --- a/tests/PayPal/Test/Api/PayerInfoTest.php +++ b/tests/PayPal/Test/Api/PayerInfoTest.php @@ -17,11 +17,11 @@ class PayerInfoTest extends \PHPUnit_Framework_TestCase { public static function createPayerInfo() { $payerInfo = new PayerInfo(); $payerInfo->setEmail(self::$email); - $payerInfo->setFirst_name(self::$firstName); - $payerInfo->setLast_name(self::$lastName); + $payerInfo->setFirstName(self::$firstName); + $payerInfo->setLastName(self::$lastName); $payerInfo->setPhone(self::$phone); - $payerInfo->setPayer_id(self::$payerId); - $payerInfo->setShipping_address(AddressTest::createAddress()); + $payerInfo->setPayerId(self::$payerId); + $payerInfo->setShippingAddress(AddressTest::createAddress()); return $payerInfo; } @@ -32,11 +32,11 @@ class PayerInfoTest extends \PHPUnit_Framework_TestCase { public function testGetterSetter() { $this->assertEquals(self::$email, $this->payerInfo->getEmail()); - $this->assertEquals(self::$firstName, $this->payerInfo->getFirst_name()); - $this->assertEquals(self::$lastName, $this->payerInfo->getLast_name()); + $this->assertEquals(self::$firstName, $this->payerInfo->getFirstName()); + $this->assertEquals(self::$lastName, $this->payerInfo->getLastName()); $this->assertEquals(self::$phone, $this->payerInfo->getPhone()); - $this->assertEquals(self::$payerId, $this->payerInfo->getPayer_id()); - $this->assertEquals(AddressTest::$line1, $this->payerInfo->getShipping_address()->getLine1()); + $this->assertEquals(self::$payerId, $this->payerInfo->getPayerId()); + $this->assertEquals(AddressTest::$line1, $this->payerInfo->getShippingAddress()->getLine1()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/PayerTest.php b/tests/PayPal/Test/Api/PayerTest.php index f956a15..7568a3c 100644 --- a/tests/PayPal/Test/Api/PayerTest.php +++ b/tests/PayPal/Test/Api/PayerTest.php @@ -15,9 +15,9 @@ class PayerTest extends \PHPUnit_Framework_TestCase { public static function createPayer() { $payer = new Payer(); - $payer->setPayment_method(self::$paymentMethod); - $payer->setPayer_info(PayerInfoTest::createPayerInfo()); - $payer->setFunding_instruments(array(FundingInstrumentTest::createFundingInstrument())); + $payer->setPaymentMethod(self::$paymentMethod); + $payer->setPayerInfo(PayerInfoTest::createPayerInfo()); + $payer->setFundingInstruments(array(FundingInstrumentTest::createFundingInstrument())); return $payer; } @@ -27,11 +27,11 @@ class PayerTest extends \PHPUnit_Framework_TestCase { } public function testGetterSetter() { - $this->assertEquals(self::$paymentMethod, $this->payer->getPayment_method()); - $this->assertEquals(PayerInfoTest::$email, $this->payer->getPayer_info()->getEmail()); + $this->assertEquals(self::$paymentMethod, $this->payer->getPaymentMethod()); + $this->assertEquals(PayerInfoTest::$email, $this->payer->getPayerInfo()->getEmail()); - $fi = $this->payer->getFunding_instruments(); - $this->assertEquals(CreditCardTokenTest::$creditCardId, $fi[0]->getCredit_card_token()->getCredit_card_id()); + $fi = $this->payer->getFundingInstruments(); + $this->assertEquals(CreditCardTokenTest::$creditCardId, $fi[0]->getCreditCardToken()->getCreditCardId()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/PaymentHistoryTest.php b/tests/PayPal/Test/Api/PaymentHistoryTest.php index 98885da..577d282 100644 --- a/tests/PayPal/Test/Api/PaymentHistoryTest.php +++ b/tests/PayPal/Test/Api/PaymentHistoryTest.php @@ -15,7 +15,7 @@ class PaymentHistoryTest extends \PHPUnit_Framework_TestCase { public static function createPaymentHistory() { $history = new PaymentHistory(); $history->setCount(self::$count); - $history->setNext_id(self::$nextId); + $history->setNextId(self::$nextId); $history->setPayments(array(PaymentTest::createPayment())); return $history; } @@ -25,7 +25,7 @@ class PaymentHistoryTest extends \PHPUnit_Framework_TestCase { public function testGetterSetters() { $this->assertEquals(self::$count, $this->history->getCount()); - $this->assertEquals(self::$nextId, $this->history->getNext_id()); + $this->assertEquals(self::$nextId, $this->history->getNextId()); } diff --git a/tests/PayPal/Test/Api/PaymentTest.php b/tests/PayPal/Test/Api/PaymentTest.php index 5bdaf31..2bf9795 100644 --- a/tests/PayPal/Test/Api/PaymentTest.php +++ b/tests/PayPal/Test/Api/PaymentTest.php @@ -1,10 +1,6 @@ setReturn_url("http://localhost/return"); - $redirectUrls->setCancel_url("http://localhost/cancel"); + $redirectUrls->setReturnUrl("http://localhost/return"); + $redirectUrls->setCancelUrl("http://localhost/cancel"); $payment = new Payment(); $payment->setIntent("sale"); - $payment->setRedirect_urls($redirectUrls); + $payment->setRedirectUrls($redirectUrls); $payment->setPayer(PayerTest::createPayer()); $payment->setTransactions(array(TransactionTest::createTransaction())); @@ -35,20 +31,20 @@ class PaymentTest extends \PHPUnit_Framework_TestCase { public static function createNewPayment() { $payer = new Payer(); - $payer->setPayment_method("credit_card"); - $payer->setFunding_instruments(array(FundingInstrumentTest::createFundingInstrument())); + $payer->setPaymentMethod("credit_card"); + $payer->setFundingInstruments(array(FundingInstrumentTest::createFundingInstrument())); $transaction = new Transaction(); $transaction->setAmount(AmountTest::createAmount()); $transaction->setDescription("This is the payment description."); $redirectUrls = new RedirectUrls(); - $redirectUrls->setReturn_url("http://localhost/return"); - $redirectUrls->setCancel_url("http://localhost/cancel"); + $redirectUrls->setReturnUrl("http://localhost/return"); + $redirectUrls->setCancelUrl("http://localhost/cancel"); $payment = new Payment(); $payment->setIntent("sale"); - $payment->setRedirect_urls($redirectUrls); + $payment->setRedirectUrls($redirectUrls); $payment->setPayer($payer); $payment->setTransactions(array($transaction)); diff --git a/tests/PayPal/Test/Api/RefundTest.php b/tests/PayPal/Test/Api/RefundTest.php index 9a0387e..657e167 100644 --- a/tests/PayPal/Test/Api/RefundTest.php +++ b/tests/PayPal/Test/Api/RefundTest.php @@ -10,19 +10,17 @@ class RefundTest extends \PHPUnit_Framework_TestCase { public static $captureId = "CAP-123"; public static $createTime = "2013-02-28T00:00:00Z"; - public static $description = "Test refund"; public static $id = "R-5678"; public static $parentPayment = "PAY-123"; public static function createRefund() { $refund = new Refund(); + $refund->setCreateTime(self::$createTime); $refund->setAmount(AmountTest::createAmount()); - $refund->setCapture_id(self::$captureId); - $refund->setCreate_time(self::$createTime); - $refund->setDescription(self::$description); + $refund->setCaptureId(self::$captureId); $refund->setId(self::$id); - $refund->setLinks(array(LinkTest::createLink())); - $refund->setParent_payment(self::$parentPayment); + $refund->setLinks(array(LinksTest::createLinks())); + $refund->setParentPayment(self::$parentPayment); return $refund; } @@ -32,14 +30,13 @@ class RefundTest extends \PHPUnit_Framework_TestCase { } public function testGetterSetter() { - $this->assertEquals(self::$captureId, $this->refund->getCapture_id()); - $this->assertEquals(self::$createTime, $this->refund->getCreate_time()); - $this->assertEquals(self::$description, $this->refund->getDescription()); + $this->assertEquals(self::$captureId, $this->refund->getCaptureId()); + $this->assertEquals(self::$createTime, $this->refund->getCreateTime()); $this->assertEquals(self::$id, $this->refund->getId()); - $this->assertEquals(self::$parentPayment, $this->refund->getParent_payment()); + $this->assertEquals(self::$parentPayment, $this->refund->getParentPayment()); $this->assertEquals(AmountTest::$currency, $this->refund->getAmount()->getCurrency()); $links = $this->refund->getLinks(); - $this->assertEquals(LinkTest::$href, $links[0]->getHref()); + $this->assertEquals(LinksTest::$href, $links[0]->getHref()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/RelatedResourcesTest.php b/tests/PayPal/Test/Api/RelatedResourcesTest.php new file mode 100644 index 0000000..c977395 --- /dev/null +++ b/tests/PayPal/Test/Api/RelatedResourcesTest.php @@ -0,0 +1,35 @@ +setAuthorization(AuthorizationTest::createAuthorization()); + $relatedResources->setCapture(CaptureTest::createCapture()); + return $relatedResources; + } + + public function setup() { + $this->relatedResources = self::createRelatedResources(); + } + + public function testGetterSetter() { + $this->assertEquals(AuthorizationTest::$create_time, $this->relatedResources->getAuthorization()->getCreateTime()); + $this->assertEquals(CaptureTest::$create_time, $this->relatedResources->getCapture()->getCreateTime()); + } + + public function testSerializeDeserialize() { + $s1 = $this->relatedResources; + + $s2 = new RelatedResources(); + $s2->fromJson($s1->toJson()); + + $this->assertEquals($s1, $s2); + } +} \ No newline at end of file diff --git a/tests/PayPal/Test/Api/SaleTest.php b/tests/PayPal/Test/Api/SaleTest.php index fb46f74..b4c6972 100644 --- a/tests/PayPal/Test/Api/SaleTest.php +++ b/tests/PayPal/Test/Api/SaleTest.php @@ -6,7 +6,7 @@ use PayPal\Api\Sale; use PayPal\Test\Constants; use PayPal\Test\Api\AmountTest; use PayPal\Test\Api\PaymentTest; -use PayPal\Test\Api\LinkTest; +use PayPal\Test\Api\LinksTest; class SaleTest extends \PHPUnit_Framework_TestCase { @@ -14,7 +14,6 @@ class SaleTest extends \PHPUnit_Framework_TestCase { public static $captureId = "CAP-123"; public static $createTime = "2013-02-28T00:00:00Z"; - public static $description = "Test refund"; public static $id = "R-5678"; public static $parentPayment = "PAY-123"; public static $state = "Created"; @@ -22,10 +21,10 @@ class SaleTest extends \PHPUnit_Framework_TestCase { public static function createSale() { $sale = new Sale(); $sale->setAmount(AmountTest::createAmount()); - $sale->setCreate_time(self::$createTime); + $sale->setCreateTime(self::$createTime); $sale->setId(self::$id); - $sale->setLinks(array(LinkTest::createLink())); - $sale->setParent_payment(self::$parentPayment); + $sale->setLinks(array(LinksTest::createLinks())); + $sale->setParentPayment(self::$parentPayment); $sale->setState(self::$state); return $sale; } @@ -35,13 +34,13 @@ class SaleTest extends \PHPUnit_Framework_TestCase { } public function testGetterSetter() { - $this->assertEquals(self::$createTime, $this->sale->getCreate_time()); + $this->assertEquals(self::$createTime, $this->sale->getCreateTime()); $this->assertEquals(self::$id, $this->sale->getId()); - $this->assertEquals(self::$parentPayment, $this->sale->getParent_payment()); + $this->assertEquals(self::$parentPayment, $this->sale->getParentPayment()); $this->assertEquals(self::$state, $this->sale->getState()); $this->assertEquals(AmountTest::$currency, $this->sale->getAmount()->getCurrency()); $links = $this->sale->getLinks(); - $this->assertEquals(LinkTest::$href, $links[0]->getHref()); + $this->assertEquals(LinksTest::$href, $links[0]->getHref()); } public function testSerializeDeserialize() { @@ -58,7 +57,7 @@ class SaleTest extends \PHPUnit_Framework_TestCase { $payment->create(); $transactions = $payment->getTransactions(); - $resources = $transactions[0]->getRelated_resources(); + $resources = $transactions[0]->getRelatedResources(); $saleId = $resources[0]->getSale()->getId(); $sale = Sale::get($saleId); diff --git a/tests/PayPal/Test/Api/ShippingAddressTest.php b/tests/PayPal/Test/Api/ShippingAddressTest.php index 4560ae1..6ca8b93 100644 --- a/tests/PayPal/Test/Api/ShippingAddressTest.php +++ b/tests/PayPal/Test/Api/ShippingAddressTest.php @@ -16,7 +16,6 @@ class ShippingAddressTest extends \PHPUnit_Framework_TestCase { public static $countryCode = "US"; public static $phone = "716-298-1822"; public static $recipientName = "TestUser"; - public static $type = "Billing"; public static function createAddress() { $addr = new ShippingAddress(); @@ -24,11 +23,10 @@ class ShippingAddressTest extends \PHPUnit_Framework_TestCase { $addr->setLine2(self::$line2); $addr->setCity(self::$city); $addr->setState(self::$state); - $addr->setPostal_code(self::$postalCode); - $addr->setCountry_code(self::$countryCode); + $addr->setPostalCode(self::$postalCode); + $addr->setCountryCode(self::$countryCode); $addr->setPhone(self::$phone); - $addr->setRecipient_name(self::$recipientName); - $addr->setType(self::$type); + $addr->setRecipientName(self::$recipientName); return $addr; } @@ -41,11 +39,10 @@ class ShippingAddressTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(self::$line2, $this->address->getLine2()); $this->assertEquals(self::$city, $this->address->getCity()); $this->assertEquals(self::$state, $this->address->getState()); - $this->assertEquals(self::$postalCode, $this->address->getPostal_code()); - $this->assertEquals(self::$countryCode, $this->address->getCountry_code()); + $this->assertEquals(self::$postalCode, $this->address->getPostalCode()); + $this->assertEquals(self::$countryCode, $this->address->getCountryCode()); $this->assertEquals(self::$phone, $this->address->getPhone()); - $this->assertEquals(self::$recipientName, $this->address->getRecipient_name()); - $this->assertEquals(self::$type, $this->address->getType()); + $this->assertEquals(self::$recipientName, $this->address->getRecipientName()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/SubTransactionTest.php b/tests/PayPal/Test/Api/SubTransactionTest.php deleted file mode 100644 index 7d57496..0000000 --- a/tests/PayPal/Test/Api/SubTransactionTest.php +++ /dev/null @@ -1,35 +0,0 @@ -setAuthorization(AuthorizationTest::createAuthorization()); - $subTransaction->setCapture(CaptureTest::createCapture()); - return $subTransaction; - } - - public function setup() { - $this->subTransaction = self::createSubTransaction(); - } - - public function testGetterSetter() { - $this->assertEquals(AuthorizationTest::$create_time, $this->subTransaction->getAuthorization()->getCreate_Time()); - $this->assertEquals(CaptureTest::$create_time, $this->subTransaction->getCapture()->getCreate_Time()); - } - - public function testSerializeDeserialize() { - $s1 = $this->subTransaction; - - $s2 = new SubTransaction(); - $s2->fromJson($s1->toJson()); - - $this->assertEquals($s1, $s2); - } -} \ No newline at end of file diff --git a/tests/PayPal/Test/Api/TransactionTest.php b/tests/PayPal/Test/Api/TransactionTest.php index d23b281..f2e0ba3 100644 --- a/tests/PayPal/Test/Api/TransactionTest.php +++ b/tests/PayPal/Test/Api/TransactionTest.php @@ -18,9 +18,9 @@ class TransactionTest extends \PHPUnit_Framework_TestCase { $transaction = new Transaction(); $transaction->setAmount(AmountTest::createAmount()); $transaction->setDescription(self::$description); - $transaction->setItem_list(ItemListTest::createItemList()); + $transaction->setItemList(ItemListTest::createItemList()); $transaction->setPayee(PayeeTest::createPayee()); - $transaction->setRelated_resources( array(SubTransactionTest::createSubTransaction()) ); + $transaction->setRelatedResources( array(RelatedResourcesTest::createRelatedResources()) ); return $transaction; } @@ -31,11 +31,11 @@ class TransactionTest extends \PHPUnit_Framework_TestCase { public function testGetterSetter() { $this->assertEquals(AmountTest::$currency, $this->transaction->getAmount()->getCurrency()); $this->assertEquals(self::$description, $this->transaction->getDescription()); - $items = $this->transaction->getItem_list()->getItems(); + $items = $this->transaction->getItemList()->getItems(); $this->assertEquals(ItemTest::$quantity, $items[0]->getQuantity()); $this->assertEquals(PayeeTest::$email, $this->transaction->getPayee()->getEmail()); - $resources = $this->transaction->getRelated_resources(); - $this->assertEquals(AuthorizationTest::$create_time, $resources[0]->getAuthorization()->getCreate_Time()); + $resources = $this->transaction->getRelatedResources(); + $this->assertEquals(AuthorizationTest::$create_time, $resources[0]->getAuthorization()->getCreateTime()); } public function testSerializeDeserialize() { From 86643ec2df4f90509ff64e5006886d6ee4038e5f Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Tue, 28 May 2013 10:15:29 +0530 Subject: [PATCH 04/20] updating stubs to have fluent setters and retaining deprecated methods --- lib/PayPal/Api/Address.php | 82 ++++++++--- lib/PayPal/Api/Amount.php | 24 ++-- lib/PayPal/Api/Authorization.php | 122 ++++++++++++---- lib/PayPal/Api/Capture.php | 122 ++++++++++++---- lib/PayPal/Api/CreditCard.php | 201 +++++++++++++++++++++------ lib/PayPal/Api/CreditCardHistory.php | 54 +++++-- lib/PayPal/Api/CreditCardToken.php | 100 ++++++++++--- lib/PayPal/Api/Details.php | 32 +++-- lib/PayPal/Api/FundingInstrument.php | 42 +++++- lib/PayPal/Api/HyperSchema.php | 100 ++++++++++--- lib/PayPal/Api/Item.php | 40 ++++-- lib/PayPal/Api/ItemList.php | 29 +++- lib/PayPal/Api/Links.php | 61 +++++--- lib/PayPal/Api/Payee.php | 37 +++-- lib/PayPal/Api/Payer.php | 63 +++++++-- lib/PayPal/Api/PayerInfo.php | 100 ++++++++++--- lib/PayPal/Api/Payment.php | 117 ++++++++++++---- lib/PayPal/Api/PaymentExecution.php | 29 +++- lib/PayPal/Api/PaymentHistory.php | 37 +++-- lib/PayPal/Api/RedirectUrls.php | 42 +++++- lib/PayPal/Api/Refund.php | 122 ++++++++++++---- lib/PayPal/Api/RelatedResources.php | 32 +++-- lib/PayPal/Api/Sale.php | 101 ++++++++++---- lib/PayPal/Api/ShippingAddress.php | 21 ++- lib/PayPal/Api/Transaction.php | 74 +++++++--- lib/PayPal/Api/Transactions.php | 8 +- 26 files changed, 1388 insertions(+), 404 deletions(-) diff --git a/lib/PayPal/Api/Address.php b/lib/PayPal/Api/Address.php index e7a208e..46129a1 100644 --- a/lib/PayPal/Api/Address.php +++ b/lib/PayPal/Api/Address.php @@ -9,8 +9,9 @@ class Address extends \PPModel { */ public function setLine1($line1) { $this->line1 = $line1; - } - + return $this; + } + /** * Line 1 of the Address (eg. number, street, etc). * @return string @@ -18,15 +19,17 @@ class Address extends \PPModel { public function getLine1() { return $this->line1; } - + + /** * Optional line 2 of the Address (eg. suite, apt #, etc.). * @param string $line2 */ public function setLine2($line2) { $this->line2 = $line2; - } - + return $this; + } + /** * Optional line 2 of the Address (eg. suite, apt #, etc.). * @return string @@ -34,15 +37,17 @@ class Address extends \PPModel { public function getLine2() { return $this->line2; } - + + /** * City name. * @param string $city */ public function setCity($city) { $this->city = $city; - } - + return $this; + } + /** * City name. * @return string @@ -50,15 +55,17 @@ class Address extends \PPModel { public function getCity() { return $this->city; } - + + /** * 2 letter country code. * @param string $country_code */ public function setCountryCode($country_code) { $this->country_code = $country_code; - } - + return $this; + } + /** * 2 letter country code. * @return string @@ -66,15 +73,30 @@ class Address extends \PPModel { public function getCountryCode() { return $this->country_code; } - + + /** + * Deprecated method + */ + public function setCountry_code($country_code) { + $this->country_code = $country_code; + return $this; + } + /** + * Deprecated method + */ + public function getCountry_code() { + return $this->country_code; + } + /** * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code. * @param string $postal_code */ public function setPostalCode($postal_code) { $this->postal_code = $postal_code; - } - + return $this; + } + /** * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code. * @return string @@ -82,15 +104,30 @@ class Address extends \PPModel { public function getPostalCode() { return $this->postal_code; } - + + /** + * Deprecated method + */ + public function setPostal_code($postal_code) { + $this->postal_code = $postal_code; + return $this; + } + /** + * Deprecated method + */ + public function getPostal_code() { + return $this->postal_code; + } + /** * 2 letter code for US states, and the equivalent for other countries. * @param string $state */ public function setState($state) { $this->state = $state; - } - + return $this; + } + /** * 2 letter code for US states, and the equivalent for other countries. * @return string @@ -98,15 +135,17 @@ class Address extends \PPModel { public function getState() { return $this->state; } - + + /** * Phone number in E.123 format. * @param string $phone */ public function setPhone($phone) { $this->phone = $phone; - } - + return $this; + } + /** * Phone number in E.123 format. * @return string @@ -114,5 +153,6 @@ class Address extends \PPModel { public function getPhone() { return $this->phone; } - + + } diff --git a/lib/PayPal/Api/Amount.php b/lib/PayPal/Api/Amount.php index 04f09dc..8618690 100644 --- a/lib/PayPal/Api/Amount.php +++ b/lib/PayPal/Api/Amount.php @@ -9,8 +9,9 @@ class Amount extends \PPModel { */ public function setCurrency($currency) { $this->currency = $currency; - } - + return $this; + } + /** * 3 letter currency code * @return string @@ -18,15 +19,17 @@ class Amount extends \PPModel { public function getCurrency() { return $this->currency; } - + + /** * Total amount charged from the Payer account (or card) to Payee. In case of a refund, this is the refunded amount to the original Payer from Payee account. * @param string $total */ public function setTotal($total) { $this->total = $total; - } - + return $this; + } + /** * Total amount charged from the Payer account (or card) to Payee. In case of a refund, this is the refunded amount to the original Payer from Payee account. * @return string @@ -34,15 +37,17 @@ class Amount extends \PPModel { public function getTotal() { return $this->total; } - + + /** * Additional details of the payment amount. * @param PayPal\Api\Details $details */ public function setDetails($details) { $this->details = $details; - } - + return $this; + } + /** * Additional details of the payment amount. * @return PayPal\Api\Details @@ -50,5 +55,6 @@ class Amount extends \PPModel { public function getDetails() { return $this->details; } - + + } diff --git a/lib/PayPal/Api/Authorization.php b/lib/PayPal/Api/Authorization.php index 17862a8..c7d5648 100644 --- a/lib/PayPal/Api/Authorization.php +++ b/lib/PayPal/Api/Authorization.php @@ -6,9 +6,9 @@ use PayPal\Rest\Call; use PayPal\Rest\ApiContext; class Authorization extends \PPModel implements IResource { - + private static $credential; - + /** * * @deprected. Pass ApiContext to create/get methods instead @@ -16,15 +16,16 @@ class Authorization extends \PPModel implements IResource { public static function setCredential($credential) { self::$credential = $credential; } - + /** * Identifier of the authorization transaction. * @param string $id */ public function setId($id) { $this->id = $id; - } - + return $this; + } + /** * Identifier of the authorization transaction. * @return string @@ -32,15 +33,17 @@ class Authorization extends \PPModel implements IResource { public function getId() { return $this->id; } - + + /** * Time the resource was created. * @param string $create_time */ public function setCreateTime($create_time) { $this->create_time = $create_time; - } - + return $this; + } + /** * Time the resource was created. * @return string @@ -48,15 +51,30 @@ class Authorization extends \PPModel implements IResource { public function getCreateTime() { return $this->create_time; } - + + /** + * Deprecated method + */ + public function setCreate_time($create_time) { + $this->create_time = $create_time; + return $this; + } + /** + * Deprecated method + */ + public function getCreate_time() { + return $this->create_time; + } + /** * Time the resource was last updated. * @param string $update_time */ public function setUpdateTime($update_time) { $this->update_time = $update_time; - } - + return $this; + } + /** * Time the resource was last updated. * @return string @@ -64,15 +82,30 @@ class Authorization extends \PPModel implements IResource { public function getUpdateTime() { return $this->update_time; } - + + /** + * Deprecated method + */ + public function setUpdate_time($update_time) { + $this->update_time = $update_time; + return $this; + } + /** + * Deprecated method + */ + public function getUpdate_time() { + return $this->update_time; + } + /** * Amount being authorized for. * @param PayPal\Api\Amount $amount */ public function setAmount($amount) { $this->amount = $amount; - } - + return $this; + } + /** * Amount being authorized for. * @return PayPal\Api\Amount @@ -80,15 +113,17 @@ class Authorization extends \PPModel implements IResource { public function getAmount() { return $this->amount; } - + + /** * State of the authorization transaction. * @param string $state */ public function setState($state) { $this->state = $state; - } - + return $this; + } + /** * State of the authorization transaction. * @return string @@ -96,15 +131,17 @@ class Authorization extends \PPModel implements IResource { public function getState() { return $this->state; } - + + /** * ID of the Payment resource that this transaction is based on. * @param string $parent_payment */ public function setParentPayment($parent_payment) { $this->parent_payment = $parent_payment; - } - + return $this; + } + /** * ID of the Payment resource that this transaction is based on. * @return string @@ -112,15 +149,30 @@ class Authorization extends \PPModel implements IResource { public function getParentPayment() { return $this->parent_payment; } - + + /** + * Deprecated method + */ + public function setParent_payment($parent_payment) { + $this->parent_payment = $parent_payment; + return $this; + } + /** + * Deprecated method + */ + public function getParent_payment() { + return $this->parent_payment; + } + /** * Date/Time until which funds may be captured against this resource. * @param string $valid_until */ public function setValidUntil($valid_until) { $this->valid_until = $valid_until; - } - + return $this; + } + /** * Date/Time until which funds may be captured against this resource. * @return string @@ -128,7 +180,21 @@ class Authorization extends \PPModel implements IResource { public function getValidUntil() { return $this->valid_until; } - + + /** + * Deprecated method + */ + public function setValid_until($valid_until) { + $this->valid_until = $valid_until; + return $this; + } + /** + * Deprecated method + */ + public function getValid_until() { + return $this->valid_until; + } + /** * * @array @@ -136,8 +202,9 @@ class Authorization extends \PPModel implements IResource { */ public function setLinks($links) { $this->links = $links; - } - + return $this; + } + /** * * @return PayPal\Api\Links @@ -145,7 +212,8 @@ class Authorization extends \PPModel implements IResource { public function getLinks() { return $this->links; } - + + public static function get($authorizationId, $apiContext = null) { if (($authorizationId == null) || (strlen($authorizationId) <= 0)) { diff --git a/lib/PayPal/Api/Capture.php b/lib/PayPal/Api/Capture.php index 96d3186..038a310 100644 --- a/lib/PayPal/Api/Capture.php +++ b/lib/PayPal/Api/Capture.php @@ -6,9 +6,9 @@ use PayPal\Rest\Call; use PayPal\Rest\ApiContext; class Capture extends \PPModel implements IResource { - + private static $credential; - + /** * * @deprected. Pass ApiContext to create/get methods instead @@ -16,15 +16,16 @@ class Capture extends \PPModel implements IResource { public static function setCredential($credential) { self::$credential = $credential; } - + /** * Identifier of the Capture transaction. * @param string $id */ public function setId($id) { $this->id = $id; - } - + return $this; + } + /** * Identifier of the Capture transaction. * @return string @@ -32,15 +33,17 @@ class Capture extends \PPModel implements IResource { public function getId() { return $this->id; } - + + /** * Time the resource was created. * @param string $create_time */ public function setCreateTime($create_time) { $this->create_time = $create_time; - } - + return $this; + } + /** * Time the resource was created. * @return string @@ -48,15 +51,30 @@ class Capture extends \PPModel implements IResource { public function getCreateTime() { return $this->create_time; } - + + /** + * Deprecated method + */ + public function setCreate_time($create_time) { + $this->create_time = $create_time; + return $this; + } + /** + * Deprecated method + */ + public function getCreate_time() { + return $this->create_time; + } + /** * Time the resource was last updated. * @param string $update_time */ public function setUpdateTime($update_time) { $this->update_time = $update_time; - } - + return $this; + } + /** * Time the resource was last updated. * @return string @@ -64,15 +82,30 @@ class Capture extends \PPModel implements IResource { public function getUpdateTime() { return $this->update_time; } - + + /** + * Deprecated method + */ + public function setUpdate_time($update_time) { + $this->update_time = $update_time; + return $this; + } + /** + * Deprecated method + */ + public function getUpdate_time() { + return $this->update_time; + } + /** * Amount being captured. If no amount is specified, amount is used from the authorization being captured. If amount is same as the amount that's authorized for, the state of the authorization changes to captured. If not, the state of the authorization changes to partially_captured. Alternatively, you could indicate a final capture by seting the is_final_capture flag to true. * @param PayPal\Api\Amount $amount */ public function setAmount($amount) { $this->amount = $amount; - } - + return $this; + } + /** * Amount being captured. If no amount is specified, amount is used from the authorization being captured. If amount is same as the amount that's authorized for, the state of the authorization changes to captured. If not, the state of the authorization changes to partially_captured. Alternatively, you could indicate a final capture by seting the is_final_capture flag to true. * @return PayPal\Api\Amount @@ -80,15 +113,17 @@ class Capture extends \PPModel implements IResource { public function getAmount() { return $this->amount; } - + + /** * whether this is a final capture for the given authorization or not. If it's final, all the remaining funds held by the authorization, will be released in the funding instrument. * @param boolean $is_final_capture */ public function setIsFinalCapture($is_final_capture) { $this->is_final_capture = $is_final_capture; - } - + return $this; + } + /** * whether this is a final capture for the given authorization or not. If it's final, all the remaining funds held by the authorization, will be released in the funding instrument. * @return boolean @@ -96,15 +131,30 @@ class Capture extends \PPModel implements IResource { public function getIsFinalCapture() { return $this->is_final_capture; } - + + /** + * Deprecated method + */ + public function setIs_final_capture($is_final_capture) { + $this->is_final_capture = $is_final_capture; + return $this; + } + /** + * Deprecated method + */ + public function getIs_final_capture() { + return $this->is_final_capture; + } + /** * State of the capture transaction. * @param string $state */ public function setState($state) { $this->state = $state; - } - + return $this; + } + /** * State of the capture transaction. * @return string @@ -112,15 +162,17 @@ class Capture extends \PPModel implements IResource { public function getState() { return $this->state; } - + + /** * ID of the Payment resource that this transaction is based on. * @param string $parent_payment */ public function setParentPayment($parent_payment) { $this->parent_payment = $parent_payment; - } - + return $this; + } + /** * ID of the Payment resource that this transaction is based on. * @return string @@ -128,7 +180,21 @@ class Capture extends \PPModel implements IResource { public function getParentPayment() { return $this->parent_payment; } - + + /** + * Deprecated method + */ + public function setParent_payment($parent_payment) { + $this->parent_payment = $parent_payment; + return $this; + } + /** + * Deprecated method + */ + public function getParent_payment() { + return $this->parent_payment; + } + /** * * @array @@ -136,8 +202,9 @@ class Capture extends \PPModel implements IResource { */ public function setLinks($links) { $this->links = $links; - } - + return $this; + } + /** * * @return PayPal\Api\Links @@ -145,7 +212,8 @@ class Capture extends \PPModel implements IResource { public function getLinks() { return $this->links; } - + + public static function get($captureId, $apiContext = null) { if (($captureId == null) || (strlen($captureId) <= 0)) { diff --git a/lib/PayPal/Api/CreditCard.php b/lib/PayPal/Api/CreditCard.php index 8c2582f..b5e7020 100644 --- a/lib/PayPal/Api/CreditCard.php +++ b/lib/PayPal/Api/CreditCard.php @@ -6,9 +6,9 @@ use PayPal\Rest\Call; use PayPal\Rest\ApiContext; class CreditCard extends \PPModel implements IResource { - + private static $credential; - + /** * * @deprected. Pass ApiContext to create/get methods instead @@ -16,15 +16,16 @@ class CreditCard extends \PPModel implements IResource { public static function setCredential($credential) { self::$credential = $credential; } - + /** * ID of the credit card being saved for later use. * @param string $id */ public function setId($id) { $this->id = $id; - } - + return $this; + } + /** * ID of the credit card being saved for later use. * @return string @@ -32,15 +33,17 @@ class CreditCard extends \PPModel implements IResource { public function getId() { return $this->id; } - + + /** * Card number. * @param string $number */ public function setNumber($number) { $this->number = $number; - } - + return $this; + } + /** * Card number. * @return string @@ -48,15 +51,17 @@ class CreditCard extends \PPModel implements IResource { public function getNumber() { return $this->number; } - + + /** * Type of the Card (eg. Visa, Mastercard, etc.). * @param string $type */ public function setType($type) { $this->type = $type; - } - + return $this; + } + /** * Type of the Card (eg. Visa, Mastercard, etc.). * @return string @@ -64,15 +69,17 @@ class CreditCard extends \PPModel implements IResource { public function getType() { return $this->type; } - + + /** * card expiry month with value 1 - 12. * @param integer $expire_month */ public function setExpireMonth($expire_month) { $this->expire_month = $expire_month; - } - + return $this; + } + /** * card expiry month with value 1 - 12. * @return integer @@ -80,15 +87,30 @@ class CreditCard extends \PPModel implements IResource { public function getExpireMonth() { return $this->expire_month; } - + + /** + * Deprecated method + */ + public function setExpire_month($expire_month) { + $this->expire_month = $expire_month; + return $this; + } + /** + * Deprecated method + */ + public function getExpire_month() { + return $this->expire_month; + } + /** * 4 digit card expiry year * @param integer $expire_year */ public function setExpireYear($expire_year) { $this->expire_year = $expire_year; - } - + return $this; + } + /** * 4 digit card expiry year * @return integer @@ -96,15 +118,30 @@ class CreditCard extends \PPModel implements IResource { public function getExpireYear() { return $this->expire_year; } - + + /** + * Deprecated method + */ + public function setExpire_year($expire_year) { + $this->expire_year = $expire_year; + return $this; + } + /** + * Deprecated method + */ + public function getExpire_year() { + return $this->expire_year; + } + /** * Card validation code. Only supported when making a Payment but not when saving a credit card for future use. * @param string $cvv2 */ public function setCvv2($cvv2) { $this->cvv2 = $cvv2; - } - + return $this; + } + /** * Card validation code. Only supported when making a Payment but not when saving a credit card for future use. * @return string @@ -112,15 +149,17 @@ class CreditCard extends \PPModel implements IResource { public function getCvv2() { return $this->cvv2; } - + + /** * Card holder's first name. * @param string $first_name */ public function setFirstName($first_name) { $this->first_name = $first_name; - } - + return $this; + } + /** * Card holder's first name. * @return string @@ -128,15 +167,30 @@ class CreditCard extends \PPModel implements IResource { public function getFirstName() { return $this->first_name; } - + + /** + * Deprecated method + */ + public function setFirst_name($first_name) { + $this->first_name = $first_name; + return $this; + } + /** + * Deprecated method + */ + public function getFirst_name() { + return $this->first_name; + } + /** * Card holder's last name. * @param string $last_name */ public function setLastName($last_name) { $this->last_name = $last_name; - } - + return $this; + } + /** * Card holder's last name. * @return string @@ -144,15 +198,30 @@ class CreditCard extends \PPModel implements IResource { public function getLastName() { return $this->last_name; } - + + /** + * Deprecated method + */ + public function setLast_name($last_name) { + $this->last_name = $last_name; + return $this; + } + /** + * Deprecated method + */ + public function getLast_name() { + return $this->last_name; + } + /** * Billing Address associated with this card. * @param PayPal\Api\Address $billing_address */ public function setBillingAddress($billing_address) { $this->billing_address = $billing_address; - } - + return $this; + } + /** * Billing Address associated with this card. * @return PayPal\Api\Address @@ -160,15 +229,30 @@ class CreditCard extends \PPModel implements IResource { public function getBillingAddress() { return $this->billing_address; } - + + /** + * Deprecated method + */ + public function setBilling_address($billing_address) { + $this->billing_address = $billing_address; + return $this; + } + /** + * Deprecated method + */ + public function getBilling_address() { + return $this->billing_address; + } + /** * A unique identifier of the payer generated and provided by the facilitator. This is required when creating or using a tokenized funding instrument. * @param string $payer_id */ public function setPayerId($payer_id) { $this->payer_id = $payer_id; - } - + return $this; + } + /** * A unique identifier of the payer generated and provided by the facilitator. This is required when creating or using a tokenized funding instrument. * @return string @@ -176,15 +260,30 @@ class CreditCard extends \PPModel implements IResource { public function getPayerId() { return $this->payer_id; } - + + /** + * Deprecated method + */ + public function setPayer_id($payer_id) { + $this->payer_id = $payer_id; + return $this; + } + /** + * Deprecated method + */ + public function getPayer_id() { + return $this->payer_id; + } + /** * State of the funding instrument. * @param string $state */ public function setState($state) { $this->state = $state; - } - + return $this; + } + /** * State of the funding instrument. * @return string @@ -192,15 +291,17 @@ class CreditCard extends \PPModel implements IResource { public function getState() { return $this->state; } - + + /** * Date/Time until this resource can be used fund a payment. * @param string $valid_until */ public function setValidUntil($valid_until) { $this->valid_until = $valid_until; - } - + return $this; + } + /** * Date/Time until this resource can be used fund a payment. * @return string @@ -208,7 +309,21 @@ class CreditCard extends \PPModel implements IResource { public function getValidUntil() { return $this->valid_until; } - + + /** + * Deprecated method + */ + public function setValid_until($valid_until) { + $this->valid_until = $valid_until; + return $this; + } + /** + * Deprecated method + */ + public function getValid_until() { + return $this->valid_until; + } + /** * * @array @@ -216,8 +331,9 @@ class CreditCard extends \PPModel implements IResource { */ public function setLinks($links) { $this->links = $links; - } - + return $this; + } + /** * * @return PayPal\Api\Links @@ -225,7 +341,8 @@ class CreditCard extends \PPModel implements IResource { public function getLinks() { return $this->links; } - + + public function create($apiContext = null) { $payLoad = $this->toJSON(); diff --git a/lib/PayPal/Api/CreditCardHistory.php b/lib/PayPal/Api/CreditCardHistory.php index 22059e1..a7e300d 100644 --- a/lib/PayPal/Api/CreditCardHistory.php +++ b/lib/PayPal/Api/CreditCardHistory.php @@ -8,10 +8,11 @@ class CreditCardHistory extends \PPModel { * @array * @param PayPal\Api\CreditCard $credit-cards */ - public function setCreditCards($credit-cards) { - $this->credit-cards = $credit-cards; - } - + public function setCreditCards($credit_cards) { + $this->credit_cards = $credit_cards; + return $this; + } + /** * A list of credit card resources * @return PayPal\Api\CreditCard @@ -19,15 +20,30 @@ class CreditCardHistory extends \PPModel { public function getCreditCards() { return $this->credit-cards; } - + + /** + * Deprecated method + */ + public function setCredit_cards($credit_cards) { + $this->credit_cards = $credit_cards; + return $this; + } + /** + * Deprecated method + */ + public function getCredit_cards() { + return $this->credit-cards; + } + /** * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items. * @param integer $count */ public function setCount($count) { $this->count = $count; - } - + return $this; + } + /** * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items. * @return integer @@ -35,15 +51,17 @@ class CreditCardHistory extends \PPModel { public function getCount() { return $this->count; } - + + /** * Identifier of the next element to get the next range of results. * @param string $next_id */ public function setNextId($next_id) { $this->next_id = $next_id; - } - + return $this; + } + /** * Identifier of the next element to get the next range of results. * @return string @@ -51,5 +69,19 @@ class CreditCardHistory extends \PPModel { public function getNextId() { return $this->next_id; } - + + /** + * Deprecated method + */ + public function setNext_id($next_id) { + $this->next_id = $next_id; + return $this; + } + /** + * Deprecated method + */ + public function getNext_id() { + return $this->next_id; + } + } diff --git a/lib/PayPal/Api/CreditCardToken.php b/lib/PayPal/Api/CreditCardToken.php index 0f748e5..b763302 100644 --- a/lib/PayPal/Api/CreditCardToken.php +++ b/lib/PayPal/Api/CreditCardToken.php @@ -9,8 +9,9 @@ class CreditCardToken extends \PPModel { */ public function setCreditCardId($credit_card_id) { $this->credit_card_id = $credit_card_id; - } - + return $this; + } + /** * ID of a previously saved Credit Card resource using /vault/credit-card API. * @return string @@ -18,15 +19,30 @@ class CreditCardToken extends \PPModel { public function getCreditCardId() { return $this->credit_card_id; } - + + /** + * Deprecated method + */ + public function setCredit_card_id($credit_card_id) { + $this->credit_card_id = $credit_card_id; + return $this; + } + /** + * Deprecated method + */ + public function getCredit_card_id() { + return $this->credit_card_id; + } + /** * The unique identifier of the payer used when saving this credit card using /vault/credit-card API. * @param string $payer_id */ public function setPayerId($payer_id) { $this->payer_id = $payer_id; - } - + return $this; + } + /** * The unique identifier of the payer used when saving this credit card using /vault/credit-card API. * @return string @@ -34,15 +50,30 @@ class CreditCardToken extends \PPModel { public function getPayerId() { return $this->payer_id; } - + + /** + * Deprecated method + */ + public function setPayer_id($payer_id) { + $this->payer_id = $payer_id; + return $this; + } + /** + * Deprecated method + */ + public function getPayer_id() { + return $this->payer_id; + } + /** * Last 4 digits of the card number from the saved card. * @param string $last4 */ public function setLast4($last4) { $this->last4 = $last4; - } - + return $this; + } + /** * Last 4 digits of the card number from the saved card. * @return string @@ -50,15 +81,17 @@ class CreditCardToken extends \PPModel { public function getLast4() { return $this->last4; } - + + /** * Type of the Card (eg. visa, mastercard, etc.) from the saved card. Please note that the values are always in lowercase and not meant to be used directly for display. * @param string $type */ public function setType($type) { $this->type = $type; - } - + return $this; + } + /** * Type of the Card (eg. visa, mastercard, etc.) from the saved card. Please note that the values are always in lowercase and not meant to be used directly for display. * @return string @@ -66,15 +99,17 @@ class CreditCardToken extends \PPModel { public function getType() { return $this->type; } - + + /** * card expiry month from the saved card with value 1 - 12 * @param integer $expire_month */ public function setExpireMonth($expire_month) { $this->expire_month = $expire_month; - } - + return $this; + } + /** * card expiry month from the saved card with value 1 - 12 * @return integer @@ -82,15 +117,30 @@ class CreditCardToken extends \PPModel { public function getExpireMonth() { return $this->expire_month; } - + + /** + * Deprecated method + */ + public function setExpire_month($expire_month) { + $this->expire_month = $expire_month; + return $this; + } + /** + * Deprecated method + */ + public function getExpire_month() { + return $this->expire_month; + } + /** * 4 digit card expiry year from the saved card * @param integer $expire_year */ public function setExpireYear($expire_year) { $this->expire_year = $expire_year; - } - + return $this; + } + /** * 4 digit card expiry year from the saved card * @return integer @@ -98,5 +148,19 @@ class CreditCardToken extends \PPModel { public function getExpireYear() { return $this->expire_year; } - + + /** + * Deprecated method + */ + public function setExpire_year($expire_year) { + $this->expire_year = $expire_year; + return $this; + } + /** + * Deprecated method + */ + public function getExpire_year() { + return $this->expire_year; + } + } diff --git a/lib/PayPal/Api/Details.php b/lib/PayPal/Api/Details.php index e13bf4c..2a18fa1 100644 --- a/lib/PayPal/Api/Details.php +++ b/lib/PayPal/Api/Details.php @@ -9,8 +9,9 @@ class Details extends \PPModel { */ public function setShipping($shipping) { $this->shipping = $shipping; - } - + return $this; + } + /** * Amount being charged for shipping. * @return string @@ -18,15 +19,17 @@ class Details extends \PPModel { public function getShipping() { return $this->shipping; } - + + /** * Sub-total (amount) of items being paid for. * @param string $subtotal */ public function setSubtotal($subtotal) { $this->subtotal = $subtotal; - } - + return $this; + } + /** * Sub-total (amount) of items being paid for. * @return string @@ -34,15 +37,17 @@ class Details extends \PPModel { public function getSubtotal() { return $this->subtotal; } - + + /** * Amount being charged as tax. * @param string $tax */ public function setTax($tax) { $this->tax = $tax; - } - + return $this; + } + /** * Amount being charged as tax. * @return string @@ -50,15 +55,17 @@ class Details extends \PPModel { public function getTax() { return $this->tax; } - + + /** * Fee charged by PayPal. In case of a refund, this is the fee amount refunded to the original receipient of the payment. * @param string $fee */ public function setFee($fee) { $this->fee = $fee; - } - + return $this; + } + /** * Fee charged by PayPal. In case of a refund, this is the fee amount refunded to the original receipient of the payment. * @return string @@ -66,5 +73,6 @@ class Details extends \PPModel { public function getFee() { return $this->fee; } - + + } diff --git a/lib/PayPal/Api/FundingInstrument.php b/lib/PayPal/Api/FundingInstrument.php index 8728794..3ae3ba0 100644 --- a/lib/PayPal/Api/FundingInstrument.php +++ b/lib/PayPal/Api/FundingInstrument.php @@ -9,8 +9,9 @@ class FundingInstrument extends \PPModel { */ public function setCreditCard($credit_card) { $this->credit_card = $credit_card; - } - + return $this; + } + /** * Credit Card information. * @return PayPal\Api\CreditCard @@ -18,15 +19,30 @@ class FundingInstrument extends \PPModel { public function getCreditCard() { return $this->credit_card; } - + + /** + * Deprecated method + */ + public function setCredit_card($credit_card) { + $this->credit_card = $credit_card; + return $this; + } + /** + * Deprecated method + */ + public function getCredit_card() { + return $this->credit_card; + } + /** * Credit Card information. * @param PayPal\Api\CreditCardToken $credit_card_token */ public function setCreditCardToken($credit_card_token) { $this->credit_card_token = $credit_card_token; - } - + return $this; + } + /** * Credit Card information. * @return PayPal\Api\CreditCardToken @@ -34,5 +50,19 @@ class FundingInstrument extends \PPModel { public function getCreditCardToken() { return $this->credit_card_token; } - + + /** + * Deprecated method + */ + public function setCredit_card_token($credit_card_token) { + $this->credit_card_token = $credit_card_token; + return $this; + } + /** + * Deprecated method + */ + public function getCredit_card_token() { + return $this->credit_card_token; + } + } diff --git a/lib/PayPal/Api/HyperSchema.php b/lib/PayPal/Api/HyperSchema.php index b3323e3..661b8a5 100644 --- a/lib/PayPal/Api/HyperSchema.php +++ b/lib/PayPal/Api/HyperSchema.php @@ -10,8 +10,9 @@ class HyperSchema extends \PPModel { */ public function setLinks($links) { $this->links = $links; - } - + return $this; + } + /** * * @return PayPal\Api\Links @@ -19,15 +20,17 @@ class HyperSchema extends \PPModel { public function getLinks() { return $this->links; } - + + /** * * @param string $fragmentResolution */ public function setFragmentResolution($fragmentResolution) { $this->fragmentResolution = $fragmentResolution; - } - + return $this; + } + /** * * @return string @@ -35,15 +38,30 @@ class HyperSchema extends \PPModel { public function getFragmentResolution() { return $this->fragmentResolution; } - + + /** + * Deprecated method + */ + public function setFragmentresolution($fragmentResolution) { + $this->fragmentResolution = $fragmentResolution; + return $this; + } + /** + * Deprecated method + */ + public function getFragmentresolution() { + return $this->fragmentResolution; + } + /** * * @param boolean $readonly */ public function setReadonly($readonly) { $this->readonly = $readonly; - } - + return $this; + } + /** * * @return boolean @@ -51,15 +69,17 @@ class HyperSchema extends \PPModel { public function getReadonly() { return $this->readonly; } - + + /** * * @param string $contentEncoding */ public function setContentEncoding($contentEncoding) { $this->contentEncoding = $contentEncoding; - } - + return $this; + } + /** * * @return string @@ -67,15 +87,30 @@ class HyperSchema extends \PPModel { public function getContentEncoding() { return $this->contentEncoding; } - + + /** + * Deprecated method + */ + public function setContentencoding($contentEncoding) { + $this->contentEncoding = $contentEncoding; + return $this; + } + /** + * Deprecated method + */ + public function getContentencoding() { + return $this->contentEncoding; + } + /** * * @param string $pathStart */ public function setPathStart($pathStart) { $this->pathStart = $pathStart; - } - + return $this; + } + /** * * @return string @@ -83,15 +118,30 @@ class HyperSchema extends \PPModel { public function getPathStart() { return $this->pathStart; } - + + /** + * Deprecated method + */ + public function setPathstart($pathStart) { + $this->pathStart = $pathStart; + return $this; + } + /** + * Deprecated method + */ + public function getPathstart() { + return $this->pathStart; + } + /** * * @param string $mediaType */ public function setMediaType($mediaType) { $this->mediaType = $mediaType; - } - + return $this; + } + /** * * @return string @@ -99,5 +149,19 @@ class HyperSchema extends \PPModel { public function getMediaType() { return $this->mediaType; } - + + /** + * Deprecated method + */ + public function setMediatype($mediaType) { + $this->mediaType = $mediaType; + return $this; + } + /** + * Deprecated method + */ + public function getMediatype() { + return $this->mediaType; + } + } diff --git a/lib/PayPal/Api/Item.php b/lib/PayPal/Api/Item.php index 5d41685..fbd12b9 100644 --- a/lib/PayPal/Api/Item.php +++ b/lib/PayPal/Api/Item.php @@ -9,8 +9,9 @@ class Item extends \PPModel { */ public function setQuantity($quantity) { $this->quantity = $quantity; - } - + return $this; + } + /** * Number of items. * @return string @@ -18,15 +19,17 @@ class Item extends \PPModel { public function getQuantity() { return $this->quantity; } - + + /** * Name of the item. * @param string $name */ public function setName($name) { $this->name = $name; - } - + return $this; + } + /** * Name of the item. * @return string @@ -34,15 +37,17 @@ class Item extends \PPModel { public function getName() { return $this->name; } - + + /** * Cost of the item. * @param string $price */ public function setPrice($price) { $this->price = $price; - } - + return $this; + } + /** * Cost of the item. * @return string @@ -50,15 +55,17 @@ class Item extends \PPModel { public function getPrice() { return $this->price; } - + + /** * 3-letter Currency Code * @param string $currency */ public function setCurrency($currency) { $this->currency = $currency; - } - + return $this; + } + /** * 3-letter Currency Code * @return string @@ -66,15 +73,17 @@ class Item extends \PPModel { public function getCurrency() { return $this->currency; } - + + /** * Number or code to identify the item in your catalog/records. * @param string $sku */ public function setSku($sku) { $this->sku = $sku; - } - + return $this; + } + /** * Number or code to identify the item in your catalog/records. * @return string @@ -82,5 +91,6 @@ class Item extends \PPModel { public function getSku() { return $this->sku; } - + + } diff --git a/lib/PayPal/Api/ItemList.php b/lib/PayPal/Api/ItemList.php index 1181c0b..a3565da 100644 --- a/lib/PayPal/Api/ItemList.php +++ b/lib/PayPal/Api/ItemList.php @@ -10,8 +10,9 @@ class ItemList extends \PPModel { */ public function setItems($items) { $this->items = $items; - } - + return $this; + } + /** * List of items. * @return PayPal\Api\Item @@ -19,15 +20,17 @@ class ItemList extends \PPModel { public function getItems() { return $this->items; } - + + /** * Shipping address. * @param PayPal\Api\ShippingAddress $shipping_address */ public function setShippingAddress($shipping_address) { $this->shipping_address = $shipping_address; - } - + return $this; + } + /** * Shipping address. * @return PayPal\Api\ShippingAddress @@ -35,5 +38,19 @@ class ItemList extends \PPModel { public function getShippingAddress() { return $this->shipping_address; } - + + /** + * Deprecated method + */ + public function setShipping_address($shipping_address) { + $this->shipping_address = $shipping_address; + return $this; + } + /** + * Deprecated method + */ + public function getShipping_address() { + return $this->shipping_address; + } + } diff --git a/lib/PayPal/Api/Links.php b/lib/PayPal/Api/Links.php index 3f2408d..927b035 100644 --- a/lib/PayPal/Api/Links.php +++ b/lib/PayPal/Api/Links.php @@ -9,8 +9,9 @@ class Links extends \PPModel { */ public function setHref($href) { $this->href = $href; - } - + return $this; + } + /** * * @return string @@ -18,15 +19,17 @@ class Links extends \PPModel { public function getHref() { return $this->href; } - + + /** * * @param string $rel */ public function setRel($rel) { $this->rel = $rel; - } - + return $this; + } + /** * * @return string @@ -34,15 +37,17 @@ class Links extends \PPModel { public function getRel() { return $this->rel; } - + + /** * * @param PayPal\Api\HyperSchema $targetSchema */ public function setTargetSchema($targetSchema) { $this->targetSchema = $targetSchema; - } - + return $this; + } + /** * * @return PayPal\Api\HyperSchema @@ -50,15 +55,30 @@ class Links extends \PPModel { public function getTargetSchema() { return $this->targetSchema; } - + + /** + * Deprecated method + */ + public function setTargetschema($targetSchema) { + $this->targetSchema = $targetSchema; + return $this; + } + /** + * Deprecated method + */ + public function getTargetschema() { + return $this->targetSchema; + } + /** * * @param string $method */ public function setMethod($method) { $this->method = $method; - } - + return $this; + } + /** * * @return string @@ -66,15 +86,17 @@ class Links extends \PPModel { public function getMethod() { return $this->method; } - + + /** * * @param string $enctype */ public function setEnctype($enctype) { $this->enctype = $enctype; - } - + return $this; + } + /** * * @return string @@ -82,15 +104,17 @@ class Links extends \PPModel { public function getEnctype() { return $this->enctype; } - + + /** * * @param PayPal\Api\HyperSchema $schema */ public function setSchema($schema) { $this->schema = $schema; - } - + return $this; + } + /** * * @return PayPal\Api\HyperSchema @@ -98,5 +122,6 @@ class Links extends \PPModel { public function getSchema() { return $this->schema; } - + + } diff --git a/lib/PayPal/Api/Payee.php b/lib/PayPal/Api/Payee.php index 18188b1..355946d 100644 --- a/lib/PayPal/Api/Payee.php +++ b/lib/PayPal/Api/Payee.php @@ -9,8 +9,9 @@ class Payee extends \PPModel { */ public function setEmail($email) { $this->email = $email; - } - + return $this; + } + /** * Email Address associated with the Payee's PayPal Account. If the provided email address is not associated with any PayPal Account, the payee can only receiver PayPal Wallet Payments. Direct Credit Card Payments will be denied due to card compliance requirements. * @return string @@ -18,15 +19,17 @@ class Payee extends \PPModel { public function getEmail() { return $this->email; } - + + /** * Encrypted PayPal Account identifier for the Payee. * @param string $merchant_id */ public function setMerchantId($merchant_id) { $this->merchant_id = $merchant_id; - } - + return $this; + } + /** * Encrypted PayPal Account identifier for the Payee. * @return string @@ -34,15 +37,30 @@ class Payee extends \PPModel { public function getMerchantId() { return $this->merchant_id; } - + + /** + * Deprecated method + */ + public function setMerchant_id($merchant_id) { + $this->merchant_id = $merchant_id; + return $this; + } + /** + * Deprecated method + */ + public function getMerchant_id() { + return $this->merchant_id; + } + /** * Phone number (in E.123 format) associated with the Payee's PayPal Account. If the provided phont number is not associated with any PayPal Account, the payee can only receiver PayPal Wallet Payments. Direct Credit Card Payments will be denied due to card compliance requirements. * @param string $phone */ public function setPhone($phone) { $this->phone = $phone; - } - + return $this; + } + /** * Phone number (in E.123 format) associated with the Payee's PayPal Account. If the provided phont number is not associated with any PayPal Account, the payee can only receiver PayPal Wallet Payments. Direct Credit Card Payments will be denied due to card compliance requirements. * @return string @@ -50,5 +68,6 @@ class Payee extends \PPModel { public function getPhone() { return $this->phone; } - + + } diff --git a/lib/PayPal/Api/Payer.php b/lib/PayPal/Api/Payer.php index 16d91e8..a0d2f07 100644 --- a/lib/PayPal/Api/Payer.php +++ b/lib/PayPal/Api/Payer.php @@ -9,8 +9,9 @@ class Payer extends \PPModel { */ public function setPaymentMethod($payment_method) { $this->payment_method = $payment_method; - } - + return $this; + } + /** * Payment method being used - PayPal Wallet payment or Direct Credit card. * @return string @@ -18,7 +19,21 @@ class Payer extends \PPModel { public function getPaymentMethod() { return $this->payment_method; } - + + /** + * Deprecated method + */ + public function setPayment_method($payment_method) { + $this->payment_method = $payment_method; + return $this; + } + /** + * Deprecated method + */ + public function getPayment_method() { + return $this->payment_method; + } + /** * List of funding instruments from where the funds of the current payment come from. Typically a credit card. * @array @@ -26,8 +41,9 @@ class Payer extends \PPModel { */ public function setFundingInstruments($funding_instruments) { $this->funding_instruments = $funding_instruments; - } - + return $this; + } + /** * List of funding instruments from where the funds of the current payment come from. Typically a credit card. * @return PayPal\Api\FundingInstrument @@ -35,15 +51,30 @@ class Payer extends \PPModel { public function getFundingInstruments() { return $this->funding_instruments; } - + + /** + * Deprecated method + */ + public function setFunding_instruments($funding_instruments) { + $this->funding_instruments = $funding_instruments; + return $this; + } + /** + * Deprecated method + */ + public function getFunding_instruments() { + return $this->funding_instruments; + } + /** * Information related to the Payer. In case of PayPal Wallet payment, this information will be filled in by PayPal after the user approves the payment using their PayPal Wallet. * @param PayPal\Api\PayerInfo $payer_info */ public function setPayerInfo($payer_info) { $this->payer_info = $payer_info; - } - + return $this; + } + /** * Information related to the Payer. In case of PayPal Wallet payment, this information will be filled in by PayPal after the user approves the payment using their PayPal Wallet. * @return PayPal\Api\PayerInfo @@ -51,5 +82,19 @@ class Payer extends \PPModel { public function getPayerInfo() { return $this->payer_info; } - + + /** + * Deprecated method + */ + public function setPayer_info($payer_info) { + $this->payer_info = $payer_info; + return $this; + } + /** + * Deprecated method + */ + public function getPayer_info() { + return $this->payer_info; + } + } diff --git a/lib/PayPal/Api/PayerInfo.php b/lib/PayPal/Api/PayerInfo.php index 3c9ef9d..9a0e06b 100644 --- a/lib/PayPal/Api/PayerInfo.php +++ b/lib/PayPal/Api/PayerInfo.php @@ -9,8 +9,9 @@ class PayerInfo extends \PPModel { */ public function setEmail($email) { $this->email = $email; - } - + return $this; + } + /** * Email address representing the Payer. * @return string @@ -18,15 +19,17 @@ class PayerInfo extends \PPModel { public function getEmail() { return $this->email; } - + + /** * First Name of the Payer from their PayPal Account. * @param string $first_name */ public function setFirstName($first_name) { $this->first_name = $first_name; - } - + return $this; + } + /** * First Name of the Payer from their PayPal Account. * @return string @@ -34,15 +37,30 @@ class PayerInfo extends \PPModel { public function getFirstName() { return $this->first_name; } - + + /** + * Deprecated method + */ + public function setFirst_name($first_name) { + $this->first_name = $first_name; + return $this; + } + /** + * Deprecated method + */ + public function getFirst_name() { + return $this->first_name; + } + /** * Last Name of the Payer from their PayPal Account. * @param string $last_name */ public function setLastName($last_name) { $this->last_name = $last_name; - } - + return $this; + } + /** * Last Name of the Payer from their PayPal Account. * @return string @@ -50,15 +68,30 @@ class PayerInfo extends \PPModel { public function getLastName() { return $this->last_name; } - + + /** + * Deprecated method + */ + public function setLast_name($last_name) { + $this->last_name = $last_name; + return $this; + } + /** + * Deprecated method + */ + public function getLast_name() { + return $this->last_name; + } + /** * PayPal assigned Payer ID. * @param string $payer_id */ public function setPayerId($payer_id) { $this->payer_id = $payer_id; - } - + return $this; + } + /** * PayPal assigned Payer ID. * @return string @@ -66,15 +99,30 @@ class PayerInfo extends \PPModel { public function getPayerId() { return $this->payer_id; } - + + /** + * Deprecated method + */ + public function setPayer_id($payer_id) { + $this->payer_id = $payer_id; + return $this; + } + /** + * Deprecated method + */ + public function getPayer_id() { + return $this->payer_id; + } + /** * Phone number representing the Payer. * @param string $phone */ public function setPhone($phone) { $this->phone = $phone; - } - + return $this; + } + /** * Phone number representing the Payer. * @return string @@ -82,15 +130,17 @@ class PayerInfo extends \PPModel { public function getPhone() { return $this->phone; } - + + /** * Shipping address of the Payer from their PayPal Account. * @param PayPal\Api\Address $shipping_address */ public function setShippingAddress($shipping_address) { $this->shipping_address = $shipping_address; - } - + return $this; + } + /** * Shipping address of the Payer from their PayPal Account. * @return PayPal\Api\Address @@ -98,5 +148,19 @@ class PayerInfo extends \PPModel { public function getShippingAddress() { return $this->shipping_address; } - + + /** + * Deprecated method + */ + public function setShipping_address($shipping_address) { + $this->shipping_address = $shipping_address; + return $this; + } + /** + * Deprecated method + */ + public function getShipping_address() { + return $this->shipping_address; + } + } diff --git a/lib/PayPal/Api/Payment.php b/lib/PayPal/Api/Payment.php index eaef50b..144d7a0 100644 --- a/lib/PayPal/Api/Payment.php +++ b/lib/PayPal/Api/Payment.php @@ -6,9 +6,9 @@ use PayPal\Rest\Call; use PayPal\Rest\ApiContext; class Payment extends \PPModel implements IResource { - + private static $credential; - + /** * * @deprected. Pass ApiContext to create/get methods instead @@ -16,15 +16,16 @@ class Payment extends \PPModel implements IResource { public static function setCredential($credential) { self::$credential = $credential; } - + /** * Identifier of the payment resource created. * @param string $id */ public function setId($id) { $this->id = $id; - } - + return $this; + } + /** * Identifier of the payment resource created. * @return string @@ -32,15 +33,17 @@ class Payment extends \PPModel implements IResource { public function getId() { return $this->id; } - + + /** * Time the resource was created. * @param string $create_time */ public function setCreateTime($create_time) { $this->create_time = $create_time; - } - + return $this; + } + /** * Time the resource was created. * @return string @@ -48,15 +51,30 @@ class Payment extends \PPModel implements IResource { public function getCreateTime() { return $this->create_time; } - + + /** + * Deprecated method + */ + public function setCreate_time($create_time) { + $this->create_time = $create_time; + return $this; + } + /** + * Deprecated method + */ + public function getCreate_time() { + return $this->create_time; + } + /** * Time the resource was last updated. * @param string $update_time */ public function setUpdateTime($update_time) { $this->update_time = $update_time; - } - + return $this; + } + /** * Time the resource was last updated. * @return string @@ -64,15 +82,30 @@ class Payment extends \PPModel implements IResource { public function getUpdateTime() { return $this->update_time; } - + + /** + * Deprecated method + */ + public function setUpdate_time($update_time) { + $this->update_time = $update_time; + return $this; + } + /** + * Deprecated method + */ + public function getUpdate_time() { + return $this->update_time; + } + /** * Intent of the payment - Sale or Authorization or Order. * @param string $intent */ public function setIntent($intent) { $this->intent = $intent; - } - + return $this; + } + /** * Intent of the payment - Sale or Authorization or Order. * @return string @@ -80,15 +113,17 @@ class Payment extends \PPModel implements IResource { public function getIntent() { return $this->intent; } - + + /** * Source of the funds for this payment represented by a PayPal account or a direct credit card. * @param PayPal\Api\Payer $payer */ public function setPayer($payer) { $this->payer = $payer; - } - + return $this; + } + /** * Source of the funds for this payment represented by a PayPal account or a direct credit card. * @return PayPal\Api\Payer @@ -96,7 +131,8 @@ class Payment extends \PPModel implements IResource { public function getPayer() { return $this->payer; } - + + /** * A payment can have more than one transaction, with each transaction establishing a contract between the payer and a payee * @array @@ -104,8 +140,9 @@ class Payment extends \PPModel implements IResource { */ public function setTransactions($transactions) { $this->transactions = $transactions; - } - + return $this; + } + /** * A payment can have more than one transaction, with each transaction establishing a contract between the payer and a payee * @return PayPal\Api\Transaction @@ -113,15 +150,17 @@ class Payment extends \PPModel implements IResource { public function getTransactions() { return $this->transactions; } - + + /** * state of the payment * @param string $state */ public function setState($state) { $this->state = $state; - } - + return $this; + } + /** * state of the payment * @return string @@ -129,15 +168,17 @@ class Payment extends \PPModel implements IResource { public function getState() { return $this->state; } - + + /** * Redirect urls required only when using payment_method as PayPal - the only settings supported are return and cancel urls. * @param PayPal\Api\RedirectUrls $redirect_urls */ public function setRedirectUrls($redirect_urls) { $this->redirect_urls = $redirect_urls; - } - + return $this; + } + /** * Redirect urls required only when using payment_method as PayPal - the only settings supported are return and cancel urls. * @return PayPal\Api\RedirectUrls @@ -145,7 +186,21 @@ class Payment extends \PPModel implements IResource { public function getRedirectUrls() { return $this->redirect_urls; } - + + /** + * Deprecated method + */ + public function setRedirect_urls($redirect_urls) { + $this->redirect_urls = $redirect_urls; + return $this; + } + /** + * Deprecated method + */ + public function getRedirect_urls() { + return $this->redirect_urls; + } + /** * * @array @@ -153,8 +208,9 @@ class Payment extends \PPModel implements IResource { */ public function setLinks($links) { $this->links = $links; - } - + return $this; + } + /** * * @return PayPal\Api\Links @@ -162,7 +218,8 @@ class Payment extends \PPModel implements IResource { public function getLinks() { return $this->links; } - + + public function create($apiContext = null) { $payLoad = $this->toJSON(); diff --git a/lib/PayPal/Api/PaymentExecution.php b/lib/PayPal/Api/PaymentExecution.php index 785d1e6..a61e00c 100644 --- a/lib/PayPal/Api/PaymentExecution.php +++ b/lib/PayPal/Api/PaymentExecution.php @@ -9,8 +9,9 @@ class PaymentExecution extends \PPModel { */ public function setPayerId($payer_id) { $this->payer_id = $payer_id; - } - + return $this; + } + /** * PayPal assigned Payer ID returned in the approval return url. * @return string @@ -18,7 +19,21 @@ class PaymentExecution extends \PPModel { public function getPayerId() { return $this->payer_id; } - + + /** + * Deprecated method + */ + public function setPayer_id($payer_id) { + $this->payer_id = $payer_id; + return $this; + } + /** + * Deprecated method + */ + public function getPayer_id() { + return $this->payer_id; + } + /** * If the amount needs to be updated after obtaining the PayPal Payer info (eg. shipping address), it can be updated using this element. * @array @@ -26,8 +41,9 @@ class PaymentExecution extends \PPModel { */ public function setTransactions($transactions) { $this->transactions = $transactions; - } - + return $this; + } + /** * If the amount needs to be updated after obtaining the PayPal Payer info (eg. shipping address), it can be updated using this element. * @return PayPal\Api\Transactions @@ -35,5 +51,6 @@ class PaymentExecution extends \PPModel { public function getTransactions() { return $this->transactions; } - + + } diff --git a/lib/PayPal/Api/PaymentHistory.php b/lib/PayPal/Api/PaymentHistory.php index 1b3f1df..485a40b 100644 --- a/lib/PayPal/Api/PaymentHistory.php +++ b/lib/PayPal/Api/PaymentHistory.php @@ -10,8 +10,9 @@ class PaymentHistory extends \PPModel { */ public function setPayments($payments) { $this->payments = $payments; - } - + return $this; + } + /** * A list of Payment resources * @return PayPal\Api\Payment @@ -19,15 +20,17 @@ class PaymentHistory extends \PPModel { public function getPayments() { return $this->payments; } - + + /** * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items. * @param integer $count */ public function setCount($count) { $this->count = $count; - } - + return $this; + } + /** * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items. * @return integer @@ -35,15 +38,17 @@ class PaymentHistory extends \PPModel { public function getCount() { return $this->count; } - + + /** * Identifier of the next element to get the next range of results. * @param string $next_id */ public function setNextId($next_id) { $this->next_id = $next_id; - } - + return $this; + } + /** * Identifier of the next element to get the next range of results. * @return string @@ -51,5 +56,19 @@ class PaymentHistory extends \PPModel { public function getNextId() { return $this->next_id; } - + + /** + * Deprecated method + */ + public function setNext_id($next_id) { + $this->next_id = $next_id; + return $this; + } + /** + * Deprecated method + */ + public function getNext_id() { + return $this->next_id; + } + } diff --git a/lib/PayPal/Api/RedirectUrls.php b/lib/PayPal/Api/RedirectUrls.php index 902f7c7..84b34ee 100644 --- a/lib/PayPal/Api/RedirectUrls.php +++ b/lib/PayPal/Api/RedirectUrls.php @@ -9,8 +9,9 @@ class RedirectUrls extends \PPModel { */ public function setReturnUrl($return_url) { $this->return_url = $return_url; - } - + return $this; + } + /** * Url where the payer would be redirected to after approving the payment. * @return string @@ -18,15 +19,30 @@ class RedirectUrls extends \PPModel { public function getReturnUrl() { return $this->return_url; } - + + /** + * Deprecated method + */ + public function setReturn_url($return_url) { + $this->return_url = $return_url; + return $this; + } + /** + * Deprecated method + */ + public function getReturn_url() { + return $this->return_url; + } + /** * Url where the payer would be redirected to after canceling the payment. * @param string $cancel_url */ public function setCancelUrl($cancel_url) { $this->cancel_url = $cancel_url; - } - + return $this; + } + /** * Url where the payer would be redirected to after canceling the payment. * @return string @@ -34,5 +50,19 @@ class RedirectUrls extends \PPModel { public function getCancelUrl() { return $this->cancel_url; } - + + /** + * Deprecated method + */ + public function setCancel_url($cancel_url) { + $this->cancel_url = $cancel_url; + return $this; + } + /** + * Deprecated method + */ + public function getCancel_url() { + return $this->cancel_url; + } + } diff --git a/lib/PayPal/Api/Refund.php b/lib/PayPal/Api/Refund.php index 8728688..75baeb8 100644 --- a/lib/PayPal/Api/Refund.php +++ b/lib/PayPal/Api/Refund.php @@ -6,9 +6,9 @@ use PayPal\Rest\Call; use PayPal\Rest\ApiContext; class Refund extends \PPModel implements IResource { - + private static $credential; - + /** * * @deprected. Pass ApiContext to create/get methods instead @@ -16,15 +16,16 @@ class Refund extends \PPModel implements IResource { public static function setCredential($credential) { self::$credential = $credential; } - + /** * Identifier of the refund transaction. * @param string $id */ public function setId($id) { $this->id = $id; - } - + return $this; + } + /** * Identifier of the refund transaction. * @return string @@ -32,15 +33,17 @@ class Refund extends \PPModel implements IResource { public function getId() { return $this->id; } - + + /** * Time the resource was created. * @param string $create_time */ public function setCreateTime($create_time) { $this->create_time = $create_time; - } - + return $this; + } + /** * Time the resource was created. * @return string @@ -48,15 +51,30 @@ class Refund extends \PPModel implements IResource { public function getCreateTime() { return $this->create_time; } - + + /** + * Deprecated method + */ + public function setCreate_time($create_time) { + $this->create_time = $create_time; + return $this; + } + /** + * Deprecated method + */ + public function getCreate_time() { + return $this->create_time; + } + /** * Details including both refunded amount (to Payer) and refunded fee (to Payee).If amount is not specified, it's assumed to be full refund. * @param PayPal\Api\Amount $amount */ public function setAmount($amount) { $this->amount = $amount; - } - + return $this; + } + /** * Details including both refunded amount (to Payer) and refunded fee (to Payee).If amount is not specified, it's assumed to be full refund. * @return PayPal\Api\Amount @@ -64,15 +82,17 @@ class Refund extends \PPModel implements IResource { public function getAmount() { return $this->amount; } - + + /** * State of the refund transaction. * @param string $state */ public function setState($state) { $this->state = $state; - } - + return $this; + } + /** * State of the refund transaction. * @return string @@ -80,15 +100,17 @@ class Refund extends \PPModel implements IResource { public function getState() { return $this->state; } - + + /** * ID of the Sale transaction being refunded. * @param string $sale_id */ public function setSaleId($sale_id) { $this->sale_id = $sale_id; - } - + return $this; + } + /** * ID of the Sale transaction being refunded. * @return string @@ -96,15 +118,30 @@ class Refund extends \PPModel implements IResource { public function getSaleId() { return $this->sale_id; } - + + /** + * Deprecated method + */ + public function setSale_id($sale_id) { + $this->sale_id = $sale_id; + return $this; + } + /** + * Deprecated method + */ + public function getSale_id() { + return $this->sale_id; + } + /** * ID of the Capture transaction being refunded. * @param string $capture_id */ public function setCaptureId($capture_id) { $this->capture_id = $capture_id; - } - + return $this; + } + /** * ID of the Capture transaction being refunded. * @return string @@ -112,15 +149,30 @@ class Refund extends \PPModel implements IResource { public function getCaptureId() { return $this->capture_id; } - + + /** + * Deprecated method + */ + public function setCapture_id($capture_id) { + $this->capture_id = $capture_id; + return $this; + } + /** + * Deprecated method + */ + public function getCapture_id() { + return $this->capture_id; + } + /** * ID of the Payment resource that this transaction is based on. * @param string $parent_payment */ public function setParentPayment($parent_payment) { $this->parent_payment = $parent_payment; - } - + return $this; + } + /** * ID of the Payment resource that this transaction is based on. * @return string @@ -128,7 +180,21 @@ class Refund extends \PPModel implements IResource { public function getParentPayment() { return $this->parent_payment; } - + + /** + * Deprecated method + */ + public function setParent_payment($parent_payment) { + $this->parent_payment = $parent_payment; + return $this; + } + /** + * Deprecated method + */ + public function getParent_payment() { + return $this->parent_payment; + } + /** * * @array @@ -136,8 +202,9 @@ class Refund extends \PPModel implements IResource { */ public function setLinks($links) { $this->links = $links; - } - + return $this; + } + /** * * @return PayPal\Api\Links @@ -145,7 +212,8 @@ class Refund extends \PPModel implements IResource { public function getLinks() { return $this->links; } - + + public static function get($refundId, $apiContext = null) { if (($refundId == null) || (strlen($refundId) <= 0)) { diff --git a/lib/PayPal/Api/RelatedResources.php b/lib/PayPal/Api/RelatedResources.php index f8e4fef..98085f7 100644 --- a/lib/PayPal/Api/RelatedResources.php +++ b/lib/PayPal/Api/RelatedResources.php @@ -9,8 +9,9 @@ class RelatedResources extends \PPModel { */ public function setSale($sale) { $this->sale = $sale; - } - + return $this; + } + /** * A sale transaction * @return PayPal\Api\Sale @@ -18,15 +19,17 @@ class RelatedResources extends \PPModel { public function getSale() { return $this->sale; } - + + /** * An authorization transaction * @param PayPal\Api\Authorization $authorization */ public function setAuthorization($authorization) { $this->authorization = $authorization; - } - + return $this; + } + /** * An authorization transaction * @return PayPal\Api\Authorization @@ -34,15 +37,17 @@ class RelatedResources extends \PPModel { public function getAuthorization() { return $this->authorization; } - + + /** * A capture transaction * @param PayPal\Api\Capture $capture */ public function setCapture($capture) { $this->capture = $capture; - } - + return $this; + } + /** * A capture transaction * @return PayPal\Api\Capture @@ -50,15 +55,17 @@ class RelatedResources extends \PPModel { public function getCapture() { return $this->capture; } - + + /** * A refund transaction * @param PayPal\Api\Refund $refund */ public function setRefund($refund) { $this->refund = $refund; - } - + return $this; + } + /** * A refund transaction * @return PayPal\Api\Refund @@ -66,5 +73,6 @@ class RelatedResources extends \PPModel { public function getRefund() { return $this->refund; } - + + } diff --git a/lib/PayPal/Api/Sale.php b/lib/PayPal/Api/Sale.php index 31bea57..c3bdfe7 100644 --- a/lib/PayPal/Api/Sale.php +++ b/lib/PayPal/Api/Sale.php @@ -6,9 +6,9 @@ use PayPal\Rest\Call; use PayPal\Rest\ApiContext; class Sale extends \PPModel implements IResource { - + private static $credential; - + /** * * @deprected. Pass ApiContext to create/get methods instead @@ -16,15 +16,16 @@ class Sale extends \PPModel implements IResource { public static function setCredential($credential) { self::$credential = $credential; } - + /** * Identifier of the authorization transaction. * @param string $id */ public function setId($id) { $this->id = $id; - } - + return $this; + } + /** * Identifier of the authorization transaction. * @return string @@ -32,15 +33,17 @@ class Sale extends \PPModel implements IResource { public function getId() { return $this->id; } - + + /** * Time the resource was created. * @param string $create_time */ public function setCreateTime($create_time) { $this->create_time = $create_time; - } - + return $this; + } + /** * Time the resource was created. * @return string @@ -48,15 +51,30 @@ class Sale extends \PPModel implements IResource { public function getCreateTime() { return $this->create_time; } - + + /** + * Deprecated method + */ + public function setCreate_time($create_time) { + $this->create_time = $create_time; + return $this; + } + /** + * Deprecated method + */ + public function getCreate_time() { + return $this->create_time; + } + /** * Time the resource was last updated. * @param string $update_time */ public function setUpdateTime($update_time) { $this->update_time = $update_time; - } - + return $this; + } + /** * Time the resource was last updated. * @return string @@ -64,15 +82,30 @@ class Sale extends \PPModel implements IResource { public function getUpdateTime() { return $this->update_time; } - + + /** + * Deprecated method + */ + public function setUpdate_time($update_time) { + $this->update_time = $update_time; + return $this; + } + /** + * Deprecated method + */ + public function getUpdate_time() { + return $this->update_time; + } + /** * Amount being collected. * @param PayPal\Api\Amount $amount */ public function setAmount($amount) { $this->amount = $amount; - } - + return $this; + } + /** * Amount being collected. * @return PayPal\Api\Amount @@ -80,15 +113,17 @@ class Sale extends \PPModel implements IResource { public function getAmount() { return $this->amount; } - + + /** * State of the sale transaction. * @param string $state */ public function setState($state) { $this->state = $state; - } - + return $this; + } + /** * State of the sale transaction. * @return string @@ -96,15 +131,17 @@ class Sale extends \PPModel implements IResource { public function getState() { return $this->state; } - + + /** * ID of the Payment resource that this transaction is based on. * @param string $parent_payment */ public function setParentPayment($parent_payment) { $this->parent_payment = $parent_payment; - } - + return $this; + } + /** * ID of the Payment resource that this transaction is based on. * @return string @@ -112,7 +149,21 @@ class Sale extends \PPModel implements IResource { public function getParentPayment() { return $this->parent_payment; } - + + /** + * Deprecated method + */ + public function setParent_payment($parent_payment) { + $this->parent_payment = $parent_payment; + return $this; + } + /** + * Deprecated method + */ + public function getParent_payment() { + return $this->parent_payment; + } + /** * * @array @@ -120,8 +171,9 @@ class Sale extends \PPModel implements IResource { */ public function setLinks($links) { $this->links = $links; - } - + return $this; + } + /** * * @return PayPal\Api\Links @@ -129,7 +181,8 @@ class Sale extends \PPModel implements IResource { public function getLinks() { return $this->links; } - + + public static function get($saleId, $apiContext = null) { if (($saleId == null) || (strlen($saleId) <= 0)) { diff --git a/lib/PayPal/Api/ShippingAddress.php b/lib/PayPal/Api/ShippingAddress.php index dc42e7f..e1595f4 100644 --- a/lib/PayPal/Api/ShippingAddress.php +++ b/lib/PayPal/Api/ShippingAddress.php @@ -9,8 +9,9 @@ class ShippingAddress extends Address { */ public function setRecipientName($recipient_name) { $this->recipient_name = $recipient_name; - } - + return $this; + } + /** * Name of the recipient at this address. * @return string @@ -18,5 +19,19 @@ class ShippingAddress extends Address { public function getRecipientName() { return $this->recipient_name; } - + + /** + * Deprecated method + */ + public function setRecipient_name($recipient_name) { + $this->recipient_name = $recipient_name; + return $this; + } + /** + * Deprecated method + */ + public function getRecipient_name() { + return $this->recipient_name; + } + } diff --git a/lib/PayPal/Api/Transaction.php b/lib/PayPal/Api/Transaction.php index dd64b00..0b3c1f7 100644 --- a/lib/PayPal/Api/Transaction.php +++ b/lib/PayPal/Api/Transaction.php @@ -9,8 +9,9 @@ class Transaction extends \PPModel { */ public function setAmount($amount) { $this->amount = $amount; - } - + return $this; + } + /** * Amount being collected. * @return PayPal\Api\Amount @@ -18,15 +19,17 @@ class Transaction extends \PPModel { public function getAmount() { return $this->amount; } - + + /** * Recepient of the funds in this transaction. * @param PayPal\Api\Payee $payee */ public function setPayee($payee) { $this->payee = $payee; - } - + return $this; + } + /** * Recepient of the funds in this transaction. * @return PayPal\Api\Payee @@ -34,15 +37,17 @@ class Transaction extends \PPModel { public function getPayee() { return $this->payee; } - + + /** * Description of what is being paid for. * @param string $description */ public function setDescription($description) { $this->description = $description; - } - + return $this; + } + /** * Description of what is being paid for. * @return string @@ -50,15 +55,17 @@ class Transaction extends \PPModel { public function getDescription() { return $this->description; } - + + /** * List of items being paid for. * @param PayPal\Api\ItemList $item_list */ public function setItemList($item_list) { $this->item_list = $item_list; - } - + return $this; + } + /** * List of items being paid for. * @return PayPal\Api\ItemList @@ -66,7 +73,21 @@ class Transaction extends \PPModel { public function getItemList() { return $this->item_list; } - + + /** + * Deprecated method + */ + public function setItem_list($item_list) { + $this->item_list = $item_list; + return $this; + } + /** + * Deprecated method + */ + public function getItem_list() { + return $this->item_list; + } + /** * List of financial transactions (Sale, Authorization, Capture, Refund) related to the payment. * @array @@ -74,8 +95,9 @@ class Transaction extends \PPModel { */ public function setRelatedResources($related_resources) { $this->related_resources = $related_resources; - } - + return $this; + } + /** * List of financial transactions (Sale, Authorization, Capture, Refund) related to the payment. * @return PayPal\Api\RelatedResources @@ -83,7 +105,21 @@ class Transaction extends \PPModel { public function getRelatedResources() { return $this->related_resources; } - + + /** + * Deprecated method + */ + public function setRelated_resources($related_resources) { + $this->related_resources = $related_resources; + return $this; + } + /** + * Deprecated method + */ + public function getRelated_resources() { + return $this->related_resources; + } + /** * Additional transactions for complex payment (Parallel and Chained) scenarios. * @array @@ -91,8 +127,9 @@ class Transaction extends \PPModel { */ public function setTransactions($transactions) { $this->transactions = $transactions; - } - + return $this; + } + /** * Additional transactions for complex payment (Parallel and Chained) scenarios. * @return PayPal\Api\self @@ -100,5 +137,6 @@ class Transaction extends \PPModel { public function getTransactions() { return $this->transactions; } - + + } diff --git a/lib/PayPal/Api/Transactions.php b/lib/PayPal/Api/Transactions.php index 3a01e14..6c86384 100644 --- a/lib/PayPal/Api/Transactions.php +++ b/lib/PayPal/Api/Transactions.php @@ -9,8 +9,9 @@ class Transactions extends \PPModel { */ public function setAmount($amount) { $this->amount = $amount; - } - + return $this; + } + /** * Amount being collected. * @return PayPal\Api\Amount @@ -18,5 +19,6 @@ class Transactions extends \PPModel { public function getAmount() { return $this->amount; } - + + } From fd997f6b8be1dfebf92472d51d019ddcafc1cc0a Mon Sep 17 00:00:00 2001 From: vichandrasekaran Date: Tue, 28 May 2013 11:24:07 +0530 Subject: [PATCH 05/20] Update lib/PayPal/Rest/RestHandler.php Updating namespace of PPConfiguration exception thrown by the handler --- lib/PayPal/Rest/RestHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/PayPal/Rest/RestHandler.php b/lib/PayPal/Rest/RestHandler.php index 15dd599..58d3010 100644 --- a/lib/PayPal/Rest/RestHandler.php +++ b/lib/PayPal/Rest/RestHandler.php @@ -66,11 +66,11 @@ class RestHandler implements \IPPHandler { return \PPConstants::REST_LIVE_ENDPOINT; break; default: - throw new PPConfigurationException('The mode config parameter must be set to either sandbox/live'); + throw new \PPConfigurationException('The mode config parameter must be set to either sandbox/live'); break; } } else { - throw new PPConfigurationException('You must set one of service.endpoint or mode parameters in your configuration'); + throw new \PPConfigurationException('You must set one of service.endpoint or mode parameters in your configuration'); } } From 479730d1c4217639de18afe2a24e72d6f964f5ab Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Tue, 28 May 2013 18:20:40 +0530 Subject: [PATCH 06/20] adding new testcases for Auth Capture --- tests/PayPal/Test/Api/AuthorizationTest.php | 87 +++++++++++++++++++-- tests/PayPal/Test/Api/CaptureTest.php | 32 ++++++++ tests/PayPal/Test/Api/CreditCardTest.php | 3 +- 3 files changed, 112 insertions(+), 10 deletions(-) diff --git a/tests/PayPal/Test/Api/AuthorizationTest.php b/tests/PayPal/Test/Api/AuthorizationTest.php index ba104f9..bc74ef6 100644 --- a/tests/PayPal/Test/Api/AuthorizationTest.php +++ b/tests/PayPal/Test/Api/AuthorizationTest.php @@ -5,19 +5,24 @@ use PayPal\Api\Amount; use PayPal\Api\Authorization; use PayPal\Api\Links; use PayPal\Test\Constants; +use PayPal\Api\RedirectUrls; +use PayPal\Api\Address; + +use PayPal\Api\Capture; +use PayPal\Api\CreditCard; +use PayPal\Api\Payer; +use PayPal\Api\Payment; +use PayPal\Api\FundingInstrument; +use PayPal\Api\Transaction; class AuthorizationTest extends \PHPUnit_Framework_TestCase { - private $authorizations = array(); - public static $create_time = "2013-02-28T00:00:00Z"; public static $id = "AUTH-123"; public static $state = "Created"; public static $parent_payment = "PAY-12345"; - public static $currency = "USD"; public static $total = "1.12"; - public static $href = "USD"; public static $rel = "1.12"; public static $method = "1.12"; @@ -34,6 +39,53 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase { return $authorization; } + public static function authorize() + { + $addr = new Address(); + $addr->setLine1("3909 Witmer Road"); + $addr->setLine2("Niagara Falls"); + $addr->setCity("Niagara Falls"); + $addr->setState("NY"); + $addr->setPostal_code("14305"); + $addr->setCountry_code("US"); + $addr->setPhone("716-298-1822"); + + $card = new CreditCard(); + $card->setType("visa"); + $card->setNumber("4417119669820331"); + $card->setExpire_month("11"); + $card->setExpire_year("2019"); + $card->setCvv2("012"); + $card->setFirst_name("Joe"); + $card->setLast_name("Shopper"); + $card->setBilling_address($addr); + + $fi = new FundingInstrument(); + $fi->setCredit_card($card); + + $payer = new Payer(); + $payer->setPayment_method("credit_card"); + $payer->setFunding_instruments(array($fi)); + + $amount = new Amount(); + $amount->setCurrency("USD"); + $amount->setTotal("1.00"); + + $transaction = new Transaction(); + $transaction->setAmount($amount); + $transaction->setDescription("This is the payment description."); + + $payment = new Payment(); + $payment->setIntent("authorize"); + $payment->setPayer($payer); + $payment->setTransactions(array($transaction)); + + $paymnt = $payment->create(); + $resArray = $paymnt->toArray(); + + return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; + + } public function setup() { $authorization = new Authorization(); $authorization->setCreateTime(self::$create_time); @@ -41,9 +93,8 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase { $authorization->setState(self::$state); $authorization->setParentPayment(self::$parent_payment); $this->authorizations['partial'] = $authorization; - - $this->authorizations['full'] = self::createAuthorization(); + } public function testGetterSetter() { @@ -60,10 +111,30 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase { public function testSerializeDeserialize() { $a1 = $this->authorizations['partial']; - $a2 = new Authorization(); $a2->fromJson($a1->toJson()); - $this->assertEquals($a1, $a2); } + public function testOperations() { + $authId = self::authorize(); + $auth = Authorization::get($authId); + $this->assertNotNull($auth->getId()); + + $amount = new Amount(); + $amount->setCurrency("USD"); + $amount->setTotal("1.00"); + + $captur = new Capture(); + $captur->setId($authId); + $captur->setAmount($amount); + + $capt = $auth->capture($captur); + $this->assertNotNull( $capt->getId()); + + $authId = self::authorize(); + $auth = Authorization::get($authId); + $void = $auth->void(); + $this->assertNotNull($void->getId()); + + } } \ No newline at end of file diff --git a/tests/PayPal/Test/Api/CaptureTest.php b/tests/PayPal/Test/Api/CaptureTest.php index 56000dc..a1162fd 100644 --- a/tests/PayPal/Test/Api/CaptureTest.php +++ b/tests/PayPal/Test/Api/CaptureTest.php @@ -2,6 +2,9 @@ namespace PayPal\Test\Api; use PayPal\Api\Capture; +use PayPal\Api\Refund; +use PayPal\Api\Authorization; +use PayPal\Api\Amount; use PayPal\Test\Constants; class CaptureTest extends \PHPUnit_Framework_TestCase { @@ -52,4 +55,33 @@ class CaptureTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($c1, $c2); } + + public function testOperations() + { + $authId = AuthorizationTest::authorize(); + $auth = Authorization::get($authId); + + $amount = new Amount(); + $amount->setCurrency("USD"); + $amount->setTotal("1.00"); + + $captr = new Capture(); + $captr->setId($authId); + $captr->setAmount($amount); + + $capt = $auth->capture($captr); + $captureId = $capt->getId(); + $this->assertNotNull($captureId); + + $refund = new Refund(); + $refund->setId($captureId); + $refund->setAmount($amount); + + $capture = Capture::get($captureId); + $this->assertNotNull($capture->getId()); + + $retund = $capture->refund($refund); + $this->assertNotNull($retund->getId()); + + } } \ No newline at end of file diff --git a/tests/PayPal/Test/Api/CreditCardTest.php b/tests/PayPal/Test/Api/CreditCardTest.php index c4ae466..27896fe 100644 --- a/tests/PayPal/Test/Api/CreditCardTest.php +++ b/tests/PayPal/Test/Api/CreditCardTest.php @@ -1,11 +1,9 @@ assertGreaterThan(0, count($c2->getLinks())); $this->assertEquals(self::$cardType, $c2->getType()); $this->assertNotNull($c2->getState()); + $this->assertEquals(true, $c2->delete()); } } \ No newline at end of file From 50d2c56f8be5efa2349be6c6cac4ff30a9f5f346 Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Wed, 29 May 2013 14:37:22 +0530 Subject: [PATCH 07/20] Updated stubs to support namespace --- lib/PayPal/Api/Address.php | 19 +++-- lib/PayPal/Api/Amount.php | 3 +- lib/PayPal/Api/Authorization.php | 48 +++++++---- lib/PayPal/Api/Capture.php | 44 +++++++--- lib/PayPal/Api/CreditCard.php | 69 ++++++++++----- lib/PayPal/Api/CreditCardHistory.php | 28 +++++-- lib/PayPal/Api/CreditCardToken.php | 35 ++++++-- lib/PayPal/Api/Details.php | 3 +- lib/PayPal/Api/FundingInstrument.php | 19 +++-- lib/PayPal/Api/HyperSchema.php | 55 +----------- lib/PayPal/Api/Item.php | 3 +- lib/PayPal/Api/ItemList.php | 11 ++- lib/PayPal/Api/Links.php | 16 +--- lib/PayPal/Api/Payee.php | 11 ++- lib/PayPal/Api/Payer.php | 28 +++++-- lib/PayPal/Api/PayerInfo.php | 35 ++++++-- lib/PayPal/Api/Payment.php | 40 ++++++--- lib/PayPal/Api/PaymentExecution.php | 11 ++- lib/PayPal/Api/PaymentHistory.php | 11 ++- lib/PayPal/Api/RedirectUrls.php | 19 +++-- lib/PayPal/Api/Refund.php | 41 ++++++--- lib/PayPal/Api/RelatedResources.php | 3 +- lib/PayPal/Api/Sale.php | 36 +++++--- lib/PayPal/Api/ShippingAddress.php | 9 +- lib/PayPal/Api/Transaction.php | 20 +++-- lib/PayPal/Api/Transactions.php | 3 +- lib/PayPal/Auth/OAuthTokenCredential.php | 24 +++--- lib/PayPal/Rest/ApiContext.php | 3 +- lib/PayPal/Rest/RestHandler.php | 25 ++++-- .../Test/Auth/OAuthTokenCredentialTest.php | 9 +- tests/PayPal/Test/Common/ArrayClass.php | 29 +++++++ tests/PayPal/Test/Common/ArrayUtilTest.php | 6 +- tests/PayPal/Test/Common/ChildClass.php | 6 ++ tests/PayPal/Test/Common/ModelTest.php | 84 ++----------------- tests/PayPal/Test/Common/NestedClass.php | 27 ++++++ tests/PayPal/Test/Common/SimpleClass.php | 19 +++++ tests/PayPal/Test/Common/UserAgentTest.php | 2 +- 37 files changed, 530 insertions(+), 324 deletions(-) create mode 100644 tests/PayPal/Test/Common/ArrayClass.php create mode 100644 tests/PayPal/Test/Common/ChildClass.php create mode 100644 tests/PayPal/Test/Common/NestedClass.php create mode 100644 tests/PayPal/Test/Common/SimpleClass.php diff --git a/lib/PayPal/Api/Address.php b/lib/PayPal/Api/Address.php index 46129a1..fa9300e 100644 --- a/lib/PayPal/Api/Address.php +++ b/lib/PayPal/Api/Address.php @@ -1,8 +1,9 @@ country_code = $country_code; return $this; } /** - * Deprecated method + * 2 letter country code. + * @return string + * @deprecated. Instead use getCountryCode */ public function getCountry_code() { return $this->country_code; @@ -106,14 +111,18 @@ class Address extends \PPModel { } /** - * Deprecated method + * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code. + * @param string $postal_code + * @deprecated. Instead use setPostalCode */ public function setPostal_code($postal_code) { $this->postal_code = $postal_code; return $this; } /** - * Deprecated method + * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code. + * @return string + * @deprecated. Instead use getPostalCode */ public function getPostal_code() { return $this->postal_code; diff --git a/lib/PayPal/Api/Amount.php b/lib/PayPal/Api/Amount.php index 8618690..8c7cfe2 100644 --- a/lib/PayPal/Api/Amount.php +++ b/lib/PayPal/Api/Amount.php @@ -1,8 +1,9 @@ create_time = $create_time; return $this; } /** - * Deprecated method + * Time the resource was created. + * @return string + * @deprecated. Instead use getCreateTime */ public function getCreate_time() { return $this->create_time; @@ -84,14 +92,18 @@ class Authorization extends \PPModel implements IResource { } /** - * Deprecated method + * Time the resource was last updated. + * @param string $update_time + * @deprecated. Instead use setUpdateTime */ public function setUpdate_time($update_time) { $this->update_time = $update_time; return $this; } /** - * Deprecated method + * Time the resource was last updated. + * @return string + * @deprecated. Instead use getUpdateTime */ public function getUpdate_time() { return $this->update_time; @@ -151,14 +163,18 @@ class Authorization extends \PPModel implements IResource { } /** - * Deprecated method + * ID of the Payment resource that this transaction is based on. + * @param string $parent_payment + * @deprecated. Instead use setParentPayment */ public function setParent_payment($parent_payment) { $this->parent_payment = $parent_payment; return $this; } /** - * Deprecated method + * ID of the Payment resource that this transaction is based on. + * @return string + * @deprecated. Instead use getParentPayment */ public function getParent_payment() { return $this->parent_payment; @@ -182,14 +198,18 @@ class Authorization extends \PPModel implements IResource { } /** - * Deprecated method + * Date/Time until which funds may be captured against this resource. + * @param string $valid_until + * @deprecated. Instead use setValidUntil */ public function setValid_until($valid_until) { $this->valid_until = $valid_until; return $this; } /** - * Deprecated method + * Date/Time until which funds may be captured against this resource. + * @return string + * @deprecated. Instead use getValidUntil */ public function getValid_until() { return $this->valid_until; @@ -223,7 +243,7 @@ class Authorization extends \PPModel implements IResource { if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } - $call = new \PPRestCall($apiContext); + $call = new PPRestCall($apiContext); $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/authorization/$authorizationId", "GET", $payLoad); $ret = new Authorization(); $ret->fromJson($json); @@ -241,7 +261,7 @@ class Authorization extends \PPModel implements IResource { if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } - $call = new \PPRestCall($apiContext); + $call = new PPRestCall($apiContext); $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/authorization/{$this->getId()}/capture", "POST", $payLoad); $ret = new Capture(); $ret->fromJson($json); @@ -256,7 +276,7 @@ class Authorization extends \PPModel implements IResource { if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } - $call = new \PPRestCall($apiContext); + $call = new PPRestCall($apiContext); $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/authorization/{$this->getId()}/void", "POST", $payLoad); $ret = new Authorization(); $ret->fromJson($json); @@ -271,7 +291,7 @@ class Authorization extends \PPModel implements IResource { if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } - $call = new \PPRestCall($apiContext); + $call = new PPRestCall($apiContext); $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/authorization/{$this->getId()}/reauthorize", "POST", $payLoad); $this->fromJson($json); return $this; diff --git a/lib/PayPal/Api/Capture.php b/lib/PayPal/Api/Capture.php index 038a310..773f952 100644 --- a/lib/PayPal/Api/Capture.php +++ b/lib/PayPal/Api/Capture.php @@ -1,17 +1,21 @@ create_time = $create_time; return $this; } /** - * Deprecated method + * Time the resource was created. + * @return string + * @deprecated. Instead use getCreateTime */ public function getCreate_time() { return $this->create_time; @@ -84,14 +92,18 @@ class Capture extends \PPModel implements IResource { } /** - * Deprecated method + * Time the resource was last updated. + * @param string $update_time + * @deprecated. Instead use setUpdateTime */ public function setUpdate_time($update_time) { $this->update_time = $update_time; return $this; } /** - * Deprecated method + * Time the resource was last updated. + * @return string + * @deprecated. Instead use getUpdateTime */ public function getUpdate_time() { return $this->update_time; @@ -133,14 +145,18 @@ class Capture extends \PPModel implements IResource { } /** - * Deprecated method + * whether this is a final capture for the given authorization or not. If it's final, all the remaining funds held by the authorization, will be released in the funding instrument. + * @param boolean $is_final_capture + * @deprecated. Instead use setIsFinalCapture */ public function setIs_final_capture($is_final_capture) { $this->is_final_capture = $is_final_capture; return $this; } /** - * Deprecated method + * whether this is a final capture for the given authorization or not. If it's final, all the remaining funds held by the authorization, will be released in the funding instrument. + * @return boolean + * @deprecated. Instead use getIsFinalCapture */ public function getIs_final_capture() { return $this->is_final_capture; @@ -182,14 +198,18 @@ class Capture extends \PPModel implements IResource { } /** - * Deprecated method + * ID of the Payment resource that this transaction is based on. + * @param string $parent_payment + * @deprecated. Instead use setParentPayment */ public function setParent_payment($parent_payment) { $this->parent_payment = $parent_payment; return $this; } /** - * Deprecated method + * ID of the Payment resource that this transaction is based on. + * @return string + * @deprecated. Instead use getParentPayment */ public function getParent_payment() { return $this->parent_payment; @@ -223,7 +243,7 @@ class Capture extends \PPModel implements IResource { if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } - $call = new \PPRestCall($apiContext); + $call = new PPRestCall($apiContext); $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/capture/$captureId", "GET", $payLoad); $ret = new Capture(); $ret->fromJson($json); @@ -241,7 +261,7 @@ class Capture extends \PPModel implements IResource { if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } - $call = new \PPRestCall($apiContext); + $call = new PPRestCall($apiContext); $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/capture/{$this->getId()}/refund", "POST", $payLoad); $ret = new Refund(); $ret->fromJson($json); diff --git a/lib/PayPal/Api/CreditCard.php b/lib/PayPal/Api/CreditCard.php index b5e7020..7e13b7d 100644 --- a/lib/PayPal/Api/CreditCard.php +++ b/lib/PayPal/Api/CreditCard.php @@ -1,17 +1,20 @@ expire_month = $expire_month; return $this; } /** - * Deprecated method + * card expiry month with value 1 - 12. + * @return integer + * @deprecated. Instead use getExpireMonth */ public function getExpire_month() { return $this->expire_month; @@ -120,14 +127,18 @@ class CreditCard extends \PPModel implements IResource { } /** - * Deprecated method + * 4 digit card expiry year + * @param integer $expire_year + * @deprecated. Instead use setExpireYear */ public function setExpire_year($expire_year) { $this->expire_year = $expire_year; return $this; } /** - * Deprecated method + * 4 digit card expiry year + * @return integer + * @deprecated. Instead use getExpireYear */ public function getExpire_year() { return $this->expire_year; @@ -169,14 +180,18 @@ class CreditCard extends \PPModel implements IResource { } /** - * Deprecated method + * Card holder's first name. + * @param string $first_name + * @deprecated. Instead use setFirstName */ public function setFirst_name($first_name) { $this->first_name = $first_name; return $this; } /** - * Deprecated method + * Card holder's first name. + * @return string + * @deprecated. Instead use getFirstName */ public function getFirst_name() { return $this->first_name; @@ -200,14 +215,18 @@ class CreditCard extends \PPModel implements IResource { } /** - * Deprecated method + * Card holder's last name. + * @param string $last_name + * @deprecated. Instead use setLastName */ public function setLast_name($last_name) { $this->last_name = $last_name; return $this; } /** - * Deprecated method + * Card holder's last name. + * @return string + * @deprecated. Instead use getLastName */ public function getLast_name() { return $this->last_name; @@ -231,14 +250,18 @@ class CreditCard extends \PPModel implements IResource { } /** - * Deprecated method + * Billing Address associated with this card. + * @param PayPal\Api\Address $billing_address + * @deprecated. Instead use setBillingAddress */ public function setBilling_address($billing_address) { $this->billing_address = $billing_address; return $this; } /** - * Deprecated method + * Billing Address associated with this card. + * @return PayPal\Api\Address + * @deprecated. Instead use getBillingAddress */ public function getBilling_address() { return $this->billing_address; @@ -262,14 +285,18 @@ class CreditCard extends \PPModel implements IResource { } /** - * Deprecated method + * A unique identifier of the payer generated and provided by the facilitator. This is required when creating or using a tokenized funding instrument. + * @param string $payer_id + * @deprecated. Instead use setPayerId */ public function setPayer_id($payer_id) { $this->payer_id = $payer_id; return $this; } /** - * Deprecated method + * A unique identifier of the payer generated and provided by the facilitator. This is required when creating or using a tokenized funding instrument. + * @return string + * @deprecated. Instead use getPayerId */ public function getPayer_id() { return $this->payer_id; @@ -311,14 +338,18 @@ class CreditCard extends \PPModel implements IResource { } /** - * Deprecated method + * Date/Time until this resource can be used fund a payment. + * @param string $valid_until + * @deprecated. Instead use setValidUntil */ public function setValid_until($valid_until) { $this->valid_until = $valid_until; return $this; } /** - * Deprecated method + * Date/Time until this resource can be used fund a payment. + * @return string + * @deprecated. Instead use getValidUntil */ public function getValid_until() { return $this->valid_until; @@ -349,7 +380,7 @@ class CreditCard extends \PPModel implements IResource { if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } - $call = new \PPRestCall($apiContext); + $call = new PPRestCall($apiContext); $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card", "POST", $payLoad); $this->fromJson($json); return $this; @@ -363,7 +394,7 @@ class CreditCard extends \PPModel implements IResource { if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } - $call = new \PPRestCall($apiContext); + $call = new PPRestCall($apiContext); $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card/$creditCardId", "GET", $payLoad); $ret = new CreditCard(); $ret->fromJson($json); @@ -378,7 +409,7 @@ class CreditCard extends \PPModel implements IResource { if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } - $call = new \PPRestCall($apiContext); + $call = new PPRestCall($apiContext); $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card/{$this->getId()}", "POST", $payLoad); return true; } diff --git a/lib/PayPal/Api/CreditCardHistory.php b/lib/PayPal/Api/CreditCardHistory.php index a7e300d..19607d6 100644 --- a/lib/PayPal/Api/CreditCardHistory.php +++ b/lib/PayPal/Api/CreditCardHistory.php @@ -1,15 +1,16 @@ credit_cards = $credit_cards; + public function setCreditCards($credit-cards) { + $this->credit-cards = $credit-cards; return $this; } @@ -22,14 +23,19 @@ class CreditCardHistory extends \PPModel { } /** - * Deprecated method + * A list of credit card resources + * @array + * @param PayPal\Api\CreditCard $credit-cards + * @deprecated. Instead use setCreditCards */ - public function setCredit_cards($credit_cards) { - $this->credit_cards = $credit_cards; + public function setCredit_cards($credit-cards) { + $this->credit-cards = $credit-cards; return $this; } /** - * Deprecated method + * A list of credit card resources + * @return PayPal\Api\CreditCard + * @deprecated. Instead use getCreditCards */ public function getCredit_cards() { return $this->credit-cards; @@ -71,14 +77,18 @@ class CreditCardHistory extends \PPModel { } /** - * Deprecated method + * Identifier of the next element to get the next range of results. + * @param string $next_id + * @deprecated. Instead use setNextId */ public function setNext_id($next_id) { $this->next_id = $next_id; return $this; } /** - * Deprecated method + * Identifier of the next element to get the next range of results. + * @return string + * @deprecated. Instead use getNextId */ public function getNext_id() { return $this->next_id; diff --git a/lib/PayPal/Api/CreditCardToken.php b/lib/PayPal/Api/CreditCardToken.php index b763302..13430dd 100644 --- a/lib/PayPal/Api/CreditCardToken.php +++ b/lib/PayPal/Api/CreditCardToken.php @@ -1,8 +1,9 @@ credit_card_id = $credit_card_id; return $this; } /** - * Deprecated method + * ID of a previously saved Credit Card resource using /vault/credit-card API. + * @return string + * @deprecated. Instead use getCreditCardId */ public function getCredit_card_id() { return $this->credit_card_id; @@ -52,14 +57,18 @@ class CreditCardToken extends \PPModel { } /** - * Deprecated method + * The unique identifier of the payer used when saving this credit card using /vault/credit-card API. + * @param string $payer_id + * @deprecated. Instead use setPayerId */ public function setPayer_id($payer_id) { $this->payer_id = $payer_id; return $this; } /** - * Deprecated method + * The unique identifier of the payer used when saving this credit card using /vault/credit-card API. + * @return string + * @deprecated. Instead use getPayerId */ public function getPayer_id() { return $this->payer_id; @@ -119,14 +128,18 @@ class CreditCardToken extends \PPModel { } /** - * Deprecated method + * card expiry month from the saved card with value 1 - 12 + * @param integer $expire_month + * @deprecated. Instead use setExpireMonth */ public function setExpire_month($expire_month) { $this->expire_month = $expire_month; return $this; } /** - * Deprecated method + * card expiry month from the saved card with value 1 - 12 + * @return integer + * @deprecated. Instead use getExpireMonth */ public function getExpire_month() { return $this->expire_month; @@ -150,14 +163,18 @@ class CreditCardToken extends \PPModel { } /** - * Deprecated method + * 4 digit card expiry year from the saved card + * @param integer $expire_year + * @deprecated. Instead use setExpireYear */ public function setExpire_year($expire_year) { $this->expire_year = $expire_year; return $this; } /** - * Deprecated method + * 4 digit card expiry year from the saved card + * @return integer + * @deprecated. Instead use getExpireYear */ public function getExpire_year() { return $this->expire_year; diff --git a/lib/PayPal/Api/Details.php b/lib/PayPal/Api/Details.php index 2a18fa1..ab38367 100644 --- a/lib/PayPal/Api/Details.php +++ b/lib/PayPal/Api/Details.php @@ -1,8 +1,9 @@ credit_card = $credit_card; return $this; } /** - * Deprecated method + * Credit Card information. + * @return PayPal\Api\CreditCard + * @deprecated. Instead use getCreditCard */ public function getCredit_card() { return $this->credit_card; @@ -52,14 +57,18 @@ class FundingInstrument extends \PPModel { } /** - * Deprecated method + * Credit Card information. + * @param PayPal\Api\CreditCardToken $credit_card_token + * @deprecated. Instead use setCreditCardToken */ public function setCredit_card_token($credit_card_token) { $this->credit_card_token = $credit_card_token; return $this; } /** - * Deprecated method + * Credit Card information. + * @return PayPal\Api\CreditCardToken + * @deprecated. Instead use getCreditCardToken */ public function getCredit_card_token() { return $this->credit_card_token; diff --git a/lib/PayPal/Api/HyperSchema.php b/lib/PayPal/Api/HyperSchema.php index 661b8a5..a09ee92 100644 --- a/lib/PayPal/Api/HyperSchema.php +++ b/lib/PayPal/Api/HyperSchema.php @@ -1,8 +1,9 @@ fragmentResolution; } - /** - * Deprecated method - */ - public function setFragmentresolution($fragmentResolution) { - $this->fragmentResolution = $fragmentResolution; - return $this; - } - /** - * Deprecated method - */ - public function getFragmentresolution() { - return $this->fragmentResolution; - } /** * @@ -88,19 +76,6 @@ class HyperSchema extends \PPModel { return $this->contentEncoding; } - /** - * Deprecated method - */ - public function setContentencoding($contentEncoding) { - $this->contentEncoding = $contentEncoding; - return $this; - } - /** - * Deprecated method - */ - public function getContentencoding() { - return $this->contentEncoding; - } /** * @@ -119,19 +94,6 @@ class HyperSchema extends \PPModel { return $this->pathStart; } - /** - * Deprecated method - */ - public function setPathstart($pathStart) { - $this->pathStart = $pathStart; - return $this; - } - /** - * Deprecated method - */ - public function getPathstart() { - return $this->pathStart; - } /** * @@ -150,18 +112,5 @@ class HyperSchema extends \PPModel { return $this->mediaType; } - /** - * Deprecated method - */ - public function setMediatype($mediaType) { - $this->mediaType = $mediaType; - return $this; - } - /** - * Deprecated method - */ - public function getMediatype() { - return $this->mediaType; - } } diff --git a/lib/PayPal/Api/Item.php b/lib/PayPal/Api/Item.php index fbd12b9..4a40632 100644 --- a/lib/PayPal/Api/Item.php +++ b/lib/PayPal/Api/Item.php @@ -1,8 +1,9 @@ shipping_address = $shipping_address; return $this; } /** - * Deprecated method + * Shipping address. + * @return PayPal\Api\ShippingAddress + * @deprecated. Instead use getShippingAddress */ public function getShipping_address() { return $this->shipping_address; diff --git a/lib/PayPal/Api/Links.php b/lib/PayPal/Api/Links.php index 927b035..9cbd85e 100644 --- a/lib/PayPal/Api/Links.php +++ b/lib/PayPal/Api/Links.php @@ -1,8 +1,9 @@ targetSchema; } - /** - * Deprecated method - */ - public function setTargetschema($targetSchema) { - $this->targetSchema = $targetSchema; - return $this; - } - /** - * Deprecated method - */ - public function getTargetschema() { - return $this->targetSchema; - } /** * diff --git a/lib/PayPal/Api/Payee.php b/lib/PayPal/Api/Payee.php index 355946d..d0ccea3 100644 --- a/lib/PayPal/Api/Payee.php +++ b/lib/PayPal/Api/Payee.php @@ -1,8 +1,9 @@ merchant_id = $merchant_id; return $this; } /** - * Deprecated method + * Encrypted PayPal Account identifier for the Payee. + * @return string + * @deprecated. Instead use getMerchantId */ public function getMerchant_id() { return $this->merchant_id; diff --git a/lib/PayPal/Api/Payer.php b/lib/PayPal/Api/Payer.php index a0d2f07..d21d238 100644 --- a/lib/PayPal/Api/Payer.php +++ b/lib/PayPal/Api/Payer.php @@ -1,8 +1,9 @@ payment_method = $payment_method; return $this; } /** - * Deprecated method + * Payment method being used - PayPal Wallet payment or Direct Credit card. + * @return string + * @deprecated. Instead use getPaymentMethod */ public function getPayment_method() { return $this->payment_method; @@ -53,14 +58,19 @@ class Payer extends \PPModel { } /** - * Deprecated method + * List of funding instruments from where the funds of the current payment come from. Typically a credit card. + * @array + * @param PayPal\Api\FundingInstrument $funding_instruments + * @deprecated. Instead use setFundingInstruments */ public function setFunding_instruments($funding_instruments) { $this->funding_instruments = $funding_instruments; return $this; } /** - * Deprecated method + * List of funding instruments from where the funds of the current payment come from. Typically a credit card. + * @return PayPal\Api\FundingInstrument + * @deprecated. Instead use getFundingInstruments */ public function getFunding_instruments() { return $this->funding_instruments; @@ -84,14 +94,18 @@ class Payer extends \PPModel { } /** - * Deprecated method + * Information related to the Payer. In case of PayPal Wallet payment, this information will be filled in by PayPal after the user approves the payment using their PayPal Wallet. + * @param PayPal\Api\PayerInfo $payer_info + * @deprecated. Instead use setPayerInfo */ public function setPayer_info($payer_info) { $this->payer_info = $payer_info; return $this; } /** - * Deprecated method + * Information related to the Payer. In case of PayPal Wallet payment, this information will be filled in by PayPal after the user approves the payment using their PayPal Wallet. + * @return PayPal\Api\PayerInfo + * @deprecated. Instead use getPayerInfo */ public function getPayer_info() { return $this->payer_info; diff --git a/lib/PayPal/Api/PayerInfo.php b/lib/PayPal/Api/PayerInfo.php index 9a0e06b..a9ff596 100644 --- a/lib/PayPal/Api/PayerInfo.php +++ b/lib/PayPal/Api/PayerInfo.php @@ -1,8 +1,9 @@ first_name = $first_name; return $this; } /** - * Deprecated method + * First Name of the Payer from their PayPal Account. + * @return string + * @deprecated. Instead use getFirstName */ public function getFirst_name() { return $this->first_name; @@ -70,14 +75,18 @@ class PayerInfo extends \PPModel { } /** - * Deprecated method + * Last Name of the Payer from their PayPal Account. + * @param string $last_name + * @deprecated. Instead use setLastName */ public function setLast_name($last_name) { $this->last_name = $last_name; return $this; } /** - * Deprecated method + * Last Name of the Payer from their PayPal Account. + * @return string + * @deprecated. Instead use getLastName */ public function getLast_name() { return $this->last_name; @@ -101,14 +110,18 @@ class PayerInfo extends \PPModel { } /** - * Deprecated method + * PayPal assigned Payer ID. + * @param string $payer_id + * @deprecated. Instead use setPayerId */ public function setPayer_id($payer_id) { $this->payer_id = $payer_id; return $this; } /** - * Deprecated method + * PayPal assigned Payer ID. + * @return string + * @deprecated. Instead use getPayerId */ public function getPayer_id() { return $this->payer_id; @@ -150,14 +163,18 @@ class PayerInfo extends \PPModel { } /** - * Deprecated method + * Shipping address of the Payer from their PayPal Account. + * @param PayPal\Api\Address $shipping_address + * @deprecated. Instead use setShippingAddress */ public function setShipping_address($shipping_address) { $this->shipping_address = $shipping_address; return $this; } /** - * Deprecated method + * Shipping address of the Payer from their PayPal Account. + * @return PayPal\Api\Address + * @deprecated. Instead use getShippingAddress */ public function getShipping_address() { return $this->shipping_address; diff --git a/lib/PayPal/Api/Payment.php b/lib/PayPal/Api/Payment.php index 144d7a0..cf223f0 100644 --- a/lib/PayPal/Api/Payment.php +++ b/lib/PayPal/Api/Payment.php @@ -1,17 +1,21 @@ create_time = $create_time; return $this; } /** - * Deprecated method + * Time the resource was created. + * @return string + * @deprecated. Instead use getCreateTime */ public function getCreate_time() { return $this->create_time; @@ -84,14 +92,18 @@ class Payment extends \PPModel implements IResource { } /** - * Deprecated method + * Time the resource was last updated. + * @param string $update_time + * @deprecated. Instead use setUpdateTime */ public function setUpdate_time($update_time) { $this->update_time = $update_time; return $this; } /** - * Deprecated method + * Time the resource was last updated. + * @return string + * @deprecated. Instead use getUpdateTime */ public function getUpdate_time() { return $this->update_time; @@ -188,14 +200,18 @@ class Payment extends \PPModel implements IResource { } /** - * Deprecated method + * Redirect urls required only when using payment_method as PayPal - the only settings supported are return and cancel urls. + * @param PayPal\Api\RedirectUrls $redirect_urls + * @deprecated. Instead use setRedirectUrls */ public function setRedirect_urls($redirect_urls) { $this->redirect_urls = $redirect_urls; return $this; } /** - * Deprecated method + * Redirect urls required only when using payment_method as PayPal - the only settings supported are return and cancel urls. + * @return PayPal\Api\RedirectUrls + * @deprecated. Instead use getRedirectUrls */ public function getRedirect_urls() { return $this->redirect_urls; @@ -226,7 +242,7 @@ class Payment extends \PPModel implements IResource { if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } - $call = new \PPRestCall($apiContext); + $call = new PPRestCall($apiContext); $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/payment", "POST", $payLoad); $this->fromJson($json); return $this; @@ -240,7 +256,7 @@ class Payment extends \PPModel implements IResource { if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } - $call = new \PPRestCall($apiContext); + $call = new PPRestCall($apiContext); $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/payment/$paymentId", "GET", $payLoad); $ret = new Payment(); $ret->fromJson($json); @@ -258,7 +274,7 @@ class Payment extends \PPModel implements IResource { if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } - $call = new \PPRestCall($apiContext); + $call = new PPRestCall($apiContext); $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/payment/{$this->getId()}/execute", "POST", $payLoad); $ret = new Payment(); $ret->fromJson($json); @@ -274,7 +290,7 @@ class Payment extends \PPModel implements IResource { if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } - $call = new \PPRestCall($apiContext); + $call = new PPRestCall($apiContext); $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/payment?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad); $ret = new PaymentHistory(); $ret->fromJson($json); diff --git a/lib/PayPal/Api/PaymentExecution.php b/lib/PayPal/Api/PaymentExecution.php index a61e00c..b7048eb 100644 --- a/lib/PayPal/Api/PaymentExecution.php +++ b/lib/PayPal/Api/PaymentExecution.php @@ -1,8 +1,9 @@ payer_id = $payer_id; return $this; } /** - * Deprecated method + * PayPal assigned Payer ID returned in the approval return url. + * @return string + * @deprecated. Instead use getPayerId */ public function getPayer_id() { return $this->payer_id; diff --git a/lib/PayPal/Api/PaymentHistory.php b/lib/PayPal/Api/PaymentHistory.php index 485a40b..e9f28af 100644 --- a/lib/PayPal/Api/PaymentHistory.php +++ b/lib/PayPal/Api/PaymentHistory.php @@ -1,8 +1,9 @@ next_id = $next_id; return $this; } /** - * Deprecated method + * Identifier of the next element to get the next range of results. + * @return string + * @deprecated. Instead use getNextId */ public function getNext_id() { return $this->next_id; diff --git a/lib/PayPal/Api/RedirectUrls.php b/lib/PayPal/Api/RedirectUrls.php index 84b34ee..c954b49 100644 --- a/lib/PayPal/Api/RedirectUrls.php +++ b/lib/PayPal/Api/RedirectUrls.php @@ -1,8 +1,9 @@ return_url = $return_url; return $this; } /** - * Deprecated method + * Url where the payer would be redirected to after approving the payment. + * @return string + * @deprecated. Instead use getReturnUrl */ public function getReturn_url() { return $this->return_url; @@ -52,14 +57,18 @@ class RedirectUrls extends \PPModel { } /** - * Deprecated method + * Url where the payer would be redirected to after canceling the payment. + * @param string $cancel_url + * @deprecated. Instead use setCancelUrl */ public function setCancel_url($cancel_url) { $this->cancel_url = $cancel_url; return $this; } /** - * Deprecated method + * Url where the payer would be redirected to after canceling the payment. + * @return string + * @deprecated. Instead use getCancelUrl */ public function getCancel_url() { return $this->cancel_url; diff --git a/lib/PayPal/Api/Refund.php b/lib/PayPal/Api/Refund.php index 75baeb8..095200a 100644 --- a/lib/PayPal/Api/Refund.php +++ b/lib/PayPal/Api/Refund.php @@ -1,17 +1,20 @@ create_time = $create_time; return $this; } /** - * Deprecated method + * Time the resource was created. + * @return string + * @deprecated. Instead use getCreateTime */ public function getCreate_time() { return $this->create_time; @@ -120,14 +127,18 @@ class Refund extends \PPModel implements IResource { } /** - * Deprecated method + * ID of the Sale transaction being refunded. + * @param string $sale_id + * @deprecated. Instead use setSaleId */ public function setSale_id($sale_id) { $this->sale_id = $sale_id; return $this; } /** - * Deprecated method + * ID of the Sale transaction being refunded. + * @return string + * @deprecated. Instead use getSaleId */ public function getSale_id() { return $this->sale_id; @@ -151,14 +162,18 @@ class Refund extends \PPModel implements IResource { } /** - * Deprecated method + * ID of the Capture transaction being refunded. + * @param string $capture_id + * @deprecated. Instead use setCaptureId */ public function setCapture_id($capture_id) { $this->capture_id = $capture_id; return $this; } /** - * Deprecated method + * ID of the Capture transaction being refunded. + * @return string + * @deprecated. Instead use getCaptureId */ public function getCapture_id() { return $this->capture_id; @@ -182,14 +197,18 @@ class Refund extends \PPModel implements IResource { } /** - * Deprecated method + * ID of the Payment resource that this transaction is based on. + * @param string $parent_payment + * @deprecated. Instead use setParentPayment */ public function setParent_payment($parent_payment) { $this->parent_payment = $parent_payment; return $this; } /** - * Deprecated method + * ID of the Payment resource that this transaction is based on. + * @return string + * @deprecated. Instead use getParentPayment */ public function getParent_payment() { return $this->parent_payment; @@ -223,7 +242,7 @@ class Refund extends \PPModel implements IResource { if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } - $call = new \PPRestCall($apiContext); + $call = new PPRestCall($apiContext); $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/refund/$refundId", "GET", $payLoad); $ret = new Refund(); $ret->fromJson($json); diff --git a/lib/PayPal/Api/RelatedResources.php b/lib/PayPal/Api/RelatedResources.php index 98085f7..7e97776 100644 --- a/lib/PayPal/Api/RelatedResources.php +++ b/lib/PayPal/Api/RelatedResources.php @@ -1,8 +1,9 @@ create_time = $create_time; return $this; } /** - * Deprecated method + * Time the resource was created. + * @return string + * @deprecated. Instead use getCreateTime */ public function getCreate_time() { return $this->create_time; @@ -84,14 +92,18 @@ class Sale extends \PPModel implements IResource { } /** - * Deprecated method + * Time the resource was last updated. + * @param string $update_time + * @deprecated. Instead use setUpdateTime */ public function setUpdate_time($update_time) { $this->update_time = $update_time; return $this; } /** - * Deprecated method + * Time the resource was last updated. + * @return string + * @deprecated. Instead use getUpdateTime */ public function getUpdate_time() { return $this->update_time; @@ -151,14 +163,18 @@ class Sale extends \PPModel implements IResource { } /** - * Deprecated method + * ID of the Payment resource that this transaction is based on. + * @param string $parent_payment + * @deprecated. Instead use setParentPayment */ public function setParent_payment($parent_payment) { $this->parent_payment = $parent_payment; return $this; } /** - * Deprecated method + * ID of the Payment resource that this transaction is based on. + * @return string + * @deprecated. Instead use getParentPayment */ public function getParent_payment() { return $this->parent_payment; @@ -192,7 +208,7 @@ class Sale extends \PPModel implements IResource { if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } - $call = new \PPRestCall($apiContext); + $call = new PPRestCall($apiContext); $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/sale/$saleId", "GET", $payLoad); $ret = new Sale(); $ret->fromJson($json); @@ -210,7 +226,7 @@ class Sale extends \PPModel implements IResource { if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } - $call = new \PPRestCall($apiContext); + $call = new PPRestCall($apiContext); $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/sale/{$this->getId()}/refund", "POST", $payLoad); $ret = new Refund(); $ret->fromJson($json); diff --git a/lib/PayPal/Api/ShippingAddress.php b/lib/PayPal/Api/ShippingAddress.php index e1595f4..a7f4de9 100644 --- a/lib/PayPal/Api/ShippingAddress.php +++ b/lib/PayPal/Api/ShippingAddress.php @@ -1,6 +1,7 @@ recipient_name = $recipient_name; return $this; } /** - * Deprecated method + * Name of the recipient at this address. + * @return string + * @deprecated. Instead use getRecipientName */ public function getRecipient_name() { return $this->recipient_name; diff --git a/lib/PayPal/Api/Transaction.php b/lib/PayPal/Api/Transaction.php index 0b3c1f7..d8420aa 100644 --- a/lib/PayPal/Api/Transaction.php +++ b/lib/PayPal/Api/Transaction.php @@ -1,8 +1,9 @@ item_list = $item_list; return $this; } /** - * Deprecated method + * List of items being paid for. + * @return PayPal\Api\ItemList + * @deprecated. Instead use getItemList */ public function getItem_list() { return $this->item_list; @@ -107,14 +112,19 @@ class Transaction extends \PPModel { } /** - * Deprecated method + * List of financial transactions (Sale, Authorization, Capture, Refund) related to the payment. + * @array + * @param PayPal\Api\RelatedResources $related_resources + * @deprecated. Instead use setRelatedResources */ public function setRelated_resources($related_resources) { $this->related_resources = $related_resources; return $this; } /** - * Deprecated method + * List of financial transactions (Sale, Authorization, Capture, Refund) related to the payment. + * @return PayPal\Api\RelatedResources + * @deprecated. Instead use getRelatedResources */ public function getRelated_resources() { return $this->related_resources; diff --git a/lib/PayPal/Api/Transactions.php b/lib/PayPal/Api/Transactions.php index 6c86384..2219837 100644 --- a/lib/PayPal/Api/Transactions.php +++ b/lib/PayPal/Api/Transactions.php @@ -1,8 +1,9 @@ logger = new \PPLoggingManager(__CLASS__, $config); + $this->logger = new PPLoggingManager(__CLASS__, $config); // Check if Access Token is not null and has not expired. // The API returns expiry time as a relative time unit // We use a buffer time when checking for token expiry to account @@ -81,14 +85,14 @@ class OAuthTokenCredential { $base64ClientID = base64_encode($this->clientId . ":" . $this->clientSecret); $headers = array( - "User-Agent" => \PPUserAgent::getValue(RestHandler::$sdkName, RestHandler::$sdkVersion), + "User-Agent" => PPUserAgent::getValue(RestHandler::$sdkName, RestHandler::$sdkVersion), "Authorization" => "Basic " . $base64ClientID, "Accept" => "*/*" ); $httpConfiguration = $this->getOAuthHttpConfiguration($config); $httpConfiguration->setHeaders($headers); - $connection = \PPConnectionManager::getInstance()->getConnection($httpConfiguration, $config); + $connection = PPConnectionManager::getInstance()->getConnection($httpConfiguration, $config); $res = $connection->execute("grant_type=client_credentials"); $jsonResponse = json_decode($res, true); if($jsonResponse == NULL || @@ -115,19 +119,19 @@ class OAuthTokenCredential { } else if (isset($config['mode'])) { switch (strtoupper($config['mode'])) { case 'SANDBOX': - $baseEndpoint = \PPConstants::REST_SANDBOX_ENDPOINT; + $baseEndpoint = PPConstants::REST_SANDBOX_ENDPOINT; break; case 'LIVE': - $baseEndpoint = \PPConstants::REST_LIVE_ENDPOINT; + $baseEndpoint = PPConstants::REST_LIVE_ENDPOINT; break; default: - throw new \PPConfigurationException('The mode config parameter must be set to either sandbox/live'); + throw new PPConfigurationException('The mode config parameter must be set to either sandbox/live'); } } else { - throw new \PPConfigurationException('You must set one of service.endpoint or mode parameters in your configuration'); + throw new PPConfigurationException('You must set one of service.endpoint or mode parameters in your configuration'); } $baseEndpoint = rtrim(trim($baseEndpoint), '/'); - return new \PPHttpConfig($baseEndpoint . "/v1/oauth2/token", "POST"); + return new PPHttpConfig($baseEndpoint . "/v1/oauth2/token", "POST"); } } diff --git a/lib/PayPal/Rest/ApiContext.php b/lib/PayPal/Rest/ApiContext.php index 8cf1ae9..a485897 100644 --- a/lib/PayPal/Rest/ApiContext.php +++ b/lib/PayPal/Rest/ApiContext.php @@ -1,12 +1,13 @@ getCredentialObject(); if(!is_array($credValues)) { - throw new \PPMissingCredentialException("Empty or invalid credentials passed"); + throw new PPMissingCredentialException("Empty or invalid credentials passed"); } $credential = new OAuthTokenCredential($credValues['clientId'], $credValues['clientSecret']); } if($credential == NULL || ! ($credential instanceof OAuthTokenCredential) ) { - throw new \PPInvalidCredentialException("Invalid credentials passed"); + throw new PPInvalidCredentialException("Invalid credentials passed"); } @@ -43,7 +50,7 @@ class RestHandler implements \IPPHandler { ); if(!array_key_exists("User-Agent", $httpConfig->getHeaders())) { - $httpConfig->addHeader("User-Agent", \PPUserAgent::getValue(self::$sdkName, self::$sdkVersion)); + $httpConfig->addHeader("User-Agent", PPUserAgent::getValue(self::$sdkName, self::$sdkVersion)); } if(!is_null($credential) && $credential instanceof OAuthTokenCredential) { $httpConfig->addHeader('Authorization', "Bearer " . $credential->getAccessToken($config)); @@ -60,17 +67,17 @@ class RestHandler implements \IPPHandler { } else if (isset($config['mode'])) { switch (strtoupper($config['mode'])) { case 'SANDBOX': - return \PPConstants::REST_SANDBOX_ENDPOINT; + return PPConstants::REST_SANDBOX_ENDPOINT; break; case 'LIVE': - return \PPConstants::REST_LIVE_ENDPOINT; + return PPConstants::REST_LIVE_ENDPOINT; break; default: - throw new \PPConfigurationException('The mode config parameter must be set to either sandbox/live'); + throw new PPConfigurationException('The mode config parameter must be set to either sandbox/live'); break; } } else { - throw new \PPConfigurationException('You must set one of service.endpoint or mode parameters in your configuration'); + throw new PPConfigurationException('You must set one of service.endpoint or mode parameters in your configuration'); } } diff --git a/tests/PayPal/Test/Auth/OAuthTokenCredentialTest.php b/tests/PayPal/Test/Auth/OAuthTokenCredentialTest.php index 5597d03..5dfe13e 100644 --- a/tests/PayPal/Test/Auth/OAuthTokenCredentialTest.php +++ b/tests/PayPal/Test/Auth/OAuthTokenCredentialTest.php @@ -4,12 +4,13 @@ use PayPal\Auth\OAuthTokenCredential; use PayPal\Test\Constants; - +use PayPal\Core\PPConfigManager; +use PayPal\Exception\PPConnectionException; class OAuthTokenCredentialTest extends PHPUnit_Framework_TestCase { public function testGetAccessToken() { $cred = new OAuthTokenCredential(Constants::CLIENT_ID, Constants::CLIENT_SECRET); - $config = \PPConfigManager::getInstance()->getConfigHashmap(); + $config = PPConfigManager::getInstance()->getConfigHashmap(); $token = $cred->getAccessToken($config); $this->assertNotNull($token); @@ -27,8 +28,8 @@ class OAuthTokenCredentialTest extends PHPUnit_Framework_TestCase { } public function testInvalidCredentials() { - $this->setExpectedException('\PPConnectionException'); + $this->setExpectedException('PayPal\Exception\PPConnectionException'); $cred = new OAuthTokenCredential('dummy', 'secret'); - $this->assertNull($cred->getAccessToken(\PPConfigManager::getInstance()->getConfigHashmap())); + $this->assertNull($cred->getAccessToken(PPConfigManager::getInstance()->getConfigHashmap())); } } \ No newline at end of file diff --git a/tests/PayPal/Test/Common/ArrayClass.php b/tests/PayPal/Test/Common/ArrayClass.php new file mode 100644 index 0000000..3470847 --- /dev/null +++ b/tests/PayPal/Test/Common/ArrayClass.php @@ -0,0 +1,29 @@ +name = $name; + } + public function getName() { + return $this->name; + } + + public function setDescription($desc) { + $this->desc = $desc; + } + public function getDescription() { + return $this->desc; + } + + public function setTags($tags) { + if(!is_array($tags)) { + $tags = array($tags); + } + $this->tags = $tags; + } + public function getTags() { + return $this->tags; + } +} \ No newline at end of file diff --git a/tests/PayPal/Test/Common/ArrayUtilTest.php b/tests/PayPal/Test/Common/ArrayUtilTest.php index 6dd2930..824b684 100644 --- a/tests/PayPal/Test/Common/ArrayUtilTest.php +++ b/tests/PayPal/Test/Common/ArrayUtilTest.php @@ -1,8 +1,8 @@ name = $name; - } - public function getName() { - return $this->name; - } - - public function setDescription($desc) { - $this->desc = $desc; - } - public function getDescription() { - return $this->desc; - } -} - -class ArrayClass extends \PPModel { - - public function setName($name) { - $this->name = $name; - } - public function getName() { - return $this->name; - } - - public function setDescription($desc) { - $this->desc = $desc; - } - public function getDescription() { - return $this->desc; - } - - public function setTags($tags) { - if(!is_array($tags)) { - $tags = array($tags); - } - $this->tags = $tags; - } - public function getTags() { - return $this->tags; - } -} - -class NestedClass extends \PPModel { - - public function setId($id) { - $this->id = $id; - } - public function getId() { - return $this->id; - } - - /** - * - * @param ArrayClass $info - */ - public function setInfo($info) { - $this->info = $info; - } - /** - * - * @return ArrayClass - */ - public function getInfo() { - return $this->info; - } -} - -class ChildClass extends SimpleClass { - -} - -class ModelTest extends PHPUnit_Framework_TestCase { +namespace PayPal\Test\Common; +use PayPal\Common\PPModel; +use PayPal\Test\Common\ArrayClass; +use PayPal\Test\Common\SimpleClass; +use PayPal\Test\Common\NestedClass; +class ModelTest extends \PHPUnit_Framework_TestCase { public function testSimpleClassConversion() { $o = new SimpleClass(); diff --git a/tests/PayPal/Test/Common/NestedClass.php b/tests/PayPal/Test/Common/NestedClass.php new file mode 100644 index 0000000..06e5e00 --- /dev/null +++ b/tests/PayPal/Test/Common/NestedClass.php @@ -0,0 +1,27 @@ +id = $id; + } + public function getId() { + return $this->id; + } + + /** + * + * @param PayPal\Test\Common\ArrayClass $info + */ + public function setInfo($info) { + $this->info = $info; + } + /** + * + * @return PayPal\Test\Common\ArrayClass + */ + public function getInfo() { + return $this->info; + } +} \ No newline at end of file diff --git a/tests/PayPal/Test/Common/SimpleClass.php b/tests/PayPal/Test/Common/SimpleClass.php new file mode 100644 index 0000000..86732b1 --- /dev/null +++ b/tests/PayPal/Test/Common/SimpleClass.php @@ -0,0 +1,19 @@ +name = $name; + } + public function getName() { + return $this->name; + } + + public function setDescription($desc) { + $this->desc = $desc; + } + public function getDescription() { + return $this->desc; + } +} \ No newline at end of file diff --git a/tests/PayPal/Test/Common/UserAgentTest.php b/tests/PayPal/Test/Common/UserAgentTest.php index 5bf8765..d945374 100644 --- a/tests/PayPal/Test/Common/UserAgentTest.php +++ b/tests/PayPal/Test/Common/UserAgentTest.php @@ -1,6 +1,6 @@ Date: Wed, 29 May 2013 14:48:10 +0530 Subject: [PATCH 08/20] upgrading to namespace based SDK core --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 50cb3b2..d1d4f8d 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "php": ">=5.3.0", "ext-curl": "*", "ext-json": "*", - "paypal/sdk-core-php": "1.4.*" + "paypal/sdk-core-php": "2.4.*" }, "require-dev": { "phpunit/phpunit": "3.7.*" From 2b965b059673c961b324ec15ba9f9f2b83d78894 Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Wed, 29 May 2013 17:23:47 +0530 Subject: [PATCH 09/20] updating sample to show full API flow --- sample/payments/AuthorizationCapture.php | 74 ++++++++++++++++--- sample/payments/GetAuthorization.php | 59 +++++++++++++++- sample/payments/GetCapture.php | 82 ++++++++++++++++++++- sample/payments/RefundCapture.php | 90 ++++++++++++++++++++++-- sample/payments/VoidAuthorization.php | 59 +++++++++++++++- sample/vault/DeleteCreditCard.php | 31 +++++++- 6 files changed, 374 insertions(+), 21 deletions(-) diff --git a/sample/payments/AuthorizationCapture.php b/sample/payments/AuthorizationCapture.php index 328b518..d87474a 100644 --- a/sample/payments/AuthorizationCapture.php +++ b/sample/payments/AuthorizationCapture.php @@ -6,23 +6,28 @@ require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Capture; use PayPal\Api\Authorization; +use PayPal\Api\Address; use PayPal\Api\Amount; +use PayPal\Api\CreditCard; +use PayPal\Api\Payer; +use PayPal\Api\Payment; +use PayPal\Api\FundingInstrument; +use PayPal\Api\Transaction; -### Amount -//Let's you specify a payment amount. - $amount = new Amount(); - $amount->setCurrency("USD"); - $amount->setTotal("1.00"); +// create payment to get authorization Id +$authId = createAuthorization(); +$amt = new Amount(); +$amt->setCurrency("USD"); +$amt->setTotal("1.00"); ### Capture - $captur = new Capture(); -$captur->setId('5RA45624N3531924N'); -$captur->setAmount($amount); +$captur->setId($authId); +$captur->setAmount($amt); // get the authorization -$authorization = Authorization::get('8UA90289RG279654G', $apiContext); +$authorization = Authorization::get($authId, $apiContext); // ### Capture Payment // Capture Payment by posting to the APIService @@ -42,7 +47,56 @@ try { Capture payment: getId();?> -
toArray());?>
+
+		toArray());?>
+	
Back +setLine1("3909 Witmer Road"); + $addr->setLine2("Niagara Falls"); + $addr->setCity("Niagara Falls"); + $addr->setState("NY"); + $addr->setPostal_code("14305"); + $addr->setCountry_code("US"); + $addr->setPhone("716-298-1822"); + + $card = new CreditCard(); + $card->setType("visa"); + $card->setNumber("4417119669820331"); + $card->setExpire_month("11"); + $card->setExpire_year("2019"); + $card->setCvv2("012"); + $card->setFirst_name("Joe"); + $card->setLast_name("Shopper"); + $card->setBilling_address($addr); + + $fi = new FundingInstrument(); + $fi->setCredit_card($card); + + $payer = new Payer(); + $payer->setPayment_method("credit_card"); + $payer->setFunding_instruments(array($fi)); + + $amount = new Amount(); + $amount->setCurrency("USD"); + $amount->setTotal("1.00"); + + $transaction = new Transaction(); + $transaction->setAmount($amount); + $transaction->setDescription("This is the payment description."); + + $payment = new Payment(); + $payment->setIntent("authorize"); + $payment->setPayer($payer); + $payment->setTransactions(array($transaction)); + + $paymnt = $payment->create(); + $resArray = $paymnt->toArray(); + + return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; +} \ No newline at end of file diff --git a/sample/payments/GetAuthorization.php b/sample/payments/GetAuthorization.php index 1bf13a0..c72e0e4 100644 --- a/sample/payments/GetAuthorization.php +++ b/sample/payments/GetAuthorization.php @@ -6,13 +6,23 @@ require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Authorization; +use PayPal\Api\Address; +use PayPal\Api\Amount; +use PayPal\Api\CreditCard; +use PayPal\Api\Payer; +use PayPal\Api\Payment; +use PayPal\Api\FundingInstrument; +use PayPal\Api\Transaction; + +// create payment to get authorization Id +$authId = createAuthorization(); // ### GetAuthorization // GetAuthorization by posting to the APIService // using a valid ApiContext (See bootstrap.php for more on `ApiContext`) // The return object contains the status; try { - $authorization = Authorization::get('1FR49283DF589111P', $apiContext); + $authorization = Authorization::get($authId, $apiContext); } catch (\PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); @@ -29,3 +39,50 @@ try { Back +setLine1("3909 Witmer Road"); + $addr->setLine2("Niagara Falls"); + $addr->setCity("Niagara Falls"); + $addr->setState("NY"); + $addr->setPostal_code("14305"); + $addr->setCountry_code("US"); + $addr->setPhone("716-298-1822"); + + $card = new CreditCard(); + $card->setType("visa"); + $card->setNumber("4417119669820331"); + $card->setExpire_month("11"); + $card->setExpire_year("2019"); + $card->setCvv2("012"); + $card->setFirst_name("Joe"); + $card->setLast_name("Shopper"); + $card->setBilling_address($addr); + + $fi = new FundingInstrument(); + $fi->setCredit_card($card); + + $payer = new Payer(); + $payer->setPayment_method("credit_card"); + $payer->setFunding_instruments(array($fi)); + + $amount = new Amount(); + $amount->setCurrency("USD"); + $amount->setTotal("1.00"); + + $transaction = new Transaction(); + $transaction->setAmount($amount); + $transaction->setDescription("This is the payment description."); + + $payment = new Payment(); + $payment->setIntent("authorize"); + $payment->setPayer($payer); + $payment->setTransactions(array($transaction)); + + $paymnt = $payment->create(); + $resArray = $paymnt->toArray(); + + return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; +} \ No newline at end of file diff --git a/sample/payments/GetCapture.php b/sample/payments/GetCapture.php index 73a7062..9b08564 100644 --- a/sample/payments/GetCapture.php +++ b/sample/payments/GetCapture.php @@ -5,13 +5,46 @@ require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Capture; +use PayPal\Api\Address; +use PayPal\Api\Amount; +use PayPal\Api\CreditCard; +use PayPal\Api\Payer; +use PayPal\Api\Payment; +use PayPal\Api\FundingInstrument; +use PayPal\Api\Transaction; + +// create payment to get authorization Id +$authId = createAuthorization(); +$amt = new Amount(); +$amt->setCurrency("USD"); +$amt->setTotal("1.00"); + +### Capture +$captur = new Capture(); +$captur->setId($authId); +$captur->setAmount($amt); + +// get the authorization +$authorization = Authorization::get($authId, $apiContext); + +// ### Capture Payment +// Capture Payment by posting to the APIService +// using a valid ApiContext (See bootstrap.php for more on `ApiContext`) +// The return object contains the status; +try { + $capt = $authorization->capture($captur, $apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} // ### Get Capture // Get Capture by posting to the APIService // using a valid ApiContext (See bootstrap.php for more on `ApiContext`) // The return object contains the status; try { - $capture = Capture::get('7BA08426L46375838', $apiContext); + $capture = Capture::get($capt->getId(), $apiContext); } catch (\PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); @@ -28,3 +61,50 @@ try { Back +setLine1("3909 Witmer Road"); + $addr->setLine2("Niagara Falls"); + $addr->setCity("Niagara Falls"); + $addr->setState("NY"); + $addr->setPostal_code("14305"); + $addr->setCountry_code("US"); + $addr->setPhone("716-298-1822"); + + $card = new CreditCard(); + $card->setType("visa"); + $card->setNumber("4417119669820331"); + $card->setExpire_month("11"); + $card->setExpire_year("2019"); + $card->setCvv2("012"); + $card->setFirst_name("Joe"); + $card->setLast_name("Shopper"); + $card->setBilling_address($addr); + + $fi = new FundingInstrument(); + $fi->setCredit_card($card); + + $payer = new Payer(); + $payer->setPayment_method("credit_card"); + $payer->setFunding_instruments(array($fi)); + + $amount = new Amount(); + $amount->setCurrency("USD"); + $amount->setTotal("1.00"); + + $transaction = new Transaction(); + $transaction->setAmount($amount); + $transaction->setDescription("This is the payment description."); + + $payment = new Payment(); + $payment->setIntent("authorize"); + $payment->setPayer($payer); + $payment->setTransactions(array($transaction)); + + $paymnt = $payment->create(); + $resArray = $paymnt->toArray(); + + return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; +} \ No newline at end of file diff --git a/sample/payments/RefundCapture.php b/sample/payments/RefundCapture.php index 447cd4c..983e6b6 100644 --- a/sample/payments/RefundCapture.php +++ b/sample/payments/RefundCapture.php @@ -2,7 +2,40 @@ require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Capture; use PayPal\Api\Refund; +use PayPal\Api\Address; use PayPal\Api\Amount; +use PayPal\Api\CreditCard; +use PayPal\Api\Payer; +use PayPal\Api\Payment; +use PayPal\Api\FundingInstrument; +use PayPal\Api\Transaction; + +// create payment to get authorization Id +$authId = createAuthorization(); + +$amt = new Amount(); +$amt->setCurrency("USD"); +$amt->setTotal("1.00"); + +### Capture +$captur = new Capture(); +$captur->setId($authId); +$captur->setAmount($amt); + +// get the authorization +$authorization = Authorization::get($authId, $apiContext); + +// ### Capture Payment +// Capture Payment by posting to the APIService +// using a valid ApiContext (See bootstrap.php for more on `ApiContext`) +// The return object contains the status; +try { + $capt = $authorization->capture($captur, $apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} // # Refund Capture Sample // This sample code demonstrate how you can @@ -14,17 +47,14 @@ use PayPal\Api\Amount; // ### Refund // Create a refund object indicating // refund amount - $amount = new Amount(); - $amount->setCurrency("USD"); - $amount->setTotal("1.00"); $refund = new Refund(); -$refund->setId('7BA08426L46375838'); -$refund->setAmount($amount); +$refund->setId($capt->getId()); +$refund->setAmount($amt); -$capture = Capture::get('7BA08426L46375838', $apiContext); +$capture = Capture::get($capt->getId(), $apiContext); try { // (See bootstrap.php for more on `ApiContext`) $captureRefund = $capture->refund($refund, $apiContext); @@ -42,4 +72,50 @@ try { Back - +setLine1("3909 Witmer Road"); + $addr->setLine2("Niagara Falls"); + $addr->setCity("Niagara Falls"); + $addr->setState("NY"); + $addr->setPostal_code("14305"); + $addr->setCountry_code("US"); + $addr->setPhone("716-298-1822"); + + $card = new CreditCard(); + $card->setType("visa"); + $card->setNumber("4417119669820331"); + $card->setExpire_month("11"); + $card->setExpire_year("2019"); + $card->setCvv2("012"); + $card->setFirst_name("Joe"); + $card->setLast_name("Shopper"); + $card->setBilling_address($addr); + + $fi = new FundingInstrument(); + $fi->setCredit_card($card); + + $payer = new Payer(); + $payer->setPayment_method("credit_card"); + $payer->setFunding_instruments(array($fi)); + + $amount = new Amount(); + $amount->setCurrency("USD"); + $amount->setTotal("1.00"); + + $transaction = new Transaction(); + $transaction->setAmount($amount); + $transaction->setDescription("This is the payment description."); + + $payment = new Payment(); + $payment->setIntent("authorize"); + $payment->setPayer($payer); + $payment->setTransactions(array($transaction)); + + $paymnt = $payment->create(); + $resArray = $paymnt->toArray(); + + return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; +} \ No newline at end of file diff --git a/sample/payments/VoidAuthorization.php b/sample/payments/VoidAuthorization.php index dfeb051..147ff07 100644 --- a/sample/payments/VoidAuthorization.php +++ b/sample/payments/VoidAuthorization.php @@ -6,8 +6,18 @@ require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Authorization; +use PayPal\Api\Address; +use PayPal\Api\Amount; +use PayPal\Api\CreditCard; +use PayPal\Api\Payer; +use PayPal\Api\Payment; +use PayPal\Api\FundingInstrument; +use PayPal\Api\Transaction; -$authorization = Authorization::get('87U86133WD4359724', $apiContext); +// create payment to get authorization Id +$authId = createAuthorization(); + +$authorization = Authorization::get($authId, $apiContext); // ### VoidAuthorization @@ -31,3 +41,50 @@ try { Back +setLine1("3909 Witmer Road"); + $addr->setLine2("Niagara Falls"); + $addr->setCity("Niagara Falls"); + $addr->setState("NY"); + $addr->setPostal_code("14305"); + $addr->setCountry_code("US"); + $addr->setPhone("716-298-1822"); + + $card = new CreditCard(); + $card->setType("visa"); + $card->setNumber("4417119669820331"); + $card->setExpire_month("11"); + $card->setExpire_year("2019"); + $card->setCvv2("012"); + $card->setFirst_name("Joe"); + $card->setLast_name("Shopper"); + $card->setBilling_address($addr); + + $fi = new FundingInstrument(); + $fi->setCredit_card($card); + + $payer = new Payer(); + $payer->setPayment_method("credit_card"); + $payer->setFunding_instruments(array($fi)); + + $amount = new Amount(); + $amount->setCurrency("USD"); + $amount->setTotal("1.00"); + + $transaction = new Transaction(); + $transaction->setAmount($amount); + $transaction->setDescription("This is the payment description."); + + $payment = new Payment(); + $payment->setIntent("authorize"); + $payment->setPayer($payer); + $payment->setTransactions(array($transaction)); + + $paymnt = $payment->create(); + $resArray = $paymnt->toArray(); + + return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; +} \ No newline at end of file diff --git a/sample/vault/DeleteCreditCard.php b/sample/vault/DeleteCreditCard.php index a815163..0eed82c 100644 --- a/sample/vault/DeleteCreditCard.php +++ b/sample/vault/DeleteCreditCard.php @@ -1,6 +1,35 @@ setType("visa"); +$card->setNumber("4417119669820331"); +$card->setExpire_month("11"); +$card->setExpire_year("2019"); +$card->setCvv2("012"); +$card->setFirst_name("Joe"); +$card->setLast_name("Shopper"); + +// ### Save card +// Creates the credit card as a resource +// in the PayPal vault. The response contains +// an 'id' that you can use to refer to it +// in the future payments. +// (See bootstrap.php for more on `ApiContext`) +try { + $res = $card->create($apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception:" . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} // # Delete CreditCard Sample // This sample code demonstrate how you can @@ -9,7 +38,7 @@ use PayPal\Api\CreditCard; // API used: /v1/vault/credit-card/{} // NOTE: HTTP method used here is DELETE -$creditCard = CreditCard::get('CARD-38K23067VS968933SKGPU66Q', $apiContext); +$creditCard = CreditCard::get($res->getId(), $apiContext); try { // (See bootstrap.php for more on `ApiContext`) From aa1dee57a6eacbdf19a739d7b48f31ec643f4bb4 Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Wed, 29 May 2013 18:02:32 +0530 Subject: [PATCH 10/20] updated code comments to reflect on groc docs --- sample/payments/RefundCapture.php | 12 ++- sample/source/AuthorizationCapture.html | 92 +++++++++++++++++++++ sample/source/DeleteCreditCard.html | 53 ++++++++++++ sample/source/GetAuthorization.html | 81 ++++++++++++++++++ sample/source/GetCapture.html | 98 ++++++++++++++++++++++ sample/source/RefundCapture.html | 104 ++++++++++++++++++++++++ sample/source/VoidAuthorization.html | 82 +++++++++++++++++++ sample/vault/DeleteCreditCard.php | 14 ++-- 8 files changed, 523 insertions(+), 13 deletions(-) create mode 100644 sample/source/AuthorizationCapture.html create mode 100644 sample/source/DeleteCreditCard.html create mode 100644 sample/source/GetAuthorization.html create mode 100644 sample/source/GetCapture.html create mode 100644 sample/source/RefundCapture.html create mode 100644 sample/source/VoidAuthorization.html diff --git a/sample/payments/RefundCapture.php b/sample/payments/RefundCapture.php index 983e6b6..8c3583a 100644 --- a/sample/payments/RefundCapture.php +++ b/sample/payments/RefundCapture.php @@ -1,4 +1,9 @@ }/refund require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Capture; use PayPal\Api\Refund; @@ -37,13 +42,6 @@ try { exit(1); } -// # Refund Capture Sample -// This sample code demonstrate how you can -// process a refund on a Captured transaction created -// using the Capture API. -// API used: /v1/payments/capture/{}/refund - - // ### Refund // Create a refund object indicating // refund amount diff --git a/sample/source/AuthorizationCapture.html b/sample/source/AuthorizationCapture.html new file mode 100644 index 0000000..6f964db --- /dev/null +++ b/sample/source/AuthorizationCapture.html @@ -0,0 +1,92 @@ +AuthorizationCaptureBack
<?php

AuthorizationCapture

+ +

This sample code demonstrate how you can capture the authorized payment +API used: /v1/payments/payment

require __DIR__ . '/../bootstrap.php'; +use PayPal\Api\Capture; +use PayPal\Api\Authorization; +use PayPal\Api\Address; +use PayPal\Api\Amount; +use PayPal\Api\CreditCard; +use PayPal\Api\Payer; +use PayPal\Api\Payment; +use PayPal\Api\FundingInstrument; +use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization(); + +$amt = new Amount(); +$amt->setCurrency("USD"); +$amt->setTotal("1.00"); + +### Capture +$captur = new Capture(); +$captur->setId($authId); +$captur->setAmount($amt);

get the authorization

$authorization = Authorization::get($authId, $apiContext);

Capture Payment

+ +

Capture Payment by posting to the APIService +using a valid ApiContext (See bootstrap.php for more on ApiContext) +The return object contains the status;

try { + $capt = $authorization->capture($captur, $apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> +<html> +<body> + <div> + Capture payment: + <?php echo $capt->getId();?> + </div> + <pre> + <?php var_dump($capt->toArray());?> + </pre> + <a href='../index.html'>Back</a> +</body> +</html> +<?php +function createAuthorization() +{ + $addr = new Address(); + $addr->setLine1("3909 Witmer Road"); + $addr->setLine2("Niagara Falls"); + $addr->setCity("Niagara Falls"); + $addr->setState("NY"); + $addr->setPostal_code("14305"); + $addr->setCountry_code("US"); + $addr->setPhone("716-298-1822"); + + $card = new CreditCard(); + $card->setType("visa"); + $card->setNumber("4417119669820331"); + $card->setExpire_month("11"); + $card->setExpire_year("2019"); + $card->setCvv2("012"); + $card->setFirst_name("Joe"); + $card->setLast_name("Shopper"); + $card->setBilling_address($addr); + + $fi = new FundingInstrument(); + $fi->setCredit_card($card); + + $payer = new Payer(); + $payer->setPayment_method("credit_card"); + $payer->setFunding_instruments(array($fi)); + + $amount = new Amount(); + $amount->setCurrency("USD"); + $amount->setTotal("1.00"); + + $transaction = new Transaction(); + $transaction->setAmount($amount); + $transaction->setDescription("This is the payment description."); + + $payment = new Payment(); + $payment->setIntent("authorize"); + $payment->setPayer($payer); + $payment->setTransactions(array($transaction)); + + $paymnt = $payment->create(); + $resArray = $paymnt->toArray(); + + return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; +}
\ No newline at end of file diff --git a/sample/source/DeleteCreditCard.html b/sample/source/DeleteCreditCard.html new file mode 100644 index 0000000..b690aae --- /dev/null +++ b/sample/source/DeleteCreditCard.html @@ -0,0 +1,53 @@ +DeleteCreditCardBack
<?php

Delete CreditCard Sample

+ +

This sample code demonstrate how you can

//delete a saved creditcard

using the delete API. +API used: /v1/vault/credit-card/{} +NOTE: HTTP method used here is DELETE

require __DIR__ . '/../bootstrap.php'; +use PayPal\Api\CreditCard; +use PayPal\Api\CreditCard; +use PayPal\Api\Address;

save card for demo

+ +

CreditCard

+ +

A resource representing a credit card that can be +used to fund a payment.

$card = new CreditCard(); +$card->setType("visa"); +$card->setNumber("4417119669820331"); +$card->setExpire_month("11"); +$card->setExpire_year("2019"); +$card->setCvv2("012"); +$card->setFirst_name("Joe"); +$card->setLast_name("Shopper");

Save card

+ +

Creates the credit card as a resource +in the PayPal vault. The response contains +an 'id' that you can use to refer to it +in the future payments. +(See bootstrap.php for more on ApiContext)

try { + $res = $card->create($apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception:" . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} + + +$creditCard = CreditCard::get($res->getId(), $apiContext); + +try {

Delete Card

+ +

deletes saved credit card +(See bootstrap.php for more on ApiContext)

$creditCard->delete($apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + exit(1); +} +?> + +<html> +<body> +<div>Delete CreditCard:</div> + <p> Credit Card deleted Successfully</p> + <a href='../index.html'>Back</a> +</body> +</html>
\ No newline at end of file diff --git a/sample/source/GetAuthorization.html b/sample/source/GetAuthorization.html new file mode 100644 index 0000000..513f5f6 --- /dev/null +++ b/sample/source/GetAuthorization.html @@ -0,0 +1,81 @@ +GetAuthorizationBack
<?php

GetAuthorization

+ +

This sample code demonstrate how you can get details of an authorized payment +API used: /v1/payments/authorization/<$authorizationId>

require __DIR__ . '/../bootstrap.php'; + +use PayPal\Api\Authorization; +use PayPal\Api\Address; +use PayPal\Api\Amount; +use PayPal\Api\CreditCard; +use PayPal\Api\Payer; +use PayPal\Api\Payment; +use PayPal\Api\FundingInstrument; +use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization();

GetAuthorization

+ +

GetAuthorization by posting to the APIService +using a valid ApiContext (See bootstrap.php for more on ApiContext) +The return object contains the status;

try { + $authorization = Authorization::get($authId, $apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> +<html> +<body> + <div> + Get Authorization: + <?php echo $authorization->getId();?> + </div> + <pre><?php var_dump($authorization->toArray());?></pre> + <a href='../index.html'>Back</a> +</body> +</html> +<?php +function createAuthorization() +{ + $addr = new Address(); + $addr->setLine1("3909 Witmer Road"); + $addr->setLine2("Niagara Falls"); + $addr->setCity("Niagara Falls"); + $addr->setState("NY"); + $addr->setPostal_code("14305"); + $addr->setCountry_code("US"); + $addr->setPhone("716-298-1822"); + + $card = new CreditCard(); + $card->setType("visa"); + $card->setNumber("4417119669820331"); + $card->setExpire_month("11"); + $card->setExpire_year("2019"); + $card->setCvv2("012"); + $card->setFirst_name("Joe"); + $card->setLast_name("Shopper"); + $card->setBilling_address($addr); + + $fi = new FundingInstrument(); + $fi->setCredit_card($card); + + $payer = new Payer(); + $payer->setPayment_method("credit_card"); + $payer->setFunding_instruments(array($fi)); + + $amount = new Amount(); + $amount->setCurrency("USD"); + $amount->setTotal("1.00"); + + $transaction = new Transaction(); + $transaction->setAmount($amount); + $transaction->setDescription("This is the payment description."); + + $payment = new Payment(); + $payment->setIntent("authorize"); + $payment->setPayer($payer); + $payment->setTransactions(array($transaction)); + + $paymnt = $payment->create(); + $resArray = $paymnt->toArray(); + + return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; +}
\ No newline at end of file diff --git a/sample/source/GetCapture.html b/sample/source/GetCapture.html new file mode 100644 index 0000000..bcd6310 --- /dev/null +++ b/sample/source/GetCapture.html @@ -0,0 +1,98 @@ +GetCaptureBack
<?php

GetCapture

+ +

This sample code demonstrate how you can get the details of Captured Payment +API used: /v1/payments/capture/<$captureId>

require __DIR__ . '/../bootstrap.php'; +use PayPal\Api\Capture; +use PayPal\Api\Address; +use PayPal\Api\Amount; +use PayPal\Api\CreditCard; +use PayPal\Api\Payer; +use PayPal\Api\Payment; +use PayPal\Api\FundingInstrument; +use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization(); +$amt = new Amount(); +$amt->setCurrency("USD"); +$amt->setTotal("1.00"); + +### Capture +$captur = new Capture(); +$captur->setId($authId); +$captur->setAmount($amt);

get the authorization

$authorization = Authorization::get($authId, $apiContext);

Capture Payment

+ +

Capture Payment by posting to the APIService +using a valid ApiContext (See bootstrap.php for more on ApiContext) +The return object contains the status;

try { + $capt = $authorization->capture($captur, $apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +}

Get Capture

+ +

Get Capture by posting to the APIService +using a valid ApiContext (See bootstrap.php for more on ApiContext) +The return object contains the status;

try { + $capture = Capture::get($capt->getId(), $apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> +<html> +<body> + <div> + Get Capture : + <?php echo $capture->getId();?> + </div> + <pre><?php var_dump($capture->toArray());?></pre> + <a href='../index.html'>Back</a> +</body> +</html> +<?php +function createAuthorization() +{ + $addr = new Address(); + $addr->setLine1("3909 Witmer Road"); + $addr->setLine2("Niagara Falls"); + $addr->setCity("Niagara Falls"); + $addr->setState("NY"); + $addr->setPostal_code("14305"); + $addr->setCountry_code("US"); + $addr->setPhone("716-298-1822"); + + $card = new CreditCard(); + $card->setType("visa"); + $card->setNumber("4417119669820331"); + $card->setExpire_month("11"); + $card->setExpire_year("2019"); + $card->setCvv2("012"); + $card->setFirst_name("Joe"); + $card->setLast_name("Shopper"); + $card->setBilling_address($addr); + + $fi = new FundingInstrument(); + $fi->setCredit_card($card); + + $payer = new Payer(); + $payer->setPayment_method("credit_card"); + $payer->setFunding_instruments(array($fi)); + + $amount = new Amount(); + $amount->setCurrency("USD"); + $amount->setTotal("1.00"); + + $transaction = new Transaction(); + $transaction->setAmount($amount); + $transaction->setDescription("This is the payment description."); + + $payment = new Payment(); + $payment->setIntent("authorize"); + $payment->setPayer($payer); + $payment->setTransactions(array($transaction)); + + $paymnt = $payment->create(); + $resArray = $paymnt->toArray(); + + return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; +}
\ No newline at end of file diff --git a/sample/source/RefundCapture.html b/sample/source/RefundCapture.html new file mode 100644 index 0000000..7d0a43f --- /dev/null +++ b/sample/source/RefundCapture.html @@ -0,0 +1,104 @@ +RefundCaptureBack
<?php

Refund Capture Sample

+ +

This sample code demonstrate how you can +process a refund on a Captured transaction created +using the Capture API. +API used: /v1/payments/capture/{}/refund

require __DIR__ . '/../bootstrap.php'; +use PayPal\Api\Capture; +use PayPal\Api\Refund; +use PayPal\Api\Address; +use PayPal\Api\Amount; +use PayPal\Api\CreditCard; +use PayPal\Api\Payer; +use PayPal\Api\Payment; +use PayPal\Api\FundingInstrument; +use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization(); + +$amt = new Amount(); +$amt->setCurrency("USD"); +$amt->setTotal("1.00"); + +### Capture +$captur = new Capture(); +$captur->setId($authId); +$captur->setAmount($amt);

get the authorization

$authorization = Authorization::get($authId, $apiContext);

Capture Payment

+ +

Capture Payment by posting to the APIService +using a valid ApiContext (See bootstrap.php for more on ApiContext) +The return object contains the status;

try { + $capt = $authorization->capture($captur, $apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +}

Refund

+ +

Create a refund object indicating +refund amount

$refund = new Refund(); +$refund->setId($capt->getId()); +$refund->setAmount($amt); + + +$capture = Capture::get($capt->getId(), $apiContext); +try {

(See bootstrap.php for more on ApiContext)

$captureRefund = $capture->refund($refund, $apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> + +<html> +<body> + <div>Refund Capture:</div> + <pre><?php var_dump($captureRefund);?></pre> + <a href='../index.html'>Back</a> +</body> +</html> +<?php +function createAuthorization() +{ + $addr = new Address(); + $addr->setLine1("3909 Witmer Road"); + $addr->setLine2("Niagara Falls"); + $addr->setCity("Niagara Falls"); + $addr->setState("NY"); + $addr->setPostal_code("14305"); + $addr->setCountry_code("US"); + $addr->setPhone("716-298-1822"); + + $card = new CreditCard(); + $card->setType("visa"); + $card->setNumber("4417119669820331"); + $card->setExpire_month("11"); + $card->setExpire_year("2019"); + $card->setCvv2("012"); + $card->setFirst_name("Joe"); + $card->setLast_name("Shopper"); + $card->setBilling_address($addr); + + $fi = new FundingInstrument(); + $fi->setCredit_card($card); + + $payer = new Payer(); + $payer->setPayment_method("credit_card"); + $payer->setFunding_instruments(array($fi)); + + $amount = new Amount(); + $amount->setCurrency("USD"); + $amount->setTotal("1.00"); + + $transaction = new Transaction(); + $transaction->setAmount($amount); + $transaction->setDescription("This is the payment description."); + + $payment = new Payment(); + $payment->setIntent("authorize"); + $payment->setPayer($payer); + $payment->setTransactions(array($transaction)); + + $paymnt = $payment->create(); + $resArray = $paymnt->toArray(); + + return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; +}
\ No newline at end of file diff --git a/sample/source/VoidAuthorization.html b/sample/source/VoidAuthorization.html new file mode 100644 index 0000000..b091c04 --- /dev/null +++ b/sample/source/VoidAuthorization.html @@ -0,0 +1,82 @@ +VoidAuthorizationBack
<?php

VoidAuthorization

+ +

This sample code demonstrate how you can void an authorized payment +API used: /v1/payments/authorization/<{authorizationid}>/void"

require __DIR__ . '/../bootstrap.php'; + +use PayPal\Api\Authorization; +use PayPal\Api\Address; +use PayPal\Api\Amount; +use PayPal\Api\CreditCard; +use PayPal\Api\Payer; +use PayPal\Api\Payment; +use PayPal\Api\FundingInstrument; +use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization(); + +$authorization = Authorization::get($authId, $apiContext);

VoidAuthorization

+ +

VoidAuthorization by posting to the APIService +using a valid ApiContext (See bootstrap.php for more on ApiContext) +The return object contains the status;

try { + $void = $authorization->void($apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> +<html> +<body> + <div> + Void Authorization: + </div> + <pre><?php var_dump($void->toArray());?></pre> + <a href='../index.html'>Back</a> +</body> +</html> +<?php +function createAuthorization() +{ + $addr = new Address(); + $addr->setLine1("3909 Witmer Road"); + $addr->setLine2("Niagara Falls"); + $addr->setCity("Niagara Falls"); + $addr->setState("NY"); + $addr->setPostal_code("14305"); + $addr->setCountry_code("US"); + $addr->setPhone("716-298-1822"); + + $card = new CreditCard(); + $card->setType("visa"); + $card->setNumber("4417119669820331"); + $card->setExpire_month("11"); + $card->setExpire_year("2019"); + $card->setCvv2("012"); + $card->setFirst_name("Joe"); + $card->setLast_name("Shopper"); + $card->setBilling_address($addr); + + $fi = new FundingInstrument(); + $fi->setCredit_card($card); + + $payer = new Payer(); + $payer->setPayment_method("credit_card"); + $payer->setFunding_instruments(array($fi)); + + $amount = new Amount(); + $amount->setCurrency("USD"); + $amount->setTotal("1.00"); + + $transaction = new Transaction(); + $transaction->setAmount($amount); + $transaction->setDescription("This is the payment description."); + + $payment = new Payment(); + $payment->setIntent("authorize"); + $payment->setPayer($payer); + $payment->setTransactions(array($transaction)); + + $paymnt = $payment->create(); + $resArray = $paymnt->toArray(); + + return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; +}
\ No newline at end of file diff --git a/sample/vault/DeleteCreditCard.php b/sample/vault/DeleteCreditCard.php index 0eed82c..33f9d84 100644 --- a/sample/vault/DeleteCreditCard.php +++ b/sample/vault/DeleteCreditCard.php @@ -1,4 +1,10 @@ } +// NOTE: HTTP method used here is DELETE require __DIR__ . '/../bootstrap.php'; use PayPal\Api\CreditCard; use PayPal\Api\CreditCard; @@ -31,16 +37,12 @@ try { exit(1); } -// # Delete CreditCard Sample -// This sample code demonstrate how you can -//delete a saved creditcard -// using the delete API. -// API used: /v1/vault/credit-card/{} -// NOTE: HTTP method used here is DELETE $creditCard = CreditCard::get($res->getId(), $apiContext); try { + // ### Delete Card + // deletes saved credit card // (See bootstrap.php for more on `ApiContext`) $creditCard->delete($apiContext); } catch (\PPConnectionException $ex) { From bbfa24016162d298fde7dc143928dd5b625a8cd7 Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Thu, 30 May 2013 12:00:13 +0530 Subject: [PATCH 11/20] updating index with new samples --- sample/index.html | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/sample/index.html b/sample/index.html index 280cc33..111b5a3 100644 --- a/sample/index.html +++ b/sample/index.html @@ -82,12 +82,47 @@ Source - Payment with saved credit card + Get Details of Authorized Payment - Execute + Execute - Source + Source + + Capture Authorized Payment + + Execute + + Source + + + Void Authorized Payment + + Execute + + Source + + + Get Details of Captured Payment + + Execute + + Source + + + Refund Captured Payment + + Execute + + Source + + + Delete saved CreditCard + + Execute + + Source + From 321e7de108c5457224a9f011cc420133b88b063f Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Thu, 30 May 2013 15:23:13 +0530 Subject: [PATCH 12/20] passing API context to create authorization --- sample/payments/AuthorizationCapture.php | 6 +++--- sample/payments/GetAuthorization.php | 6 +++--- sample/payments/GetCapture.php | 7 ++++--- sample/payments/RefundCapture.php | 21 +++++++++++++-------- sample/payments/VoidAuthorization.php | 6 +++--- 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/sample/payments/AuthorizationCapture.php b/sample/payments/AuthorizationCapture.php index d87474a..ab414f2 100644 --- a/sample/payments/AuthorizationCapture.php +++ b/sample/payments/AuthorizationCapture.php @@ -15,7 +15,7 @@ use PayPal\Api\FundingInstrument; use PayPal\Api\Transaction; // create payment to get authorization Id -$authId = createAuthorization(); +$authId = createAuthorization($apiContext); $amt = new Amount(); $amt->setCurrency("USD"); @@ -54,7 +54,7 @@ try { setLine1("3909 Witmer Road"); @@ -95,7 +95,7 @@ function createAuthorization() $payment->setPayer($payer); $payment->setTransactions(array($transaction)); - $paymnt = $payment->create(); + $paymnt = $payment->create($apiContext); $resArray = $paymnt->toArray(); return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; diff --git a/sample/payments/GetAuthorization.php b/sample/payments/GetAuthorization.php index c72e0e4..d27e1ed 100644 --- a/sample/payments/GetAuthorization.php +++ b/sample/payments/GetAuthorization.php @@ -15,7 +15,7 @@ use PayPal\Api\FundingInstrument; use PayPal\Api\Transaction; // create payment to get authorization Id -$authId = createAuthorization(); +$authId = createAuthorization($apiContext); // ### GetAuthorization // GetAuthorization by posting to the APIService @@ -40,7 +40,7 @@ try { setLine1("3909 Witmer Road"); @@ -81,7 +81,7 @@ function createAuthorization() $payment->setPayer($payer); $payment->setTransactions(array($transaction)); - $paymnt = $payment->create(); + $paymnt = $payment->create($apiContext); $resArray = $paymnt->toArray(); return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; diff --git a/sample/payments/GetCapture.php b/sample/payments/GetCapture.php index 9b08564..474fc5e 100644 --- a/sample/payments/GetCapture.php +++ b/sample/payments/GetCapture.php @@ -12,9 +12,10 @@ use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; use PayPal\Api\Transaction; +use PayPal\Api\Authorization; // create payment to get authorization Id -$authId = createAuthorization(); +$authId = createAuthorization($apiContext); $amt = new Amount(); $amt->setCurrency("USD"); $amt->setTotal("1.00"); @@ -62,7 +63,7 @@ try { setLine1("3909 Witmer Road"); @@ -103,7 +104,7 @@ function createAuthorization() $payment->setPayer($payer); $payment->setTransactions(array($transaction)); - $paymnt = $payment->create(); + $paymnt = $payment->create($apiContext); $resArray = $paymnt->toArray(); return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; diff --git a/sample/payments/RefundCapture.php b/sample/payments/RefundCapture.php index 8c3583a..65135ec 100644 --- a/sample/payments/RefundCapture.php +++ b/sample/payments/RefundCapture.php @@ -5,6 +5,7 @@ // using the Capture API. // API used: /v1/payments/capture/{}/refund require __DIR__ . '/../bootstrap.php'; +use PayPal\Api\Authorization; use PayPal\Api\Capture; use PayPal\Api\Refund; use PayPal\Api\Address; @@ -14,9 +15,11 @@ use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; use PayPal\Api\Transaction; +use PayPal\Rest\ApiContext; +use PayPal\Auth\OAuthTokenCredential; // create payment to get authorization Id -$authId = createAuthorization(); +$authId = createAuthorization($apiContext); $amt = new Amount(); $amt->setCurrency("USD"); @@ -24,7 +27,6 @@ $amt->setTotal("1.00"); ### Capture $captur = new Capture(); -$captur->setId($authId); $captur->setAmount($amt); // get the authorization @@ -48,14 +50,17 @@ try { $refund = new Refund(); -$refund->setId($capt->getId()); $refund->setAmount($amt); - $capture = Capture::get($capt->getId(), $apiContext); + +// create new API context +$context = new ApiContext(new OAuthTokenCredential( + 'Aer9WxCa2q0dlmoyWv2n__xE10ttwuXL3pNLzLFU30atoUda5bKGh_lUqSzy', + 'EIUvhhC4ga-Fy5N7vIZPRBOpcdoi2iVRhTwJ_ZhMD9RdZZSMtSGSNLAwq-ND')); try { // (See bootstrap.php for more on `ApiContext`) - $captureRefund = $capture->refund($refund, $apiContext); + $captureRefund = $capture->refund($refund, $context); } catch (\PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); @@ -71,7 +76,7 @@ try { setLine1("3909 Witmer Road"); @@ -101,7 +106,7 @@ function createAuthorization() $amount = new Amount(); $amount->setCurrency("USD"); - $amount->setTotal("1.00"); + $amount->setTotal("10.00"); $transaction = new Transaction(); $transaction->setAmount($amount); @@ -112,7 +117,7 @@ function createAuthorization() $payment->setPayer($payer); $payment->setTransactions(array($transaction)); - $paymnt = $payment->create(); + $paymnt = $payment->create($apiContext); $resArray = $paymnt->toArray(); return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; diff --git a/sample/payments/VoidAuthorization.php b/sample/payments/VoidAuthorization.php index 147ff07..dff13be 100644 --- a/sample/payments/VoidAuthorization.php +++ b/sample/payments/VoidAuthorization.php @@ -15,7 +15,7 @@ use PayPal\Api\FundingInstrument; use PayPal\Api\Transaction; // create payment to get authorization Id -$authId = createAuthorization(); +$authId = createAuthorization($apiContext); $authorization = Authorization::get($authId, $apiContext); @@ -42,7 +42,7 @@ try { setLine1("3909 Witmer Road"); @@ -83,7 +83,7 @@ function createAuthorization() $payment->setPayer($payer); $payment->setTransactions(array($transaction)); - $paymnt = $payment->create(); + $paymnt = $payment->create($apiContext); $resArray = $paymnt->toArray(); return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; From b5dab145363395ed32595d1389e0667e41a78511 Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Thu, 30 May 2013 15:26:09 +0530 Subject: [PATCH 13/20] removing duplicate use --- sample/vault/DeleteCreditCard.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/sample/vault/DeleteCreditCard.php b/sample/vault/DeleteCreditCard.php index 33f9d84..29d25e0 100644 --- a/sample/vault/DeleteCreditCard.php +++ b/sample/vault/DeleteCreditCard.php @@ -7,7 +7,6 @@ // NOTE: HTTP method used here is DELETE require __DIR__ . '/../bootstrap.php'; use PayPal\Api\CreditCard; -use PayPal\Api\CreditCard; use PayPal\Api\Address; // save card for demo @@ -37,9 +36,7 @@ try { exit(1); } - $creditCard = CreditCard::get($res->getId(), $apiContext); - try { // ### Delete Card // deletes saved credit card From 3b797097c8e709e1d15c8757b54d92cf80864de1 Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Thu, 30 May 2013 15:38:30 +0530 Subject: [PATCH 14/20] regenerated stubs From d8a1e896bdf2114c4d440587b5a3f1cf51af1fd3 Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Thu, 30 May 2013 15:39:21 +0530 Subject: [PATCH 15/20] changing the HTTP method --- lib/PayPal/Api/CreditCard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/PayPal/Api/CreditCard.php b/lib/PayPal/Api/CreditCard.php index 7e13b7d..cd0ee91 100644 --- a/lib/PayPal/Api/CreditCard.php +++ b/lib/PayPal/Api/CreditCard.php @@ -410,7 +410,7 @@ class CreditCard extends PPModel implements IResource { $apiContext = new ApiContext(self::$credential); } $call = new PPRestCall($apiContext); - $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card/{$this->getId()}", "POST", $payLoad); + $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card/{$this->getId()}", "DELETE", $payLoad); return true; } } From ffeb952377b97812a40bf5140d9b7060e4de715d Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Thu, 30 May 2013 15:39:32 +0530 Subject: [PATCH 16/20] new stub From 37c96172856a2dc5774b9eb29de264d8df4b472c Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Thu, 30 May 2013 15:40:41 +0530 Subject: [PATCH 17/20] replacing '-' with '_' --- lib/PayPal/Api/CreditCardHistory.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/PayPal/Api/CreditCardHistory.php b/lib/PayPal/Api/CreditCardHistory.php index 19607d6..896dd69 100644 --- a/lib/PayPal/Api/CreditCardHistory.php +++ b/lib/PayPal/Api/CreditCardHistory.php @@ -9,8 +9,8 @@ class CreditCardHistory extends PPModel { * @array * @param PayPal\Api\CreditCard $credit-cards */ - public function setCreditCards($credit-cards) { - $this->credit-cards = $credit-cards; + public function setCreditCards($credit_cards) { + $this->credit_cards = $credit_cards; return $this; } @@ -28,8 +28,8 @@ class CreditCardHistory extends PPModel { * @param PayPal\Api\CreditCard $credit-cards * @deprecated. Instead use setCreditCards */ - public function setCredit_cards($credit-cards) { - $this->credit-cards = $credit-cards; + public function setCredit_cards($credit_cards) { + $this->credit_cards = $credit_cards; return $this; } /** From d207a66a4a5b2dc22ad4c56b288a290dd276c3a7 Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Thu, 30 May 2013 16:21:39 +0530 Subject: [PATCH 18/20] updating the credential --- sample/payments/RefundCapture.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sample/payments/RefundCapture.php b/sample/payments/RefundCapture.php index 65135ec..b33dc91 100644 --- a/sample/payments/RefundCapture.php +++ b/sample/payments/RefundCapture.php @@ -56,8 +56,8 @@ $capture = Capture::get($capt->getId(), $apiContext); // create new API context $context = new ApiContext(new OAuthTokenCredential( - 'Aer9WxCa2q0dlmoyWv2n__xE10ttwuXL3pNLzLFU30atoUda5bKGh_lUqSzy', - 'EIUvhhC4ga-Fy5N7vIZPRBOpcdoi2iVRhTwJ_ZhMD9RdZZSMtSGSNLAwq-ND')); + 'EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM', + 'EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM')); try { // (See bootstrap.php for more on `ApiContext`) $captureRefund = $capture->refund($refund, $context); From 9498a2efce9e4f7b8cef01b4cdf8d0d0cddc8f94 Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Thu, 30 May 2013 16:26:31 +0530 Subject: [PATCH 19/20] updating code docs --- sample/source/AuthorizationCapture.html | 6 +++--- sample/source/CreatePayment.html | 4 ++-- sample/source/CreatePaymentUsingPayPal.html | 4 ++-- .../source/CreatePaymentUsingSavedCard.html | 4 ++-- sample/source/DeleteCreditCard.html | 3 --- sample/source/ExecutePayment.html | 4 ++-- sample/source/GetAuthorization.html | 6 +++--- sample/source/GetCapture.html | 7 ++++--- sample/source/GetPayment.html | 4 ++-- sample/source/ListPayments.html | 4 ++-- sample/source/RefundCapture.html | 20 ++++++++++--------- sample/source/VoidAuthorization.html | 6 +++--- 12 files changed, 36 insertions(+), 36 deletions(-) diff --git a/sample/source/AuthorizationCapture.html b/sample/source/AuthorizationCapture.html index 6f964db..2bcf992 100644 --- a/sample/source/AuthorizationCapture.html +++ b/sample/source/AuthorizationCapture.html @@ -10,7 +10,7 @@ API used: /v1/payments/payment

use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; -use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization(); +use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization($apiContext); $amt = new Amount(); $amt->setCurrency("USD"); @@ -44,7 +44,7 @@ The return object contains the status;

</body> </html> <?php -function createAuthorization() +function createAuthorization($apiContext) { $addr = new Address(); $addr->setLine1("3909 Witmer Road"); @@ -85,7 +85,7 @@ The return object contains the status;

$payment->setPayer($payer); $payment->setTransactions(array($transaction)); - $paymnt = $payment->create(); + $paymnt = $payment->create($apiContext); $resArray = $paymnt->toArray(); return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; diff --git a/sample/source/CreatePayment.html b/sample/source/CreatePayment.html index 11c231e..bd7e65c 100644 --- a/sample/source/CreatePayment.html +++ b/sample/source/CreatePayment.html @@ -1,4 +1,4 @@ -CreatePayment
<?php

CreatePaymentSample

+CreatePaymentBack
<?php

CreatePaymentSample

This sample code demonstrate how you can process a payment with a credit card. @@ -81,4 +81,4 @@ The return object contains the status;

<pre><?php var_dump($payment->toArray());?></pre> <a href='../index.html'>Back</a> </body> -</html>
\ No newline at end of file +</html>
\ No newline at end of file diff --git a/sample/source/CreatePaymentUsingPayPal.html b/sample/source/CreatePaymentUsingPayPal.html index 3282114..1cf0ed2 100644 --- a/sample/source/CreatePaymentUsingPayPal.html +++ b/sample/source/CreatePaymentUsingPayPal.html @@ -1,4 +1,4 @@ -CreatePaymentUsingPayPal
<?php

Create Payment using PayPal as payment method

+CreatePaymentUsingPayPalBack
<?php

Create Payment using PayPal as payment method

This sample code demonstrates how you can process a PayPal Account based Payment. @@ -64,4 +64,4 @@ payment id in a database.

if(isset($redirectUrl)) { header("Location: $redirectUrl"); exit; -}
\ No newline at end of file +}
\ No newline at end of file diff --git a/sample/source/CreatePaymentUsingSavedCard.html b/sample/source/CreatePaymentUsingSavedCard.html index 9e070fa..e729795 100644 --- a/sample/source/CreatePaymentUsingSavedCard.html +++ b/sample/source/CreatePaymentUsingSavedCard.html @@ -1,4 +1,4 @@ -CreatePaymentUsingSavedCard
<?php

Create payment using a saved credit card

+CreatePaymentUsingSavedCardBack
<?php

Create payment using a saved credit card

This sample code demonstrates how you can process a Payment using a previously saved credit card. @@ -68,4 +68,4 @@ The return object contains the status;

<pre><?php var_dump($payment->toArray());?></pre> <a href='../index.html'>Back</a> </body> -</html>
\ No newline at end of file +</html>
\ No newline at end of file diff --git a/sample/source/DeleteCreditCard.html b/sample/source/DeleteCreditCard.html index b690aae..6dfd07a 100644 --- a/sample/source/DeleteCreditCard.html +++ b/sample/source/DeleteCreditCard.html @@ -4,7 +4,6 @@ API used: /v1/vault/credit-card/{} NOTE: HTTP method used here is DELETE

require __DIR__ . '/../bootstrap.php'; use PayPal\Api\CreditCard; -use PayPal\Api\CreditCard; use PayPal\Api\Address;

save card for demo

CreditCard

@@ -31,9 +30,7 @@ in the future payments. exit(1); } - $creditCard = CreditCard::get($res->getId(), $apiContext); - try {

Delete Card

deletes saved credit card diff --git a/sample/source/ExecutePayment.html b/sample/source/ExecutePayment.html index ab77e3d..2bc88b6 100644 --- a/sample/source/ExecutePayment.html +++ b/sample/source/ExecutePayment.html @@ -1,4 +1,4 @@ -ExecutePayment

<?php

Execute Payment Sample

+ExecutePaymentBack
<?php

Execute Payment Sample

This sample shows how you can complete a payment that has been approved by @@ -29,4 +29,4 @@ when the user is redirected from paypal back to your site

} else { echo "User cancelled payment."; -}
\ No newline at end of file +}
\ No newline at end of file diff --git a/sample/source/GetAuthorization.html b/sample/source/GetAuthorization.html index 513f5f6..fa7afcb 100644 --- a/sample/source/GetAuthorization.html +++ b/sample/source/GetAuthorization.html @@ -10,7 +10,7 @@ API used: /v1/payments/authorization/<$authorizationId>

use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; -use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization();

GetAuthorization

+use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization($apiContext);

GetAuthorization

GetAuthorization by posting to the APIService using a valid ApiContext (See bootstrap.php for more on ApiContext) @@ -33,7 +33,7 @@ The return object contains the status;

</body> </html> <?php -function createAuthorization() +function createAuthorization($apiContext) { $addr = new Address(); $addr->setLine1("3909 Witmer Road"); @@ -74,7 +74,7 @@ The return object contains the status;

$payment->setPayer($payer); $payment->setTransactions(array($transaction)); - $paymnt = $payment->create(); + $paymnt = $payment->create($apiContext); $resArray = $paymnt->toArray(); return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; diff --git a/sample/source/GetCapture.html b/sample/source/GetCapture.html index bcd6310..4b647a8 100644 --- a/sample/source/GetCapture.html +++ b/sample/source/GetCapture.html @@ -9,7 +9,8 @@ API used: /v1/payments/capture/<$captureId>

use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; -use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization(); +use PayPal\Api\Transaction; +use PayPal\Api\Authorization;

create payment to get authorization Id

$authId = createAuthorization($apiContext); $amt = new Amount(); $amt->setCurrency("USD"); $amt->setTotal("1.00"); @@ -50,7 +51,7 @@ The return object contains the status;

</body> </html> <?php -function createAuthorization() +function createAuthorization($apiContext) { $addr = new Address(); $addr->setLine1("3909 Witmer Road"); @@ -91,7 +92,7 @@ The return object contains the status;

$payment->setPayer($payer); $payment->setTransactions(array($transaction)); - $paymnt = $payment->create(); + $paymnt = $payment->create($apiContext); $resArray = $paymnt->toArray(); return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; diff --git a/sample/source/GetPayment.html b/sample/source/GetPayment.html index 0f451bf..c59c1c8 100644 --- a/sample/source/GetPayment.html +++ b/sample/source/GetPayment.html @@ -1,4 +1,4 @@ -GetPayment
<?php

GetPaymentSample

+GetPaymentBack
<?php

GetPaymentSample

This sample code demonstrate how you can retrieve a list of all Payment resources @@ -29,4 +29,4 @@ Payment ID <pre><?php var_dump($payment->toArray());?></pre> <a href='../index.html'>Back</a> </body> -</html>

\ No newline at end of file +</html>
\ No newline at end of file diff --git a/sample/source/ListPayments.html b/sample/source/ListPayments.html index c86444d..b4050b3 100644 --- a/sample/source/ListPayments.html +++ b/sample/source/ListPayments.html @@ -1,4 +1,4 @@ -ListPayments
<?php

GetPaymentList

+ListPaymentsBack
<?php

GetPaymentList

This sample code demonstrate how you can retrieve a list of all Payment resources @@ -28,4 +28,4 @@ Refer the method doc for valid values for keys <pre><?php var_dump($payments->toArray());?></pre> <a href='../index.html'>Back</a> </body> -</html>

\ No newline at end of file +</html>
\ No newline at end of file diff --git a/sample/source/RefundCapture.html b/sample/source/RefundCapture.html index 7d0a43f..2b48d65 100644 --- a/sample/source/RefundCapture.html +++ b/sample/source/RefundCapture.html @@ -4,6 +4,7 @@ process a refund on a Captured transaction created using the Capture API. API used: /v1/payments/capture/{}/refund

require __DIR__ . '/../bootstrap.php'; +use PayPal\Api\Authorization; use PayPal\Api\Capture; use PayPal\Api\Refund; use PayPal\Api\Address; @@ -12,7 +13,9 @@ API used: /v1/payments/capture/{}/refund

use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; -use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization(); +use PayPal\Api\Transaction; +use PayPal\Rest\ApiContext; +use PayPal\Auth\OAuthTokenCredential;

create payment to get authorization Id

$authId = createAuthorization($apiContext); $amt = new Amount(); $amt->setCurrency("USD"); @@ -20,7 +23,6 @@ API used: /v1/payments/capture/{}/refund

### Capture $captur = new Capture(); -$captur->setId($authId); $captur->setAmount($amt);

get the authorization

$authorization = Authorization::get($authId, $apiContext);

Capture Payment

Capture Payment by posting to the APIService @@ -35,12 +37,12 @@ The return object contains the status;

Create a refund object indicating refund amount

$refund = new Refund(); -$refund->setId($capt->getId()); $refund->setAmount($amt); - -$capture = Capture::get($capt->getId(), $apiContext); -try {

(See bootstrap.php for more on ApiContext)

$captureRefund = $capture->refund($refund, $apiContext); +$capture = Capture::get($capt->getId(), $apiContext);

create new API context

$context = new ApiContext(new OAuthTokenCredential( + 'EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM', + 'EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM')); +try {

(See bootstrap.php for more on ApiContext)

$captureRefund = $capture->refund($refund, $context); } catch (\PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); @@ -56,7 +58,7 @@ refund amount

</body> </html> <?php -function createAuthorization() +function createAuthorization($apiContext) { $addr = new Address(); $addr->setLine1("3909 Witmer Road"); @@ -86,7 +88,7 @@ refund amount

$amount = new Amount(); $amount->setCurrency("USD"); - $amount->setTotal("1.00"); + $amount->setTotal("10.00"); $transaction = new Transaction(); $transaction->setAmount($amount); @@ -97,7 +99,7 @@ refund amount

$payment->setPayer($payer); $payment->setTransactions(array($transaction)); - $paymnt = $payment->create(); + $paymnt = $payment->create($apiContext); $resArray = $paymnt->toArray(); return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; diff --git a/sample/source/VoidAuthorization.html b/sample/source/VoidAuthorization.html index b091c04..f3de626 100644 --- a/sample/source/VoidAuthorization.html +++ b/sample/source/VoidAuthorization.html @@ -10,7 +10,7 @@ API used: /v1/payments/authorization/<{authorizationid}>/void"

use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; -use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization(); +use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization($apiContext); $authorization = Authorization::get($authId, $apiContext);

VoidAuthorization

@@ -34,7 +34,7 @@ The return object contains the status;

</body> </html> <?php -function createAuthorization() +function createAuthorization($apiContext) { $addr = new Address(); $addr->setLine1("3909 Witmer Road"); @@ -75,7 +75,7 @@ The return object contains the status;

$payment->setPayer($payer); $payment->setTransactions(array($transaction)); - $paymnt = $payment->create(); + $paymnt = $payment->create($apiContext); $resArray = $paymnt->toArray(); return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; From 8e387a31594dab32aecad0aa8d14aaf20d8d9712 Mon Sep 17 00:00:00 2001 From: lathavairamani Date: Thu, 30 May 2013 16:44:53 +0530 Subject: [PATCH 20/20] updated variable names in sample --- sample/payments/AuthorizationCapture.php | 12 ++++++------ sample/source/AuthorizationCapture.html | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sample/payments/AuthorizationCapture.php b/sample/payments/AuthorizationCapture.php index ab414f2..52345fa 100644 --- a/sample/payments/AuthorizationCapture.php +++ b/sample/payments/AuthorizationCapture.php @@ -22,9 +22,9 @@ $amt->setCurrency("USD"); $amt->setTotal("1.00"); ### Capture -$captur = new Capture(); -$captur->setId($authId); -$captur->setAmount($amt); +$capture = new Capture(); +$capture->setId($authId); +$capture->setAmount($amt); // get the authorization $authorization = Authorization::get($authId, $apiContext); @@ -34,7 +34,7 @@ $authorization = Authorization::get($authId, $apiContext); // using a valid ApiContext (See bootstrap.php for more on `ApiContext`) // The return object contains the status; try { - $capt = $authorization->capture($captur, $apiContext); + $getCapture = $authorization->capture($capture, $apiContext); } catch (\PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); @@ -45,10 +45,10 @@ try {
Capture payment: - getId();?> + getId();?>
-		toArray());?>
+		toArray());?>
 	
Back diff --git a/sample/source/AuthorizationCapture.html b/sample/source/AuthorizationCapture.html index 2bcf992..cd22334 100644 --- a/sample/source/AuthorizationCapture.html +++ b/sample/source/AuthorizationCapture.html @@ -17,14 +17,14 @@ API used: /v1/payments/payment

$amt->setTotal("1.00"); ### Capture -$captur = new Capture(); -$captur->setId($authId); -$captur->setAmount($amt);

get the authorization

$authorization = Authorization::get($authId, $apiContext);

Capture Payment

+$capture = new Capture(); +$capture->setId($authId); +$capture->setAmount($amt);

get the authorization

$authorization = Authorization::get($authId, $apiContext);

Capture Payment

Capture Payment by posting to the APIService using a valid ApiContext (See bootstrap.php for more on ApiContext) The return object contains the status;

try { - $capt = $authorization->capture($captur, $apiContext); + $getCapture = $authorization->capture($capture, $apiContext); } catch (\PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); @@ -35,10 +35,10 @@ The return object contains the status;

<body> <div> Capture payment: - <?php echo $capt->getId();?> + <?php echo $getCapture->getId();?> </div> <pre> - <?php var_dump($capt->toArray());?> + <?php var_dump($getCapture->toArray());?> </pre> <a href='../index.html'>Back</a> </body>