Führe ein unveränderliches Zahlungsjournal mit Ansicht und CSV-Export ein
Jede Zahlung und jede Erstattung wird in derselben Transaktion wie der Bestellstatus unveränderlich gebucht: Zeitpunkt, Betrag, Beleg beim Anbieter (Session, pi_, re_), handelnde Person, Begründung und Zahler samt Rechnungsadresse zum Zeitpunkt. Testzahlungen zählen nie als Umsatz. Verwaltung: Verkauf, Einnahmen und Erstattungen mit Zeitraum, Summen und Export. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6518d1b80f
commit
fe39e1efb6
15 files changed
+1485
-22
No files matched your search
@@ -8,6 +8,7 @@
|
||||
use App\Domain\Commerce\Payment;
|
||||
use App\Domain\Commerce\Shop;
|
||||
use App\Domain\Commerce\Stripe\StripeSignature;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -42,7 +43,7 @@ public function __invoke(Request $request, StripeSignature $signature, Checkout
|
||||
$session = (array) ($event['data']['object'] ?? []);
|
||||
|
||||
return match ($event['type']) {
|
||||
'checkout.session.completed', 'checkout.session.async_payment_succeeded' => $this->paid($session, $checkout),
|
||||
'checkout.session.completed', 'checkout.session.async_payment_succeeded' => $this->paid($session, $checkout, $event),
|
||||
'checkout.session.expired', 'checkout.session.async_payment_failed' => $this->notPaid($session, (string) $event['type']),
|
||||
default => response()->json(['received' => true, 'handled' => false]),
|
||||
};
|
||||
@@ -50,8 +51,9 @@ public function __invoke(Request $request, StripeSignature $signature, Checkout
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $session
|
||||
* @param array<string, mixed> $event
|
||||
*/
|
||||
private function paid(array $session, Checkout $checkout): JsonResponse
|
||||
private function paid(array $session, Checkout $checkout, array $event): JsonResponse
|
||||
{
|
||||
if (($session['payment_status'] ?? null) !== 'paid') {
|
||||
return response()->json(['received' => true, 'handled' => false]);
|
||||
@@ -73,6 +75,9 @@ private function paid(array $session, Checkout $checkout): JsonResponse
|
||||
$reference,
|
||||
(int) ($session['amount_total'] ?? -1),
|
||||
(string) ($session['currency'] ?? ''),
|
||||
(bool) ($event['livemode'] ?? $session['livemode'] ?? false),
|
||||
is_numeric($event['created'] ?? null) ? CarbonImmutable::createFromTimestampUTC((int) $event['created']) : null,
|
||||
filled($session['payment_intent'] ?? null) ? (string) $session['payment_intent'] : null,
|
||||
);
|
||||
} catch (DomainRuleException $exception) {
|
||||
// Dauerhafter Fehler (Betragsabweichung, Bestellung nicht mehr offen): nichts freischalten, Zahlung zur
|
||||
|
||||
Reference in new issue
Block a user