Add cash-on-delivery payment type with cart fee pipeline

This commit is contained in:
2026-07-19 03:35:16 +03:00
parent 4c00369005
commit 808c769595
4 changed files with 113 additions and 2 deletions
+42
View File
@@ -0,0 +1,42 @@
<?php
namespace Modules\Core\Providers;
use Illuminate\Support\ServiceProvider;
use Lunar\Pipelines\Cart\ApplyShipping;
class PaymentServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->mergeConfigFrom(__DIR__ . '/../../config/payment.php', 'payment');
}
public function boot(): void
{
config([
'lunar.payments.types' => array_merge(
config('lunar.payments.types', []),
config('payment.types', [])
),
]);
$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]);
}
}