forked from LiveCarta/PayPal-PHP-SDK
6
.coveralls.yml
Normal file
6
.coveralls.yml
Normal file
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
V0.7.1 (July 31, 2013)
|
||||
-----------------------
|
||||
* Added support for Reauthorization
|
||||
|
||||
V0.7.0 (May 30, 2013)
|
||||
-----------------------
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
REST API SDK for PHP (V0.7.0) [](https://travis-ci.org/paypal/rest-api-sdk-php)
|
||||
==============================
|
||||
REST API SDK for PHP
|
||||
====================
|
||||
[](https://travis-ci.org/paypal/rest-api-sdk-php) [](https://coveralls.io/r/paypal/rest-api-sdk-php?branch=master) [](https://packagist.org/packages/paypal/rest-api-sdk-php) [](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)
|
||||
14
build.xml
14
build.xml
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="paypal-rest-sdk-php" basedir="." default="all">
|
||||
|
||||
<property name="basedir" value="." />
|
||||
<property name="release.dir" value="${basedir}/release" />
|
||||
<property name="output.dir" value="${basedir}/build" />
|
||||
<property name="phplint.out" value="${output.dir}/phplint.txt" />
|
||||
@@ -9,9 +10,6 @@
|
||||
<property name="coverage.out" value="${coverage.dir}/junit.xml" />
|
||||
<property name="clover.out" value="${coverage.dir}/clover.xml" />
|
||||
<property name="test.dir" value="${output.dir}/test" />
|
||||
<property name="coverage.out" value="${coverage.dir}/junit.xml" />
|
||||
<property name="clover.out" value="${coverage.dir}/clover.xml" />
|
||||
|
||||
|
||||
<fileset id="src.files" dir="${basedir}/lib" includes="**/*.php" />
|
||||
|
||||
@@ -38,12 +36,12 @@
|
||||
</target>
|
||||
|
||||
<target name="phploc">
|
||||
<exec command="phploc.bat --log-xml ${phploc.out} ." dir="${basedir}/lib" />
|
||||
<exec command="phploc --log-xml ${phploc.out} ." dir="${basedir}/lib" />
|
||||
</target>
|
||||
|
||||
<target name="coverage">
|
||||
<mkdir dir="${output.dir}/coverage"/>
|
||||
<exec command="phpunit.bat --coverage-html=${coverage.dir} --coverage-clover=${clover.out} --log-junit=${coverage.out} --exclude-group=PayPal\\Api\\*" />
|
||||
<exec command="phpunit --coverage-html=${coverage.dir} --coverage-clover=${clover.out} --log-junit=${coverage.out} --exclude-group=PayPal\\Api\\*" />
|
||||
</target>
|
||||
|
||||
<target name="clean" description="Deletes build artifacts">
|
||||
@@ -52,13 +50,13 @@
|
||||
</target>
|
||||
|
||||
<target name="test" description="Runs test cases">
|
||||
<exec command="phpunit.bat --testdox-html=${test.dir}/testdox.html --log-junit=${test.dir}/junit.xml"/>
|
||||
<exec command="phpunit --testdox-html=${test.dir}/testdox.html --log-junit=${test.dir}/junit.xml"/>
|
||||
</target>
|
||||
|
||||
<!-- Requires phing -->
|
||||
<target name="convert-test-report">
|
||||
<target name="convert-test-report" >
|
||||
<mkdir dir="build/test/report"/>
|
||||
<phpunitreport infile="build/test/junit.xml"
|
||||
<phpunitreport infile="${coverage.out}"
|
||||
format="frames"
|
||||
todir="build/test/report" />
|
||||
</target>
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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"};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -102,6 +102,13 @@
|
||||
<td></td>
|
||||
<td><a href="source/VoidAuthorization.html" class="source imagelink" >Source</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Reauthorize a Payment</td>
|
||||
<td></td>
|
||||
<td><a href="payments/Reauthorization.php" class="execute imagelink" >Execute</a></td>
|
||||
<td></td>
|
||||
<td><a href="source/Reauthorization.html" class="source imagelink" >Source</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Get Details of Captured Payment</td>
|
||||
<td></td>
|
||||
|
||||
42
sample/payments/Reauthorization.php
Normal file
42
sample/payments/Reauthorization.php
Normal file
@@ -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>
|
||||
39
sample/source/Reauthorization.html
Normal file
39
sample/source/Reauthorization.html
Normal file
@@ -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>
|
||||
@@ -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