Laravel Inbox Pattern - ShipSaaS
GitHubShipSaaS
  • Laravel Inbox Pattern - ShipSaaS
  • Installation
  • Usage
    • Glossary
    • Configuration
    • Receive Webhook Requests
    • Inbox Processor / Handler
    • Run The Inbox Process
  • Use cases for Inbox
  • Architechture Notes
  • Best Practices
  • Database Info
Powered by GitBook
On this page
  1. Usage

Inbox Processor / Handler

It is like the Queue Worker, you need to create the handler classes and register for the particular topic.

Simply bind your own Handler class using addProcessor method from our helper. You can add multiple processors, Inbox Process will loop through all of them and execute.

use ShipSaasInboxProcess\InboxProcessSetup;

// AppServiceProvider@boot
InboxProcessSetup::addProcessor(
    'stripe', 
    StripeInvoiceWebhookHandler::class
);
InboxProcessSetup::addProcessor(
    'stripe', 
    StripePaymentWebhookHandler::class
);

The Inbox Process will either use the handle method or __invoke.

Your processor class will be resolved using the super cool dependency injection powered by Laravel.

class StripeInvoiceWebhookHandler 
{
    public function __construct(
        private StripeClient $stripeClient
    ) {}

    public function handle(array $payload): void
    {
        if ($payload['type'] !== 'invoice') {
            return;
        }
        
        // handle this request
    }
}
PreviousReceive Webhook RequestsNextRun The Inbox Process

Last updated 1 year ago