forked from LiveCarta/PayPal-PHP-SDK
Renaming Namespaces and Organizing Classes
- Updated OpenId classes to be in API namespace - Updated PP Naming Convention to PayPal Naming Convention - FormatConverter Class got its own namespace - Handlers are grouped in Handler namespace - Samples and Tests Updated Accordingly
This commit is contained in:
@@ -3,14 +3,14 @@
|
||||
namespace PayPal\Core;
|
||||
|
||||
/**
|
||||
* Class PPConfigManager
|
||||
* Class PayPalConfigManager
|
||||
*
|
||||
* PPConfigManager loads the SDK configuration file and
|
||||
* PayPalConfigManager loads the SDK configuration file and
|
||||
* hands out appropriate config params to other classes
|
||||
*
|
||||
* @package PayPal\Core
|
||||
*/
|
||||
class PPConfigManager
|
||||
class PayPalConfigManager
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -3,12 +3,12 @@
|
||||
namespace PayPal\Core;
|
||||
|
||||
/**
|
||||
* Class PPConstants
|
||||
* Class PayPalConstants
|
||||
* Placeholder for Paypal Constants
|
||||
*
|
||||
* @package PayPal\Core
|
||||
*/
|
||||
class PPConstants
|
||||
class PayPalConstants
|
||||
{
|
||||
|
||||
const SDK_NAME = 'PayPal-PHP-SDK';
|
||||
@@ -3,21 +3,21 @@
|
||||
namespace PayPal\Core;
|
||||
|
||||
use PayPal\Auth\OAuthTokenCredential;
|
||||
use PayPal\Exception\PPInvalidCredentialException;
|
||||
use PayPal\Exception\PayPalInvalidCredentialException;
|
||||
|
||||
/**
|
||||
* Class PPCredentialManager
|
||||
* Class PayPalCredentialManager
|
||||
*
|
||||
* PPCredentialManager holds all the credential information in one place.
|
||||
* PayPalCredentialManager holds all the credential information in one place.
|
||||
*
|
||||
* @package PayPal\Core
|
||||
*/
|
||||
class PPCredentialManager
|
||||
class PayPalCredentialManager
|
||||
{
|
||||
/**
|
||||
* Singleton Object
|
||||
*
|
||||
* @var self
|
||||
* @var PayPalCredentialManager
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
@@ -56,12 +56,12 @@ class PPCredentialManager
|
||||
* Create singleton instance for this class.
|
||||
*
|
||||
* @param array|null $config
|
||||
* @return PPCredentialManager
|
||||
* @return PayPalCredentialManager
|
||||
*/
|
||||
public static function getInstance($config = null)
|
||||
{
|
||||
if (!self::$instance) {
|
||||
self::$instance = new self($config == null ? PPConfigManager::getInstance()->getConfigHashmap() : $config);
|
||||
self::$instance = new self($config == null ? PayPalConfigManager::getInstance()->getConfigHashmap() : $config);
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ class PPCredentialManager
|
||||
*
|
||||
* @param null $userId
|
||||
* @return OAuthTokenCredential
|
||||
* @throws PPInvalidCredentialException
|
||||
* @throws PayPalInvalidCredentialException
|
||||
*/
|
||||
public function getCredentialObject($userId = null)
|
||||
{
|
||||
@@ -151,7 +151,7 @@ class PPCredentialManager
|
||||
}
|
||||
|
||||
if (empty($credObj)) {
|
||||
throw new PPInvalidCredentialException("Credential not found for " . ($userId ? $userId : " default user") .
|
||||
throw new PayPalInvalidCredentialException("Credential not found for " . ($userId ? $userId : " default user") .
|
||||
". Please make sure your configuration/APIContext has credential information");
|
||||
}
|
||||
return $credObj;
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
namespace PayPal\Core;
|
||||
|
||||
use PayPal\Exception\PPConfigurationException;
|
||||
use PayPal\Exception\PayPalConfigurationException;
|
||||
|
||||
/**
|
||||
* Class PPHttpConfig
|
||||
* Class PayPalHttpConfig
|
||||
* Http Configuration Class
|
||||
*
|
||||
* @package PayPal\Core
|
||||
*/
|
||||
class PPHttpConfig
|
||||
class PayPalHttpConfig
|
||||
{
|
||||
/**
|
||||
* Some default options for curl
|
||||
* These are typically overridden by PPConnectionManager
|
||||
* These are typically overridden by PayPalConnectionManager
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
@@ -228,13 +228,13 @@ class PPHttpConfig
|
||||
* Set HTTP proxy information
|
||||
*
|
||||
* @param string $proxy
|
||||
* @throws PPConfigurationException
|
||||
* @throws PayPalConfigurationException
|
||||
*/
|
||||
public function setHttpProxy($proxy)
|
||||
{
|
||||
$urlParts = parse_url($proxy);
|
||||
if ($urlParts == false || !array_key_exists("host", $urlParts)) {
|
||||
throw new PPConfigurationException("Invalid proxy configuration " . $proxy);
|
||||
throw new PayPalConfigurationException("Invalid proxy configuration " . $proxy);
|
||||
}
|
||||
$this->curlOptions[CURLOPT_PROXY] = $urlParts["host"];
|
||||
if (isset($urlParts["port"])) {
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
namespace PayPal\Core;
|
||||
|
||||
use PayPal\Exception\PPConfigurationException;
|
||||
use PayPal\Exception\PPConnectionException;
|
||||
use PayPal\Exception\PayPalConfigurationException;
|
||||
use PayPal\Exception\PayPalConnectionException;
|
||||
|
||||
/**
|
||||
* A wrapper class based on the curl extension.
|
||||
* Requires the PHP curl module to be enabled.
|
||||
* See for full requirements the PHP manual: http://php.net/curl
|
||||
*/
|
||||
class PPHttpConnection
|
||||
class PayPalHttpConnection
|
||||
{
|
||||
|
||||
/**
|
||||
* @var PPHttpConfig
|
||||
* @var PayPalHttpConfig
|
||||
*/
|
||||
private $httpConfig;
|
||||
|
||||
@@ -28,24 +28,24 @@ class PPHttpConnection
|
||||
/**
|
||||
* LoggingManager
|
||||
*
|
||||
* @var PPLoggingManager
|
||||
* @var PayPalLoggingManager
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
*
|
||||
* @param PPHttpConfig $httpConfig
|
||||
* @param PayPalHttpConfig $httpConfig
|
||||
* @param array $config
|
||||
* @throws PPConfigurationException
|
||||
* @throws PayPalConfigurationException
|
||||
*/
|
||||
public function __construct(PPHttpConfig $httpConfig, array $config)
|
||||
public function __construct(PayPalHttpConfig $httpConfig, array $config)
|
||||
{
|
||||
if (!function_exists("curl_init")) {
|
||||
throw new PPConfigurationException("Curl module is not available on this system");
|
||||
throw new PayPalConfigurationException("Curl module is not available on this system");
|
||||
}
|
||||
$this->httpConfig = $httpConfig;
|
||||
$this->logger = PPLoggingManager::getInstance(__CLASS__);
|
||||
$this->logger = PayPalLoggingManager::getInstance(__CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,14 +67,14 @@ class PPHttpConnection
|
||||
* Executes an HTTP request
|
||||
*
|
||||
* @param string $data query string OR POST content as a string
|
||||
* @throws PPConnectionException
|
||||
* @throws PayPalConnectionException
|
||||
*/
|
||||
/**
|
||||
* Executes an HTTP request
|
||||
*
|
||||
* @param string $data query string OR POST content as a string
|
||||
* @return mixed
|
||||
* @throws PPConnectionException
|
||||
* @throws PayPalConnectionException
|
||||
*/
|
||||
public function execute($data)
|
||||
{
|
||||
@@ -134,7 +134,7 @@ class PPHttpConnection
|
||||
|
||||
//Throw Exception if Retries and Certificates doenst work
|
||||
if (curl_errno($ch)) {
|
||||
$ex = new PPConnectionException(
|
||||
$ex = new PayPalConnectionException(
|
||||
$this->httpConfig->getUrl(),
|
||||
curl_error($ch),
|
||||
curl_errno($ch)
|
||||
@@ -148,7 +148,7 @@ class PPHttpConnection
|
||||
$this->logger->fine(($result && $result != '' ? "Response : " . $result : "No Response Body") . "\n\n");
|
||||
//More Exceptions based on HttpStatus Code
|
||||
if (in_array($httpStatus, self::$retryCodes)) {
|
||||
$ex = new PPConnectionException(
|
||||
$ex = new PayPalConnectionException(
|
||||
$this->httpConfig->getUrl(),
|
||||
"Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}. " .
|
||||
"Retried $retries times."
|
||||
@@ -156,7 +156,7 @@ class PPHttpConnection
|
||||
$ex->setData($result);
|
||||
throw $ex;
|
||||
} else if ($httpStatus < 200 || $httpStatus >= 300) {
|
||||
$ex = new PPConnectionException(
|
||||
$ex = new PayPalConnectionException(
|
||||
$this->httpConfig->getUrl(),
|
||||
"Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}.",
|
||||
$httpStatus
|
||||
@@ -6,7 +6,7 @@ namespace PayPal\Core;
|
||||
* Logging Levels.
|
||||
* Class containing all the constants for Logging Levels.
|
||||
*/
|
||||
class PPLoggingLevel
|
||||
class PayPalLoggingLevel
|
||||
{
|
||||
|
||||
// FINE Logging Level
|
||||
@@ -20,4 +20,4 @@ class PPLoggingLevel
|
||||
|
||||
// ERROR Logging Level
|
||||
const ERROR = 0;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ namespace PayPal\Core;
|
||||
* This does an error_log for now
|
||||
* Potential frameworks to use are PEAR logger, log4php from Apache
|
||||
*/
|
||||
class PPLoggingManager
|
||||
class PayPalLoggingManager
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -75,7 +75,7 @@ class PPLoggingManager
|
||||
date_default_timezone_set('GMT');
|
||||
}
|
||||
|
||||
$config = PPConfigManager::getInstance()->getConfigHashmap();
|
||||
$config = PayPalConfigManager::getInstance()->getConfigHashmap();
|
||||
|
||||
$this->isLoggingEnabled = (array_key_exists('log.LogEnabled', $config) && $config['log.LogEnabled'] == '1');
|
||||
|
||||
@@ -83,9 +83,9 @@ class PPLoggingManager
|
||||
$this->loggerFile = ($config['log.FileName']) ? $config['log.FileName'] : ini_get('error_log');
|
||||
$loggingLevel = strtoupper($config['log.LogLevel']);
|
||||
$this->loggingLevel =
|
||||
(isset($loggingLevel) && defined(__NAMESPACE__ . "\\PPLoggingLevel::$loggingLevel")) ?
|
||||
constant(__NAMESPACE__ . "\\PPLoggingLevel::$loggingLevel") :
|
||||
PPLoggingManager::DEFAULT_LOGGING_LEVEL;
|
||||
(isset($loggingLevel) && defined(__NAMESPACE__ . "\\PayPalLoggingLevel::$loggingLevel")) ?
|
||||
constant(__NAMESPACE__ . "\\PayPalLoggingLevel::$loggingLevel") :
|
||||
PayPalLoggingManager::DEFAULT_LOGGING_LEVEL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ class PPLoggingManager
|
||||
* @param string $message
|
||||
* @param int $level
|
||||
*/
|
||||
private function log($message, $level = PPLoggingLevel::INFO)
|
||||
private function log($message, $level = PayPalLoggingLevel::INFO)
|
||||
{
|
||||
if ($this->isLoggingEnabled && ($level <= $this->loggingLevel)) {
|
||||
error_log("[" . date('d-m-Y h:i:s') . "] " . $this->loggerName . ": $message\n", 3, $this->loggerFile);
|
||||
@@ -109,7 +109,7 @@ class PPLoggingManager
|
||||
*/
|
||||
public function error($message)
|
||||
{
|
||||
$this->log('ERROR: ' . $message, PPLoggingLevel::ERROR);
|
||||
$this->log('ERROR: ' . $message, PayPalLoggingLevel::ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +119,7 @@ class PPLoggingManager
|
||||
*/
|
||||
public function warning($message)
|
||||
{
|
||||
$this->log('WARNING: ' . $message, PPLoggingLevel::WARN);
|
||||
$this->log('WARNING: ' . $message, PayPalLoggingLevel::WARN);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,7 +129,7 @@ class PPLoggingManager
|
||||
*/
|
||||
public function info($message)
|
||||
{
|
||||
$this->log('INFO: ' . $message, PPLoggingLevel::INFO);
|
||||
$this->log('INFO: ' . $message, PayPalLoggingLevel::INFO);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +139,7 @@ class PPLoggingManager
|
||||
*/
|
||||
public function fine($message)
|
||||
{
|
||||
$this->log('FINE: ' . $message, PPLoggingLevel::FINE);
|
||||
$this->log('FINE: ' . $message, PayPalLoggingLevel::FINE);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user