Project dashboard
Keep configured SonarQube projects together and scan project health without opening a collection of browser tabs.
diff --git a/sonar-desk-licensing/MARKETING_LAUNCH_GUIDE.md b/sonar-desk-licensing/MARKETING_LAUNCH_GUIDE.md new file mode 100644 index 0000000..a948ee0 --- /dev/null +++ b/sonar-desk-licensing/MARKETING_LAUNCH_GUIDE.md @@ -0,0 +1,415 @@ +# SonarDesk Commercial Launch & Selling Guide + +## 1. Recommended commercial model + +Launch SonarDesk as a **direct-download macOS product with recurring licensing**. Use **Paddle as the production Merchant of Record (MoR)** for the initial launch because this codebase already has Paddle checkout, subscription lifecycle handling, customer lookup, upgrades/cancellation, webhook verification and product mapping implemented. + +Do **not** operate Paddle and Lemon Squeezy as two public checkout systems at launch. Pick one system of record. Running two providers doubles reconciliation, refund, subscription-state and support complexity. + +### Launch pricing + +| Plan | Monthly | Annual | Activations | Positioning | +|---|---:|---:|---:|---| +| Personal | £2.99/month | £24.99/year | 1 Mac | Individual developer | +| Professional | £4.99/month | £44.99/year | 3 Macs | Multi-Mac / professional workflow | + +Both plans should include the complete feature set and a **7-day free trial**. Do not artificially cripple Personal. The upgrade is based on activation allowance, which is simple to understand and easy to support. + +Annual should be the visual default. At these prices it produces better unit economics than very low monthly pricing because both Paddle and Lemon Squeezy publish a fixed transaction component in addition to their percentage fee. + +### Launch offer + +For the first 30 days, use a single promotion rather than permanently reducing the list price: + +- 20% off the first annual term using a launch coupon such as `LAUNCH20`. +- Do not discount monthly plans. +- Do not promise “lifetime” access while the licensing model is subscription-based. +- Keep the public list price stable so the product does not look disposable or permanently on sale. + +## 2. Why Paddle is the recommended launch provider + +Paddle's public pay-as-you-go pricing is 5% + $0.50 per checkout transaction and includes payments/billing, tax compliance and related Merchant of Record services. Paddle supports a sandbox, checkout, subscription lifecycle events and signed webhooks. + +This project is already designed around Paddle: + +- `CheckoutController` supplies Paddle price IDs to Paddle.js. +- `/api/v1/webhooks/paddle` accepts Paddle events. +- `PaddleWebhookVerifier` verifies signed webhook requests. +- `PurchaseProvisioner` provisions from `subscription.*` and `transaction.completed` events. +- `PaddleCatalogSeeder` maps Paddle products/prices to SonarDesk licence products. +- The portal can upgrade Personal to Professional and cancel Paddle subscriptions. + +That makes Paddle the lowest-risk route to a release. + +Official references: + +- Paddle pricing: https://www.paddle.com/pricing +- Paddle quickstart: https://developer.paddle.com/get-started/quickstart/ +- Paddle webhooks: https://developer.paddle.com/webhooks/ +- Paddle webhook simulator: https://developer.paddle.com/webhooks/simulator/ + +## 3. Paddle setup — complete production checklist + +### A. Create/complete the Paddle account + +1. Create the Paddle account and complete business verification. +2. Add the legal/business details that Paddle requests. +3. Configure payout details. +4. Add the production website/domain. +5. Complete Paddle's domain/default payment link approval before launch. +6. Keep the account in sandbox while integrating. Switch the application to production only after the full purchase flow has passed end-to-end testing. + +### B. Create the catalog + +Create two Paddle products: + +**SonarDesk Personal** +- Monthly recurring price: **£3.99 GBP / month** +- Annual recurring price: **£29.99 GBP / year** +- Trial: **7 days** + +**SonarDesk Professional** +- Monthly recurring price: **£6.99 GBP / month** +- Annual recurring price: **£59.99 GBP / year** +- Trial: **7 days** + +Use tax-inclusive/exclusive behaviour consistently with the checkout experience you want Paddle to present. Paddle, as MoR, calculates the applicable transaction taxes in checkout. + +Copy the resulting two product IDs and four price IDs. + +### C. Create application credentials + +In Paddle Developer Tools: + +1. Create a server API key for the licensing application. +2. Create a client-side token for Paddle.js. +3. Never put the server API key into browser JavaScript or source control. +4. Keep sandbox and production credentials separate. + +### D. Configure the webhook + +Create a Paddle notification destination: + +`https://YOUR-DOMAIN/api/v1/webhooks/paddle` + +Subscribe at minimum to: + +- `transaction.completed` +- `subscription.created` +- `subscription.updated` +- `subscription.activated` +- `subscription.canceled` +- `subscription.paused` +- `subscription.resumed` +- `subscription.past_due` + +The current code uses subscription events as the authoritative state for recurring licences. Paddle documents `transaction.completed` as the point at which transaction processing is complete. Paddle also documents at-least-once webhook delivery, so webhook handlers must remain idempotent; this project stores webhook event IDs for that purpose. + +Copy the webhook endpoint secret. + +### E. Production `.env` + +Set the following values on the production server. Do not commit them. + +```dotenv +APP_ENV=production +APP_DEBUG=false +APP_URL=https://YOUR-DOMAIN + +PADDLE_ENVIRONMENT=production +PADDLE_API_URL=https://api.paddle.com +PADDLE_API_KEY=YOUR_PRODUCTION_API_KEY +PADDLE_CLIENT_SIDE_TOKEN=YOUR_PRODUCTION_CLIENT_TOKEN +PADDLE_WEBHOOK_SECRET=YOUR_PRODUCTION_WEBHOOK_SECRET +PADDLE_WEBHOOK_TOLERANCE=300 + +PADDLE_PERSONAL_PRODUCT_ID=pro_... +PADDLE_PERSONAL_MONTHLY_PRICE_ID=pri_... +PADDLE_PERSONAL_ANNUAL_PRICE_ID=pri_... +PADDLE_PROFESSIONAL_PRODUCT_ID=pro_... +PADDLE_PROFESSIONAL_MONTHLY_PRICE_ID=pri_... +PADDLE_PROFESSIONAL_ANNUAL_PRICE_ID=pri_... +``` + +Also configure the existing SonarDesk licence signing keys, mailer, support email and application database. + +### F. Seed the price mapping + +After the production IDs are in `.env`: + +```bash +php artisan config:clear +php artisan db:seed --class=PaddleCatalogSeeder +php artisan config:cache +``` + +Check the `license_products` table and confirm there are four active Paddle rows with the correct product/price IDs and activation limits. + +### G. Test in sandbox before production + +Test every one of these scenarios: + +1. Personal monthly trial signup. +2. Personal annual trial signup. +3. Professional monthly trial signup. +4. Professional annual trial signup. +5. Licence email is delivered. +6. Licence activates in SonarDesk. +7. Second activation is rejected for Personal. +8. Up to three activations work for Professional. +9. Portal displays the licence. +10. Deactivate a Mac and activate a replacement Mac. +11. Upgrade Personal to Professional. +12. Cancel a subscription. +13. Simulate a failed payment / past-due subscription. +14. Simulate cancellation/expiry and confirm entitlement behaviour. +15. Replay the same webhook and confirm a duplicate licence is not created. +16. Refund test transaction and verify the intended entitlement state. +17. Verify support and transactional email deliverability. +18. Verify checkout on Safari and Chrome, including a private window. + +Use Paddle's webhook simulator for lifecycle testing as well as a real sandbox checkout. + +### H. Go live + +1. Create the production catalog (do not reuse sandbox IDs). +2. Add production API key/client token/webhook secret. +3. Seed the production catalog mapping. +4. Change `PADDLE_ENVIRONMENT=production` and `PADDLE_API_URL=https://api.paddle.com`. +5. Run `php artisan config:cache`. +6. Make one real low-value purchase with a controlled account. +7. Confirm the webhook, licence issuance, email, activation, portal and cancellation path. +8. Refund the test purchase in Paddle after validation if appropriate. + +## 4. Lemon Squeezy — alternative setup + +Lemon Squeezy is also a Merchant of Record and publishes base ecommerce pricing of 5% + $0.50 per transaction, with additional fees in some cases (for example certain international, PayPal and subscription payments). It also provides software licence keys and a License API. + +Official references: + +- Pricing: https://www.lemonsqueezy.com/pricing +- Fees: https://docs.lemonsqueezy.com/help/getting-started/fees +- Webhooks: https://docs.lemonsqueezy.com/help/webhooks +- License API: https://docs.lemonsqueezy.com/api/license-api + +### Important for this codebase + +The application has a Lemon Squeezy webhook verifier and basic purchase provisioning, but the **public checkout and customer portal are currently Paddle-first**. Lemon Squeezy should therefore be treated as an alternative migration path, not a second launch checkout, until its full subscription lifecycle and portal actions are implemented and tested. + +If switching to Lemon Squeezy: + +1. Create a store and complete activation/verification. +2. Create Personal and Professional products/variants with the same public pricing. +3. Decide whether SonarDesk's own signed licence system remains authoritative (recommended for consistency with the Mac app) or whether you migrate fully to Lemon Squeezy's License API. Do not mix both without a clear source of truth. +4. Create a webhook at: + + `https://YOUR-DOMAIN/api/v1/webhooks/lemon-squeezy` + +5. Generate a strong signing secret and set: + +```dotenv +LEMON_SQUEEZY_WEBHOOK_SECRET=YOUR_SECRET +``` + +6. Subscribe to the events the application needs, including order creation/refund and all relevant subscription state events. +7. Add `license_products` mappings where `payment_provider=lemon-squeezy`, mapping Lemon Squeezy variant IDs to `external_price_id`. +8. Implement/verify checkout links or overlay checkout on `/buy` before exposing Lemon Squeezy publicly. +9. Extend `PurchaseProvisioner::provisionLemonSqueezy()` so subscription updates, cancellations, pauses, payment failures/recovery and upgrades are handled with the same completeness as Paddle. +10. Add customer-portal actions for cancellation/change-of-plan or route customers to Lemon Squeezy's supported customer management flow. +11. Run the same end-to-end test matrix used for Paddle. + +Lemon Squeezy webhooks are signed and should always be verified. Their documentation states that unsuccessful webhook deliveries are retried; keep processing idempotent and persist event identity/state. + +## 5. Website conversion strategy + +The updated site now has a clearer commercial funnel: + +`Home → Features → Pricing → Paddle checkout → licence email → app activation → customer portal` + +### Home page + +The home page should answer these questions in order: + +1. What is it? A native macOS companion for SonarQube. +2. Why should I care? Faster access to project health and issues without browser-tab friction. +3. What does it do? Projects, quality gates, measures, issues, multiple servers and secure token storage. +4. Is it safe? SonarQube tokens are stored in macOS Keychain and server permissions remain authoritative. +5. What does it cost? Clear Personal and Professional pricing. +6. What should I do next? Start the 7-day free trial. + +### Product language to keep consistent + +**Primary one-line pitch** + +> SonarDesk is a native macOS companion for SonarQube that puts project health, quality gates and issues in one focused desktop workspace. + +**Short description** + +> Monitor SonarQube projects, quality gates, bugs, vulnerabilities, code smells and measures without living in a browser. + +**Positioning rule** + +Never imply SonarDesk replaces SonarQube. The stronger and more credible position is: **SonarQube remains the source of truth; SonarDesk makes everyday monitoring faster on macOS.** + +## 6. Launch channels + +### Phase 1 — pre-launch (7–14 days) + +- Finish notarised/signable release build and direct-download hosting. +- Finish Paddle production approval. +- Record a 30–60 second clean screen capture showing: connect server → project dashboard → issues → issue details. +- Produce 4–6 high-resolution screenshots. +- Create the launch coupon. +- Test website analytics and conversion events. +- Prepare support macros for activation, lost key, machine replacement, refund and SonarQube connection problems. +- Recruit 5–10 testers from existing developer contacts for final feedback and testimonials you have permission to publish. + +### Phase 2 — launch day + +Publish in this order: + +1. SonarDesk release page on your own site. +2. LinkedIn launch post. +3. Medium article. +4. Relevant developer communities where self-promotion is allowed and useful. +5. Existing customer/user mailing list only if recipients have consented to product marketing. + +Do not spam generic communities. Show the product solving a concrete SonarQube workflow problem. + +### Phase 3 — first 30 days + +Publish practical content rather than repeating sales copy: + +- “A faster way to review SonarQube issues on macOS” +- “How I use SonarQube quality gates in a desktop workflow” +- “What SonarDesk stores locally and how tokens are protected” +- “Personal vs Professional: which SonarDesk licence do I need?” +- Short release notes for every update + +Track: website → pricing clicks, checkout starts, trial starts, trial-to-paid conversion, cancellations, refunds, activation failures and support topics. + +## 7. LinkedIn release post + +**SonarDesk 1.0 is now available for macOS.** + +If SonarQube is part of your development workflow, you probably know the routine: open the browser, find the project, check the quality gate, scan the latest issues, then switch back to your editor. + +I built SonarDesk to make that recurring workflow faster on the Mac. + +SonarDesk is a native macOS companion for SonarQube. It brings project health, quality gates, bugs, vulnerabilities, code smells and measures into one focused desktop workspace. + +Version 1.0 includes: + +- Project dashboards and quality gate status +- Bugs, vulnerabilities and code smells +- Detailed issue views and filtering +- Server-side pagination for larger issue sets +- Multiple SonarQube server configurations +- SonarQube token storage in macOS Keychain +- Direct licensing and a self-service customer portal + +SonarQube remains the source of truth. SonarDesk is designed to make the information you check throughout the day quicker to reach and easier to keep visible. + +Personal is £24.99/year for one active Mac. Professional is £44.99/year for up to three active Macs. Monthly options are also available, and every plan starts with a 7-day free trial. + +Learn more and try SonarDesk: **YOUR_RELEASE_URL** + +#macOS #SonarQube #SoftwareDevelopment #CodeQuality #DeveloperTools + +## 8. Medium launch article + +# Introducing SonarDesk: a native SonarQube companion for macOS + +SonarQube is a valuable part of the software-development toolchain. It gives teams a central place to understand code quality, security findings and the state of quality gates. But the information developers need throughout the day often lives one browser context-switch away from the work itself. + +That is the problem I wanted SonarDesk to solve. + +## A focused Mac workspace for SonarQube + +SonarDesk is a native macOS companion for SonarQube. It is not a replacement for SonarQube, and it does not try to become another analysis engine. Your SonarQube server remains the source of truth. + +Instead, SonarDesk focuses on the recurring desktop workflow: open a project, see its health, check the quality gate, browse bugs, vulnerabilities and code smells, inspect an issue, and get back to the code. + +## What SonarDesk 1.0 includes + +The first release includes project dashboards, quality gate status, important measures, issue browsing and detailed issue views. Issue lists support practical filtering and server-side pagination, which helps keep the workflow manageable as result sets grow. + +SonarDesk can also keep multiple SonarQube server configurations available from the same Mac application. SonarQube access tokens are stored using macOS Keychain, and access remains governed by the permissions of the credentials you provide. + +## Why a native app? + +The browser is excellent for deep investigation and administration, and SonarDesk is not intended to remove it from the workflow. The benefit of a dedicated desktop app is focus. The project-health information you check repeatedly can have a consistent place on the Mac, separate from documentation, tickets, dashboards and all the other tabs competing for attention. + +## Direct distribution and licensing + +SonarDesk is distributed directly for macOS. Customers receive a licence and can manage activations through the SonarDesk customer portal. + +There are two plans. Personal supports one active Mac and costs £24.99 per year or £2.99 per month. Professional supports up to three active Macs and costs £44.99 per year or £4.99 per month. Both include the complete feature set and start with a seven-day free trial. + +## What comes next + +Version 1.0 establishes the core SonarQube monitoring workflow on macOS. Future releases will continue to focus on making project and issue review faster, clearer and more useful without turning SonarDesk into a replacement for the platform it connects to. + +If SonarQube is part of your day-to-day development workflow and you work on a Mac, you can learn more and start a free trial here: + +**YOUR_RELEASE_URL** + +## 9. Short announcement copy + +**SonarDesk 1.0 for macOS is available now.** Monitor SonarQube project health, quality gates, bugs, vulnerabilities and code smells from a focused native Mac app. Personal and Professional plans include a 7-day free trial. **YOUR_RELEASE_URL** + +## 10. Product listing copy + +### Name +SonarDesk + +### Tagline +Native SonarQube monitoring for macOS. + +### 80-character style description +Monitor SonarQube projects, quality gates and issues from your Mac. + +### Full product description +SonarDesk is a native macOS companion for developers and engineering teams using SonarQube. It provides a focused desktop view of project health, quality gates, measures, bugs, vulnerabilities and code smells, with detailed issue views, filtering, server-side pagination and support for multiple SonarQube server configurations. SonarQube tokens are stored in macOS Keychain, and your existing SonarQube permissions remain authoritative. + +## 11. Release readiness checklist + +Do not announce the public release until all items below are true: + +- Production app is signed with Developer ID and notarised. +- DMG/ZIP download is served over HTTPS. +- Version and build number are final. +- Sparkle/update mechanism, if used, is production-configured and signed. +- Privacy policy, terms and cookie information match actual behaviour. +- Support address is monitored. +- Paddle production checkout is approved and working. +- Webhook signature verification is enabled. +- Production webhook endpoint returns successful responses. +- Production product and price IDs are mapped in the database. +- Licence signing private key is backed up securely and is not in source control. +- Licence activation/validation/deactivation work from a clean Mac. +- Purchase email and support email pass SPF/DKIM/DMARC checks. +- Trial, paid renewal, cancellation, failed payment and refund paths are tested. +- Website has working Home, Features, Pricing, Release, Support, Privacy and Terms pages. +- Open Graph image and favicon render correctly. +- A real production purchase has been tested end-to-end. +- Download analytics and checkout conversion events are visible. +- Launch screenshots/video are ready. +- LinkedIn and Medium copy has been proofread and final URLs inserted. + +## 12. First commercial targets + +For the first 90 days, optimize for learning rather than vanity traffic. Review weekly: + +- Unique visitors to the product page +- Pricing-page visits +- Checkout starts +- Trial starts +- Trial-to-paid conversion +- Annual vs monthly mix +- Personal vs Professional mix +- Cancellation/refund reasons +- Activation failure rate +- Top support issues + +Do not change pricing every week. Collect enough data to understand whether the problem is traffic, positioning, checkout friction, onboarding or product value before changing the commercial model. diff --git a/sonar-desk-licensing/app/Console/Commands/SonarDeskAccountsBackfill.php b/sonar-desk-licensing/app/Console/Commands/SonarDeskAccountsBackfill.php new file mode 100644 index 0000000..ecd3464 --- /dev/null +++ b/sonar-desk-licensing/app/Console/Commands/SonarDeskAccountsBackfill.php @@ -0,0 +1,59 @@ +whereNotNull('customer_email') + ->where('customer_email', '<>', '') + ->select(['customer_email', 'customer_name']) + ->orderBy('customer_email') + ->get() + ->unique(fn (License $license) => strtolower(trim((string) $license->customer_email))); + + $missing = 0; + $created = 0; + + foreach ($customers as $license) { + $email = strtolower(trim((string) $license->customer_email)); + if ($email === '') { + continue; + } + + if (User::query()->whereRaw('lower(email) = ?', [$email])->exists()) { + continue; + } + + $missing++; + if ($this->option('dry-run')) { + $this->line("MISSING {$email}"); + continue; + } + + if ($accounts->ensure($email, $license->customer_name, ! $this->option('no-email'))) { + $created++; + $this->info("CREATED {$email}"); + } + } + + if ($this->option('dry-run')) { + $this->info("{$missing} account(s) would be created."); + } else { + $this->info("{$created} account(s) created."); + } + + return self::SUCCESS; + } +} diff --git a/sonar-desk-licensing/app/Console/Commands/SonarDeskLicenseDeliver.php b/sonar-desk-licensing/app/Console/Commands/SonarDeskLicenseDeliver.php new file mode 100644 index 0000000..68d5efe --- /dev/null +++ b/sonar-desk-licensing/app/Console/Commands/SonarDeskLicenseDeliver.php @@ -0,0 +1,20 @@ +option('limit'), 100)); + $count = $delivery->deliverPending($limit); + $this->info("Delivered {$count} licence email(s)."); + return self::SUCCESS; + } +} diff --git a/sonar-desk-licensing/app/Http/Controllers/Api/PaymentWebhookController.php b/sonar-desk-licensing/app/Http/Controllers/Api/PaymentWebhookController.php index e4c8036..502f650 100755 --- a/sonar-desk-licensing/app/Http/Controllers/Api/PaymentWebhookController.php +++ b/sonar-desk-licensing/app/Http/Controllers/Api/PaymentWebhookController.php @@ -11,68 +11,181 @@ use App\Services\Payments\PurchaseProvisioner; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; +use RuntimeException; +use Throwable; final class PaymentWebhookController extends Controller { - public function __invoke(string $provider, Request $request, PurchaseProvisioner $provisioner, LicenseDeliveryService $delivery): JsonResponse - { + public function __invoke( + string $provider, + Request $request, + PurchaseProvisioner $provisioner, + LicenseDeliveryService $delivery + ): JsonResponse { $raw = (string) $request->getContent(); + $verifier = match ($provider) { - 'paddle' => app(PaddleWebhookVerifier::class),'lemon-squeezy' => app(LemonSqueezyWebhookVerifier::class),default => null + 'paddle' => app(PaddleWebhookVerifier::class), + 'lemon-squeezy' => app(LemonSqueezyWebhookVerifier::class), + default => null, }; + if (! $verifier) { - return response()->json(['message' => 'Unknown webhook provider.'], 404); + return response()->json([ + 'message' => 'Unknown webhook provider.', + ], 404); } + try { $verifier->verify($request, $raw); - } catch (\Throwable $e) { + } catch (Throwable $e) { report($e); - return response()->json(['message' => 'Invalid webhook signature.'], 400); + return response()->json([ + 'message' => 'Invalid webhook signature.', + ], 400); } + try { - $payload = json_decode($raw, true, flags: JSON_THROW_ON_ERROR); - } catch (\Throwable) { - return response()->json(['message' => 'Invalid JSON.'], 400); + $payload = json_decode( + $raw, + true, + flags: JSON_THROW_ON_ERROR + ); + } catch (Throwable) { + return response()->json([ + 'message' => 'Invalid JSON.', + ], 400); } - $externalID = (string) ($provider === 'paddle' ? ($payload['event_id'] ?? '') : ($payload['meta']['event_name'] ?? '').':'.($payload['data']['id'] ?? '')); - $eventType = (string) ($provider === 'paddle' ? ($payload['event_type'] ?? 'unknown') : ($payload['meta']['event_name'] ?? 'unknown')); + + $externalID = (string) ( + $provider === 'paddle' + ? ($payload['event_id'] ?? '') + : ($payload['meta']['event_name'] ?? '') + .':' + .($payload['data']['id'] ?? '') + ); + + $eventType = (string) ( + $provider === 'paddle' + ? ($payload['event_type'] ?? 'unknown') + : ($payload['meta']['event_name'] ?? 'unknown') + ); + if ($externalID === '') { - return response()->json(['message' => 'Webhook event has no stable identifier.'], 400); + return response()->json([ + 'message' => 'Webhook event has no stable identifier.', + ], 400); } + $payloadHash = hash('sha256', $raw); + try { - DB::transaction(function () use ($provider, $externalID, $eventType, $payload, $raw, $provisioner) { - $event = LicenseWebhookEvent::firstOrCreate(['provider' => $provider, 'external_event_id' => $externalID], ['event_type' => $eventType, 'payload_sha256' => hash('sha256', $raw), 'payload' => $payload]); - if ($event->processed_at) { - return; - } - if (! hash_equals($event->payload_sha256, hash('sha256', $raw))) { - throw new \RuntimeException('Webhook ID was reused with a different payload.'); - } - try { - $provisioner->provision($provider, $payload); - $event->update(['processed_at' => now(), 'processing_error' => null]); - } catch (\Throwable $e) { - $event->update(['processing_error' => mb_substr($e->getMessage(), 0, 4000)]); - throw $e; - } - }); - } catch (\Throwable $e) { - report($e); + /* + * Paddle can deliver several related events concurrently. + * + * Laravel retries this complete transaction when MySQL reports + * a deadlock. Five attempts gives short-lived lock contention + * enough opportunity to resolve without acknowledging an event + * that was not actually processed. + */ + DB::transaction( + function () use ( + $provider, + $externalID, + $eventType, + $payload, + $payloadHash, + $provisioner + ): void { + /* + * Insert the event if this is its first delivery. + * + * Once present, lock the row so duplicate deliveries of + * the same event cannot provision concurrently. + */ + LicenseWebhookEvent::firstOrCreate( + [ + 'provider' => $provider, + 'external_event_id' => $externalID, + ], + [ + 'event_type' => $eventType, + 'payload_sha256' => $payloadHash, + 'payload' => $payload, + ] + ); - return response()->json(['message' => 'Webhook could not be processed.'], 500); + $event = LicenseWebhookEvent::query() + ->where('provider', $provider) + ->where('external_event_id', $externalID) + ->lockForUpdate() + ->firstOrFail(); + + if ($event->processed_at) { + return; + } + + if (! hash_equals( + (string) $event->payload_sha256, + $payloadHash + )) { + throw new RuntimeException( + 'Webhook ID was reused with a different payload.' + ); + } + + try { + $provisioner->provision( + $provider, + $payload + ); + + $event->processed_at = now(); + $event->processing_error = null; + $event->save(); + } catch (Throwable $e) { + /* + * This assignment is useful when the surrounding + * transaction eventually succeeds. If processing + * throws, the transaction itself is rolled back and + * Paddle will retry the event. + */ + $event->processing_error = mb_substr( + $e->getMessage(), + 0, + 4000 + ); + + $event->save(); + + throw $e; + } + }, + 5 + ); + } catch (Throwable $e) { + report($e); + return response()->json([ + 'message' => 'Webhook could not be processed.', + ], 500); } - // Delivery is intentionally outside the webhook transaction. A temporary mail - // outage must not roll back an otherwise valid Paddle event. Pending outbox - // rows remain available for portal resend or a later webhook delivery attempt. + /* + * Delivery deliberately happens outside the webhook transaction. + * + * A temporary SMTP failure must not undo a successfully processed + * payment event. The outbox retains anything that still needs + * delivery. + */ try { $delivery->deliverPending(10); - } catch (\Throwable $e) { + } catch (Throwable $e) { report($e); } - return response()->json(['ok' => true]); + return response()->json([ + 'ok' => true, + ]); } } diff --git a/sonar-desk-licensing/app/Http/Controllers/CheckoutController.php b/sonar-desk-licensing/app/Http/Controllers/CheckoutController.php index 2aeb9d6..47a5f82 100755 --- a/sonar-desk-licensing/app/Http/Controllers/CheckoutController.php +++ b/sonar-desk-licensing/app/Http/Controllers/CheckoutController.php @@ -17,10 +17,10 @@ final class CheckoutController extends Controller } $plans = [ - 'personal-monthly' => ['name' => 'Personal', 'billing' => 'Monthly', 'display_price' => '£1.99 / month', 'price_id' => $paddle['personal_monthly_price_id'], 'activation_limit' => 1], - 'personal-annual' => ['name' => 'Personal', 'billing' => 'Annual', 'display_price' => '£14.99 / year', 'price_id' => $paddle['personal_annual_price_id'], 'activation_limit' => 1], - 'professional-monthly' => ['name' => 'Professional', 'billing' => 'Monthly', 'display_price' => '£3.99 / month', 'price_id' => $paddle['professional_monthly_price_id'], 'activation_limit' => 3], - 'professional-annual' => ['name' => 'Professional', 'billing' => 'Annual', 'display_price' => '£29.99 / year', 'price_id' => $paddle['professional_annual_price_id'], 'activation_limit' => 3], + 'personal-monthly' => ['name' => 'Personal', 'billing' => 'Monthly', 'display_price' => '£2.99 / month', 'price_id' => $paddle['personal_monthly_price_id'], 'activation_limit' => 1], + 'personal-annual' => ['name' => 'Personal', 'billing' => 'Annual', 'display_price' => '£24.99 / year', 'price_id' => $paddle['personal_annual_price_id'], 'activation_limit' => 1], + 'professional-monthly' => ['name' => 'Professional', 'billing' => 'Monthly', 'display_price' => '£4.99 / month', 'price_id' => $paddle['professional_monthly_price_id'], 'activation_limit' => 3], + 'professional-annual' => ['name' => 'Professional', 'billing' => 'Annual', 'display_price' => '£44.99 / year', 'price_id' => $paddle['professional_annual_price_id'], 'activation_limit' => 3], ]; foreach ($plans as $plan) { diff --git a/sonar-desk-licensing/app/Http/Controllers/Portal/PortalController.php b/sonar-desk-licensing/app/Http/Controllers/Portal/PortalController.php index 3610f54..0f7c8dd 100755 --- a/sonar-desk-licensing/app/Http/Controllers/Portal/PortalController.php +++ b/sonar-desk-licensing/app/Http/Controllers/Portal/PortalController.php @@ -7,15 +7,14 @@ use App\Models\License; use App\Models\LicenseDeliveryOutbox; use App\Models\LicenseProduct; use App\Services\Payments\PaddleClient; +use App\Services\Licensing\LicenseDeliveryService; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Crypt; -use Illuminate\Support\Facades\Mail; use RuntimeException; final class PortalController extends Controller { - public function __construct(private PaddleClient $paddle) {} + public function __construct(private PaddleClient $paddle, private LicenseDeliveryService $delivery) {} private function owned(Request $request) { @@ -116,9 +115,11 @@ final class PortalController extends Controller return back()->withErrors(['licence' => 'This licence was issued manually and its full key is not recoverable. Contact support.']); } - $plain = Crypt::decryptString($out->encrypted_license_key); - Mail::raw("Your SonarDesk licence key is:\n\n{$plain}\n\nKeep this key private.", fn ($m) => $m->to($request->user()->email)->subject('Your SonarDesk licence key')); - $out->update(['delivered_at' => now()]); + $out->update([ + 'recipient_email' => strtolower($request->user()->email), + 'delivered_at' => null, + ]); + $this->delivery->deliverPending(1); return back()->with('status', 'Licence key sent to your verified email address.'); } diff --git a/sonar-desk-licensing/app/Models/LicenseDeliveryOutbox.php b/sonar-desk-licensing/app/Models/LicenseDeliveryOutbox.php index e0af182..ac7fb94 100755 --- a/sonar-desk-licensing/app/Models/LicenseDeliveryOutbox.php +++ b/sonar-desk-licensing/app/Models/LicenseDeliveryOutbox.php @@ -3,6 +3,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; class LicenseDeliveryOutbox extends Model { @@ -11,4 +12,9 @@ class LicenseDeliveryOutbox extends Model protected $fillable = ['license_id', 'encrypted_license_key', 'recipient_email', 'delivered_at']; protected $casts = ['delivered_at' => 'datetime']; + + public function license(): BelongsTo + { + return $this->belongsTo(License::class); + } } diff --git a/sonar-desk-licensing/app/Services/Accounts/PurchasedAccountProvisioner.php b/sonar-desk-licensing/app/Services/Accounts/PurchasedAccountProvisioner.php new file mode 100644 index 0000000..2498f89 --- /dev/null +++ b/sonar-desk-licensing/app/Services/Accounts/PurchasedAccountProvisioner.php @@ -0,0 +1,109 @@ +findByEmail($email); + + if ($user) { + return $user; + } + + $created = false; + + try { + $user = User::create([ + 'name' => $this->displayName($name, $email), + 'email' => $email, + 'email_verified_at' => now(), + 'password' => Str::random(64), + 'is_admin' => false, + ]); + + $created = true; + } catch (UniqueConstraintViolationException $exception) { + /* + * Another webhook may have created this account after our SELECT + * but before our INSERT. In that case the unique email constraint + * correctly rejects our INSERT; simply reuse the account that won + * the race. + */ + $user = $this->findByEmail($email); + + if (! $user) { + /* + * The unique violation was not caused by the email account + * appearing concurrently, so preserve the original failure. + */ + throw $exception; + } + } + + /* + * Only the request that actually created the account should send the + * account setup/reset link. Concurrent Paddle events must not result + * in several setup emails being sent to the customer. + */ + if ($created && $sendSetupLink) { + DB::afterCommit(static function () use ($email): void { + Password::sendResetLink(['email' => $email]); + }); + } + + return $user; + } + + private function findByEmail(string $email): ?User + { + return User::query() + ->whereRaw('LOWER(email) = ?', [$email]) + ->first(); + } + + private function displayName(?string $name, string $email): string + { + $name = trim((string) $name); + + if ($name !== '') { + return mb_substr($name, 0, 120); + } + + $localPart = strstr($email, '@', true) ?: 'SonarDesk Customer'; + $localPart = trim(str_replace(['.', '_', '-'], ' ', $localPart)); + + return mb_substr( + $localPart !== '' + ? ucwords($localPart) + : 'SonarDesk Customer', + 0, + 120 + ); + } +} diff --git a/sonar-desk-licensing/app/Services/Licensing/LicenseDeliveryService.php b/sonar-desk-licensing/app/Services/Licensing/LicenseDeliveryService.php index ecfd43a..38a2c05 100755 --- a/sonar-desk-licensing/app/Services/Licensing/LicenseDeliveryService.php +++ b/sonar-desk-licensing/app/Services/Licensing/LicenseDeliveryService.php @@ -12,6 +12,7 @@ final class LicenseDeliveryService { $delivered = 0; $pending = LicenseDeliveryOutbox::query() + ->with('license') ->whereNull('delivered_at') ->whereNotNull('recipient_email') ->where('recipient_email', '!=', '') @@ -20,16 +21,28 @@ final class LicenseDeliveryService ->get(); foreach ($pending as $outbox) { + $license = $outbox->license; + if (! $license) { + continue; + } + $plain = Crypt::decryptString($outbox->encrypted_license_key); $recipient = strtolower(trim((string) $outbox->recipient_email)); if ($recipient === '') { continue; } - Mail::raw( - "Thank you for choosing SonarDesk.\n\nYour licence key is:\n\n{$plain}\n\nOpen SonarDesk → Settings → Licence and enter this key to activate your Mac.\n\nKeep this key private. You can manage activations from the SonarDesk licence portal.", - fn ($message) => $message->to($recipient)->subject('Your SonarDesk licence key') - ); + $data = [ + 'customerName' => $license->customer_name, + 'edition' => $license->edition, + 'licenseKey' => $plain, + 'expiresAt' => $license->expires_at, + 'portalUrl' => config('sonardesk.portal_url') ?: url('/portal'), + ]; + + Mail::send(['html' => 'emails.license-key', 'text' => 'emails.license-key-text'], $data, function ($message) use ($recipient): void { + $message->to($recipient)->subject('Your SonarDesk licence key'); + }); $outbox->update(['delivered_at' => now()]); $delivered++; diff --git a/sonar-desk-licensing/app/Services/Payments/CustomerAccountProvisioner.php b/sonar-desk-licensing/app/Services/Payments/CustomerAccountProvisioner.php new file mode 100644 index 0000000..f970ea9 --- /dev/null +++ b/sonar-desk-licensing/app/Services/Payments/CustomerAccountProvisioner.php @@ -0,0 +1,63 @@ +first(); + if ($user) { + return $user; + } + + $displayName = trim((string) $name); + if ($displayName === '') { + $displayName = Str::headline(Str::before($email, '@')) ?: 'SonarDesk Customer'; + } + + $user = User::firstOrCreate( + ['email' => $email], + [ + 'name' => $displayName, + // The customer never receives or knows this password. They choose their + // own password through Laravel's signed, single-use reset flow. + 'password' => Str::random(64), + // Access still requires possession of the mailbox because account setup + // is completed using the reset link sent to this address. + 'email_verified_at' => now(), + ], + ); + + if ($user->wasRecentlyCreated) { + DB::afterCommit(function () use ($email): void { + try { + $status = Password::sendResetLink(['email' => $email]); + if ($status !== Password::RESET_LINK_SENT) { + Log::warning('SonarDesk customer account created but setup email was not sent.', [ + 'email' => $email, + 'status' => $status, + ]); + } + } catch (\Throwable $exception) { + // A mail outage must never undo a paid licence. The customer can + // also use Forgot Password once mail is restored. + report($exception); + } + }); + } + + return $user; + } +} diff --git a/sonar-desk-licensing/app/Services/Payments/PaddleClient.php b/sonar-desk-licensing/app/Services/Payments/PaddleClient.php index 4dc7eb8..f2f23aa 100755 --- a/sonar-desk-licensing/app/Services/Payments/PaddleClient.php +++ b/sonar-desk-licensing/app/Services/Payments/PaddleClient.php @@ -2,6 +2,7 @@ namespace App\Services\Payments; +use Illuminate\Http\Client\PendingRequest; use Illuminate\Http\Client\Response; use Illuminate\Support\Facades\Http; use RuntimeException; @@ -19,60 +20,147 @@ final class PaddleClient if (! $response->successful()) { return null; } + $data = $response->json('data'); return is_array($data) ? $data : null; } - public function updateSubscriptionPrice(string $subscriptionID, string $priceID): array + public function subscription(string $subscriptionID): array { $this->requireWritableConfiguration(); - $response = $this->request()->patch('/subscriptions/'.$subscriptionID, [ - 'proration_billing_mode' => 'prorated_immediately', - 'items' => [[ - 'price_id' => $priceID, - 'quantity' => 1, - ]], - ]); + $response = $this->request() + ->get('/subscriptions/'.$subscriptionID); - return $this->subscriptionData($response, 'Paddle could not update the subscription.'); + return $this->subscriptionData( + $response, + 'Paddle could not retrieve the subscription.' + ); } - public function cancelSubscriptionImmediately(string $subscriptionID): array - { + public function updateSubscriptionPrice( + string $subscriptionID, + string $priceID + ): array { $this->requireWritableConfiguration(); - $response = $this->request()->post('/subscriptions/'.$subscriptionID.'/cancel', [ - 'effective_from' => 'immediately', - ]); + /* + * Paddle restricts subscription item changes while a subscription + * is trialing. Existing item quantities may only be updated using + * do_not_bill during the trial. + * + * Once the subscription is outside its trial we can use normal + * immediate proration. + */ + $subscription = $this->subscription($subscriptionID); - return $this->subscriptionData($response, 'Paddle could not cancel the subscription.'); + $status = (string) ($subscription['status'] ?? ''); + + $prorationBillingMode = $status === 'trialing' + ? 'do_not_bill' + : 'prorated_immediately'; + + /* + * Preserve the existing subscription item and replace its price. + * + * Paddle treats the submitted items array as the desired + * subscription items, so quantity is retained where possible. + */ + $existingItems = is_array($subscription['items'] ?? null) + ? $subscription['items'] + : []; + + $existingItem = $existingItems[0] ?? []; + + $quantity = max( + 1, + (int) ($existingItem['quantity'] ?? 1) + ); + + $response = $this->request()->patch( + '/subscriptions/'.$subscriptionID, + [ + 'proration_billing_mode' => $prorationBillingMode, + 'items' => [ + [ + 'price_id' => $priceID, + 'quantity' => $quantity, + ], + ], + ] + ); + + return $this->subscriptionData( + $response, + 'Paddle could not update the subscription.' + ); } - private function request() + public function cancelSubscriptionImmediately( + string $subscriptionID + ): array { + $this->requireWritableConfiguration(); + + $response = $this->request()->post( + '/subscriptions/'.$subscriptionID.'/cancel', + [ + 'effective_from' => 'immediately', + ] + ); + + return $this->subscriptionData( + $response, + 'Paddle could not cancel the subscription.' + ); + } + + private function request(): PendingRequest { - return Http::baseUrl((string) config('sonardesk.paddle.api_url')) - ->withToken((string) config('sonardesk.paddle.api_key')) + return Http::baseUrl( + (string) config('sonardesk.paddle.api_url') + ) + ->withToken( + (string) config('sonardesk.paddle.api_key') + ) ->acceptJson() ->timeout(15); } private function requireWritableConfiguration(): void { - if (trim((string) config('sonardesk.paddle.api_key')) === '') { - throw new RuntimeException('Paddle subscription management is not configured.'); + if ( + trim( + (string) config('sonardesk.paddle.api_key') + ) === '' + ) { + throw new RuntimeException( + 'Paddle subscription management is not configured.' + ); } } - private function subscriptionData(Response $response, string $fallback): array - { + private function subscriptionData( + Response $response, + string $fallback + ): array { if (! $response->successful()) { - $detail = trim((string) ($response->json('error.detail') ?? '')); - throw new RuntimeException($detail !== '' ? $detail : $fallback); + $detail = trim( + (string) ( + $response->json('error.detail') + ?? '' + ) + ); + + throw new RuntimeException( + $detail !== '' + ? $detail + : $fallback + ); } $data = $response->json('data'); + if (! is_array($data)) { throw new RuntimeException($fallback); } diff --git a/sonar-desk-licensing/app/Services/Payments/PaddleWebhookVerifier.php b/sonar-desk-licensing/app/Services/Payments/PaddleWebhookVerifier.php index 6b862a2..477bcb7 100755 --- a/sonar-desk-licensing/app/Services/Payments/PaddleWebhookVerifier.php +++ b/sonar-desk-licensing/app/Services/Payments/PaddleWebhookVerifier.php @@ -3,36 +3,104 @@ namespace App\Services\Payments; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Log; use RuntimeException; final class PaddleWebhookVerifier implements WebhookVerifier { public function verify(Request $request, string $rawBody): void { - $secret = (string) config('sonardesk.paddle.webhook_secret'); - $header = (string) $request->header('Paddle-Signature'); - if ($secret === '' || $header === '') { - throw new RuntimeException('Paddle webhook verification is not configured.'); + $secret = trim((string) config('sonardesk.paddle.webhook_secret')); + $header = trim((string) $request->header('Paddle-Signature')); + + if ($secret === '') { + throw new RuntimeException('Paddle webhook secret is not configured.'); } + + if ($header === '') { + throw new RuntimeException('Paddle-Signature header is missing.'); + } + $parts = []; + foreach (explode(';', $header) as $part) { - [$k,$v] = array_pad(explode('=', trim($part), 2), 2, null); - if ($k && $v) { - $parts[$k][] = $v; + [$key, $value] = array_pad( + explode('=', trim($part), 2), + 2, + null + ); + + if ($key !== null && $value !== null) { + $parts[$key][] = $value; } } - $ts = isset($parts['ts'][0]) ? (int) $parts['ts'][0] : 0; + + $timestamp = isset($parts['ts'][0]) + ? (int) $parts['ts'][0] + : 0; + $signatures = $parts['h1'] ?? []; - $tolerance = max(1, (int) config('sonardesk.paddle.timestamp_tolerance', 300)); - if (! $ts || abs(time() - $ts) > $tolerance) { - throw new RuntimeException('Paddle webhook timestamp is outside the allowed tolerance.'); + + if ($timestamp === 0) { + throw new RuntimeException( + 'Paddle webhook signature has no timestamp.' + ); } - $expected = hash_hmac('sha256', $ts.':'.$rawBody, $secret); + + if ($signatures === []) { + throw new RuntimeException( + 'Paddle webhook signature has no h1 signature.' + ); + } + + $tolerance = max( + 1, + (int) config('sonardesk.paddle.timestamp_tolerance', 300) + ); + + $age = abs(time() - $timestamp); + + if ($age > $tolerance) { + throw new RuntimeException( + "Paddle webhook timestamp is outside the allowed tolerance ({$age}s)." + ); + } + + $signedPayload = $timestamp . ':' . $rawBody; + + $expected = hash_hmac( + 'sha256', + $signedPayload, + $secret + ); + + Log::debug('Paddle webhook signature diagnostics', [ + 'timestamp' => $timestamp, + 'age_seconds' => $age, + 'body_length' => strlen($rawBody), + 'body_sha256' => hash('sha256', $rawBody), + + // Safe diagnostics — do NOT log the secret itself. + 'secret_prefix' => substr($secret, 0, 11), + 'secret_length' => strlen($secret), + + 'received_signature_prefixes' => array_map( + static fn (string $signature): string => + substr($signature, 0, 12), + $signatures + ), + + 'expected_signature_prefix' => substr($expected, 0, 12), + ]); + foreach ($signatures as $signature) { if (hash_equals($expected, $signature)) { return; } } - throw new RuntimeException('Paddle webhook signature is invalid.'); + + throw new RuntimeException( + 'Paddle webhook signature is invalid.' + ); } } diff --git a/sonar-desk-licensing/app/Services/Payments/PurchaseProvisioner.php b/sonar-desk-licensing/app/Services/Payments/PurchaseProvisioner.php index 2cc9680..03b231b 100755 --- a/sonar-desk-licensing/app/Services/Payments/PurchaseProvisioner.php +++ b/sonar-desk-licensing/app/Services/Payments/PurchaseProvisioner.php @@ -3,14 +3,22 @@ namespace App\Services\Payments; use App\Models\License; +use App\Models\LicenseDeliveryOutbox; use App\Models\LicenseProduct; +use App\Services\Accounts\PurchasedAccountProvisioner; use App\Services\Licensing\LicenseIssuer; use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\DB; use RuntimeException; +use Throwable; final class PurchaseProvisioner { - public function __construct(private LicenseIssuer $issuer, private PaddleClient $paddle) {} + public function __construct( + private LicenseIssuer $issuer, + private PaddleClient $paddle, + private PurchasedAccountProvisioner $accounts, + ) {} public function provision(string $provider, array $event): void { @@ -26,16 +34,24 @@ final class PurchaseProvisioner return; } - throw new RuntimeException('Unsupported payment provider.'); + throw new RuntimeException( + 'Unsupported payment provider.' + ); } private function provisionPaddle(array $event): void { $type = (string) ($event['event_type'] ?? ''); - $data = $event['data'] ?? []; + + $data = is_array($event['data'] ?? null) + ? $event['data'] + : []; if (str_starts_with($type, 'subscription.')) { - $this->syncPaddleSubscription($type, $data); + $this->syncPaddleSubscription( + $type, + $data + ); return; } @@ -47,200 +63,724 @@ final class PurchaseProvisioner } if ($type === 'transaction.refunded') { - $transactionID = (string) ($data['id'] ?? ''); - if ($transactionID !== '') { - License::where('payment_provider', 'paddle') - ->where('external_order_id', $transactionID) + $transactionID = $this->nullableString( + $data['id'] ?? null + ); + + if ($transactionID !== null) { + License::query() + ->where('payment_provider', 'paddle') + ->where( + 'external_order_id', + $transactionID + ) ->whereNull('external_subscription_id') ->whereNull('revoked_at') - ->update(['revoked_at' => now(), 'revoke_reason' => 'Payment refunded']); + ->update([ + 'revoked_at' => now(), + 'revoke_reason' => 'Payment refunded', + ]); } } } - private function syncPaddleSubscription(string $type, array $data): void - { - $subscriptionID = (string) ($data['id'] ?? ''); - if ($subscriptionID === '') { - throw new RuntimeException('Paddle subscription webhook has no subscription ID.'); + private function syncPaddleSubscription( + string $type, + array $data + ): void { + $subscriptionID = $this->nullableString( + $data['id'] ?? null + ); + + if ($subscriptionID === null) { + throw new RuntimeException( + 'Paddle subscription webhook has no subscription ID.' + ); } - $status = (string) ($data['status'] ?? ''); - $item = $this->firstRecurringItem($data['items'] ?? []); - $price = $item['price'] ?? []; - $priceID = (string) ($price['id'] ?? $item['price_id'] ?? ''); - $productID = (string) ($price['product_id'] ?? $item['product_id'] ?? ''); + /* + * Multiple Paddle events for the same subscription can arrive + * simultaneously. + * + * The unique index protects database integrity, but by itself it + * cannot stop two workers from both observing "no licence" before + * either worker inserts the subscription ID. + * + * A MySQL advisory lock serialises provisioning for one Paddle + * subscription while still allowing unrelated subscriptions to be + * processed concurrently. + */ + $lockName = 'sonardesk:paddle:subscription:' + .$subscriptionID; - $license = License::where('payment_provider', 'paddle') - ->where('external_subscription_id', $subscriptionID) + $this->withMysqlLock( + $lockName, + function () use ( + $type, + $data, + $subscriptionID + ): void { + $this->syncLockedPaddleSubscription( + $type, + $data, + $subscriptionID + ); + } + ); + } + + private function syncLockedPaddleSubscription( + string $type, + array $data, + string $subscriptionID + ): void { + $transactionID = $this->nullableString( + $data['transaction_id'] ?? null + ); + + $status = (string) ($data['status'] ?? ''); + + $items = is_array($data['items'] ?? null) + ? $data['items'] + : []; + + $item = $this->firstRecurringItem($items); + + $price = is_array($item['price'] ?? null) + ? $item['price'] + : []; + + $priceID = (string) ( + $price['id'] + ?? $item['price_id'] + ?? '' + ); + + $productID = (string) ( + $price['product_id'] + ?? $item['product_id'] + ?? '' + ); + + /* + * The Paddle subscription ID is the authoritative identity for a + * recurring licence. + * + * lockForUpdate protects an existing licence while we mutate it. + * Creation of a missing licence is serialised by the advisory lock + * acquired by syncPaddleSubscription(). + */ + $license = License::query() + ->where('payment_provider', 'paddle') + ->where( + 'external_subscription_id', + $subscriptionID + ) + ->lockForUpdate() ->first(); if (! $license) { - $product = $this->mappedProduct('paddle', $priceID, $productID); - $custom = is_array($data['custom_data'] ?? null) ? $data['custom_data'] : []; - $customer = $this->paddle->customer($this->nullableString($data['customer_id'] ?? null)); + $product = $this->mappedProduct( + 'paddle', + $priceID, + $productID + ); + + $custom = is_array($data['custom_data'] ?? null) + ? $data['custom_data'] + : []; + + $customerID = $this->nullableString( + $data['customer_id'] ?? null + ); + + $customer = $this->paddle->customer( + $customerID + ) ?? []; + [$license] = $this->issuer->issue( $product, - $this->nullableString($custom['customer_name'] ?? $custom['name'] ?? $customer['name'] ?? null), - $this->nullableString($custom['customer_email'] ?? $custom['email'] ?? $customer['email'] ?? null), + $this->nullableString( + $custom['customer_name'] + ?? $custom['name'] + ?? $customer['name'] + ?? null + ), + $this->nullableString( + $custom['customer_email'] + ?? $custom['email'] + ?? $customer['email'] + ?? null + ), 'paddle', - $this->nullableString($data['transaction_id'] ?? null), - $this->nullableString($data['customer_id'] ?? null), + $transactionID, + $customerID, true, ); - $license->external_subscription_id = $subscriptionID; - } elseif ($priceID !== '' && $priceID !== $license->external_price_id) { - // Upgrades/downgrades change the entitlement attached to the existing key. - $product = $this->mappedProduct('paddle', $priceID, $productID); + + /* + * LicenseIssuer may return an existing licence if the + * transaction ID has already been seen. + * + * Re-read it with a row lock before attaching the Paddle + * subscription. + */ + $license = License::query() + ->whereKey($license->getKey()) + ->lockForUpdate() + ->firstOrFail(); + + /* + * Do not attach this subscription to a licence already owned + * by a different subscription. + */ + if ( + $license->external_subscription_id !== null + && $license->external_subscription_id + !== $subscriptionID + ) { + throw new RuntimeException( + 'Paddle transaction resolved to a licence ' + .'belonging to another subscription.' + ); + } + + $license->external_subscription_id = + $subscriptionID; + } elseif ( + $priceID !== '' + && $priceID !== $license->external_price_id + ) { + /* + * Upgrades and downgrades modify the entitlement attached to + * the existing licence key rather than issuing another key. + */ + $product = $this->mappedProduct( + 'paddle', + $priceID, + $productID + ); + $license->license_product_id = $product->id; $license->edition = $product->edition; - $license->activation_limit = $product->activation_limit; - $license->max_major_version = $product->max_major_version; + $license->activation_limit = + $product->activation_limit; + $license->max_major_version = + $product->max_major_version; } - $periodEnd = $data['current_billing_period']['ends_at'] ?? null; + $periodEnd = + $data['current_billing_period']['ends_at'] + ?? null; + $scheduled = $data['scheduled_change'] ?? null; - $cancelAt = is_array($scheduled) && ($scheduled['action'] ?? null) === 'cancel' + + $cancelAt = is_array($scheduled) + && ($scheduled['action'] ?? null) === 'cancel' ? ($scheduled['effective_at'] ?? null) : null; - $license->external_customer_id = $this->nullableString($data['customer_id'] ?? null) ?? $license->external_customer_id; - $license->external_price_id = $priceID !== '' ? $priceID : $license->external_price_id; - $license->subscription_status = $status !== '' ? $status : $license->subscription_status; - $license->current_period_ends_at = $periodEnd ? Carbon::parse($periodEnd) : $license->current_period_ends_at; - $license->cancel_scheduled_at = $cancelAt ? Carbon::parse($cancelAt) : null; + $license->external_customer_id = + $this->nullableString( + $data['customer_id'] ?? null + ) + ?? $license->external_customer_id; - if (in_array($status, ['active', 'trialing'], true)) { + $this->backfillPaddleCustomer( + $license, + $data + ); + + /* + * Account provisioning is expected to be idempotent. + */ + $this->accounts->ensure( + $license->customer_email, + $license->customer_name + ); + + if ($priceID !== '') { + $license->external_price_id = $priceID; + } + + if ( + $transactionID !== null + && ! $license->external_order_id + ) { + $license->external_order_id = + $transactionID; + } + + if ($status !== '') { + $license->subscription_status = $status; + } + + if ($periodEnd) { + $license->current_period_ends_at = + Carbon::parse($periodEnd); + } + + $license->cancel_scheduled_at = $cancelAt + ? Carbon::parse($cancelAt) + : null; + + /* + * Subscription entitlement. + */ + if (in_array( + $status, + ['active', 'trialing'], + true + )) { $license->revoked_at = null; $license->revoke_reason = null; - // Trialing/active subscriptions remain valid through the current period. - $license->expires_at = $periodEnd ? Carbon::parse($periodEnd) : null; + + $license->expires_at = $periodEnd + ? Carbon::parse($periodEnd) + : null; } elseif ($status === 'past_due') { - // Do not instantly kill a licence on the first failed renewal. Preserve the - // period Paddle says is current; a later canceled event ends entitlement. - $license->expires_at = $periodEnd ? Carbon::parse($periodEnd) : ($license->expires_at ?? now()->addDays(7)); - } elseif (in_array($status, ['canceled', 'paused'], true)) { + /* + * A failed renewal does not immediately destroy the + * entitlement. Preserve Paddle's current billing period when + * available and otherwise provide the existing grace period. + */ + $license->expires_at = $periodEnd + ? Carbon::parse($periodEnd) + : ( + $license->expires_at + ?? now()->addDays(7) + ); + } elseif (in_array( + $status, + ['canceled', 'paused'], + true + )) { $license->expires_at = now(); $license->revoked_at = now(); - $license->revoke_reason = $status === 'paused' ? 'Subscription paused' : 'Subscription canceled'; + + $license->revoke_reason = + $status === 'paused' + ? 'Subscription paused' + : 'Subscription canceled'; } $license->save(); } - private function syncPaddleTransaction(array $data): void - { - $subscriptionID = $this->nullableString($data['subscription_id'] ?? null); - $transactionID = (string) ($data['id'] ?? ''); + private function syncPaddleTransaction( + array $data + ): void { + $subscriptionID = $this->nullableString( + $data['subscription_id'] ?? null + ); - // Recurring purchases are provisioned from subscription events because those - // events contain the authoritative trial/status/current-period state. - if ($subscriptionID) { - License::where('payment_provider', 'paddle') - ->where('external_subscription_id', $subscriptionID) - ->whereNull('external_order_id') - ->update(['external_order_id' => $transactionID ?: null]); + $transactionID = $this->nullableString( + $data['id'] ?? null + ); + + /* + * A recurring transaction belongs to its subscription. + * + * Serialise this operation using the same lock as subscription + * provisioning. This prevents transaction.completed from updating + * the licence while a subscription event is still creating or + * modifying it. + */ + if ($subscriptionID !== null) { + $lockName = 'sonardesk:paddle:subscription:' + .$subscriptionID; + + $this->withMysqlLock( + $lockName, + function () use ( + $subscriptionID, + $transactionID + ): void { + if ($transactionID === null) { + return; + } + + $license = License::query() + ->where( + 'payment_provider', + 'paddle' + ) + ->where( + 'external_subscription_id', + $subscriptionID + ) + ->lockForUpdate() + ->first(); + + /* + * transaction.completed may legitimately arrive before + * subscription.created. In that case there is nothing + * to update yet. The subscription event will create the + * licence and Paddle's transaction_id can populate the + * order ID. + */ + if (! $license) { + return; + } + + if (! $license->external_order_id) { + $license->external_order_id = + $transactionID; + + $license->save(); + } + } + ); return; } - // Keep support for any future one-time Paddle licence product. - $item = $data['items'][0] ?? []; - $price = $item['price'] ?? []; - $priceID = (string) ($price['id'] ?? $item['price_id'] ?? ''); - $productID = (string) ($price['product_id'] ?? $item['product_id'] ?? ''); - $product = $this->mappedProduct('paddle', $priceID, $productID); - $custom = is_array($data['custom_data'] ?? null) ? $data['custom_data'] : []; - $customer = $this->paddle->customer($this->nullableString($data['customer_id'] ?? null)); + /* + * No subscription ID means this may be a one-time purchase. + */ + $items = is_array($data['items'] ?? null) + ? $data['items'] + : []; - $this->issuer->issue( + $item = $items[0] ?? []; + + $price = is_array($item['price'] ?? null) + ? $item['price'] + : []; + + $priceID = (string) ( + $price['id'] + ?? $item['price_id'] + ?? '' + ); + + $productID = (string) ( + $price['product_id'] + ?? $item['product_id'] + ?? '' + ); + + $product = $this->mappedProduct( + 'paddle', + $priceID, + $productID + ); + + $custom = is_array($data['custom_data'] ?? null) + ? $data['custom_data'] + : []; + + $customerID = $this->nullableString( + $data['customer_id'] ?? null + ); + + $customer = $this->paddle->customer( + $customerID + ) ?? []; + + [$license] = $this->issuer->issue( $product, - $this->nullableString($custom['customer_name'] ?? $custom['name'] ?? $customer['name'] ?? null), - $this->nullableString($custom['customer_email'] ?? $custom['email'] ?? $customer['email'] ?? null), + $this->nullableString( + $custom['customer_name'] + ?? $custom['name'] + ?? $customer['name'] + ?? null + ), + $this->nullableString( + $custom['customer_email'] + ?? $custom['email'] + ?? $customer['email'] + ?? null + ), 'paddle', $transactionID, - $this->nullableString($data['customer_id'] ?? null), + $customerID, true, ); + + $this->accounts->ensure( + $license->customer_email, + $license->customer_name + ); } - private function provisionLemonSqueezy(array $event): void - { - $type = (string) ($event['meta']['event_name'] ?? ''); - $attributes = $event['data']['attributes'] ?? []; - $order = (string) ($event['data']['id'] ?? $attributes['order_id'] ?? ''); + private function provisionLemonSqueezy( + array $event + ): void { + $type = (string) ( + $event['meta']['event_name'] + ?? '' + ); - if (in_array($type, ['order_refunded', 'subscription_expired'], true)) { - License::where('payment_provider', 'lemon-squeezy') + $attributes = is_array( + $event['data']['attributes'] ?? null + ) + ? $event['data']['attributes'] + : []; + + $order = (string) ( + $event['data']['id'] + ?? $attributes['order_id'] + ?? '' + ); + + if (in_array( + $type, + [ + 'order_refunded', + 'subscription_expired', + ], + true + )) { + License::query() + ->where( + 'payment_provider', + 'lemon-squeezy' + ) ->where('external_order_id', $order) ->whereNull('revoked_at') - ->update(['revoked_at' => now(), 'revoke_reason' => 'Payment refunded or subscription expired']); + ->update([ + 'revoked_at' => now(), + 'revoke_reason' => + 'Payment refunded or subscription expired', + ]); return; } - if (! in_array($type, ['order_created', 'subscription_created'], true)) { + if (! in_array( + $type, + [ + 'order_created', + 'subscription_created', + ], + true + )) { return; } $product = $this->mappedProduct( 'lemon-squeezy', - (string) ($attributes['variant_id'] ?? ''), - (string) ($attributes['product_id'] ?? ''), + (string) ( + $attributes['variant_id'] + ?? '' + ), + (string) ( + $attributes['product_id'] + ?? '' + ), ); - $this->issuer->issue( + [$license] = $this->issuer->issue( $product, - $this->nullableString($attributes['user_name'] ?? null), - $this->nullableString($attributes['user_email'] ?? null), + $this->nullableString( + $attributes['user_name'] ?? null + ), + $this->nullableString( + $attributes['user_email'] ?? null + ), 'lemon-squeezy', $order, - $this->nullableString($attributes['customer_id'] ?? null), + $this->nullableString( + $attributes['customer_id'] ?? null + ), true, ); + + $this->accounts->ensure( + $license->customer_email, + $license->customer_name + ); } - private function mappedProduct(string $provider, string $priceID, string $productID): LicenseProduct - { - // Price IDs are the authoritative mapping because monthly and annual prices - // intentionally share the same Paddle product ID. + private function backfillPaddleCustomer( + License $license, + array $data + ): void { + $custom = is_array( + $data['custom_data'] ?? null + ) + ? $data['custom_data'] + : []; + + $customerID = $this->nullableString( + $data['customer_id'] + ?? $license->external_customer_id + ); + + $customer = $this->paddle->customer( + $customerID + ) ?? []; + + $name = $this->nullableString( + $custom['customer_name'] + ?? $custom['name'] + ?? $customer['name'] + ?? null + ); + + $email = $this->nullableString( + $custom['customer_email'] + ?? $custom['email'] + ?? $customer['email'] + ?? null + ); + + if (! $license->customer_name && $name) { + $license->customer_name = $name; + } + + if (! $license->customer_email && $email) { + $email = strtolower($email); + + $license->customer_email = $email; + + LicenseDeliveryOutbox::query() + ->where( + 'license_id', + $license->id + ) + ->whereNull('delivered_at') + ->update([ + 'recipient_email' => $email, + ]); + } + } + + private function mappedProduct( + string $provider, + string $priceID, + string $productID + ): LicenseProduct { + /* + * Price IDs are authoritative because multiple billing intervals + * can belong to the same Paddle product. + */ if ($priceID !== '') { - $product = LicenseProduct::where('payment_provider', $provider) - ->where('external_price_id', $priceID) + $product = LicenseProduct::query() + ->where( + 'payment_provider', + $provider + ) + ->where( + 'external_price_id', + $priceID + ) ->where('active', true) ->first(); } else { - $product = LicenseProduct::where('payment_provider', $provider) - ->where('external_product_id', $productID) + $product = LicenseProduct::query() + ->where( + 'payment_provider', + $provider + ) + ->where( + 'external_product_id', + $productID + ) ->where('active', true) ->first(); } if (! $product) { - throw new RuntimeException("No active licence product maps to {$provider} price {$priceID} / product {$productID}."); + throw new RuntimeException( + "No active licence product maps to {$provider} " + ."price {$priceID} / product {$productID}." + ); } return $product; } - private function firstRecurringItem(array $items): array - { + private function firstRecurringItem( + array $items + ): array { foreach ($items as $item) { + if (! is_array($item)) { + continue; + } + if (($item['recurring'] ?? true) === true) { return $item; } } - return $items[0] ?? []; + $first = $items[0] ?? []; + + return is_array($first) + ? $first + : []; } - private function nullableString(mixed $value): ?string - { + private function nullableString( + mixed $value + ): ?string { if (! is_scalar($value)) { return null; } + $value = trim((string) $value); - return $value === '' ? null : $value; + return $value === '' + ? null + : $value; + } + + /** + * Execute a callback while holding a MySQL advisory lock. + * + * The lock is connection-scoped, so it must always be explicitly + * released in finally. A short timeout is sufficient because Paddle + * will retry failed webhook deliveries and the controller also retries + * database deadlocks. + */ + private function withMysqlLock( + string $name, + callable $callback + ): mixed { + /* + * MySQL advisory lock names have a finite length. Hashing also + * prevents provider supplied identifiers from creating unusual + * lock names. + */ + $lockName = 'sd:'.substr(hash('sha256', $name), 0, 61); + + $row = DB::selectOne( + 'SELECT GET_LOCK(?, ?) AS acquired', + [ + $lockName, + 10, + ] + ); + + $acquired = (int) ( + $row->acquired + ?? 0 + ); + + if ($acquired !== 1) { + throw new RuntimeException( + 'Could not acquire Paddle subscription lock.' + ); + } + + try { + return $callback(); + } finally { + try { + DB::selectOne( + 'SELECT RELEASE_LOCK(?) AS released', + [$lockName] + ); + } catch (Throwable $e) { + /* + * Do not hide the original processing exception merely + * because releasing an advisory lock failed. MySQL also + * releases connection-owned locks when the connection + * closes. + */ + report($e); + } + } } } diff --git a/sonar-desk-licensing/config/sonardesk.php b/sonar-desk-licensing/config/sonardesk.php old mode 100755 new mode 100644 index 55987ab..d56d04b --- a/sonar-desk-licensing/config/sonardesk.php +++ b/sonar-desk-licensing/config/sonardesk.php @@ -1,6 +1,7 @@ env('SONARDESK_ENVIRONMENT', 'develop'), 'product_code' => env('SONARDESK_PRODUCT_CODE', 'sonardesk'), 'private_key_path' => env('SONARDESK_LICENSE_PRIVATE_KEY_PATH'), 'public_key' => env('SONARDESK_LICENSE_PUBLIC_KEY'), @@ -26,6 +27,7 @@ return [ 'alert_emails' => array_values(array_filter(array_map('trim', explode(',', (string) env('SONARDESK_SUPPORT_ALERT_EMAILS', ''))))), 'notify_admin_users' => filter_var(env('SONARDESK_SUPPORT_NOTIFY_ADMINS', true), FILTER_VALIDATE_BOOL), ], + 'paddle' => [ 'api_key' => env('PADDLE_API_KEY'), 'client_side_token' => env('PADDLE_CLIENT_SIDE_TOKEN'), @@ -33,13 +35,15 @@ return [ 'api_url' => env('PADDLE_API_URL', env('APP_ENV') === 'production' ? 'https://api.paddle.com' : 'https://sandbox-api.paddle.com'), 'webhook_secret' => env('PADDLE_WEBHOOK_SECRET'), 'timestamp_tolerance' => (int) env('PADDLE_WEBHOOK_TOLERANCE', 300), - 'personal_product_id' => env('PADDLE_PERSONAL_PRODUCT_ID'), + + // SonarDesk is one Paddle product with four recurring prices. + 'product_id' => env('PADDLE_PRODUCT_ID'), 'personal_monthly_price_id' => env('PADDLE_PERSONAL_MONTHLY_PRICE_ID'), 'personal_annual_price_id' => env('PADDLE_PERSONAL_ANNUAL_PRICE_ID'), - 'professional_product_id' => env('PADDLE_PROFESSIONAL_PRODUCT_ID'), 'professional_monthly_price_id' => env('PADDLE_PROFESSIONAL_MONTHLY_PRICE_ID'), 'professional_annual_price_id' => env('PADDLE_PROFESSIONAL_ANNUAL_PRICE_ID'), ], + 'lemon_squeezy' => [ 'webhook_secret' => env('LEMON_SQUEEZY_WEBHOOK_SECRET'), ], diff --git a/sonar-desk-licensing/database/database.sqlite b/sonar-desk-licensing/database/database.sqlite deleted file mode 100755 index 379c23d..0000000 Binary files a/sonar-desk-licensing/database/database.sqlite and /dev/null differ diff --git a/sonar-desk-licensing/database/seeders/PaddleCatalogSeeder.php b/sonar-desk-licensing/database/seeders/PaddleCatalogSeeder.php index 29a2390..1c23d60 100755 --- a/sonar-desk-licensing/database/seeders/PaddleCatalogSeeder.php +++ b/sonar-desk-licensing/database/seeders/PaddleCatalogSeeder.php @@ -10,10 +10,10 @@ class PaddleCatalogSeeder extends Seeder public function run(): void { $products = [ - ['code' => 'personal-monthly', 'name' => 'SonarDesk Personal Monthly', 'edition' => 'Personal', 'activation_limit' => 1, 'external_product_id' => config('sonardesk.paddle.personal_product_id'), 'external_price_id' => config('sonardesk.paddle.personal_monthly_price_id')], - ['code' => 'personal-annual', 'name' => 'SonarDesk Personal Annual', 'edition' => 'Personal', 'activation_limit' => 1, 'external_product_id' => config('sonardesk.paddle.personal_product_id'), 'external_price_id' => config('sonardesk.paddle.personal_annual_price_id')], - ['code' => 'professional-monthly', 'name' => 'SonarDesk Professional Monthly', 'edition' => 'Professional', 'activation_limit' => 3, 'external_product_id' => config('sonardesk.paddle.professional_product_id'), 'external_price_id' => config('sonardesk.paddle.professional_monthly_price_id')], - ['code' => 'professional-annual', 'name' => 'SonarDesk Professional Annual', 'edition' => 'Professional', 'activation_limit' => 3, 'external_product_id' => config('sonardesk.paddle.professional_product_id'), 'external_price_id' => config('sonardesk.paddle.professional_annual_price_id')], + ['code' => 'personal-monthly', 'name' => 'SonarDesk Personal Monthly', 'edition' => 'Personal', 'activation_limit' => 1, 'external_product_id' => config('sonardesk.paddle.product_id'), 'external_price_id' => config('sonardesk.paddle.personal_monthly_price_id')], + ['code' => 'personal-annual', 'name' => 'SonarDesk Personal Annual', 'edition' => 'Personal', 'activation_limit' => 1, 'external_product_id' => config('sonardesk.paddle.product_id'), 'external_price_id' => config('sonardesk.paddle.personal_annual_price_id')], + ['code' => 'professional-monthly', 'name' => 'SonarDesk Professional Monthly', 'edition' => 'Professional', 'activation_limit' => 3, 'external_product_id' => config('sonardesk.paddle.product_id'), 'external_price_id' => config('sonardesk.paddle.professional_monthly_price_id')], + ['code' => 'professional-annual', 'name' => 'SonarDesk Professional Annual', 'edition' => 'Professional', 'activation_limit' => 3, 'external_product_id' => config('sonardesk.paddle.product_id'), 'external_price_id' => config('sonardesk.paddle.professional_annual_price_id')], ]; foreach ($products as $data) { diff --git a/sonar-desk-licensing/deploy.php b/sonar-desk-licensing/deploy.php index c80c1ac..628690d 100755 --- a/sonar-desk-licensing/deploy.php +++ b/sonar-desk-licensing/deploy.php @@ -18,14 +18,14 @@ add('shared_dirs', ['storage']); add('writable_dirs', ['storage', 'bootstrap/cache']); // Host Definitions -host('main') - ->set('hostname', 'sonardesk.absdev.net') +host('production') + ->set('hostname', 'sonardsk.absdev.net') ->set('remote_user', 'mag') ->set('branch', 'main') ->set('deploy_path', '/var/www/sonardesk/main'); host('stage') - ->set('hostname', 'sonardesk.absdev.net') + ->set('hostname', 'sonardesk.stage.absdev.net') ->set('remote_user', 'mag') ->set('branch', 'stage') ->set('deploy_path', '/var/www/sonardesk/stage'); diff --git a/sonar-desk-licensing/docs/RELEASE-HARDENING.md b/sonar-desk-licensing/docs/RELEASE-HARDENING.md new file mode 100644 index 0000000..afefa8a --- /dev/null +++ b/sonar-desk-licensing/docs/RELEASE-HARDENING.md @@ -0,0 +1,11 @@ + +## Licensing/email release checks + +- Production app endpoint: `https://sonardsk.absdev.net`. +- Stage app endpoint: `https://sonardesk.stage.absdev.net`. +- Production must use Paddle production credentials and the production webhook destination. +- `MAIL_MAILER` must be a real delivery transport in production; never `log`. +- Run the Laravel scheduler continuously so pending licence-key emails retry automatically. +- Verify `php artisan sonardesk:license-deliver` reports no unexpected pending delivery failures. +- Verify a real Paddle purchase creates one licence, sends one key email, activates a clean Mac, validates after relaunch, and deactivates from the portal. +- Never deploy `.env`, signing seeds, Paddle secrets, or webhook secrets from source control. diff --git a/sonar-desk-licensing/resources/views/checkout/buy.blade.php b/sonar-desk-licensing/resources/views/checkout/buy.blade.php index 294121f..76ff5be 100755 --- a/sonar-desk-licensing/resources/views/checkout/buy.blade.php +++ b/sonar-desk-licensing/resources/views/checkout/buy.blade.php @@ -33,8 +33,8 @@
Paddle is confirming your subscription. Your SonarDesk licence key will be sent to the email used at checkout. You can then activate it in SonarDesk → Settings → Licence.
-If the email takes a moment, wait for the Paddle confirmation and check your junk folder. You can also create a portal account with the same email address.
+Paddle is confirming your subscription. Your SonarDesk licence key is generated by our licensing server and emailed to the address used at checkout. You can then activate it in SonarDesk → Settings → Licence.
+Delivery normally follows the subscription webhook within moments. Check your junk folder if needed. You can also create a portal account with the same email address and resend the key from My licences.
Create portal account| + + |
Built around the checks developers make every day: project status, quality gates, issues, security findings and measures.
Keep configured SonarQube projects together and scan project health without opening a collection of browser tabs.
Surface the status and metrics that tell you whether a project needs attention, in a layout designed for quick review.
Browse the major SonarQube issue categories, filter the list and open an issue to inspect its details and context.
Issue browsing is designed to remain practical on projects with larger result sets by paging data from the server.
Configure the environments you work with and keep them available from the same SonarDesk workspace.
SonarQube tokens are stored using macOS Keychain rather than being treated as ordinary application preferences.
After checkout, the licence key is emailed to the customer. The SonarDesk portal can resend the key and manage licence information and Mac activations.
SonarDesk is distributed directly for macOS, giving the product a focused release and support channel outside the Mac App Store.
Choose Personal for one active Mac or Professional for up to three.