Skip to content

Commit

Permalink
Fix issue converting numeric attribute to json
Browse files Browse the repository at this point in the history
Fix the issue while converting a numeric attribute to json element.
The issue was identified while trying to send a tax value as 0
  • Loading branch information
Pedro Gonçalves committed Nov 14, 2019
1 parent 8d46ae6 commit d2406c3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/MercadoPago/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ public function setQueryParams($entity, $urlParams = [])
protected function _attributesToJson($entity, &$result)
{
if (is_array($entity)) {
$attributes = array_filter($entity);
$attributes = array_filter($entity, function($entity) {
return ($entity !== null && $entity !== false && $entity !== '');
});
} else {
$attributes = $entity->toArray();
}
Expand All @@ -308,7 +310,7 @@ protected function _attributesToJson($entity, &$result)
if ($value instanceof Entity || is_array($value)) {
$this->_attributesToJson($value, $result[$key]);
} else {
if ($value != null || is_bool($value)){
if ($value != null || is_bool($value) || is_numeric($value)){
$result[$key] = $value;
}
}
Expand Down

0 comments on commit d2406c3

Please sign in to comment.