Nueva version con enviroment Pasarela
This commit is contained in:
@@ -1,4 +1,28 @@
|
||||
var apiKey = "hmngy-60lXd3pZRePVdSpItDhnC3408GvLDHU4";
|
||||
var apiKey;
|
||||
var imagen_pasarela;
|
||||
async function cargarEnv() {
|
||||
const response = await fetch('.app_config');
|
||||
const texto = await response.text();
|
||||
|
||||
const env = {};
|
||||
|
||||
texto.split('\n').forEach(linea => {
|
||||
// Ignorar comentarios y líneas vacías
|
||||
if (linea.trim() && !linea.startsWith('#')) {
|
||||
const [clave, ...valores] = linea.split('=');
|
||||
env[clave.trim()] = valores.join('=').trim();
|
||||
}
|
||||
});
|
||||
|
||||
return env;
|
||||
}
|
||||
|
||||
// Usar
|
||||
cargarEnv().then(env => {
|
||||
// Usar las variables
|
||||
apiKey = env.apiKey_pasarela;
|
||||
imagen_pasarela = env.imagen_pasarela;
|
||||
});
|
||||
|
||||
function stripeTokenHandler(token) {
|
||||
let form = document.getElementById("payment-form");
|
||||
@@ -10,7 +34,7 @@ function stripeTokenHandler(token) {
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
fetch("http://127.0.0.1:8000/api/obtLavePublicaStripe", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
@@ -118,10 +142,12 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
document.getElementById("mensajePago").innerHTML = `
|
||||
✅ Pago realizado con éxito. ID Transacción: ${response.idTransaction}
|
||||
`;
|
||||
card.clear();
|
||||
} else {
|
||||
document.getElementById("mensajePago").innerHTML = `
|
||||
❌ Hubo un error: ${response.error}
|
||||
`;
|
||||
card.clear();
|
||||
document.getElementById("btnstripe").style.display = "inline-block";
|
||||
}
|
||||
})
|
||||
@@ -130,6 +156,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
document.getElementById("mensajePago").innerHTML = `
|
||||
❌ Error de conexión o del servidor. Intente nuevamente.
|
||||
`;
|
||||
card.clear();
|
||||
document.getElementById("btnstripe").style.display = "inline-block";
|
||||
});
|
||||
}
|
||||
@@ -141,7 +168,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
});
|
||||
});
|
||||
|
||||
function abrirModal() {
|
||||
window.abrirModal = function() {
|
||||
const modal = document.getElementById("miModal");
|
||||
const contenido = document.getElementById("modalContenido");
|
||||
|
||||
@@ -150,7 +177,7 @@ function abrirModal() {
|
||||
setTimeout(() => contenido.classList.add("animar-entrada"), 10);
|
||||
}
|
||||
|
||||
function cerrarModal() {
|
||||
window.cerrarModal = function() {
|
||||
const modal = document.getElementById("miModal");
|
||||
const contenido = document.getElementById("modalContenido");
|
||||
|
||||
@@ -175,7 +202,7 @@ function cerrarModal() {
|
||||
<!-- Cuerpo del modal -->
|
||||
<div class="modal-body">
|
||||
<div class="mb-3">
|
||||
<label for="nameStripe">Nombre</label>
|
||||
<label for="nameStripe">Nombre123</label>
|
||||
<input type="text" id="nameUser" class="form-control" required>
|
||||
</div>
|
||||
|
||||
@@ -218,4 +245,17 @@ function cerrarModal() {
|
||||
</div>
|
||||
`;
|
||||
document.body.insertAdjacentHTML("beforeend", modalHTML);
|
||||
|
||||
// Crear la URL completa
|
||||
const base64Url = `data:image/webp;base64,${imagen_pasarela}`;
|
||||
|
||||
// Cambiar solo la imagen del CSS
|
||||
const header = document.querySelector(".modal-header-personalizada");
|
||||
header.style.backgroundImage = `url('${base64Url}')`;
|
||||
const script = document.createElement('script');
|
||||
script.src = '../../config.js';
|
||||
script.type = 'text/javascript';
|
||||
document.body.appendChild(script);
|
||||
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user