Skip to content

Commit

Permalink
v. 3.10.2
Browse files Browse the repository at this point in the history
* Correção: Corrigido erro de compatibilidade com PHP 5.5 que gerava erro fatal (Arrays are not allowed in class constants) ao chegar no checkout. Reportado por Bruno. Fixes #280
* Correção: Corrigido possível erro de compatibilidade com PHP 7.0 (Indirect access to variables, properties and methods will be evaluated strictly in left-to-right order since PHP 7.0. Use curly braces to remove ambiguity.) que ocorria ao tentar obter o valor das parcelas no backend (chamado apenas quando a obtenção de parcelas no frontend falha ou trazia valor incorreto).
* Melhoria: Melhoria estética na forma como o IP do cliente era obtido. Agora o IP é obtido do "jeito Magento", ganhando mais compatibilidade com outros módulos que eventualmente o alterem propositalmente.
  • Loading branch information
r-martins committed Sep 10, 2020
1 parent 3fce025 commit 5e96d9a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 6 additions & 8 deletions app/code/community/RicardoMartins/PagSeguro/Model/Recurring.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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
);
Expand All @@ -325,7 +323,7 @@ public function cancelPagseguroProfile($profile)

return $this->callPutAPI(
$suffix,
self::HEADER_V3_JSON,
explode(',', self::HEADER_V3_JSON),
'',
true
);
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/RicardoMartins/PagSeguro/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<RicardoMartins_PagSeguro>
<version>3.10.1</version>
<version>3.10.2</version>
</RicardoMartins_PagSeguro>
</modules>
<global>
Expand Down

0 comments on commit 5e96d9a

Please sign in to comment.