Prevent double-confirmation of same payment by different users

- Create pagos_confirmados table to track consumed email receipts
- PagoValidadorService now validates: valor + fecha + hora (±10min) + llave Bancolombia
- Each matched email is hashed (sha1 body+date) and marked as used; a second
  match returns estado=ya_usado instead of confirmado
- Add partial remitente name matching against the registered user's name
- GeminiVisionService prompt now extracts llave (@xxx) from the receipt image
- TelegramBotService shows distinct message for ya_usado state

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro
2026-07-18 03:30:20 +00:00
co-authored by Claude Sonnet 4.6
parent 157691e166
commit ba4ec8b6cf
5 changed files with 207 additions and 26 deletions
@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('pagos_confirmados', function (Blueprint $table) {
$table->id();
$table->string('email_hash', 64)->unique();
$table->unsignedBigInteger('usuario_id')->nullable();
$table->integer('valor');
$table->string('canal', 20)->default('telegram');
$table->string('banco', 60)->nullable();
$table->string('referencia', 80)->nullable();
$table->timestamp('confirmado_en')->useCurrent();
$table->index('usuario_id');
});
}
public function down(): void
{
Schema::dropIfExists('pagos_confirmados');
}
};