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