diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 0000000..90f55b5 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1,6 @@ +# .coveralls.yml configuration + +# for php-coveralls +src_dir: lib +coverage_clover: build/coverage/clover.xml +json_path: build/coverage/coveralls-upload.json \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index fb3f07e..91cb229 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 -c .coveralls.yml notifications: recipients: - DL-PP-Platform-PHP-SDK@ebay.com 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) ----------------------- 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 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 @@ - + - + - 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": { 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