From e7367961075f1b7465d95b6cbfca1296c4c9c7da Mon Sep 17 00:00:00 2001 From: Be-Klasen Date: Fri, 26 Aug 2016 14:06:39 +0200 Subject: [PATCH] Update Client.php to replace depracated methods for newer PHP version using iconv_set_encoding is deprecated in PHP>50600. The proposed change checks the PHP version and uses the new method instead when appropriate. --- src/OffAmazonPaymentsService/Client.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/OffAmazonPaymentsService/Client.php b/src/OffAmazonPaymentsService/Client.php index c2e62c2..b5894ff 100644 --- a/src/OffAmazonPaymentsService/Client.php +++ b/src/OffAmazonPaymentsService/Client.php @@ -113,9 +113,19 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf */ public function __construct($config = null) { - iconv_set_encoding('output_encoding', 'UTF-8'); - iconv_set_encoding('input_encoding', 'UTF-8'); - iconv_set_encoding('internal_encoding', 'UTF-8'); + if (!defined('PHP_VERSION_ID')) { + $version = explode('.', PHP_VERSION); + define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2])); + } + if (PHP_VERSION_ID >= 50600) + { + ini_set("default_charset", "UTF-8"); + } else { + iconv_set_encoding("internal_encoding", "UTF-8"); + iconv_set_encoding("input_encoding", "UTF-8"); + iconv_set_encoding("output_encoding", "UTF-8"); + } + $this->_merchantValues = OffAmazonPaymentsService_MerchantValuesBuilder::create($config)->build(); $this->_httpRequestFactory = new HttpRequestFactoryCurlImpl($this->_merchantValues); @@ -1835,4 +1845,4 @@ private function _convertReverseProviderCredit($request) return $parameters; } -} \ No newline at end of file +}