From 20da98e05835c1043bb7eeba6761cb8b249a30c3 Mon Sep 17 00:00:00 2001 From: rhames07 Date: Thu, 21 Sep 2023 15:25:28 -0300 Subject: [PATCH] Improve RecuperableError cause processing --- src/MercadoPago/Generic/RecuperableError.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/MercadoPago/Generic/RecuperableError.php b/src/MercadoPago/Generic/RecuperableError.php index 6d6662b6..14ce953f 100644 --- a/src/MercadoPago/Generic/RecuperableError.php +++ b/src/MercadoPago/Generic/RecuperableError.php @@ -31,7 +31,16 @@ public function proccess_causes($causes){ if(is_array($cause) && (!isset($cause['code']) && !isset($cause['description']))){ $this->proccess_causes($cause); }else{ - $this->add_cause($cause['code'], $cause['description']); + $code = isset($cause['code']) ? $cause['code'] : ""; + $description = $cause; + if (is_array($cause)) { + if (isset($cause['description'])) { + $description = $cause['description']; + } elseif (isset($cause['message'])) { + $description = $cause['message']; + } + } + $this->add_cause($code, $description); } } }