diff --git a/src/Signer/DefaultSigner.php b/src/Signer/DefaultSigner.php index 11cc1a0..acf495b 100644 --- a/src/Signer/DefaultSigner.php +++ b/src/Signer/DefaultSigner.php @@ -4,7 +4,7 @@ class DefaultSigner implements Signer { - public function calculateSignature(array $payload, string $secret): string + public function calculateSignature(string $webhookUrl, array $payload, string $secret): string { $payloadJson = json_encode($payload); diff --git a/src/Signer/Signer.php b/src/Signer/Signer.php index 5bfd95b..a5fc0ed 100644 --- a/src/Signer/Signer.php +++ b/src/Signer/Signer.php @@ -6,5 +6,5 @@ interface Signer { public function signatureHeaderName(): string; - public function calculateSignature(array $payload, string $secret): string; + public function calculateSignature(string $webhookUrl, array $payload, string $secret): string; } diff --git a/src/WebhookCall.php b/src/WebhookCall.php index a5f74cd..4fa58de 100644 --- a/src/WebhookCall.php +++ b/src/WebhookCall.php @@ -220,7 +220,7 @@ protected function getAllHeaders(): array return $headers; } - $signature = $this->signer->calculateSignature($this->payload, $this->secret); + $signature = $this->signer->calculateSignature($this->callWebhookJob->webhookUrl, $this->payload, $this->secret); $headers[$this->signer->signatureHeaderName()] = $signature; diff --git a/tests/DefaultSignerTest.php b/tests/DefaultSignerTest.php index 63e75b4..6c748c3 100644 --- a/tests/DefaultSignerTest.php +++ b/tests/DefaultSignerTest.php @@ -11,7 +11,7 @@ public function it_can_calculate_a_signature_for_a_given_payload_and_secret() { $signer = new DefaultSigner(); - $signature = $signer->calculateSignature(['a' => '1'], 'abc'); + $signature = $signer->calculateSignature('https://my.app/webhooks', ['a' => '1'], 'abc'); $this->assertEquals( '345611a3626cf5e080a7a412184001882ab231b8bdb465dc76dbf709f01f210a',