Skip to content

Commit 3db50a1

Browse files
committed
Update WebhookCallEvent.php to accept string payload and add additional test to capture this case.
1 parent 0586057 commit 3db50a1

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/Events/WebhookCallEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ abstract class WebhookCallEvent
1010
public function __construct(
1111
public string $httpVerb,
1212
public string $webhookUrl,
13-
public array $payload,
13+
public array|string $payload,
1414
public array $headers,
1515
public array $meta,
1616
public array $tags,

tests/CallWebhookJobTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,3 +321,32 @@ function baseGetRequest(array $overrides = []): array
321321
->testClient
322322
->assertRequestsMade([$baseRequest]);
323323
});
324+
325+
326+
it('send raw body data in event if rawBody is set', function () {
327+
$this->testClient->throwConnectionException();
328+
329+
$testBody = "<xml>anotherOption</xml>";
330+
WebhookCall::create()
331+
->url('https://example.com/webhooks')
332+
->useSecret('abc')
333+
->sendRawBody($testBody)
334+
->doNotSign()
335+
->dispatch();
336+
337+
$baseRequest = baseRequest();
338+
339+
$baseRequest['options']['body'] = $testBody;
340+
unset($baseRequest['options']['headers']['Signature']);
341+
342+
artisan('queue:work --once');
343+
344+
Event::assertDispatched(WebhookCallFailedEvent::class, function (WebhookCallFailedEvent $event) use ($testBody) {
345+
expect($event->errorType)->not->toBeNull()
346+
->and($event->errorMessage)->not->toBeNull()
347+
->and($event->payload)->toBe($testBody);
348+
349+
return true;
350+
});
351+
});
352+

0 commit comments

Comments
 (0)