Wallet-Topup ueber Stripe (Credit-Pakete mit Bonus-Staffel)

End-to-end-Aufladung der Credit-Wallet, spiegelt den Einzel-PM-Fluss:

- Paket-Staffel mit Bonus in config/credits.php (10->10, 25->27, 50->55,
  100->115 Credits; price_cents netto, Stripe Tax ergaenzt USt.)
- credit_topups (Pending->Paid) + CreditTopupService: startTopup legt den
  Pending-Kauf an, fulfill() schreibt die Wallet idempotent gut (credited_at)
- StripeCheckoutService::forCreditTopup via checkoutCharge + credit_topup_id
  Metadata; ProcessStripeWebhook schreibt bei checkout.session.completed gut
- Checkout-Route /admin/me/checkout/credits/{pack} mit Rechnungsadress-Gate

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-06-17 14:56:23 +00:00
parent 69411b4c87
commit 344aac0740
10 changed files with 382 additions and 1 deletions

View file

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Wallet-Aufladung über Stripe. Spiegelt den Einzel-PM-Fluss: ein Pending-Kauf
* wird beim Checkout angelegt und per `checkout.session.completed`-Webhook auf
* `paid` gesetzt dann wird die Wallet gutgeschrieben (`credited_at` als
* Idempotenz-Marke gegen Doppelgutschrift bei wiederholten Webhooks).
*/
return new class extends Migration
{
public function up(): void
{
Schema::create('credit_topups', function (Blueprint $table): void {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('pack_key');
$table->integer('credits');
$table->integer('price_cents');
$table->string('currency', 3)->default('EUR');
$table->string('status')->default('pending');
$table->string('stripe_checkout_session_id')->nullable();
$table->string('stripe_payment_intent_id')->nullable();
$table->timestamp('paid_at')->nullable();
$table->timestamp('credited_at')->nullable();
$table->timestamps();
$table->index(['user_id', 'status']);
});
}
public function down(): void
{
Schema::dropIfExists('credit_topups');
}
};