Skip to content

Commit

Permalink
v. 3.7.12
Browse files Browse the repository at this point in the history
- Correção na exibição de parcelas na página de produto que quebrava a página. Contribuição de @arthurabreu00.
- Melhorias diversas no código a fim de garantir compatibilidade com Magento ECG e outras validações do Magento Marketplace.
  • Loading branch information
r-martins committed Oct 1, 2019
1 parent b215813 commit d7a9d0d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
3 changes: 2 additions & 1 deletion app/code/community/RicardoMartins/PagSeguro/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ public function getExternalPagSeguroScriptBlock()
$scriptBlock = Mage::app()->getLayout()->createBlock('core/text', 'pagseguro_direct');
$scriptBlock->setText(
sprintf(
'<script type="text/javascript" src="%s" defer>', Mage::helper('ricardomartins_pagseguro')->getJsUrl()
'<script type="text/javascript" src="%s" defer></script>',
Mage::helper('ricardomartins_pagseguro')->getJsUrl()
)
);
return $scriptBlock;
Expand Down
37 changes: 25 additions & 12 deletions app/code/community/RicardoMartins/PagSeguro/Helper/Params.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function getItemsParams(Mage_Sales_Model_Order $order)
}
}
}

return $return;
}

Expand Down Expand Up @@ -135,6 +136,7 @@ public function getCreditCardInstallmentsParams(Mage_Sales_Model_Order $order, $
'installmentValue' => number_format($order->getGrandTotal(), 2, '.', ''),
);
}

return $return;
}

Expand Down Expand Up @@ -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) {
Expand All @@ -206,6 +208,7 @@ public function getAddressParams(Mage_Sales_Model_Order $order, $type)
$return['shippingCost'] = number_format($shippingCost, 2, '.', '');
}
}

return $return;
}

Expand All @@ -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);
Expand Down Expand Up @@ -260,6 +260,7 @@ public function getStateCode($state)
return $code;
}
}

return $state;
}

Expand Down Expand Up @@ -319,6 +320,7 @@ public function getExtraAmount($order)
if ($itemPrice == 0) {
$extra -= 0.01 * $item->getQtyOrdered();
}

$itemsTotal += $itemPrice;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -366,14 +369,15 @@ 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);
//se começar com zero, pula o primeiro digito
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);
Expand All @@ -399,14 +403,15 @@ 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) {
return '1';
} else if (strstr($method, 'sedex') !== false) {
return '2';
}

return '3';
}

Expand All @@ -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);

Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
}

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.7.11</version>
<version>3.7.12</version>
</RicardoMartins_PagSeguro>
</modules>
<global>
Expand Down

0 comments on commit d7a9d0d

Please sign in to comment.