Skip to content

Commit

Permalink
Adicionado rotina para remoção de acentuação antes de enviar para API
Browse files Browse the repository at this point in the history
  • Loading branch information
eneiasramos committed Jun 29, 2022
1 parent 8698dd7 commit 91bfbf0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions app/code/community/RicardoMartins/PagSeguro/Helper/Params.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public function getAddressParams(Mage_Sales_Model_Order $order, $type)
$addressComplement = $this->_getAddressAttributeValue($address, $addressComplementAttribute);
$addressDistrict = $this->_getAddressAttributeValue($address, $addressNeighborhoodAttribute);
$addressPostalCode = $digits->filter($address->getPostcode());
$addressCity = $address->getCity();
$addressCity = $this->removeAccents($address->getCity());
$addressState = $this->getStateCode($address->getRegion());


Expand Down Expand Up @@ -355,6 +355,11 @@ public function stripAccents($string)
return preg_replace('/[`^~\'"]/', null, iconv('UTF-8', 'ASCII//TRANSLIT', $string));
}

public function removeAccents($text)
{
return Mage::helper('core')->removeAccents($text);
}

/**
* Calculates the "Extra" value that corresponds to Tax values minus Discount given
* It makes the correct discount to be shown correctly on PagSeguro
Expand Down Expand Up @@ -525,13 +530,17 @@ protected function _getShippingType(Mage_Sales_Model_Order $order)
protected function _getAddressAttributeValue($address, $attributeId)
{
$isStreetline = preg_match('/^street_(\d{1})$/', $attributeId, $matches);
$result = '';

if ($isStreetline !== false && isset($matches[1])) { //uses streetlines
return $address->getStreet(intval($matches[1]));
$result = $address->getStreet(intval($matches[1]));
} else if ($attributeId == '') { //do not tell pagseguro
return '';
} else {
$result = (string)$address->getData($attributeId);
}
return (string)$address->getData($attributeId);

return $this->removeAccents($result);
}

/**
Expand Down

0 comments on commit 91bfbf0

Please sign in to comment.