Echte Credit-Wallet (1 Credit = 1 EUR) mit append-only Ledger als Basis fuer die Credit-Oekonomie aus dem Decision-Update (Rev. 4): - credit_wallets (denormalisierter Saldo) + credit_transactions (Ledger, vorzeichenbehaftet, balance_after, polymorphe reference) - CreditWalletService: einziger Schreibpfad, atomar mit Row-Lock, InsufficientCreditsException mit shortfall fuer den Mini-Checkout - Tier-Enum (Einzel/Starter/Business/Pro/Agency) + User::currentTier() - CreditPricingService: tier-gestaffelte Ableitung aus config/credits.php (Extra-PM 19/15/12/10/8, Boost 12/20/35, PDF 3, Depublish 25, Pruef-Quota) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
25 lines
676 B
PHP
25 lines
676 B
PHP
<?php
|
|
|
|
namespace App\Exceptions;
|
|
|
|
use RuntimeException;
|
|
|
|
/**
|
|
* Wird geworfen, wenn eine Wallet-Belastung das verfügbare Guthaben
|
|
* übersteigt. Trägt benötigtes und verfügbares Guthaben für den
|
|
* kontextuellen Mini-Checkout („Kostet 15 Credits, du hast 8").
|
|
*/
|
|
class InsufficientCreditsException extends RuntimeException
|
|
{
|
|
public function __construct(
|
|
public readonly int $required,
|
|
public readonly int $available,
|
|
) {
|
|
parent::__construct("Nicht genügend Credits: benötigt {$required}, verfügbar {$available}.");
|
|
}
|
|
|
|
public function shortfall(): int
|
|
{
|
|
return max(0, $this->required - $this->available);
|
|
}
|
|
}
|