forked from LiveCarta/PayPal-PHP-SDK
updated CreditCardHistory.php, added sample and testcase for Reauthorization
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
72
tests/PayPal/Test/Api/CreditCardHistoryTest.php
Normal file
72
tests/PayPal/Test/Api/CreditCardHistoryTest.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Api\CreditCardHistory;
|
||||
|
||||
use PayPal\Api\Address;
|
||||
use PayPal\Api\CreditCard;
|
||||
use PayPal\Test\Constants;
|
||||
|
||||
class CreditCardHistoryTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
private $cards;
|
||||
|
||||
public static $id = "id";
|
||||
public static $validUntil = "2013-02-28T00:00:00Z";
|
||||
public static $state = "created";
|
||||
public static $payerId = "payer-id";
|
||||
public static $cardType = "visa";
|
||||
public static $cardNumber = "4417119669820331";
|
||||
public static $expireMonth = 11;
|
||||
public static $expireYear = "2019";
|
||||
public static $cvv = "012";
|
||||
public static $firstName = "V";
|
||||
public static $lastName = "C";
|
||||
|
||||
public static function createCreditCard() {
|
||||
$card = new CreditCard();
|
||||
$card->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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user