45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?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]);
|
|
|
|
$this->loadRoutesFrom(__DIR__ . '/../Payment/routes/webhooks.php');
|
|
}
|
|
}
|