From 9204220d4025ade29b435b7e8ada07346654e9d1 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Sat, 24 Jan 2026 12:13:29 -0500 Subject: [PATCH] Update WhatsAppService.php --- services/WhatsAppService.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/services/WhatsAppService.php b/services/WhatsAppService.php index 6f8c792..2d5ca1a 100644 --- a/services/WhatsAppService.php +++ b/services/WhatsAppService.php @@ -122,15 +122,16 @@ class WhatsAppService if ($isNamed) { // bodyParameters is like ['name' => 'Alice', ...] + // Convert named params to the WhatsApp API expected parameter objects foreach ($bodyParameters as $paramName => $paramValue) { if (is_array($paramValue) && isset($paramValue['type'])) { - // already detailed param object: ensure name is set - if (!isset($paramValue['name'])) $paramValue['name'] = $paramName; - $normalizedBody[] = $paramValue; + // already detailed param object: remove any unexpected keys like 'name' + $paramObj = $paramValue; + unset($paramObj['name']); + $normalizedBody[] = $paramObj; } else { $normalizedBody[] = [ 'type' => 'text', - 'name' => $paramName, 'text' => (string)$paramValue ]; } @@ -139,7 +140,10 @@ class WhatsAppService // Indexed array: preserve objects or convert strings foreach ($bodyParameters as $bp) { if (is_array($bp) && isset($bp['type'])) { - $normalizedBody[] = $bp; // already detailed + // ensure no unsupported keys like 'name' are passed through + $bpCopy = $bp; + unset($bpCopy['name']); + $normalizedBody[] = $bpCopy; // already detailed } elseif (is_string($bp) || is_numeric($bp)) { $normalizedBody[] = [ 'type' => 'text',