This repository has been archived by the owner on Sep 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from paypal/rel-reauth
Reauthorization release
- Loading branch information
Showing
12 changed files
with
208 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
- [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE html><html lang="en"><head><title>Reauthorization</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content=""><meta name="groc-document-path" content="Reauthorization"><meta name="groc-project-path" content="Reauthorization.php"><link rel="stylesheet" type="text/css" media="all" href="assets/style.css"><body></body></html><a href="../">Back<div id="document"><div class="segment"><a id="segment-0" name="segment-0" class="section_anchor"></a><div class="code"><div class="wrapper"><span class="cp"><?php</span></div></div></div><div class="segment"><a id="segment-1" name="segment-1" class="section_anchor"></a><div class="comments"><div class="pilwrap"><a href="#segment-1" class="pilcrow">¶</a></div><div class="wrapper"><h2 id="reauthorization-sample">Reauthorization Sample</h2> | ||
|
||
<p>Sample showing how to do a reauthorization | ||
API used: v1/payments/authorization/{authorization_id}/reauthorize</p></div></div><div class="code"><div class="wrapper"><span class="k">require</span> <span class="nx">__DIR__</span> <span class="o">.</span> <span class="s1">'/../bootstrap.php'</span><span class="p">;</span> | ||
<span class="k">use</span> <span class="nx">PayPal\Api\Authorization</span><span class="p">;</span> | ||
<span class="k">use</span> <span class="nx">PayPal\Api\Amount</span><span class="p">;</span> | ||
<span class="k">use</span> <span class="nx">PayPal\Exception\PPConnectionException</span><span class="p">;</span></div></div></div><div class="segment"><a id="segment-2" name="segment-2" class="section_anchor"></a><div class="comments"><div class="pilwrap"><a href="#segment-2" class="pilcrow">¶</a></div><div class="wrapper"><h3 id="reauthorization">Reauthorization</h3> | ||
|
||
<p>Retrieve a authorization id from authorization object | ||
by making a <code>Payment Using PayPal</code> with intent | ||
as <code>authorize</code>. You can reauthorize a payment only once 4 to 29 | ||
days after 3-day honor period for the original authorization | ||
expires.</p></div></div><div class="code"><div class="wrapper"><span class="nv">$authorization</span> <span class="o">=</span> <span class="nx">Authorization</span><span class="o">::</span><span class="na">get</span><span class="p">(</span><span class="s1">'7GH53639GA425732B'</span><span class="p">,</span> <span class="nv">$apiContext</span><span class="p">);</span> | ||
|
||
<span class="nv">$amount</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Amount</span><span class="p">();</span> | ||
<span class="nv">$amount</span><span class="o">-></span><span class="na">setCurrency</span><span class="p">(</span><span class="s2">"USD"</span><span class="p">);</span> | ||
<span class="nv">$amount</span><span class="o">-></span><span class="na">setTotal</span><span class="p">(</span><span class="s2">"1.00"</span><span class="p">);</span> | ||
|
||
<span class="nv">$authorization</span><span class="o">-></span><span class="na">setAmount</span><span class="p">(</span><span class="nv">$amount</span><span class="p">);</span> | ||
<span class="k">try</span><span class="p">{</span> | ||
<span class="nv">$reauthorization</span> <span class="o">=</span> <span class="nv">$authorization</span><span class="o">-></span><span class="na">reauthorize</span><span class="p">(</span><span class="nv">$apiContext</span><span class="p">);</span> | ||
<span class="p">}</span><span class="k">catch</span> <span class="p">(</span><span class="nx">\PPConnectionException</span> <span class="nv">$ex</span><span class="p">){</span> | ||
<span class="k">echo</span> <span class="s2">"Exception: "</span> <span class="o">.</span> <span class="nv">$ex</span><span class="o">-></span><span class="na">getMessage</span><span class="p">()</span> <span class="o">.</span> <span class="nx">PHP_EOL</span><span class="p">;</span> | ||
<span class="nb">var_dump</span><span class="p">(</span><span class="nv">$ex</span><span class="o">-></span><span class="na">getData</span><span class="p">());</span> | ||
<span class="k">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span> | ||
<span class="p">}</span> | ||
<span class="cp">?></span><span class="x"></span> | ||
<span class="x"><html></span> | ||
<span class="x"><body></span> | ||
<span class="x"> <div></span> | ||
<span class="x"> Reauthorize:</span> | ||
<span class="x"> </span><span class="cp"><?php</span> <span class="k">echo</span> <span class="nv">$reauthorization</span><span class="o">-></span><span class="na">getId</span><span class="p">();</span><span class="cp">?></span><span class="x"></span> | ||
<span class="x"> </div></span> | ||
<span class="x"> <pre></span> | ||
<span class="x"> </span><span class="cp"><?php</span> <span class="nb">var_dump</span><span class="p">(</span><span class="nv">$reauthorization</span><span class="o">-></span><span class="na">toArray</span><span class="p">());</span><span class="cp">?></span><span class="x"></span> | ||
<span class="x"> </pre></span> | ||
<span class="x"> <a href='../index.html'>Back</a></span> | ||
<span class="x"></body></span> | ||
<span class="x"></html></span></div></div></div><div class="segment"><div class="comments"><a href="../">Back</a></div></div></div><script type="text/javascript" src="assets/jquery.min.js"></script><script type="text/javascript" src="assets/docs.js"></script></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |