2026-08-04 22:23:54 +07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Modules\Payment\Providers;
|
|
|
|
|
|
2026-08-09 16:20:21 +07:00
|
|
|
use Illuminate\Support\Facades\Event;
|
2026-08-04 22:23:54 +07:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2026-08-08 22:42:16 +07:00
|
|
|
use Modules\Payment\Enums\PaymentMethod;
|
2026-08-09 16:20:21 +07:00
|
|
|
use Modules\Payment\Events\PaymentCompleted;
|
|
|
|
|
use Modules\Payment\Events\RefundProcessed;
|
2026-08-08 22:42:16 +07:00
|
|
|
use Modules\Payment\Factories\PaymentGatewayFactory;
|
|
|
|
|
use Modules\Payment\Gateways\KbzMiniAppGateway;
|
2026-08-09 16:20:21 +07:00
|
|
|
use Modules\Payment\Listeners\MarkBookingPaid;
|
|
|
|
|
use Modules\Payment\Listeners\MarkBookingRefunded;
|
2026-08-04 22:23:54 +07:00
|
|
|
|
|
|
|
|
class PaymentServiceProvider extends ServiceProvider
|
|
|
|
|
{
|
2026-08-08 22:42:16 +07:00
|
|
|
public function register(): void
|
|
|
|
|
{
|
|
|
|
|
$this->app->singleton(PaymentGatewayFactory::class, function (): PaymentGatewayFactory {
|
|
|
|
|
$factory = new PaymentGatewayFactory;
|
|
|
|
|
$factory->register(PaymentMethod::KbzMiniApp, KbzMiniAppGateway::class);
|
|
|
|
|
|
|
|
|
|
return $factory;
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-08-04 22:23:54 +07:00
|
|
|
|
2026-08-09 16:20:21 +07:00
|
|
|
public function boot(): void
|
|
|
|
|
{
|
|
|
|
|
Event::listen(PaymentCompleted::class, MarkBookingPaid::class);
|
|
|
|
|
Event::listen(RefundProcessed::class, MarkBookingRefunded::class);
|
|
|
|
|
}
|
2026-08-04 22:23:54 +07:00
|
|
|
}
|