diff --git a/src/MercadoPago/Entities/OAuth.php b/src/MercadoPago/Entities/OAuth.php new file mode 100644 index 00000000..0d5a314b --- /dev/null +++ b/src/MercadoPago/Entities/OAuth.php @@ -0,0 +1,82 @@ +client_secret = SDK::getAccessToken(); + $this->grant_type = 'authorization_code'; + $this->code = $authorization_code; + $this->redirect_uri = $redirect_uri; + + return $this->save(); + } + + public function refreshOAuthCredentials($refresh_token){ + $this->client_secret = SDK::getAccessToken(); + $this->grant_type = 'refresh_token'; + $this->refresh_token = $refresh_token; + + return $this->save(); + } +} diff --git a/src/MercadoPago/Generic/RecuperableError.php b/src/MercadoPago/Generic/RecuperableError.php index 530b8688..6d6662b6 100644 --- a/src/MercadoPago/Generic/RecuperableError.php +++ b/src/MercadoPago/Generic/RecuperableError.php @@ -24,11 +24,15 @@ public function add_cause($code, $description) { } public function proccess_causes($causes){ - foreach ($causes as $cause){ - if(is_array($cause) && (!isset($cause['code']) && !isset($cause['description']))){ - $this->proccess_causes($cause); - }else{ - $this->add_cause($cause['code'], $cause['description']); + if(isset($causes['code']) && isset($causes['description'])){ + $this->add_cause($causes['code'], $causes['description']); + }else{ + foreach ($causes as $cause){ + if(is_array($cause) && (!isset($cause['code']) && !isset($cause['description']))){ + $this->proccess_causes($cause); + }else{ + $this->add_cause($cause['code'], $cause['description']); + } } } } 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; } }