From e0046e3bbee8699fe4d195910a1d2543678d93fe Mon Sep 17 00:00:00 2001 From: aydiv Date: Thu, 4 Jul 2013 06:58:07 +0000 Subject: [PATCH 1/9] Updating ant targets for cross platform support --- build.xml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/build.xml b/build.xml index 5c927f4..d4e2ad4 100644 --- a/build.xml +++ b/build.xml @@ -1,6 +1,7 @@ + @@ -9,9 +10,6 @@ - - - @@ -38,12 +36,12 @@ - + - + @@ -52,13 +50,13 @@ - + - + - From acd4872654e3d8bb5166dee44d100138c00e73d5 Mon Sep 17 00:00:00 2001 From: Prasanna Annamalai Date: Thu, 25 Jul 2013 14:13:58 +0530 Subject: [PATCH 2/9] Adding support for coveralls --- .coveralls.yml | 4 ++++ .travis.yml | 7 ++++++- composer.json | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .coveralls.yml diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 0000000..8f1c076 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1,4 @@ +# .coveralls.yml configuration + +# for php-coveralls +coverage_clover: build/coverage/clover.xml diff --git a/.travis.yml b/.travis.yml index fb3f07e..07a23de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,12 @@ php: - 5.4 - 5.3 before_script: - - composer install + - composer install --dev + - composer update satooshi/php-coveralls --dev +script: + - ant coverage +after_script: + - php vendor/bin/coveralls -v notifications: recipients: - DL-PP-Platform-PHP-SDK@ebay.com diff --git a/composer.json b/composer.json index 4f89af9..20d7592 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ "paypal/sdk-core-php": "2.4.*" }, "require-dev": { - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "3.7.*", + "satooshi/php-coveralls": "dev-master" }, "autoload": { "psr-0": { From 475640f3c931bc8baeed7834b25d5d5180ccb8a6 Mon Sep 17 00:00:00 2001 From: Prasanna Annamalai Date: Thu, 25 Jul 2013 14:22:59 +0530 Subject: [PATCH 3/9] Adding support for coveralls --- .coveralls.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.coveralls.yml b/.coveralls.yml index 8f1c076..4eaf074 100644 --- a/.coveralls.yml +++ b/.coveralls.yml @@ -1,4 +1,6 @@ # .coveralls.yml configuration # for php-coveralls -coverage_clover: build/coverage/clover.xml +src_dir: lib +coverage_clover: build/logs/clover.xml +json_path: build/logs/coveralls-upload.json \ No newline at end of file From 55befa55cbd2c86635058309fca7008c9e1a22d3 Mon Sep 17 00:00:00 2001 From: Prasanna Annamalai Date: Thu, 25 Jul 2013 14:24:34 +0530 Subject: [PATCH 4/9] Added coveralls support --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 07a23de..91cb229 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ before_script: script: - ant coverage after_script: - - php vendor/bin/coveralls -v + - php vendor/bin/coveralls -v -c .coveralls.yml notifications: recipients: - DL-PP-Platform-PHP-SDK@ebay.com From 3e58b6afc342c17a63cf3f857cde5951d37984c0 Mon Sep 17 00:00:00 2001 From: Prasanna Annamalai Date: Thu, 25 Jul 2013 14:30:21 +0530 Subject: [PATCH 5/9] Added coveralls support --- .coveralls.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.coveralls.yml b/.coveralls.yml index 4eaf074..1953492 100644 --- a/.coveralls.yml +++ b/.coveralls.yml @@ -2,5 +2,5 @@ # for php-coveralls src_dir: lib -coverage_clover: build/logs/clover.xml +coverage_clover: build/coverage/clover.xml json_path: build/logs/coveralls-upload.json \ No newline at end of file From 57d8e0de385e17235a1f386206fea69b4152ad11 Mon Sep 17 00:00:00 2001 From: Prasanna Annamalai Date: Thu, 25 Jul 2013 14:37:18 +0530 Subject: [PATCH 6/9] Added support for coveralls --- .coveralls.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.coveralls.yml b/.coveralls.yml index 1953492..90f55b5 100644 --- a/.coveralls.yml +++ b/.coveralls.yml @@ -3,4 +3,4 @@ # for php-coveralls src_dir: lib coverage_clover: build/coverage/clover.xml -json_path: build/logs/coveralls-upload.json \ No newline at end of file +json_path: build/coverage/coveralls-upload.json \ No newline at end of file From f9bba4641e9d3041ef014e133901b01d5c64079c Mon Sep 17 00:00:00 2001 From: Prasanna Annamalai Date: Thu, 25 Jul 2013 15:01:39 +0530 Subject: [PATCH 7/9] Added coveralls support and updates badges for composer --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ab01226..2dcdc6d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ -REST API SDK for PHP (V0.7.0) [![Build Status](https://travis-ci.org/paypal/rest-api-sdk-php.png?branch=master)](https://travis-ci.org/paypal/rest-api-sdk-php) -============================== +REST API SDK for PHP +==================== +[![Build Status](https://travis-ci.org/paypal/rest-api-sdk-php.png?branch=master)](https://travis-ci.org/paypal/rest-api-sdk-php) [![Coverage Status](https://coveralls.io/repos/paypal/rest-api-sdk-php/badge.png?branch=master)](https://coveralls.io/r/paypal/rest-api-sdk-php?branch=master) [![Latest Stable Version](https://poser.pugx.org/paypal/rest-api-sdk-php/v/stable.png)](https://packagist.org/packages/paypal/rest-api-sdk-php) [![Total Downloads](https://poser.pugx.org/paypal/rest-api-sdk-php/downloads.png)](https://packagist.org/packages/paypal/rest-api-sdk-php) This repository contains PayPal's PHP SDK and samples for REST API. @@ -64,5 +65,4 @@ More help --------- * [API Reference](https://developer.paypal.com/webapps/developer/docs/api/) - * [Reporting issues / feature requests] (https://github.com/paypal/rest-api-sdk-php/issues) - + * [Reporting issues / feature requests] (https://github.com/paypal/rest-api-sdk-php/issues) \ No newline at end of file From f1038717a76cd10ddc061c212044926c27917311 Mon Sep 17 00:00:00 2001 From: lathavairamani Date: Wed, 31 Jul 2013 17:40:36 +0530 Subject: [PATCH 8/9] updated CreditCardHistory.php, added sample and testcase for Reauthorization --- lib/PayPal/Api/CreditCardHistory.php | 8 +-- sample/index.html | 7 ++ sample/payments/Reauthorization.php | 42 +++++++++++ sample/source/Reauthorization.html | 39 ++++++++++ tests/PayPal/Test/Api/AuthorizationTest.php | 16 +++++ .../PayPal/Test/Api/CreditCardHistoryTest.php | 72 +++++++++++++++++++ 6 files changed, 180 insertions(+), 4 deletions(-) create mode 100644 sample/payments/Reauthorization.php create mode 100644 sample/source/Reauthorization.html create mode 100644 tests/PayPal/Test/Api/CreditCardHistoryTest.php diff --git a/lib/PayPal/Api/CreditCardHistory.php b/lib/PayPal/Api/CreditCardHistory.php index 896dd69..4251e62 100644 --- a/lib/PayPal/Api/CreditCardHistory.php +++ b/lib/PayPal/Api/CreditCardHistory.php @@ -10,7 +10,7 @@ class CreditCardHistory extends PPModel { * @param PayPal\Api\CreditCard $credit-cards */ public function setCreditCards($credit_cards) { - $this->credit_cards = $credit_cards; + $this->{"credit-cards"} = $credit_cards; return $this; } @@ -19,7 +19,7 @@ class CreditCardHistory extends PPModel { * @return PayPal\Api\CreditCard */ public function getCreditCards() { - return $this->credit-cards; + return $this->{"credit-cards"}; } /** @@ -29,7 +29,7 @@ class CreditCardHistory extends PPModel { * @deprecated. Instead use setCreditCards */ public function setCredit_cards($credit_cards) { - $this->credit_cards = $credit_cards; + $this->{"credit-cards"} = $credit_cards; return $this; } /** @@ -38,7 +38,7 @@ class CreditCardHistory extends PPModel { * @deprecated. Instead use getCreditCards */ public function getCredit_cards() { - return $this->credit-cards; + return $this->{"credit-cards"}; } /** diff --git a/sample/index.html b/sample/index.html index 111b5a3..648cf4d 100644 --- a/sample/index.html +++ b/sample/index.html @@ -102,6 +102,13 @@ Source + + Reauthorize a Payment + + Execute + + Source + Get Details of Captured Payment diff --git a/sample/payments/Reauthorization.php b/sample/payments/Reauthorization.php new file mode 100644 index 0000000..c7fe031 --- /dev/null +++ b/sample/payments/Reauthorization.php @@ -0,0 +1,42 @@ +setCurrency("USD"); +$amount->setTotal("1.00"); + +$authorization->setAmount($amount); +try{ + $reauthorization = $authorization->reauthorize($apiContext); +}catch (PPConnectionException $ex){ + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> + + +
+ Reauthorize: + getId();?> +
+
+		toArray());?>
+	
+ Back + + \ No newline at end of file diff --git a/sample/source/Reauthorization.html b/sample/source/Reauthorization.html new file mode 100644 index 0000000..a8a15fe --- /dev/null +++ b/sample/source/Reauthorization.html @@ -0,0 +1,39 @@ +ReauthorizationBack
<?php

