Ejegg has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/402889 )
Change subject: Update Amazon SDK ...................................................................... Update Amazon SDK Change-Id: If3cf11e0883d512e1bd817797bb4b6c62961d6db --- A amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/ArrayUtil.php M amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/BaseClient.php M amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/IpnHandler.php M amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/PaymentsClient.php M amzn/login-and-pay-with-amazon-sdk-php/composer.json M composer/installed.json 6 files changed, 90 insertions(+), 72 deletions(-) Approvals: Ejegg: Verified; Looks good to me, approved diff --git a/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/ArrayUtil.php b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/ArrayUtil.php new file mode 100644 index 0000000..4285620 --- /dev/null +++ b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/ArrayUtil.php @@ -0,0 +1,18 @@ +<?php + +namespace PayWithAmazon; + +class ArrayUtil +{ + public static function trimArray($array) + { + foreach ($array as $key => $value) + { + if(!is_null($value) && !is_array($value) && $key!=='proxy_password') + { + $array[$key] = trim($value); + } + } + return $array; + } +} diff --git a/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/BaseClient.php b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/BaseClient.php index 899ae49..9ede9f2 100644 --- a/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/BaseClient.php +++ b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/BaseClient.php @@ -1,5 +1,7 @@ <?php namespace PayWithAmazon; +use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; /* Class BaseClient * Takes configuration information @@ -7,6 +9,7 @@ * returns Response Object */ +require_once 'ArrayUtil.php'; require_once 'ResponseParser.php'; require_once 'HttpCurl.php'; require_once 'Regions.php'; @@ -18,6 +21,11 @@ // Override in concrete classes with API's service version protected $serviceVersion; + + /** + * @var LoggerInterface + */ + protected $logger; // Construct User agent string based off of the application_name, application_version, PHP platform protected $userAgent = null; @@ -39,7 +47,8 @@ 'proxy_username' => null, 'proxy_password' => null, 'client_id' => null, - 'handle_throttle' => true + 'handle_throttle' => true, + 'logger' => null ); protected $modePath = null; @@ -81,6 +90,17 @@ $this->checkConfigKeys($configArray); } else { throw new \Exception('$config is of the incorrect type ' . gettype($configArray) . ' and should be of the type array'); + } + if (empty($configArray['logger'])) { + $this->logger = new NullLogger(); + } else { + if ($configArray['logger'] instanceof LoggerInterface) { + $this->logger = $configArray['logger']; + } else { + throw new \InvalidArgumentException( + 'Logger passed in config must implement Psr\Log\LoggerInterface' + ); + } } } else { throw new \Exception('$config cannot be null.'); @@ -127,7 +147,7 @@ private function checkConfigKeys($config) { $config = array_change_key_case($config, CASE_LOWER); - $config = $this->trimArray($config); + $config = ArrayUtil::trimArray($config); foreach ($config as $key => $value) { if (array_key_exists($key, $this->config)) { @@ -245,20 +265,6 @@ public function getParameters() { return trim($this->parameters); - } - - /* Trim the input Array key values */ - - protected function trimArray($array) - { - foreach ($array as $key => $value) - { - if(!is_array($value) && $key!=='proxy_password') - { - $array[$key] = trim($value); - } - } - return $array; } /* setParametersAndPost - sets the parameters array with non empty values from the requestParameters array sent to API calls. @@ -560,6 +566,7 @@ $this->pauseOnRetry(++$retries, $statusCode); } } else { + $this->logger->info("Returned status code $statusCode, not retrying."); $shouldRetry = false; } } catch (\Exception $e) { @@ -582,6 +589,7 @@ { if ($retries <= self::MAX_ERROR_RETRY) { $delay = (int) (pow(4, $retries) * $this->basePause); + $this->logger->info("Returned status code $status on try $retries, waiting $delay microseconds."); usleep($delay); } else { throw new \Exception('Error Code: '. $status.PHP_EOL.'Maximum number of retry attempts - '. $retries .' reached'); diff --git a/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/IpnHandler.php b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/IpnHandler.php index 2514af1..94318a0 100644 --- a/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/IpnHandler.php +++ b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/IpnHandler.php @@ -5,9 +5,10 @@ * Takes headers and body of the IPN message as input in the constructor * verifies that the IPN is from the right resource and has the valid data */ - +require_once 'ArrayUtil.php'; require_once 'HttpCurl.php'; require_once 'IpnHandlerInterface.php'; + class IpnHandler implements IpnHandlerInterface { @@ -61,7 +62,7 @@ private function checkConfigKeys($ipnConfig) { $ipnConfig = array_change_key_case($ipnConfig, CASE_LOWER); - $ipnConfig = $this->trimArray($ipnConfig); + $ipnConfig = ArrayUtil::trimArray($ipnConfig); foreach ($ipnConfig as $key => $value) { if (array_key_exists($key, $this->ipnConfig)) { @@ -97,17 +98,6 @@ } else { throw new \Exception("Key " . $name . " was not found in the configuration", 1); } - } - - /* Trim the input Array key values */ - - private function trimArray($array) - { - foreach ($array as $key => $value) - { - $array[$key] = trim($value); - } - return $array; } private function validateHeaders() diff --git a/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/PaymentsClient.php b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/PaymentsClient.php index 1b7919a..ed1de47 100644 --- a/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/PaymentsClient.php +++ b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/PaymentsClient.php @@ -719,7 +719,7 @@ public function charge($requestParameters = array()) { $requestParameters = array_change_key_case($requestParameters, CASE_LOWER); - $requestParameters= $this->trimArray($requestParameters); + $requestParameters= ArrayUtil::trimArray($requestParameters); $setParameters = $authorizeParameters = $confirmParameters = $requestParameters; diff --git a/amzn/login-and-pay-with-amazon-sdk-php/composer.json b/amzn/login-and-pay-with-amazon-sdk-php/composer.json index a34204b..3aecf61 100644 --- a/amzn/login-and-pay-with-amazon-sdk-php/composer.json +++ b/amzn/login-and-pay-with-amazon-sdk-php/composer.json @@ -25,6 +25,7 @@ }, "require": { "ext-curl": "*", - "php": ">=5.3.0" + "php": ">=5.3.0", + "psr/log": "^1.0" } } diff --git a/composer/installed.json b/composer/installed.json index 0521000..0e6aed3 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -43,47 +43,6 @@ ] }, { - "name": "amzn/login-and-pay-with-amazon-sdk-php", - "version": "dev-master", - "version_normalized": "9999999-dev", - "source": { - "type": "git", - "url": "https://github.com/ejegg/login-and-pay-with-amazon-sdk-php", - "reference": "855d642f85f14c76ca810013b0323ae4ac37f1c6" - }, - "require": { - "ext-curl": "*", - "php": ">=5.3.0" - }, - "time": "2016-02-17T00:44:20+00:00", - "type": "library", - "installation-source": "source", - "autoload": { - "psr-4": { - "PayWithAmazon\\": "PayWithAmazon/" - } - }, - "license": [ - "Apache OSL-2" - ], - "authors": [ - { - "name": "Amazon Payments", - "email": "eps-...@amazon.com" - } - ], - "description": "Pay with Amazon SDK", - "homepage": "https://github.com/amzn/login-and-pay-with-amazon-sdk-php", - "keywords": [ - "amazon", - "amazon payments", - "pay", - "pay with amazon", - "payment", - "payments" - ] - }, - { "name": "ircmaxell/password-compat", "version": "v1.0.4", "version_normalized": "1.0.4.0", @@ -884,5 +843,47 @@ "queue", "transaction" ] + }, + { + "name": "amzn/login-and-pay-with-amazon-sdk-php", + "version": "dev-master", + "version_normalized": "9999999-dev", + "source": { + "type": "git", + "url": "https://github.com/ejegg/login-and-pay-with-amazon-sdk-php", + "reference": "3349385d31f214fc2d2b7f68af289a957458559c" + }, + "require": { + "ext-curl": "*", + "php": ">=5.3.0", + "psr/log": "^1.0" + }, + "time": "2018-01-05T16:31:47+00:00", + "type": "library", + "installation-source": "source", + "autoload": { + "psr-4": { + "PayWithAmazon\\": "PayWithAmazon/" + } + }, + "license": [ + "Apache OSL-2" + ], + "authors": [ + { + "name": "Amazon Payments", + "email": "eps-...@amazon.com" + } + ], + "description": "Pay with Amazon SDK", + "homepage": "https://github.com/amzn/login-and-pay-with-amazon-sdk-php", + "keywords": [ + "amazon", + "amazon payments", + "pay", + "pay with amazon", + "payment", + "payments" + ] } ] -- To view, visit https://gerrit.wikimedia.org/r/402889 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If3cf11e0883d512e1bd817797bb4b6c62961d6db Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/SmashPig/vendor Gerrit-Branch: master Gerrit-Owner: Ejegg <ej...@ejegg.com> Gerrit-Reviewer: Ejegg <ej...@ejegg.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits