mergeConfigFrom(__DIR__ . '/../../config/payment.php', 'payment'); $this->app->singleton(PaymentDriverRegistry::class); } public function boot(): void { $registry = $this->app->make(PaymentDriverRegistry::class); $registry->register('offline', OfflinePaymentDriver::class, 'Offline / Manual'); $registry->register('stripe', StripePaymentDriver::class, 'Stripe'); $registry->register('bank-transfer', BankTransferPaymentDriver::class, 'Bank Transfer'); $registry->register('cash-on-delivery', CashOnDeliveryPaymentDriver::class, 'Cash on Delivery'); $cartPipeline = config('lunar.cart.pipelines.cart', []); $insertAfter = array_search(ApplyShipping::class, $cartPipeline, true); foreach (config('payment.cart_pipeline', []) as $pipe) { if (in_array($pipe, $cartPipeline, true)) { continue; } if ($insertAfter === false) { $cartPipeline[] = $pipe; } else { array_splice($cartPipeline, $insertAfter + 1, 0, [$pipe]); $insertAfter++; } } config(['lunar.cart.pipelines.cart' => $cartPipeline]); // Same contract-swap mechanism this codebase already uses for // Customer/Staff (see e.g. consuming apps' own AppServiceProvider, // ModelManifest::replace(Contracts\Customer::class, ...)) — every // place Lunar's own code resolves a transaction via // Transaction::modelClass() (Order::transactions()'s own relation // included) gets Modules\Core\Payment\Models\CoreTransaction // instead of the vendor's own Transaction. That subclass's // driver() override is the ENTIRE fix for the admin panel's // refund/capture actions silently landing on our real payment // system — see CoreTransaction's own docblock. Lunar's own // Payments facade/PaymentManager is never touched at all. ModelManifest::replace(TransactionContract::class, CoreTransaction::class); Event::listen(PaymentMethodCreated::class, [LogPaymentMethodActivity::class, 'handleCreated']); Event::listen(PaymentMethodUpdated::class, [LogPaymentMethodActivity::class, 'handleUpdated']); Event::listen(PaymentMethodDeleted::class, [LogPaymentMethodActivity::class, 'handleDeleted']); $this->loadRoutesFrom(__DIR__ . '/../Payment/routes/webhooks.php'); if ($this->app->runningInConsole()) { $this->commands([SyncPaymentDriversCommand::class]); } } }