Reauthorization Sample

+ +

Sample showing how to do a reauthorization +API used: v1/payments/authorization/{authorization_id}/reauthorize

require __DIR__ . '/../bootstrap.php'; +use PayPal\Api\Authorization; +use PayPal\Api\Amount; +use PayPal\Exception\PPConnectionException;

Reauthorization

+ +

Retrieve a authorization id from authorization object +by making a Payment Using PayPal with intent +as authorize. You can reauthorize a payment only once 4 to 29 +days after 3-day honor period for the original authorization +expires.

$authorization = Authorization::get('7GH53639GA425732B', $apiContext); + +$amount = new Amount(); +$amount->setCurrency("USD"); +$amount->setTotal("1.00"); + +$authorization->setAmount($amount); +try{ + $reauthorization = $authorization->reauthorize($apiContext); +}catch (\PPConnectionException $ex){ + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> +<html> +<body> + <div> + Reauthorize: + <?php echo $reauthorization->getId();?> + </div> + <pre> + <?php var_dump($reauthorization->toArray());?> + </pre> + <a href='../index.html'>Back</a> +</body> +</html>
\ No newline at end of file diff --git a/tests/PayPal/Test/Api/AuthorizationTest.php b/tests/PayPal/Test/Api/AuthorizationTest.php index bc74ef6..63ba8cb 100644 --- a/tests/PayPal/Test/Api/AuthorizationTest.php +++ b/tests/PayPal/Test/Api/AuthorizationTest.php @@ -14,6 +14,7 @@ use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; use PayPal\Api\Transaction; +use PayPal\Exception\PPConnectionException; class AuthorizationTest extends \PHPUnit_Framework_TestCase { private $authorizations = array(); @@ -137,4 +138,19 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase { $this->assertNotNull($void->getId()); } + + public function testReauthorize(){ + $authorization = Authorization::get('7GH53639GA425732B'); + + $amount = new Amount(); + $amount->setCurrency("USD"); + $amount->setTotal("1.00"); + + $authorization->setAmount($amount); + try{ + $reauthorization = $authorization->reauthorize(); + }catch (PPConnectionException $ex){ + $this->assertEquals(strpos($ex->getMessage(),"500"), false); + } + } } \ No newline at end of file diff --git a/tests/PayPal/Test/Api/CreditCardHistoryTest.php b/tests/PayPal/Test/Api/CreditCardHistoryTest.php new file mode 100644 index 0000000..a7f1b53 --- /dev/null +++ b/tests/PayPal/Test/Api/CreditCardHistoryTest.php @@ -0,0 +1,72 @@ +setType(self::$cardType); + $card->setNumber(self::$cardNumber); + $card->setExpireMonth(self::$expireMonth); + $card->setExpireYear(self::$expireYear); + $card->setCvv2(self::$cvv); + $card->setFirstName(self::$firstName); + $card->setLastName(self::$lastName); + $card->setId(self::$id); + $card->setValidUntil(self::$validUntil); + $card->setState(self::$state); + $card->setPayerId(self::$payerId); + return $card; + } + + public function setup() { + + $card = self::createCreditCard(); + $card->setBillingAddress(AddressTest::createAddress()); + $card->setLinks(array(LinksTest::createLinks())); + $this->cards['full'] = $card; + + $card = self::createCreditCard(); + $this->cards['partial'] = $card; + } + + public function testGetterSetters() { + $cardHistory = new CreditCardHistory(); + $cardHistory->setCreditCards(array($this->cards['partial'], $this->cards['full'])); + $cardHistory->setCount(2); + + $this->assertEquals(2, count($cardHistory->getCreditCards())); + } + + + public function testSerializationDeserialization() { + $cardHistory = new CreditCardHistory(); + $cardHistory->setCreditCards(array($this->cards['partial'], $this->cards['full'])); + $cardHistory->setCount(2); + + $cardHistoryCopy = new CreditCardHistory(); + $cardHistoryCopy->fromJson($cardHistory->toJSON()); + + $this->assertEquals($cardHistory, $cardHistoryCopy); + } +} \ No newline at end of file From 1bd151216ddabb5247eda09fbb40bf2e87e0ab60 Mon Sep 17 00:00:00 2001 From: lathavairamani Date: Wed, 31 Jul 2013 19:11:44 +0530 Subject: [PATCH 9/9] updated changelog for Reauthorization --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8d213e..0c6c6f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ CHANGELOG ========= +V0.7.1 (July 31, 2013) +----------------------- + * Added support for Reauthorization + V0.7.0 (May 30, 2013) -----------------------