### Install Filament Webhook Client Package Source: https://context7.com/tappnetwork/filament-webhook-client/llms.txt Instructions for installing the Filament Webhook Client package using Composer. It also includes commands to publish optional configuration and translation files. ```bash # Install the package composer require tapp/filament-webhook-client:"^4.0" # Publish the configuration file (optional) php artisan vendor:publish --tag="filament-webhook-client-config" # Publish translations (optional) php artisan vendor:publish --tag="filament-webhook-client-translations" ``` -------------------------------- ### Install Filament Webhook Client Plugin Source: https://github.com/tappnetwork/filament-webhook-client/blob/4.x/README.md Installs the Filament Webhook Client plugin using Composer. This command requires Composer to be installed and accessible in your environment. ```bash composer require tapp/filament-webhook-client:"^4.0" ``` -------------------------------- ### Filament Webhook Client Configuration Example Source: https://github.com/tappnetwork/filament-webhook-client/blob/4.x/README.md Example of the published configuration file for the Filament Webhook Client plugin. This file defines the resources, models, policies, and navigation settings for the webhook client integration. ```php return [ 'resources' => [ 'WebhookCallResource' => \Tapp\FilamentWebhookClient\Resources\WebhookCallResource::class, ], 'models' => [ 'webhook-call' => \Spatie\WebhookClient\Models\WebhookCall::class, ], 'policies' => [ 'webhook-call' => \Tapp\FilamentWebhookClient\Policies\WebhookCallPolicy::class, ], 'navigation' => [ 'sort' => 1, 'icon' => 'heroicon-o-rectangle-stack', ], ]; ``` -------------------------------- ### Customize Navigation Labels with Translation Files in PHP Source: https://context7.com/tappnetwork/filament-webhook-client/llms.txt Modifies the navigation labels for the Filament Webhook Client by publishing and editing translation files. Examples are provided for English and Spanish, showing how to change the group name, singular label, and plural label. ```php 'System Logs', 'navigation.label' => 'Incoming Webhook', 'navigation.plural-label' => 'Incoming Webhooks', ]; // Spanish translation example // resources/lang/vendor/filament-webhook-client/es/filament-webhook-client.php return [ 'navigation.group' => 'Registros del Sistema', 'navigation.label' => 'Webhook Entrante', 'navigation.plural-label' => 'Webhooks Entrantes', ]; ``` -------------------------------- ### Run Plugin Tests Source: https://github.com/tappnetwork/filament-webhook-client/blob/4.x/README.md Executes the test suite for the Filament Webhook Client plugin. This command is used to ensure the plugin is functioning correctly and to verify any changes made during development. ```bash composer test ``` -------------------------------- ### Publish Filament Webhook Client Configuration Source: https://github.com/tappnetwork/filament-webhook-client/blob/4.x/README.md Publishes the configuration file for the Filament Webhook Client plugin. This allows for customization of resources, models, policies, and navigation. ```bash php artisan vendor:publish --tag="filament-webhook-client-config" ``` -------------------------------- ### Configure Spatie Webhook Client and Register Routes Source: https://context7.com/tappnetwork/filament-webhook-client/llms.txt This snippet shows the configuration for the Spatie Webhook Client package, defining settings for different webhook providers like Stripe and GitHub. It also includes the registration of webhook endpoints in Laravel's web routes file, mapping specific URLs to the configured webhook clients. ```php [ [ 'name' => 'stripe', 'signing_secret' => env('STRIPE_WEBHOOK_SECRET'), 'signature_header_name' => 'Stripe-Signature', 'signature_validator' => \Spatie\WebhookClient\SignatureValidator\DefaultSignatureValidator::class, 'webhook_profile' => \Spatie\WebhookClient\WebhookProfile\ProcessEverythingWebhookProfile::class, 'webhook_response' => \Spatie\WebhookClient\WebhookResponse\DefaultRespondsTo::class, 'webhook_model' => \Spatie\WebhookClient\Models\WebhookCall::class, 'store_headers' => ['content-type', 'stripe-signature', 'user-agent'], 'process_webhook_job' => \App\Jobs\ProcessStripeWebhook::class, ], [ 'name' => 'github', 'signing_secret' => env('GITHUB_WEBHOOK_SECRET'), 'signature_header_name' => 'X-Hub-Signature-256', 'signature_validator' => \Spatie\WebhookClient\SignatureValidator\DefaultSignatureValidator::class, 'webhook_profile' => \Spatie\WebhookClient\WebhookProfile\ProcessEverythingWebhookProfile::class, 'webhook_response' => \Spatie\WebhookClient\WebhookResponse\DefaultRespondsTo::class, 'webhook_model' => \Spatie\WebhookClient\Models\WebhookCall::class, 'store_headers' => ['content-type', 'x-github-event', 'x-hub-signature-256'], 'process_webhook_job' => \App\Jobs\ProcessGitHubWebhook::class, ], ], ]; // routes/web.php - Register webhook endpoints Route::webhooks('webhooks/stripe', 'stripe'); Route::webhooks('webhooks/github', 'github'); ``` -------------------------------- ### Configure Filament Webhook Client Options Source: https://context7.com/tappnetwork/filament-webhook-client/llms.txt Shows the default configuration file for Filament Webhook Client. It allows customization of resource, model, policy classes, and navigation settings like sort order and icon. ```php [ 'WebhookCallResource' => WebhookCallResource::class, ], // Model class for webhook calls (from Spatie package) 'models' => [ 'webhook-call' => WebhookCall::class, ], // Policy class for authorization 'policies' => [ 'webhook-call' => WebhookCallPolicy::class, ], // Navigation configuration 'navigation' => [ 'sort' => 1, // Position in navigation 'icon' => 'heroicon-o-rectangle-stack', // Navigation icon ], ]; ``` -------------------------------- ### Extend Spatie WebhookCall Model with Customizations Source: https://context7.com/tappnetwork/filament-webhook-client/llms.txt Illustrates how to create a custom WebhookCall model by extending the Spatie WebhookCall model. This allows for adding custom methods and relationships, and the configuration needs to be updated to point to this new model. ```php payload ?? []; } public function isSuccessful(): bool { return empty($this->exception); } public function getSourceName(): string { return $this->name ?? 'Unknown'; } } // config/filament-webhook-client.php return [ 'models' => [ 'webhook-call' => \App\Models\WebhookCall::class, ], // ... ]; ``` -------------------------------- ### Configure Filament Admin Panel Provider Source: https://github.com/tappnetwork/filament-webhook-client/blob/4.x/README.md Integrates the Filament Webhook Client plugin into a Filament admin panel by adding it to the `plugins()` method in the `AdminPanelProvider`. This makes the webhook calls resource available in the admin interface. ```php use Tapp\FilamentWebhookClient\FilamentWebhookClientPlugin; public function panel(Panel $panel): Panel { return $panel // ... ->plugins([ FilamentWebhookClientPlugin::make(), //... ]); } ``` -------------------------------- ### Register Filament Webhook Client Plugin in Panel Provider Source: https://context7.com/tappnetwork/filament-webhook-client/llms.txt Demonstrates how to register the FilamentWebhookClientPlugin within a Filament panel provider. This makes the Webhook Calls resource available in the admin panel. ```php default() ->id('admin') ->path('admin') ->login() ->plugins([ FilamentWebhookClientPlugin::make(), // ... other plugins ]); } } ``` -------------------------------- ### Customize WebhookCallResource Table and Filters in PHP Source: https://context7.com/tappnetwork/filament-webhook-client/llms.txt Extends the default WebhookCallResource to add custom table columns (ID, Source, URL, Status, Created At), filters (Source), record actions (View), and bulk actions (Delete). It also sets a default sort order. This customization is registered in the `config/filament-webhook-client.php` configuration file. ```php columns([ TextColumn::make('id') ->label('ID') ->sortable(), TextColumn::make('name') ->label('Source') ->sortable() ->searchable() ->badge() ->color(fn (string $state): string => match ($state) { 'stripe' => 'success', 'github' => 'info', default => 'gray', }), TextColumn::make('url') ->sortable() ->searchable() ->limit(50), IconColumn::make('exception') ->label('Status') ->boolean() ->trueIcon('heroicon-o-x-circle') ->falseIcon('heroicon-o-check-circle') ->trueColor('danger') ->falseColor('success') ->getStateUsing(fn ($record) => !empty($record->exception)), TextColumn::make('created_at') ->dateTime() ->sortable() ->since(), ]) ->filters([ SelectFilter::make('name') ->label('Source') ->options([ 'stripe' => 'Stripe', 'github' => 'GitHub', 'custom' => 'Custom', ]), ]) ->recordActions([ ViewAction::make() ->stickyModalFooter() ->stickyModalHeader(), ]) ->toolbarActions([ BulkActionGroup::make([ DeleteBulkAction::make(), ]), ]) ->defaultSort('created_at', 'desc'); } } // Register in config/filament-webhook-client.php return [ 'resources' => [ 'WebhookCallResource' => \App\Filament\Resources\CustomWebhookCallResource::class, ], // ... ]; ``` -------------------------------- ### Process Stripe Webhook Payload in Laravel Job Source: https://context7.com/tappnetwork/filament-webhook-client/llms.txt This PHP job class extends Spatie's `ProcessWebhookJob` to handle incoming Stripe webhooks. It uses a `match` expression to determine the type of Stripe event and dispatches corresponding private methods for specific event handling, such as payment success, new subscriptions, or canceled subscriptions. Unhandled events are logged. ```php // app/Jobs/ProcessStripeWebhook.php namespace App\Jobs; use Spatie\WebhookClient\Jobs\ProcessWebhookJob; class ProcessStripeWebhook extends ProcessWebhookJob { public function handle(): void { $payload = $this->webhookCall->payload; match ($payload['type'] ?? null) { 'payment_intent.succeeded' => $this->handlePaymentSuccess($payload), 'customer.subscription.created' => $this->handleSubscriptionCreated($payload), 'customer.subscription.deleted' => $this->handleSubscriptionCanceled($payload), default => logger()->info('Unhandled Stripe event', $payload), }; } private function handlePaymentSuccess(array $payload): void { // Process successful payment } private function handleSubscriptionCreated(array $payload): void { // Process new subscription } private function handleSubscriptionCanceled(array $payload): void { // Process canceled subscription } } ``` -------------------------------- ### PHP Custom Webhook Call Policy for Filament Source: https://context7.com/tappnetwork/filament-webhook-client/llms.txt Defines a custom policy for webhook call records in a PHP application, likely using Laravel and Filament. This policy controls access based on user roles ('admin', 'super-admin') and permissions ('view-webhooks'). It specifies which users can view, create, update, delete, restore, or force delete webhook calls. The policy is registered in the application's configuration file. ```php hasRole('admin') || $user->hasPermission('view-webhooks'); } /** * Determine whether the user can view a specific webhook call. */ public function view(User $user, WebhookCall $webhookCall): bool { return $user->hasRole('admin') || $user->hasPermission('view-webhooks'); } /** * Determine whether the user can create webhook calls. */ public function create(User $user): bool { // Webhook calls are created by the system, not users return false; } /** * Determine whether the user can update webhook calls. */ public function update(User $user, WebhookCall $webhookCall): bool { return false; } /** * Determine whether the user can delete webhook calls. */ public function delete(User $user, WebhookCall $webhookCall): bool { return $user->hasRole('super-admin'); } /** * Determine whether the user can restore webhook calls. */ public function restore(User $user, WebhookCall $webhookCall): bool { return false; } /** * Determine whether the user can permanently delete webhook calls. */ public function forceDelete(User $user, WebhookCall $webhookCall): bool { return $user->hasRole('super-admin'); } } // Register in config/filament-webhook-client.php return [ 'policies' => [ 'webhook-call' => \App\Policies\WebhookCallPolicy::class, ], // ... ]; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.