feat: clean credits users
CI / 🧪 Tests Laravel (push) Successful in 2m0s
CI / 🐳 Build & Push Image (push) Successful in 35s

This commit is contained in:
2026-08-07 15:32:40 +02:00
parent eac86afa53
commit 68560655f3
44 changed files with 417 additions and 661 deletions
+5 -18
View File
@@ -4,8 +4,7 @@ namespace App\Services;
use App\Enums\PaymentTransactionStatus;
use App\Enums\PaymentTransactionType;
use App\Models\CreditLedgerEntry;
use App\Models\CreditProduct;
use App\Models\BillingProduct;
use App\Models\PaymentTransaction;
use App\Models\User;
@@ -16,7 +15,7 @@ class PaymentTransactionRecorder
*/
public function recordCheckoutSession(
?User $user,
?CreditProduct $product,
?BillingProduct $product,
string $stripeCheckoutSessionId,
PaymentTransactionStatus $status = PaymentTransactionStatus::PENDING,
?string $stripeEventId = null,
@@ -25,9 +24,6 @@ class PaymentTransactionRecorder
?string $stripePaymentIntentId = null,
?int $amount = null,
?string $currency = null,
?int $creditsExpected = null,
?int $creditsGranted = null,
?CreditLedgerEntry $ledgerEntry = null,
?string $invoiceUrl = null,
?string $invoicePdfUrl = null,
?string $errorMessage = null,
@@ -37,8 +33,7 @@ class PaymentTransactionRecorder
'stripe_checkout_session_id' => $stripeCheckoutSessionId,
], [
'user_id' => $user?->getKey(),
'credit_product_id' => $product?->getKey(),
'credit_ledger_entry_id' => $ledgerEntry?->getKey(),
'billing_product_id' => $product?->getKey(),
'type' => PaymentTransactionType::CHECKOUT,
'status' => $status,
'stripe_event_id' => $stripeEventId,
@@ -47,8 +42,6 @@ class PaymentTransactionRecorder
'stripe_payment_intent_id' => $stripePaymentIntentId,
'amount' => $amount,
'currency' => $currency,
'credits_expected' => $creditsExpected ?? $product?->credits,
'credits_granted' => $creditsGranted ?? 0,
'invoice_url' => $invoiceUrl,
'invoice_pdf_url' => $invoicePdfUrl,
'error_message' => $errorMessage,
@@ -62,7 +55,7 @@ class PaymentTransactionRecorder
*/
public function recordInvoice(
?User $user,
?CreditProduct $product,
?BillingProduct $product,
string $stripeInvoiceId,
?string $stripePriceId,
PaymentTransactionStatus $status,
@@ -73,9 +66,6 @@ class PaymentTransactionRecorder
?string $stripeSubscriptionId = null,
?int $amount = null,
?string $currency = null,
?int $creditsExpected = null,
?int $creditsGranted = null,
?CreditLedgerEntry $ledgerEntry = null,
?string $invoiceUrl = null,
?string $invoicePdfUrl = null,
?string $errorMessage = null,
@@ -86,8 +76,7 @@ class PaymentTransactionRecorder
'stripe_price_id' => $stripePriceId,
], [
'user_id' => $user?->getKey(),
'credit_product_id' => $product?->getKey(),
'credit_ledger_entry_id' => $ledgerEntry?->getKey(),
'billing_product_id' => $product?->getKey(),
'type' => PaymentTransactionType::SUBSCRIPTION_INVOICE,
'status' => $status,
'stripe_event_id' => $stripeEventId,
@@ -97,8 +86,6 @@ class PaymentTransactionRecorder
'stripe_subscription_id' => $stripeSubscriptionId,
'amount' => $amount,
'currency' => $currency,
'credits_expected' => $creditsExpected ?? $product?->credits,
'credits_granted' => $creditsGranted ?? 0,
'invoice_url' => $invoiceUrl,
'invoice_pdf_url' => $invoicePdfUrl,
'error_message' => $errorMessage,