Skip to content

Commit d2521d3

Browse files
committed
wip
1 parent 84162f9 commit d2521d3

File tree

1 file changed

+65
-2
lines changed

1 file changed

+65
-2
lines changed

README.md

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,78 @@ $signature = hash_hmac('sha256', $payloadJson, $secret);
117117

118118
### Customizing signing requests
119119

120+
If you want to customize the signing process you can create your own custom signer. A signer is any class that implements `Spatie\WebhookServer\Signer`.
120121

122+
This is what that interface looks like.
121123

122-
### Testing
124+
```php
125+
namespace Spatie\WebhookServer\Signer;
126+
127+
interface Signer
128+
{
129+
public function signatureHeaderName(): string;
130+
131+
public function calculateSignature(array $payload, string $secret): string;
132+
}
133+
```
134+
135+
After creating your signer you can specify it's class name in the `signer` key of the `webhook-server` config file. Your signer will than be used by default in all webhook calls.
136+
137+
You can also specify a signer for a specific webhook call
138+
139+
```php
140+
Webhook::create()
141+
->signUsing(YourCustomSigner::class)
142+
...
143+
->call();
144+
```
145+
146+
### Customizing the http verb
147+
148+
By default all webhooks will use the `post` method. You can customize that by specify the http verb you want in the `http_verb` key of the `webhook-server` config file.
149+
150+
You can also override the default for a specific call by use the `useHttpVerb` method.
151+
152+
```php
153+
Webhook::create()
154+
->useHttpVerb('get')
155+
...
156+
->call();
157+
```
158+
159+
### Adding extra headers
160+
161+
You can extra headers by adding the to the `headers` key in the `webhook-server` config file. If you want to add extra headers for a specific webhook you can use the `withHeaders` call.
162+
163+
```php
164+
Webhook::create()
165+
->withHeaders([
166+
'Another Header' => 'Value of Another Header'
167+
])
168+
...
169+
->call();
170+
```
171+
172+
### Verifying the ssl certificate of the receiving app
173+
174+
When using an url that starts with `https://` the package will verify if the ssl certificate of the receiving party is valid. If it is not, we will consider the webhook call failed. We don't recommend this but you can turn off this verification by setting the `verify_ssl` key in the `webhook-server` config file to `false`.
175+
176+
You can also disable the verification per webhook call with the `doNotVerifySsl` method.
177+
178+
```php
179+
Webhook::create()
180+
->doNotVerifySsl()
181+
...
182+
->call();
183+
```
184+
185+
## Testing
123186

124187
``` bash
125188
composer test
126189
```
127190

128-
### Changelog
191+
## Changelog
129192

130193
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
131194

0 commit comments

Comments
 (0)