From 5e96d9a59829eea3a38eaa7702f4a24b4ab02248 Mon Sep 17 00:00:00 2001 From: Ricardo Martins Date: Thu, 10 Sep 2020 15:48:35 +1000 Subject: [PATCH] =?UTF-8?q?v.=203.10.2=20*=20Corre=C3=A7=C3=A3o:=20Corrigi?= =?UTF-8?q?do=20erro=20de=20compatibilidade=20com=20PHP=205.5=20que=20gera?= =?UTF-8?q?va=20erro=20fatal=20(Arrays=20are=20not=20allowed=20in=20class?= =?UTF-8?q?=20constants)=20ao=20chegar=20no=20checkout.=20Reportado=20por?= =?UTF-8?q?=20Bruno.=20Fixes=20#280=20*=20Corre=C3=A7=C3=A3o:=20Corrigido?= =?UTF-8?q?=20poss=C3=ADvel=20erro=20de=20compatibilidade=20com=20PHP=207.?= =?UTF-8?q?0=20(Indirect=20access=20to=20variables,=20properties=20and=20m?= =?UTF-8?q?ethods=20will=20be=20evaluated=20strictly=20in=20left-to-right?= =?UTF-8?q?=20order=20since=20PHP=207.0.=20Use=20curly=20braces=20to=20rem?= =?UTF-8?q?ove=20ambiguity.)=20que=20ocorria=20ao=20tentar=20obter=20o=20v?= =?UTF-8?q?alor=20das=20parcelas=20no=20backend=20(chamado=20apenas=20quan?= =?UTF-8?q?do=20a=20obten=C3=A7=C3=A3o=20de=20parcelas=20no=20frontend=20f?= =?UTF-8?q?alha=20ou=20trazia=20valor=20incorreto).=20*=20Melhoria:=20Melh?= =?UTF-8?q?oria=20est=C3=A9tica=20na=20forma=20como=20o=20IP=20do=20client?= =?UTF-8?q?e=20era=20obtido.=20Agora=20o=20IP=20=C3=A9=20obtido=20do=20"je?= =?UTF-8?q?ito=20Magento",=20ganhando=20mais=20compatibilidade=20com=20out?= =?UTF-8?q?ros=20m=C3=B3dulos=20que=20eventualmente=20o=20alterem=20propos?= =?UTF-8?q?italmente.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RicardoMartins/PagSeguro/Helper/Params.php | 2 +- .../RicardoMartins/PagSeguro/Model/Payment/Cc.php | 2 +- .../RicardoMartins/PagSeguro/Model/Recurring.php | 14 ++++++-------- .../RicardoMartins/PagSeguro/etc/config.xml | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php b/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php index 3cbf6895..036c1822 100644 --- a/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php +++ b/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php @@ -800,7 +800,7 @@ public function getPaymentParamsJson($paymentInfo) */ public function addSenderIp($originalParameters) { - $senderIp = $_SERVER['REMOTE_ADDR']; + $senderIp = Mage::helper('core/http')->getRemoteAddr(true); if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { //Cloudflare $senderIp = $_SERVER['HTTP_CF_CONNECTING_IP']; diff --git a/app/code/community/RicardoMartins/PagSeguro/Model/Payment/Cc.php b/app/code/community/RicardoMartins/PagSeguro/Model/Payment/Cc.php index d126f12c..51422c76 100644 --- a/app/code/community/RicardoMartins/PagSeguro/Model/Payment/Cc.php +++ b/app/code/community/RicardoMartins/PagSeguro/Model/Payment/Cc.php @@ -283,7 +283,7 @@ public function getInstallmentValue( try{ $response = curl_exec($ch); - return json_decode($response)->installments->$creditCardBrand[$selectedInstallment-1]->installmentAmount; + return json_decode($response)->installments->{$creditCardBrand}[$selectedInstallment-1]->installmentAmount; }catch(Exception $e){ Mage::logException($e); return false; diff --git a/app/code/community/RicardoMartins/PagSeguro/Model/Recurring.php b/app/code/community/RicardoMartins/PagSeguro/Model/Recurring.php index 2a912972..85a7fcdb 100644 --- a/app/code/community/RicardoMartins/PagSeguro/Model/Recurring.php +++ b/app/code/community/RicardoMartins/PagSeguro/Model/Recurring.php @@ -16,12 +16,10 @@ class RicardoMartins_PagSeguro_Model_Recurring extends RicardoMartins_PagSeguro_ const HEADER_V3_JSON - = array('Accept: application/vnd.pagseguro.com.br.v3+json;charset=ISO-8859-1', - 'Content-Type: application/json'); + = 'Accept: application/vnd.pagseguro.com.br.v3+json;charset=ISO-8859-1,Content-Type: application/json'; const HEADER_V3_URLENCODED - = array('Accept: application/vnd.pagseguro.com.br.v3+json;charset=ISO-8859-1', - 'Content-Type: application/x-www-form-urlencoded; charset=ISO-8859-1'); + = 'Accept: application/vnd.pagseguro.com.br.v3+json;charset=ISO-8859-1,Content-Type: application/x-www-form-urlencoded; charset=ISO-8859-1'; /** @var RicardoMartins_PagSeguro_Helper_Recurring $_helper */ @@ -54,7 +52,7 @@ public function getPreApprovalDetails($preApprovalCode, $isSandbox) $key = $isSandbox ? $helper->getPagSeguroProSandboxKey() : $helper->getPagSeguroProNonSandboxKey(); $suffix .= $helper->addUrlParam($suffix, array('public_key'=> $key)); - $response = $this->callGetAPI($suffix, self::HEADER_V3_JSON, true); + $response = $this->callGetAPI($suffix, explode(',', self::HEADER_V3_JSON), true); if (isset($response->errors)) { foreach ($response->errors as $code => $error) { @@ -217,7 +215,7 @@ public function getOrderPayments($subscription) $suffix.= $helper->addUrlParam($suffix, array('isSandbox' => $isSandbox, 'public_key' => $key)); $apiReturn = $this->callGetAPI( $suffix, - self::HEADER_V3_JSON, true + explode(',', self::HEADER_V3_JSON), true ); if (!$apiReturn || !isset($apiReturn->paymentOrders)) { @@ -299,7 +297,7 @@ public function changePagseguroStatus($profile, $newStatus) $apiReturn = $this->callPutAPI( $suffix, - self::HEADER_V3_JSON, + explode(',', self::HEADER_V3_JSON), '{"status": "'. $newStatus . '"}', true ); @@ -325,7 +323,7 @@ public function cancelPagseguroProfile($profile) return $this->callPutAPI( $suffix, - self::HEADER_V3_JSON, + explode(',', self::HEADER_V3_JSON), '', true ); diff --git a/app/code/community/RicardoMartins/PagSeguro/etc/config.xml b/app/code/community/RicardoMartins/PagSeguro/etc/config.xml index 8fbbb3a1..ab3916e4 100644 --- a/app/code/community/RicardoMartins/PagSeguro/etc/config.xml +++ b/app/code/community/RicardoMartins/PagSeguro/etc/config.xml @@ -2,7 +2,7 @@ - 3.10.1 + 3.10.2