diff --git a/lib/OpenPayU/Configuration.php b/lib/OpenPayU/Configuration.php index 0b14edd..bacd68a 100644 --- a/lib/OpenPayU/Configuration.php +++ b/lib/OpenPayU/Configuration.php @@ -94,7 +94,7 @@ class OpenPayU_Configuration */ public static function getApiVersion() { - return self::API_VERSION; + return static::API_VERSION; } /** @@ -103,11 +103,11 @@ public static function getApiVersion() */ public static function setHashAlgorithm($value) { - if (!in_array($value, self::$_availableHashAlgorithm)) { + if (!in_array($value, static::$_availableHashAlgorithm)) { throw new OpenPayU_Exception_Configuration('Hash algorithm "' . $value . '"" is not available'); } - self::$hashAlgorithm = $value; + static::$hashAlgorithm = $value; } /** @@ -115,7 +115,7 @@ public static function setHashAlgorithm($value) */ public static function getHashAlgorithm() { - return self::$hashAlgorithm; + return static::$hashAlgorithm; } /** @@ -130,21 +130,21 @@ public static function setEnvironment($environment = 'secure', $domain = 'payu.c $environment = strtolower($environment); $domain = strtolower($domain) . '/'; - if (!in_array($environment, self::$_availableEnvironment)) { + if (!in_array($environment, static::$_availableEnvironment)) { throw new OpenPayU_Exception_Configuration($environment . ' - is not valid environment'); } - self::$env = $environment; + static::$env = $environment; if ($environment == 'secure') { - self::$serviceUrl = 'https://' . $environment . '.' . $domain . $api . $version; - self::$oauthEndpoint = 'https://' . $environment . '.' . $domain . self::OAUTH_CONTEXT; + static::$serviceUrl = 'https://' . $environment . '.' . $domain . $api . $version; + static::$oauthEndpoint = 'https://' . $environment . '.' . $domain . static::OAUTH_CONTEXT; } else if ($environment == 'sandbox') { - self::$serviceUrl = 'https://secure.snd.' . $domain . $api . $version; - self::$oauthEndpoint = 'https://secure.snd.' . $domain . self::OAUTH_CONTEXT; + static::$serviceUrl = 'https://secure.snd.' . $domain . $api . $version; + static::$oauthEndpoint = 'https://secure.snd.' . $domain . static::OAUTH_CONTEXT; } else if ($environment == 'custom') { - self::$serviceUrl = $domain . $api . $version; - self::$oauthEndpoint = $domain . self::OAUTH_CONTEXT; + static::$serviceUrl = $domain . $api . $version; + static::$oauthEndpoint = $domain . static::OAUTH_CONTEXT; } } @@ -153,7 +153,7 @@ public static function setEnvironment($environment = 'secure', $domain = 'payu.c */ public static function getServiceUrl() { - return self::$serviceUrl; + return static::$serviceUrl; } /** @@ -161,7 +161,7 @@ public static function getServiceUrl() */ public static function getOauthEndpoint() { - return self::$oauthEndpoint; + return static::$oauthEndpoint; } /** @@ -169,7 +169,7 @@ public static function getOauthEndpoint() */ public static function getEnvironment() { - return self::$env; + return static::$env; } /** @@ -177,7 +177,7 @@ public static function getEnvironment() */ public static function setMerchantPosId($value) { - self::$merchantPosId = trim($value); + static::$merchantPosId = trim($value); } /** @@ -185,7 +185,7 @@ public static function setMerchantPosId($value) */ public static function getMerchantPosId() { - return self::$merchantPosId; + return static::$merchantPosId; } /** @@ -193,7 +193,7 @@ public static function getMerchantPosId() */ public static function setSignatureKey($value) { - self::$signatureKey = trim($value); + static::$signatureKey = trim($value); } /** @@ -201,7 +201,7 @@ public static function setSignatureKey($value) */ public static function getSignatureKey() { - return self::$signatureKey; + return static::$signatureKey; } /** @@ -209,7 +209,7 @@ public static function getSignatureKey() */ public static function getOauthGrantType() { - return self::$oauthGrantType; + return static::$oauthGrantType; } /** @@ -222,7 +222,7 @@ public static function setOauthGrantType($oauthGrantType) throw new OpenPayU_Exception_Configuration('Oauth grand type "' . $oauthGrantType . '"" is not available'); } - self::$oauthGrantType = $oauthGrantType; + static::$oauthGrantType = $oauthGrantType; } /** @@ -230,7 +230,7 @@ public static function setOauthGrantType($oauthGrantType) */ public static function getOauthClientId() { - return self::$oauthClientId; + return static::$oauthClientId; } /** @@ -238,7 +238,7 @@ public static function getOauthClientId() */ public static function getOauthClientSecret() { - return self::$oauthClientSecret; + return static::$oauthClientSecret; } /** @@ -246,7 +246,7 @@ public static function getOauthClientSecret() */ public static function setOauthClientId($oauthClientId) { - self::$oauthClientId = trim($oauthClientId); + static::$oauthClientId = trim($oauthClientId); } /** @@ -254,7 +254,7 @@ public static function setOauthClientId($oauthClientId) */ public static function setOauthClientSecret($oauthClientSecret) { - self::$oauthClientSecret = trim($oauthClientSecret); + static::$oauthClientSecret = trim($oauthClientSecret); } /** @@ -262,7 +262,7 @@ public static function setOauthClientSecret($oauthClientSecret) */ public static function getOauthEmail() { - return self::$oauthEmail; + return static::$oauthEmail; } /** @@ -270,7 +270,7 @@ public static function getOauthEmail() */ public static function setOauthEmail($oauthEmail) { - self::$oauthEmail = $oauthEmail; + static::$oauthEmail = $oauthEmail; } /** @@ -278,7 +278,7 @@ public static function setOauthEmail($oauthEmail) */ public static function getOauthExtCustomerId() { - return self::$oauthExtCustomerId; + return static::$oauthExtCustomerId; } /** @@ -286,7 +286,7 @@ public static function getOauthExtCustomerId() */ public static function setOauthExtCustomerId($oauthExtCustomerId) { - self::$oauthExtCustomerId = $oauthExtCustomerId; + static::$oauthExtCustomerId = $oauthExtCustomerId; } /** @@ -294,7 +294,7 @@ public static function setOauthExtCustomerId($oauthExtCustomerId) */ public static function getOauthTokenCache() { - return self::$oauthTokenCache; + return static::$oauthTokenCache; } /** @@ -306,7 +306,7 @@ public static function setOauthTokenCache($oauthTokenCache) if (!$oauthTokenCache instanceof OauthCacheInterface) { throw new OpenPayU_Exception_Configuration('Oauth token cache class is not instance of OauthCacheInterface'); } - self::$oauthTokenCache = $oauthTokenCache; + static::$oauthTokenCache = $oauthTokenCache; } /** @@ -314,7 +314,7 @@ public static function setOauthTokenCache($oauthTokenCache) */ public static function getProxyHost() { - return self::$proxyHost; + return static::$proxyHost; } /** @@ -322,7 +322,7 @@ public static function getProxyHost() */ public static function setProxyHost($proxyHost) { - self::$proxyHost = $proxyHost; + static::$proxyHost = $proxyHost; } /** @@ -330,7 +330,7 @@ public static function setProxyHost($proxyHost) */ public static function getProxyPort() { - return self::$proxyPort; + return static::$proxyPort; } /** @@ -338,7 +338,7 @@ public static function getProxyPort() */ public static function setProxyPort($proxyPort) { - self::$proxyPort = $proxyPort; + static::$proxyPort = $proxyPort; } /** @@ -346,7 +346,7 @@ public static function setProxyPort($proxyPort) */ public static function getProxyUser() { - return self::$proxyUser; + return static::$proxyUser; } /** @@ -354,7 +354,7 @@ public static function getProxyUser() */ public static function setProxyUser($proxyUser) { - self::$proxyUser = $proxyUser; + static::$proxyUser = $proxyUser; } /** @@ -362,7 +362,7 @@ public static function setProxyUser($proxyUser) */ public static function getProxyPassword() { - return self::$proxyPassword; + return static::$proxyPassword; } /** @@ -370,7 +370,7 @@ public static function getProxyPassword() */ public static function setProxyPassword($proxyPassword) { - self::$proxyPassword = $proxyPassword; + static::$proxyPassword = $proxyPassword; } /** @@ -378,7 +378,7 @@ public static function setProxyPassword($proxyPassword) */ public static function setSender($sender) { - self::$sender = $sender; + static::$sender = $sender; } /** @@ -386,7 +386,7 @@ public static function setSender($sender) */ public static function getSender() { - return self::$sender; + return static::$sender; } /** @@ -394,7 +394,7 @@ public static function getSender() */ public static function getFullSenderName() { - return sprintf("%s@%s", self::getSender(), self::getSdkVersion()); + return sprintf("%s@%s", static::getSender(), static::getSdkVersion()); } /** @@ -402,7 +402,7 @@ public static function getFullSenderName() */ public static function getSdkVersion() { - $composerFilePath = self::getComposerFilePath(); + $composerFilePath = static::getComposerFilePath(); if (file_exists($composerFilePath)) { $fileContent = file_get_contents($composerFilePath); $composerData = json_decode($fileContent); @@ -411,7 +411,7 @@ public static function getSdkVersion() } } - return self::DEFAULT_SDK_VERSION; + return static::DEFAULT_SDK_VERSION; } /** @@ -419,6 +419,6 @@ public static function getSdkVersion() */ private static function getComposerFilePath() { - return realpath(dirname(__FILE__)) . '/../../' . self::COMPOSER_JSON; + return realpath(dirname(__FILE__)) . '/../../' . static::COMPOSER_JSON; } } diff --git a/lib/OpenPayU/HttpCurl.php b/lib/OpenPayU/HttpCurl.php index 729b4b5..9bba0b3 100644 --- a/lib/OpenPayU/HttpCurl.php +++ b/lib/OpenPayU/HttpCurl.php @@ -46,9 +46,9 @@ public static function doPayuRequest($requestType, $pathUrl, $auth, $data = null curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 60); - if ($proxy = self::getProxy()) { + if ($proxy = static::getProxy()) { curl_setopt($ch, CURLOPT_PROXY, $proxy); - if ($proxyAuth = self::getProxyAuth()) { + if ($proxyAuth = static::getProxyAuth()) { curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyAuth); } } @@ -88,7 +88,7 @@ public static function getSignature($headers) public static function readHeader($ch, $header) { if( preg_match('/([^:]+): (.+)/m', $header, $match) ) { - self::$headers[$match[1]] = trim($match[2]); + static::$headers[$match[1]] = trim($match[2]); } return strlen($header); diff --git a/lib/OpenPayU/Oauth/Oauth.php b/lib/OpenPayU/Oauth/Oauth.php index d7bdb76..e13486c 100644 --- a/lib/OpenPayU/Oauth/Oauth.php +++ b/lib/OpenPayU/Oauth/Oauth.php @@ -18,22 +18,22 @@ class OpenPayU_Oauth public static function getAccessToken($clientId = null, $clientSecret = null) { if (OpenPayU_Configuration::getOauthGrantType() === OauthGrantType::TRUSTED_MERCHANT) { - return self::retrieveAccessToken($clientId, $clientSecret); + return static::retrieveAccessToken($clientId, $clientSecret); } - $cacheKey = self::CACHE_KEY . OpenPayU_Configuration::getOauthClientId(); + $cacheKey = static::CACHE_KEY . OpenPayU_Configuration::getOauthClientId(); - self::getOauthTokenCache(); + static::getOauthTokenCache(); - $tokenCache = self::$oauthTokenCache->get($cacheKey); + $tokenCache = static::$oauthTokenCache->get($cacheKey); if ($tokenCache instanceof OauthResultClientCredentials && !$tokenCache->hasExpire()) { return $tokenCache; } - self::$oauthTokenCache->invalidate($cacheKey); - $response = self::retrieveAccessToken($clientId, $clientSecret); - self::$oauthTokenCache->set($cacheKey, $response); + static::$oauthTokenCache->invalidate($cacheKey); + $response = static::retrieveAccessToken($clientId, $clientSecret); + static::$oauthTokenCache->set($cacheKey, $response); return $response; } @@ -60,7 +60,7 @@ private static function retrieveAccessToken($clientId, $clientSecret) $data['ext_customer_id'] = OpenPayU_Configuration::getOauthExtCustomerId(); } - return self::parseResponse(OpenPayU_Http::doPost($oauthUrl, http_build_query($data, '', '&'), $authType)); + return static::parseResponse(OpenPayU_Http::doPost($oauthUrl, http_build_query($data, '', '&'), $authType)); } /** @@ -118,6 +118,6 @@ private static function getOauthTokenCache() OpenPayU_Configuration::setOauthTokenCache($oauthTokenCache); } - self::$oauthTokenCache = $oauthTokenCache; + static::$oauthTokenCache = $oauthTokenCache; } } \ No newline at end of file diff --git a/lib/OpenPayU/Util.php b/lib/OpenPayU/Util.php index 34c481b..1248747 100644 --- a/lib/OpenPayU/Util.php +++ b/lib/OpenPayU/Util.php @@ -135,7 +135,7 @@ public static function buildJsonFromArray($data, $rootElement = '') $data = array($rootElement => $data); } - $data = self::setSenderProperty($data); + $data = static::setSenderProperty($data); return json_encode($data); } @@ -164,7 +164,7 @@ public static function parseArrayToObject($array) return $array; } - if (self::isAssocArray($array)) { + if (static::isAssocArray($array)) { $object = new stdClass(); } else { $object = array(); @@ -175,9 +175,9 @@ public static function parseArrayToObject($array) $name = trim($name); if (isset($name)) { if (is_numeric($name)) { - $object[] = self::parseArrayToObject($value); + $object[] = static::parseArrayToObject($value); } else { - $object->$name = self::parseArrayToObject($value); + $object->$name = static::parseArrayToObject($value); } } } @@ -216,7 +216,7 @@ public static function convertArrayToHtmlForm($array, $namespace = "", &$outputF { $i = 0; $htmlOutput = ""; - $assoc = self::isAssocArray($array); + $assoc = static::isAssocArray($array); foreach ($array as $key => $value) { @@ -227,7 +227,7 @@ public static function convertArrayToHtmlForm($array, $namespace = "", &$outputF } if (is_array($value)) { - $htmlOutput .= self::convertArrayToHtmlForm($value, $key, $outputFields); + $htmlOutput .= static::convertArrayToHtmlForm($value, $key, $outputFields); } else { $htmlOutput .= sprintf("\n", $key, $value); $outputFields[$key] = $value; diff --git a/lib/OpenPayU/v2/Order.php b/lib/OpenPayU/v2/Order.php index 4e0e324..d218d7d 100644 --- a/lib/OpenPayU/v2/Order.php +++ b/lib/OpenPayU/v2/Order.php @@ -46,14 +46,14 @@ public static function create($order) } try { - $authType = self::getAuth(); + $authType = static::getAuth(); } catch (OpenPayU_Exception $e) { throw new OpenPayU_Exception($e->getMessage(), $e->getCode()); } - $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE; + $pathUrl = OpenPayU_Configuration::getServiceUrl() . static::ORDER_SERVICE; - $result = self::verifyResponse(OpenPayU_Http::doPost($pathUrl, $data, $authType), 'OrderCreateResponse'); + $result = static::verifyResponse(OpenPayU_Http::doPost($pathUrl, $data, $authType), 'OrderCreateResponse'); return $result; } @@ -73,14 +73,14 @@ public static function retrieve($orderId) } try { - $authType = self::getAuth(); + $authType = static::getAuth(); } catch (OpenPayU_Exception $e) { throw new OpenPayU_Exception($e->getMessage(), $e->getCode()); } - $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE . $orderId; + $pathUrl = OpenPayU_Configuration::getServiceUrl() . static::ORDER_SERVICE . $orderId; - $result = self::verifyResponse(OpenPayU_Http::doGet($pathUrl, $authType), 'OrderRetrieveResponse'); + $result = static::verifyResponse(OpenPayU_Http::doGet($pathUrl, $authType), 'OrderRetrieveResponse'); return $result; } @@ -100,14 +100,14 @@ public static function cancel($orderId) } try { - $authType = self::getAuth(); + $authType = static::getAuth(); } catch (OpenPayU_Exception $e) { throw new OpenPayU_Exception($e->getMessage(), $e->getCode()); } - $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE . $orderId; + $pathUrl = OpenPayU_Configuration::getServiceUrl() . static::ORDER_SERVICE . $orderId; - $result = self::verifyResponse(OpenPayU_Http::doDelete($pathUrl, $authType), 'OrderCancelResponse'); + $result = static::verifyResponse(OpenPayU_Http::doDelete($pathUrl, $authType), 'OrderCancelResponse'); return $result; } @@ -126,15 +126,15 @@ public static function statusUpdate($orderStatusUpdate) } try { - $authType = self::getAuth(); + $authType = static::getAuth(); } catch (OpenPayU_Exception $e) { throw new OpenPayU_Exception($e->getMessage(), $e->getCode()); } $data = OpenPayU_Util::buildJsonFromArray($orderStatusUpdate); - $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE . $orderStatusUpdate['orderId'] . '/status'; + $pathUrl = OpenPayU_Configuration::getServiceUrl() . static::ORDER_SERVICE . $orderStatusUpdate['orderId'] . '/status'; - $result = self::verifyResponse(OpenPayU_Http::doPut($pathUrl, $data, $authType), 'OrderStatusUpdateResponse'); + $result = static::verifyResponse(OpenPayU_Http::doPut($pathUrl, $data, $authType), 'OrderStatusUpdateResponse'); return $result; } @@ -156,7 +156,7 @@ public static function consumeNotification($data) $headers = OpenPayU_Util::getRequestHeaders(); $incomingSignature = OpenPayU_HttpCurl::getSignature($headers); - self::verifyDocumentSignature($data, $incomingSignature); + static::verifyDocumentSignature($data, $incomingSignature); return OpenPayU_Order::verifyResponse(array('response' => $data, 'code' => 200), 'OrderNotifyRequest'); } @@ -187,7 +187,7 @@ public static function verifyResponse($response, $messageName) unset($message['status']); } - $result = self::build($data); + $result = static::build($data); if ($httpStatus == 200 || $httpStatus == 201 || $httpStatus == 422 || $httpStatus == 301 || $httpStatus == 302) { @@ -219,7 +219,7 @@ public static function hostedOrderForm($order, $params = array()) OpenPayU_Configuration::getSignatureKey() ); - $formParams = array_merge(self::$defaultFormParams, $params); + $formParams = array_merge(static::$defaultFormParams, $params); $htmlOutput = sprintf("
\n", $orderFormUrl, $formParams['formId'], $formParams['formClass']); $htmlOutput .= $htmlFormFields; diff --git a/lib/OpenPayU/v2/Refund.php b/lib/OpenPayU/v2/Refund.php index eecbdea..881ce4c 100644 --- a/lib/OpenPayU/v2/Refund.php +++ b/lib/OpenPayU/v2/Refund.php @@ -38,7 +38,7 @@ public static function create($orderId, $description, $amount = null) } try { - $authType = self::getAuth(); + $authType = static::getAuth(); } catch (OpenPayU_Exception $e) { throw new OpenPayU_Exception($e->getMessage(), $e->getCode()); } @@ -47,7 +47,7 @@ public static function create($orderId, $description, $amount = null) $data = OpenPayU_Util::buildJsonFromArray($refund); - $result = self::verifyResponse(OpenPayU_Http::doPost($pathUrl, $data, $authType), 'RefundCreateResponse'); + $result = static::verifyResponse(OpenPayU_Http::doPost($pathUrl, $data, $authType), 'RefundCreateResponse'); return $result; } @@ -76,7 +76,7 @@ public static function verifyResponse($response, $messageName='') unset($message['status']); } - $result = self::build($data); + $result = static::build($data); if ($httpStatus == 200 || $httpStatus == 201 || $httpStatus == 422 || $httpStatus == 302) { return $result; diff --git a/lib/OpenPayU/v2/Retrieve.php b/lib/OpenPayU/v2/Retrieve.php index 16d6b85..da02484 100644 --- a/lib/OpenPayU/v2/Retrieve.php +++ b/lib/OpenPayU/v2/Retrieve.php @@ -24,7 +24,7 @@ public static function payMethods($lang = null) { try { - $authType = self::getAuth(); + $authType = static::getAuth(); } catch (OpenPayU_Exception $e) { throw new OpenPayU_Exception($e->getMessage(), $e->getCode()); } @@ -33,12 +33,12 @@ public static function payMethods($lang = null) throw new OpenPayU_Exception_Configuration('Retrieve works only with OAuth'); } - $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::PAYMETHODS_SERVICE; + $pathUrl = OpenPayU_Configuration::getServiceUrl() . static::PAYMETHODS_SERVICE; if ($lang !== null) { $pathUrl .= '?lang=' . $lang; } - $response = self::verifyResponse(OpenPayU_Http::doGet($pathUrl, $authType)); + $response = static::verifyResponse(OpenPayU_Http::doGet($pathUrl, $authType)); return $response; } @@ -63,7 +63,7 @@ public static function verifyResponse($response) unset($message['status']); } - $result = self::build($data); + $result = static::build($data); if ($httpStatus == 200 || $httpStatus == 201 || $httpStatus == 422 || $httpStatus == 302 || $httpStatus == 400 || $httpStatus == 404) { return $result; diff --git a/lib/OpenPayU/v2/Token.php b/lib/OpenPayU/v2/Token.php index 0c27fcf..7dcf39d 100644 --- a/lib/OpenPayU/v2/Token.php +++ b/lib/OpenPayU/v2/Token.php @@ -24,7 +24,7 @@ public static function delete($token) { try { - $authType = self::getAuth(); + $authType = static::getAuth(); } catch (OpenPayU_Exception $e) { throw new OpenPayU_Exception($e->getMessage(), $e->getCode()); } @@ -37,9 +37,9 @@ public static function delete($token) throw new OpenPayU_Exception_Configuration('Token delete request is available only for trusted_merchant'); } - $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::TOKENS_SERVICE . '/' . $token; + $pathUrl = OpenPayU_Configuration::getServiceUrl() . static::TOKENS_SERVICE . '/' . $token; - $response = self::verifyResponse(OpenPayU_Http::doDelete($pathUrl, $authType)); + $response = static::verifyResponse(OpenPayU_Http::doDelete($pathUrl, $authType)); return $response; } @@ -64,7 +64,7 @@ public static function verifyResponse($response) unset($message['status']); } - $result = self::build($data); + $result = static::build($data); if ($httpStatus == 204) { return $result;