Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Paymenter/Paymenter

1096 stars
2 code files
View Paymenter/Paymenter on GitHub

app/Providers/EventServiceProvider.php

Open in GitHub
use App\Models\Extension;
use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
 
class EventServiceProvider extends ServiceProvider
{
// ...
 
public function boot()
{
// ...
try {
foreach (Extension::where('enabled', true)->get() as $extension) {
$module = $extension->namespace . 'Listeners';
if (!class_exists($module)) {
continue;
}
Event::subscribe(new $module);
}
} catch (\Exception $e) {
// If the database is not yet migrated, this will throw an exception.
}
}
 
// ...
 
public function discoverEventsWithin(): array
{
return [
$this->app->path('Listeners'),
];
}
}

app/Extensions/Events/DiscordWebhook/DiscordWebhookListeners.php

Open in GitHub
use App\Events\Invoice\InvoiceCreated;
use App\Events\Invoice\InvoicePaid;
use App\Events\Ticket\TicketCreated;
use App\Events\Ticket\TicketMessageCreated;
use App\Events\User\UserCreated;
use App\Helpers\ExtensionHelper;
 
class DiscordWebhookListeners
{
private function sendWebhook(string $title, string $message, array $fields = [], string $color = '00ff00'): void
{
// ...
}
 
public function handleInvoiceCreated(InvoiceCreated $event): void
{
// ...
}
 
public function handleInvoicePaid(InvoicePaid $event): void
{
// ...
}
 
 
public function newTicketMessage($event)
{
// ...
}
 
public function newUser($event)
{
// ...
}
 
public function newTicket($event)
{
// ...
}
 
// ...
 
public function subscribe(): array
{
return [
InvoiceCreated::class => 'handleInvoiceCreated',
InvoicePaid::class => 'handleInvoicePaid',
TicketMessageCreated::class => 'newTicketMessage',
UserCreated::class => 'newUser',
TicketCreated::class => 'newTicket',
];
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.