lan_kiosk/app/Console/Commands/PruneStaleTransactions.php
Anna-Sara Sélea df9f1cf17e Swish feature
2026-08-22 16:13:42 +02:00

24 lines
825 B
PHP

<?php
namespace App\Console\Commands;
use App\Models\Transaction;
use Illuminate\Console\Command;
class PruneStaleTransactions extends Command
{
protected $signature = 'app:prune-stale-transactions';
protected $description = 'Mark pending transactions older than 2 hours as expired';
public function handle()
{
// Marked rather than deleted: Swish retries a callback for longer than this,
// and a payment whose row is gone can never be booked. An expired row is
// still matched by the callback, and is there to reconcile against.
$expired = Transaction::where('status', 'pending')
->where('created_at', '<', now()->subHours(2))
->update(['status' => 'expired']);
$this->info("Marked {$expired} stale transaction(s) as expired.");
}
}