feat: validación exacta de hora + remitente obligatorio + nombres guardados
- Hora exacta: tolerancia 0 (timestamp comprobante = timestamp email) - Remitente bloquea: si el email trae el nombre del remitente y no coincide, rechaza - Nuevo paso antes de mostrar datos bancarios: bot pide nombre completo del titular - Nombres aceptados se guardan en solicitudes_recarga.nombre_remitente - Próxima recarga: muestra botones con nombres anteriores confirmados o ingresa uno nuevo - Funciona igual en Telegram y web chat Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
b66b828ded
commit
bb311e7dcd
@@ -375,6 +375,24 @@ class PublicChat extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
// Capturar nombre del titular bancario para validación de recarga
|
||||
if ($this->flujo === 'pago.esperando_nombre') {
|
||||
$nombre = trim($texto);
|
||||
if (strlen($nombre) < 3) {
|
||||
$this->guardarMensajeBot($this->convId, "Por favor escribe tu nombre completo (mínimo 3 caracteres).");
|
||||
$this->cargarMensajes();
|
||||
$this->dispatchBrowserEvent('scroll-chat');
|
||||
return;
|
||||
}
|
||||
$monto = (int) ($this->flujoData['monto'] ?? 0);
|
||||
$this->flujoData['nombre_remitente'] = $nombre;
|
||||
$this->flujo = '';
|
||||
$this->mostrarTransferenciaDatos($monto);
|
||||
$this->cargarMensajes();
|
||||
$this->dispatchBrowserEvent('scroll-chat');
|
||||
return;
|
||||
}
|
||||
|
||||
// Capturar monto personalizado de recarga
|
||||
if ($this->flujo === 'recarga.monto_custom') {
|
||||
$monto = (int) preg_replace('/\D/', '', $texto);
|
||||
@@ -446,6 +464,8 @@ class PublicChat extends Component
|
||||
$action === 'asesor.solicitar' => $this->solicitarAsesor(),
|
||||
$action === 'pago.aplicar' => $this->aplicarRecargaValidada($data),
|
||||
$action === 'pago.reintentar' => $this->reintentarValidacionPago(),
|
||||
$action === 'pago.nombre_previo' => $this->usarNombrePrevio($data['nombre'] ?? ''),
|
||||
$action === 'pago.nombre_nuevo' => $this->pedirNombreNuevo(),
|
||||
$action === 'sesion.cerrar' => $this->confirmarCierreSesion(),
|
||||
$action === 'sesion.cerrar.confirmar' => $this->cerrarSesion(),
|
||||
default => $this->mostrarMenuPrincipal($this->convId),
|
||||
@@ -518,8 +538,10 @@ class PublicChat extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
$nombreParaValidar = $this->flujoData['nombre_remitente'] ?? $this->nombreUsuario;
|
||||
|
||||
$resultado = app(\App\Services\PagoValidadorService::class)->validar(
|
||||
$datosPago, $this->userId, $this->nombreUsuario, 'web'
|
||||
$datosPago, $this->userId, $nombreParaValidar, 'web'
|
||||
);
|
||||
|
||||
$motivo = $resultado['motivo'] ?? '';
|
||||
@@ -1109,6 +1131,51 @@ class PublicChat extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
$this->flujoData = ['monto' => $monto];
|
||||
|
||||
$nombresPrevios = $this->userId ? \App\Models\SolicitudRecarga::nombresPrevios($this->userId) : [];
|
||||
|
||||
if (! empty($nombresPrevios)) {
|
||||
$this->flujo = 'pago.esperando_nombre';
|
||||
|
||||
$botones = array_map(fn($n) => ['label' => $n, 'action' => 'pago.nombre_previo', 'data' => ['nombre' => $n]], $nombresPrevios);
|
||||
$botones[] = ['label' => '✏️ Usar otro nombre', 'action' => 'pago.nombre_nuevo', 'data' => []];
|
||||
|
||||
ChatMessage::create([
|
||||
'conversation_id' => $this->convId,
|
||||
'tipo' => 'bot',
|
||||
'tipo_ui' => 'buttons',
|
||||
'contenido' => '👤 ¿Desde qué cuenta vas a transferir? Elige un nombre anterior o usa uno nuevo:',
|
||||
'payload' => ['botones' => $botones],
|
||||
'leido' => true,
|
||||
]);
|
||||
} else {
|
||||
$this->flujo = 'pago.esperando_nombre';
|
||||
$this->guardarMensajeBot($this->convId, "👤 Escribe tu nombre completo tal como aparece en tu cuenta bancaria o billetera:");
|
||||
}
|
||||
|
||||
$this->cargarMensajes();
|
||||
$this->dispatchBrowserEvent('scroll-chat');
|
||||
}
|
||||
|
||||
private function usarNombrePrevio(string $nombre): void
|
||||
{
|
||||
if (strlen(trim($nombre)) < 3) {
|
||||
return;
|
||||
}
|
||||
$this->flujoData['nombre_remitente'] = trim($nombre);
|
||||
$this->flujo = '';
|
||||
$this->mostrarTransferenciaDatos((int) ($this->flujoData['monto'] ?? 0));
|
||||
}
|
||||
|
||||
private function pedirNombreNuevo(): void
|
||||
{
|
||||
$this->flujo = 'pago.esperando_nombre';
|
||||
$this->guardarMensajeBot($this->convId, "👤 Escribe tu nombre completo tal como aparece en tu cuenta bancaria:");
|
||||
}
|
||||
|
||||
private function mostrarTransferenciaDatos(int $monto): void
|
||||
{
|
||||
$banco = \App\Models\ChatConfig::get('recarga_banco_nombre', '');
|
||||
$clave = \App\Models\ChatConfig::get('recarga_banco_llave', '');
|
||||
$titular = \App\Models\ChatConfig::get('recarga_banco_titular', '');
|
||||
@@ -1134,11 +1201,11 @@ class PublicChat extends Component
|
||||
|
||||
$this->guardarMensajeBot($this->convId, "Cuando hayas transferido, envia el comprobante usando el icono de camara (📷) y el sistema lo validara automaticamente.\n\nTienes hasta 15 minutos despues de la transferencia para enviar el soporte.");
|
||||
|
||||
// Registrar solicitud pendiente
|
||||
if ($this->userId) {
|
||||
$solicitud = \App\Models\SolicitudRecarga::crear($this->userId, $monto, 'web');
|
||||
$nombre = $this->flujoData['nombre_remitente'] ?? null;
|
||||
$solicitud = \App\Models\SolicitudRecarga::crear($this->userId, $monto, 'web', $nombre);
|
||||
$this->flujo = 'pago.solicitud';
|
||||
$this->flujoData = ['solicitud_id' => $solicitud->id, 'monto' => $monto];
|
||||
$this->flujoData = array_merge($this->flujoData, ['solicitud_id' => $solicitud->id, 'monto' => $monto]);
|
||||
}
|
||||
|
||||
$this->volver('menu.principal');
|
||||
|
||||
Reference in New Issue
Block a user