PHPackages                             eoneopay/webhooks - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. eoneopay/webhooks

Abandoned → [eonx-com/webhooks](/?search=eonx-com%2Fwebhooks)ArchivedPackage[Queues &amp; Workers](/categories/queues)

eoneopay/webhooks
=================

Package to allow payloads to be sent based on event triggers

v0.20.6(6y ago)1326[2 PRs](https://github.com/loyaltycorp/webhooks/pulls)BSD-3-ClausePHPPHP &gt;=7.3

Since Mar 14Pushed 5y ago3 watchersCompare

[ Source](https://github.com/loyaltycorp/webhooks)[ Packagist](https://packagist.org/packages/eoneopay/webhooks)[ RSS](/packages/eoneopay-webhooks/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (16)Versions (27)Used By (0)

EoneoPay Activity/Webhook Library
=================================

[](#eoneopay-activitywebhook-library)

This library adds support for creating Activities which are then fired as webhooks to subscribers of those activities.

Installation
------------

[](#installation)

Use [Composer](https://getcomposer.org/) to install the package in your project:

```
composer require eoneopay/webhooks

```

Usage
-----

[](#usage)

Inject the `\EoneoPay\Webhooks\Activities\Interface\ActivityFactoryInterface` service into your application where an activity needs to be created. The send method on this interface accepts an `ActivityDataInterface` implementation that represents a specific activity to be created.

For each of the different activities you will fire inside your application you will need to create a class that implements `ActivityDataInterface`.

Theory of Operation
-------------------

[](#theory-of-operation)

- `ActivityFactoryInterface` receives an instance of `ActivityDataInterface`
    - The factory will then call the `PayloadManager` to build the payload for the `ActivityDataInterface`
    - The factory will take the payload and the `ActivityDataInterface` and save it as a new `ActivityInterface` entity.
    - Finally, the factory will dispatch an ActivityCreatedEvent
- The listeners will receive the event inside an asynchronous queue worker and call `WebhookManager#processActivity`
    - The WebhookManager will resolve any subscriptions for the activity
    - Then it will create a new WebhookRequest for each subscription
    - And dispatch a new WebhookRequestCreatedEvent.
- Another listener will accept this event and call `RequestProcessor#process`
    - Which builds a PSR7 Request
    - Sends the request
    - Records the result as a WebhookResponse

Integration
-----------

[](#integration)

#### Laravel

[](#laravel)

To integrate the package into your [Laravel](https://laravel.com) or [Lumen](https://lumen.laravel.com)you need to register the following service providers:

```
\EoneoPay\Webhooks\Bridge\Laravel\Providers\WebhookServiceProvider
\EoneoPay\Webhooks\Bridge\Laravel\Providers\WebhookEventServiceProvider

```

Any implementation of this library will need to:

- Implement and bind a service for the interface `EoneoPay\Webhooks\Subscription\Interfaces\SubscriptionResolverInterface`
- Implement a service for the interface `EoneoPay\Webhooks\Payload\Interfaces\PayloadBuilderInterface`
    - example

    ```
    interface WebHookPayloadBuilderInterface extends PayloadBuilderInterface
    { ... }

    final class PayloadBuilder implements WebHookPayloadBuilderInterface
    { ... }

    ```

    - bind and tag the service for the interface `YourNamespace\WebHookPayloadBuilderInterface`

    ```
    $this->app->bind(WebHookPayloadBuilderInterface::class, PayloadBuilder::class);
    $this->app->tag([WebHookPayloadBuilderInterface::class], ['webhooks_payload_builders']);

    ```
- Add `EoneoPay\Externals\Bridge\Laravel\ORM\ResolveTargetEntityExtension` to `config/doctrine.php` under the `extensions` key
- Modify `config/doctrine.php` to add the following changes to the configuration:

```
