HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/qas.sports-crowd.com/resources/views/paymentGateway/pay/js.blade.php
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

<script>
    $(document).ready(function() {
        function formatCurrency(value) {
            return new Intl.NumberFormat('en-US', {
                style: 'currency',
                currency: <?php echo json_encode($corporateIdentity->currency); ?>,
                currencyDisplay: 'narrowSymbol',
                minimumFractionDigits: <?php echo json_encode($corporateIdentity->minimum_fraction_digits); ?>,
                maximumFractionDigits: <?php echo json_encode($corporateIdentity->maximum_fraction_digits); ?>,
            }).format(value);
        }

        // Formatear precios en la sección de resumen
        $('.price').each(function() {
            let amountText = $(this).text();
            let formatted = formatCurrency(amountText);
            $(this).text(formatted);
        });
    });

    // Temporizador 30 minutos
    let time = <?php echo $paymentDetails->duration; ?>;
    let timerInterval;
    const timerEl = document.getElementById("timer");

    function updateTimer() {
        if (time <= 0) {
            timerEl.textContent = "00:00:00";
            clearInterval(timerInterval);

            Swal.fire({
                icon: 'error',
                title: 'Tiempo agotado',
                text: 'El tiempo para completar el pago ha expirado.',
                showConfirmButton: true,
                confirmButtonText: 'Aceptar',
                confirmButtonColor: '<?php echo $corporateIdentity->btnBox_color; ?>',
                allowOutsideClick: false,
                allowEscapeKey: false,
                allowEnterKey: false
            }).then(() => {
                window.location.href = <?php echo json_encode($paymentDetails->return_page); ?>; // Redirigir a la página principal o a donde sea necesario
            });
            return;
        }
        let minutes = String(Math.floor(time / 60)).padStart(2, '0');
        let seconds = String(time % 60).padStart(2, '0');
        timerEl.textContent = `00:${minutes}:${seconds}`;
        time--;
    }

    updateTimer();
    timerInterval = setInterval(updateTimer, 1000);

    // Habilitar botón de pago al seleccionar una pasarela
    document.querySelectorAll('input[name="gateway"]').forEach(input => {
        input.addEventListener('change', function() {
            const continueBtn = document.querySelector('.continue-btn');
            continueBtn.disabled = false;
            continueBtn.style.backgroundColor = '<?php echo $corporateIdentity->btnBox_color; ?>';
            // Scroll a la sección de resumen
            document.querySelector('.summary-section').scrollIntoView({
                behavior: 'smooth'
            });
        });
    });

    if (document.getElementById('pay-btn')) {
        document.getElementById('pay-btn').addEventListener('click', async function(e) {
            const selected = document.querySelector('input[name="gateway"]:checked');
            if (!selected) {
                Swal.fire({
                    icon: 'warning',
                    title: 'Selección de pasarela',
                    text: 'Por favor selecciona una pasarela de pago antes de continuar.',
                    showConfirmButton: true,
                    confirmButtonText: 'Aceptar',
                    confirmButtonColor: '<?php echo $corporateIdentity->btnBox_color; ?>',
                    allowOutsideClick: false,
                    allowEscapeKey: false,
                    allowEnterKey: false
                });
                return;
            }

            const gateway = selected.value;
            const urlComplement = "{{ $urlComplement }}";
            const decodedString = urlComplement.replace(/&amp;/g, "&");
            window.location.href = `../../../store/webcheckout?paymentGatewayId=${gateway}${decodedString}`;
        });
    }
</script>