https://github.com/bencoderus/laravel-webhook
Laravel webhook allows businesses to send webhooks to their merchants/clients with ease.
https://github.com/bencoderus/laravel-webhook
composer laravel laravel8 php php7 webhook
Last synced: 4 months ago
JSON representation
Laravel webhook allows businesses to send webhooks to their merchants/clients with ease.
- Host: GitHub
- URL: https://github.com/bencoderus/laravel-webhook
- Owner: bencoderus
- License: mit
- Created: 2021-03-23T18:19:29.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-27T13:11:40.000Z (about 4 years ago)
- Last Synced: 2024-09-28T19:41:43.994Z (9 months ago)
- Topics: composer, laravel, laravel8, php, php7, webhook
- Language: PHP
- Homepage:
- Size: 223 KB
- Stars: 23
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Webhook
[](//packagist.org/packages/bencoderus/laravel-webhook)
[](//packagist.org/packages/bencoderus/laravel-webhook)
[](https://scrutinizer-ci.com/g/bencoderus/laravel-webhook/?branch=master)
[](https://scrutinizer-ci.com/g/bencoderus/laravel-webhook/build-status/master)Laravel webhook allows businesses to send webhooks to their merchants/clients with ease. This package also introduces a
new artisan command to generate a webhook class.## Requirement
- Composer v1.0/2.0
- Php (7.3 and above)
- Laravel (6 and above).## Installation
You can install the package via composer:
```bash
composer require bencoderus/laravel-webhook
```## Setup
Publish basic components. (migrations and configuration files)
``` php
php artisan webhook:install
```Run migrations
```bash
php artisan migrate
```## Basic usage
Create a new webhook class
```bash
php artisan make:webhook PaymentWebhook
```Creates a new webhook class in App\Http\Webhooks
You can format your webhook payload like a resource.
```php
public function data(): array
{
return [
'status' => $this->status,
'amount' => $this->amount,
'currency' => 'USD',
];
}
```
Sending a webhook.```php
$transaction = Transaction::first();$webhook = new PaymentWebhook($transaction);
$webhook->url('https://httpbin.com')->send();
```Sending with an encrypted signature
```php
$transaction = Transaction::first();$webhook = new PaymentWebhook($transaction);
$webhook->url('https://httpbin.com')
->withSignature('x-key', 'value_to_hash')
->send();
````The default hashing algorithm is sha512 you can change it by passing a different hashing algorithm as the third
parameter for the withSignature method. PHP currently supports over 50 hashing algorithms.Sending webhooks without using a Queue.
By default, all webhooks are dispatched using a queue to facilitate webhook retrial after failure. You can also send
webhooks without using a Queue by passing ``false`` to the send method.```php
$transaction = Transaction::first();$webhook = new PaymentWebhook($transaction);
$webhook->url('https://httpbin.com')->send(false);
```### Testing
``` bash
composer test
```## Configuration
- You can enable or disable sending webhook via config/webhook.php.
- You can also enable or disable logging webhook via config/webhook.php and more.### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
### Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
## Credits
- [Benjamin Iduwe](https://github.com/bencoderus)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.