From d2406c3fed48954d6e9cd9358d9d9948faf53213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Gon=C3=A7alves?= Date: Thu, 14 Nov 2019 14:53:36 -0300 Subject: [PATCH] Fix issue converting numeric attribute to json Fix the issue while converting a numeric attribute to json element. The issue was identified while trying to send a tax value as 0 --- src/MercadoPago/Manager.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/MercadoPago/Manager.php b/src/MercadoPago/Manager.php index 1ec5fe19..c8081d09 100755 --- a/src/MercadoPago/Manager.php +++ b/src/MercadoPago/Manager.php @@ -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(); } @@ -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; } }