From d7a9d0db2c88d73ab80e6ff3c78f2ec7dcd2a026 Mon Sep 17 00:00:00 2001 From: Ricardo Martins Date: Tue, 1 Oct 2019 13:46:36 +1000 Subject: [PATCH] =?UTF-8?q?v.=203.7.12=20-=20Corre=C3=A7=C3=A3o=20na=20exi?= =?UTF-8?q?bi=C3=A7=C3=A3o=20de=20parcelas=20na=20p=C3=A1gina=20de=20produ?= =?UTF-8?q?to=20que=20quebrava=20a=20p=C3=A1gina.=20Contribui=C3=A7=C3=A3o?= =?UTF-8?q?=20de=20@arthurabreu00.=20-=20Melhorias=20diversas=20no=20c?= =?UTF-8?q?=C3=B3digo=20a=20fim=20de=20garantir=20compatibilidade=20com=20?= =?UTF-8?q?Magento=20ECG=20e=20outras=20valida=C3=A7=C3=B5es=20do=20Magent?= =?UTF-8?q?o=20Marketplace.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RicardoMartins/PagSeguro/Helper/Data.php | 3 +- .../PagSeguro/Helper/Params.php | 37 +++++++++++++------ .../RicardoMartins/PagSeguro/etc/config.xml | 2 +- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/app/code/community/RicardoMartins/PagSeguro/Helper/Data.php b/app/code/community/RicardoMartins/PagSeguro/Helper/Data.php index 2ce287ee..407ea50b 100644 --- a/app/code/community/RicardoMartins/PagSeguro/Helper/Data.php +++ b/app/code/community/RicardoMartins/PagSeguro/Helper/Data.php @@ -306,7 +306,8 @@ public function getExternalPagSeguroScriptBlock() $scriptBlock = Mage::app()->getLayout()->createBlock('core/text', 'pagseguro_direct'); $scriptBlock->setText( sprintf( - '', + Mage::helper('ricardomartins_pagseguro')->getJsUrl() ) ); return $scriptBlock; diff --git a/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php b/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php index 7f59897d..ffa6a12e 100644 --- a/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php +++ b/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php @@ -43,6 +43,7 @@ public function getItemsParams(Mage_Sales_Model_Order $order) } } } + return $return; } @@ -135,6 +136,7 @@ public function getCreditCardInstallmentsParams(Mage_Sales_Model_Order $order, $ 'installmentValue' => number_format($order->getGrandTotal(), 2, '.', ''), ); } + return $return; } @@ -193,7 +195,7 @@ public function getAddressParams(Mage_Sales_Model_Order $order, $type) if ($this->_extraDiscountGreaterThanItems && abs($this->_extraDiscount) >= $shippingCost) { $shippingDiscount = (abs($this->_extraDiscount) <= $shippingCost)? abs($this->_extraDiscount): - min(abs($this->_extraDiscount),$shippingCost); + min(abs($this->_extraDiscount), $shippingCost); //if extra discount greater, we change extraAmount to get only the difference if (abs($this->_extraDiscount) >= $shippingCost) { @@ -206,6 +208,7 @@ public function getAddressParams(Mage_Sales_Model_Order $order, $type) $return['shippingCost'] = number_format($shippingCost, 2, '.', ''); } } + return $return; } @@ -217,12 +220,9 @@ public function getAddressParams(Mage_Sales_Model_Order $order, $type) */ public function getStateCode($state) { - if(strlen($state) == 2 && is_string($state)) - { - return mb_convert_case($state,MB_CASE_UPPER); - } - else if(strlen($state) > 2 && is_string($state)) - { + if (strlen($state) == 2 && is_string($state)) { + return mb_convert_case($state, MB_CASE_UPPER); + } else if (strlen($state) > 2 && is_string($state)) { $state = self::normalizeChars($state); $state = trim($state); $state = $this->stripAccents($state); @@ -260,6 +260,7 @@ public function getStateCode($state) return $code; } } + return $state; } @@ -319,6 +320,7 @@ public function getExtraAmount($order) if ($itemPrice == 0) { $extra -= 0.01 * $item->getQtyOrdered(); } + $itemsTotal += $itemPrice; } @@ -351,12 +353,13 @@ public function removeDuplicatedSpaces($string) public function getYears() { $years = array(); - $first = date("Y"); + $first = Mage::getSingleton('core/date')->date('Y'); for ($index=0; $index <= 20; $index++) { $year = $first + $index; $years[$year] = $year; } + return $years; } @@ -366,7 +369,7 @@ public function getYears() * @param string $phone * @return array */ - private function _extractPhone($phone) + protected function _extractPhone($phone) { $digits = new Zend_Filter_Digits(); $phone = $digits->filter($phone); @@ -374,6 +377,7 @@ private function _extractPhone($phone) if (substr($phone, 0, 1) == '0') { $phone = substr($phone, 1, strlen($phone)); } + $originalPhone = $phone; $phone = preg_replace('/^(\d{2})(\d{7,9})$/', '$1-$2', $phone); @@ -399,7 +403,7 @@ private function _extractPhone($phone) * * @return string */ - private function _getShippingType(Mage_Sales_Model_Order $order) + protected function _getShippingType(Mage_Sales_Model_Order $order) { $method = strtolower($order->getShippingMethod()); if (strstr($method, 'pac') !== false) { @@ -407,6 +411,7 @@ private function _getShippingType(Mage_Sales_Model_Order $order) } else if (strstr($method, 'sedex') !== false) { return '2'; } + return '3'; } @@ -419,7 +424,7 @@ private function _getShippingType(Mage_Sales_Model_Order $order) * * @return string */ - private function _getAddressAttributeValue($address, $attributeId) + protected function _getAddressAttributeValue($address, $attributeId) { $isStreetline = preg_match('/^street_(\d{1})$/', $attributeId, $matches); @@ -564,11 +569,15 @@ protected function _getTelephoneAttribute() { return Mage::getStoreConfig('payment/rm_pagseguro/address_telephone_attribute'); } + /** * Get payment hashes (sender_hash & credit_card_token) from session + * * @param string $param sender_hash or credit_card_token * * @return bool|string + * @throws Mage_Core_Model_Store_Exception + * @throws Zend_Serializer_Exception */ public function getPaymentHash($param=null) { @@ -578,9 +587,13 @@ public function getPaymentHash($param=null) $registry = ($isAdmin)?$registry->get('PsPayment'):$registry->getData('PsPayment'); + if (!$registry) { + return false; + } + $registry = Zend_Serializer::unserialize($registry); - if (is_null($param)) { + if (null === $param) { return $registry; } diff --git a/app/code/community/RicardoMartins/PagSeguro/etc/config.xml b/app/code/community/RicardoMartins/PagSeguro/etc/config.xml index 29237e28..f1ed2795 100644 --- a/app/code/community/RicardoMartins/PagSeguro/etc/config.xml +++ b/app/code/community/RicardoMartins/PagSeguro/etc/config.xml @@ -2,7 +2,7 @@ - 3.7.11 + 3.7.12