Fix webhook payload serialization and null headers

This commit is contained in:
Lance Pioch
2026-06-12 10:26:36 -04:00
parent 2b9c08dc5d
commit 234d4f0c0d

View File

@@ -6,6 +6,7 @@ use App\Enums\WebhookType;
use App\Models\WebhookConfiguration;
use Exception;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
@@ -34,7 +35,9 @@ class ProcessWebhook implements ShouldQueue
$data = reset($data);
}
if (is_object($data)) {
if ($data instanceof Arrayable) {
$data = $data->toArray();
} elseif (is_object($data)) {
$data = get_object_vars($data);
}
@@ -64,7 +67,7 @@ class ProcessWebhook implements ShouldQueue
$headers = [];
if ($this->webhookConfiguration->type === WebhookType::Regular) {
foreach ($this->webhookConfiguration->headers as $key => $value) {
foreach ($this->webhookConfiguration->headers ?? [] as $key => $value) {
$headers[$key] = $this->webhookConfiguration->replaceVars($data, $value);
}
}