mirror of
https://github.com/anna-sara/lan_kiosk
synced 2026-09-03 11:25:02 +02:00
24 lines
825 B
PHP
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.");
|
|
}
|
|
}
|