-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 27bf724
Showing
60 changed files
with
4,938 additions
and
0 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,14 @@ | ||
tests/reports | ||
build | ||
.DS_Store | ||
*.log | ||
|
||
# IDE | ||
.project | ||
.settings | ||
.buildpath | ||
*.bak | ||
|
||
# Composer | ||
vendor | ||
composer.lock |
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,41 @@ | ||
PAYPAL, INC. | ||
|
||
SDK LICENSE | ||
|
||
NOTICE TO USER: PayPal, Inc. is providing the Software and Documentation for use under the terms of this Agreement. Any use, reproduction, modification or distribution of the Software or Documentation, or any derivatives or portions hereof, constitutes your acceptance of this Agreement. | ||
|
||
As used in this Agreement, "PayPal" means PayPal, Inc. "Software" means the software code accompanying this agreement. "Documentation" means the documents, specifications and all other items accompanying this Agreement other than the Software. | ||
|
||
1. LICENSE GRANT Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, worldwide, royalty free license to use, reproduce, prepare derivative works from, publicly display, publicly perform, distribute and sublicense the Software for any purpose, provided the copyright notice below appears in a conspicuous location within the source code of the distributed Software and this license is distributed in the supporting documentation of the Software you distribute. Furthermore, you must comply with all third party licenses in order to use the third party software contained in the Software. | ||
|
||
Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, worldwide, royalty free license to use, reproduce, publicly display, publicly perform, distribute and sublicense the Documentation for any purpose. You may not modify the Documentation. | ||
|
||
No title to the intellectual property in the Software or Documentation is transferred to you under the terms of this Agreement. You do not acquire any rights to the Software or the Documentation except as expressly set forth in this Agreement. | ||
|
||
If you choose to distribute the Software in a commercial product, you do so with the understanding that you agree to defend, indemnify and hold harmless PayPal and its suppliers against any losses, damages and costs arising from the claims, lawsuits or other legal actions arising out of such distribution. You may distribute the Software in object code form under your own license, provided that your license agreement: | ||
|
||
(a) complies with the terms and conditions of this license agreement; | ||
|
||
(b) effectively disclaims all warranties and conditions, express or implied, on behalf of PayPal; | ||
|
||
(c) effectively excludes all liability for damages on behalf of PayPal; | ||
|
||
(d) states that any provisions that differ from this Agreement are offered by you alone and not PayPal; and | ||
|
||
(e) states that the Software is available from you or PayPal and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. | ||
|
||
2. DISCLAIMER OF WARRANTY | ||
PAYPAL LICENSES THE SOFTWARE AND DOCUMENTATION TO YOU ONLY ON AN "AS IS" BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. PAYPAL MAKES NO WARRANTY THAT THE SOFTWARE OR DOCUMENTATION WILL BE ERROR-FREE. Each user of the Software or Documentation is solely responsible for determining the appropriateness of using and distributing the Software and Documentation and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs, or equipment, and unavailability or interruption of operations. Use of the Software and Documentation is made with the understanding that PayPal will not provide you with any technical or customer support or maintenance. Some states or jurisdictions do not allow the exclusion of implied warranties or limitations on how long an implied warranty may last, so the above limitations may not apply to you. To the extent permissible, any implied warranties are limited to ninety (90) days. | ||
|
||
|
||
3. LIMITATION OF LIABILITY | ||
PAYPAL AND ITS SUPPLIERS SHALL NOT BE LIABLE FOR LOSS OR DAMAGE ARISING OUT OF THIS AGREEMENT OR FROM THE USE OF THE SOFTWARE OR DOCUMENTATION. IN NO EVENT WILL PAYPAL OR ITS SUPPLIERS BE LIABLE TO YOU OR ANY THIRD PARTY FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, INCIDENTAL, OR SPECIAL DAMAGES INCLUDING LOST PROFITS, LOST SAVINGS, COSTS, FEES, OR EXPENSES OF ANY KIND ARISING OUT OF ANY PROVISION OF THIS AGREEMENT OR THE USE OR THE INABILITY TO USE THE SOFTWARE OR DOCUMENTATION, HOWEVER CAUSED AND UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. PAYPAL'S AGGREGATE LIABILITY AND THAT OF ITS SUPPLIERS UNDER OR IN CONNECTION WITH THIS AGREEMENT SHALL BE LIMITED TO THE AMOUNT PAID BY YOU FOR THE SOFTWARE AND DOCUMENTATION. | ||
|
||
4. TRADEMARK USAGE | ||
PayPal is a trademark PayPal, Inc. in the United States and other countries. Such trademarks may not be used to endorse or promote any product unless expressly permitted under separate agreement with PayPal. | ||
|
||
5. TERM | ||
Your rights under this Agreement shall terminate if you fail to comply with any of the material terms or conditions of this Agreement and do not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all your rights under this Agreement terminate, you agree to cease use and distribution of the Software and Documentation as soon as reasonably practicable. | ||
|
||
6. GOVERNING LAW AND JURISDICTION. This Agreement is governed by the statutes and laws of the State of California, without regard to the conflicts of law principles thereof. If any part of this Agreement is found void and unenforceable, it will not affect the validity of the balance of the Agreement, which shall remain valid and enforceable according to its terms. Any dispute arising out of or related to this Agreement shall be brought in the courts of Santa Clara County, California, USA. | ||
|
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,11 @@ | ||
|
||
PayPal Core SDK - V1.2.0 | ||
======================== | ||
|
||
Prerequisites | ||
------------- | ||
|
||
* PHP 5.2 and above | ||
* curl extension with support for OpenSSL | ||
* PHPUnit 3.5 for running test suite (Optional) | ||
* Composer (Optional - for running test cases) |
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,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE project> | ||
<project name="PayPal_Core_SDK" default="build"> | ||
|
||
<property name="tests.dir" value="tests"/> | ||
<property name="tests.out.dir" value="tests\reports"/> | ||
|
||
<condition property="PHPUNIT_BIN" value="phpunit.bat" else="phpunit"> | ||
<os family="windows" /> | ||
</condition> | ||
|
||
<target name="clean"> | ||
<delete dir="${tests.out.dir}" /> | ||
</target> | ||
|
||
<target name="test"> | ||
<mkdir dir="${tests.out.dir}" /> | ||
<exec dir="${basedir}" executable="${PHPUNIT_BIN}" failonerror="true"> | ||
<arg line="--testdox --bootstrap ${tests.dir}\PPBootStrap.php --log-junit ${tests.out.dir}\phpunit.xml ${tests.dir}" /> | ||
</exec> | ||
</target> | ||
|
||
<target name="build" depends="clean, test" /> | ||
</project> |
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,21 @@ | ||
{ | ||
"name": "paypal/sdk-core-php", | ||
"description": "PayPal Core SDK for PHP", | ||
"keywords": ["paypal", "php", "sdk"], | ||
"type": "library", | ||
"homepage": "https://github.com/paypal/sdk-core-php", | ||
"license": "Apache2", | ||
"authors": [ | ||
{ | ||
"name": "PayPal", | ||
"homepage": "https://github.com/paypal/sdk-core-php/contributors" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.2.0", | ||
"ext-curl": "*" | ||
}, | ||
"autoload": { | ||
"classmap": ["lib"] | ||
} | ||
} |
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,82 @@ | ||
<?php | ||
|
||
class PPAPIService { | ||
|
||
public $endpoint; | ||
public $serviceName; | ||
private $logger; | ||
private $handlers = array(); | ||
private $serviceBinding; | ||
|
||
public function __construct($port, $serviceName, $serviceBinding, $handlers=array()) { | ||
$this->serviceName = $serviceName; | ||
$config = PPConfigManager::getInstance(); | ||
if($port!= null) | ||
{ | ||
$this->endpoint = $config->get('service.EndPoint.'.$port); | ||
} | ||
// for backward compatibilty (for those who are using old config files with 'service.EndPoint') | ||
else | ||
{ | ||
$this->endpoint = $config->get('service.EndPoint'); | ||
} | ||
|
||
$this->logger = new PPLoggingManager(__CLASS__); | ||
$this->handlers = $handlers; | ||
$this->serviceBinding = $serviceBinding; | ||
} | ||
|
||
public function setServiceName($serviceName) { | ||
$this->serviceName = $serviceName; | ||
} | ||
|
||
public function addHandler($handler) { | ||
$this->handlers[] = $handler; | ||
} | ||
|
||
public function makeRequest($apiMethod, $params, $apiUsername = null, $accessToken = null, $tokenSecret = null) { | ||
|
||
$config = PPConfigManager::getInstance(); | ||
if(is_string($apiUsername) || is_null($apiUsername)) { | ||
// $apiUsername is optional, if null the default account in config file is taken | ||
$credMgr = PPCredentialManager::getInstance(); | ||
$apiCredential = clone($credMgr->getCredentialObject($apiUsername )); | ||
} else { | ||
$apiCredential = $apiUsername; //TODO: Aargh | ||
} | ||
if(isset($accessToken) && isset($tokenSecret)) { | ||
$apiCredential->setThirdPartyAuthorization( | ||
new PPTokenAuthorization($accessToken, $tokenSecret)); | ||
} | ||
|
||
if($this->serviceBinding == 'SOAP' ) { | ||
$url = $this->endpoint; | ||
} else { | ||
$url = $this->endpoint . $this->serviceName . '/' . $apiMethod; | ||
} | ||
|
||
$request = new PPRequest($params, $this->serviceBinding); | ||
$request->setCredential($apiCredential); | ||
$httpConfig = new PPHttpConfig($url, PPHttpConfig::HTTP_POST); | ||
$this->runHandlers($httpConfig, $request); | ||
|
||
$formatter = FormatterFactory::factory($this->serviceBinding); | ||
$payload = $formatter->toString($request); | ||
$connection = PPConnectionManager::getInstance()->getConnection($httpConfig); | ||
$this->logger->info("Request: $payload"); | ||
$response = $connection->execute($payload); | ||
$this->logger->info("Response: $response"); | ||
|
||
return array('request' => $payload, 'response' => $response); | ||
} | ||
|
||
private function runHandlers($httpConfig, $request) { | ||
$handler = new PPAuthenticationHandler(); | ||
$handler->handle($httpConfig, $request); | ||
foreach($this->handlers as $handlerClass) { | ||
$handler = new $handlerClass(); | ||
$handler->handle($httpConfig, $request); | ||
} | ||
} | ||
|
||
} |
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,114 @@ | ||
<?php | ||
|
||
class PPBaseService { | ||
|
||
// SDK Name | ||
protected static $SDK_NAME = "paypal-php-sdk"; | ||
// SDK Version | ||
protected static $SDK_VERSION = "2.1.96"; | ||
|
||
private $serviceName; | ||
private $serviceBinding; | ||
private $handlers; | ||
|
||
/* | ||
* Setters and getters for Third party authentication (Permission Services) | ||
*/ | ||
protected $accessToken; | ||
protected $tokenSecret; | ||
|
||
protected $lastRequest; | ||
protected $lastResponse; | ||
|
||
|
||
|
||
/** | ||
* Compute the value that needs to sent for the PAYPAL_REQUEST_SOURCE | ||
* parameter when making API calls | ||
*/ | ||
public static function getRequestSource() | ||
{ | ||
return str_replace(" ", "-", self::$SDK_NAME) . "-" . self::$SDK_VERSION; | ||
} | ||
|
||
|
||
public function getLastRequest() { | ||
return $this->lastRequest; | ||
} | ||
public function setLastRequest($lastRqst) { | ||
$this->lastRequest = $lastRqst; | ||
} | ||
public function getLastResponse() { | ||
return $this->lastResponse; | ||
} | ||
public function setLastResponse($lastRspns) { | ||
$this->lastResponse = $lastRspns; | ||
} | ||
|
||
public function getAccessToken() { | ||
return $this->accessToken; | ||
} | ||
/** | ||
* @deprecated | ||
* For using third party token permissions, | ||
* create a ICredential object and pass it to the | ||
* call() method instead. | ||
* | ||
*<pre> | ||
* $service = new *Service(); | ||
* $cred = new PPSignatureCredential("username", "password", "signature"); | ||
* $cred->setThirdPartyAuthorization(new PPTokenAuthorization("accessToken", "tokenSecret")); | ||
* $service->SomeOperation($reqObject, $cred); | ||
*</pre> | ||
*/ | ||
public function setAccessToken($accessToken) { | ||
$this->accessToken = $accessToken; | ||
} | ||
public function getTokenSecret() { | ||
return $this->tokenSecret; | ||
} | ||
/** | ||
* @deprecated | ||
* For using third party token permissions, | ||
* create a ICredential object and pass it to the | ||
* call() method instead. | ||
* | ||
*<pre> | ||
* $service = new *Service(); | ||
* $cred = new PPSignatureCredential("username", "password", "signature"); | ||
* $cred->setThirdPartyAuthorization(new PPTokenAuthorization("accessToken", "tokenSecret")); | ||
* $service->SomeOperation($reqObject, $cred); | ||
*</pre> | ||
*/ | ||
public function setTokenSecret($tokenSecret) { | ||
$this->tokenSecret = $tokenSecret; | ||
} | ||
|
||
public function __construct($serviceName, $serviceBinding, $handlers=array()) { | ||
$this->serviceName = $serviceName; | ||
$this->serviceBinding = $serviceBinding; | ||
$this->handlers = $handlers; | ||
} | ||
|
||
public function getServiceName() { | ||
return $this->serviceName; | ||
} | ||
|
||
/** | ||
* | ||
* @param string $method - API method to call | ||
* @param object $requestObject Request object | ||
* @param mixed $apiCredential - Optional API credential - can either be | ||
* a username configured in sdk_config.ini or a ICredential object | ||
* created dynamically | ||
*/ | ||
public function call($port, $method, $requestObject, $apiCredential = null) { | ||
$service = new PPAPIService($port, $this->serviceName, | ||
$this->serviceBinding, $this->handlers); | ||
$ret = $service->makeRequest($method, $requestObject, $apiCredential, | ||
$this->accessToken, $this->tokenSecret); | ||
$this->lastRequest = $ret['request']; | ||
$this->lastResponse = $ret['response']; | ||
return $this->lastResponse; | ||
} | ||
} |
Oops, something went wrong.