move into sonardesk

This commit is contained in:
Mark Gregory
2026-10-12 15:27:09 +01:00
parent 0ca7a2cf1e
commit e44a59a91e
7 changed files with 141 additions and 0 deletions
@@ -0,0 +1,42 @@
<?php
namespace Modules\Licensing\Http\Controllers;
use Illuminate\Routing\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Contracts\View\View;
/** Checkout handoff only. Billing/webhook processing remains on the legacy service. */
final class CheckoutHandoffController extends Controller
{
public function index(): View
{
return view('licensing::checkout.index', ['enabled' => $this->destination() !== null]);
}
public function redirect(): RedirectResponse
{
$destination = $this->destination();
abort_unless($destination !== null, 503, 'Checkout is not configured.');
return redirect()->away($destination, 302);
}
private function destination(): ?string
{
if (! config('sonardesk-integration.checkout_enabled')) {
return null;
}
$url = trim((string) config('sonardesk-integration.checkout_url'));
$parts = parse_url($url);
if (! is_array($parts) || strtolower($parts['scheme'] ?? '') !== 'https'
|| ! isset($parts['host']) || isset($parts['user']) || isset($parts['pass'])
|| isset($parts['fragment']) || isset($parts['port'])) {
return null;
}
$host = strtolower(rtrim($parts['host'], '.'));
$allowed = array_map(static fn ($value) => strtolower(rtrim((string) $value, '.')), config('sonardesk-integration.allowed_checkout_hosts', []));
if (! in_array($host, $allowed, true)) {
return null;
}
return $url;
}
}
@@ -21,6 +21,7 @@ final class IntegratedLicensingServiceProvider extends ServiceProvider
]);
$this->mergeConfigFrom(base_path('config/sonardesk-paddle.php'), 'sonardesk-paddle');
$this->mergeConfigFrom(base_path('config/sonardesk-integration.php'), 'sonardesk-integration');
$this->loadMigrationsFrom(__DIR__.'/../Database/Migrations');
$this->loadViewsFrom(__DIR__.'/../Resources/views', 'licensing');
$this->mergeConfigFrom(__DIR__.'/../Config/config.php', 'licensing');
@@ -34,5 +35,6 @@ final class IntegratedLicensingServiceProvider extends ServiceProvider
Route::group([], __DIR__.'/../Routes/admin.php');
Route::group([], __DIR__.'/../Routes/customer.php');
Route::group([], __DIR__.'/../Routes/distribution.php');
Route::group([], __DIR__.'/../Routes/checkout.php');
}
}
@@ -0,0 +1,15 @@
@extends('licensing::customer.layout')
@section('title', 'SonarDesk · Purchase')
@section('content')
<section class="card">
<h1>SonarDesk</h1>
<p>Native SonarQube project monitoring for macOS.</p>
<p>Choose your licence on our secure checkout service. Your subscription and licence are processed by the existing SonarDesk licensing platform.</p>
@if($enabled)
<p><a href="{{ route('sonardesk.checkout') }}" style="display:inline-block;background:#163b70;color:#fff;padding:12px 20px;border-radius:8px;text-decoration:none">View plans &amp; buy</a></p>
@else
<p role="status">Online checkout is not yet enabled on this site. No payment will be taken here.</p>
@endif
<p><a href="{{ route('sonardesk.downloads') }}">Downloads &amp; release notes</a> · <a href="{{ route('account.sonardesk.index') }}">My licences</a></p>
</section>
@endsection
+8
View File
@@ -0,0 +1,8 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Licensing\Http\Controllers\CheckoutHandoffController;
Route::middleware(['web', 'throttle:30,1'])->prefix('sonardesk')->name('sonardesk.')->group(function (): void {
Route::get('/buy', [CheckoutHandoffController::class, 'index'])->name('buy');
Route::get('/checkout', [CheckoutHandoffController::class, 'redirect'])->name('checkout');
});