Paga con tarjeta de crédito/débito de la forma más segura
//Oculta o muestra el formulario si hay una tarjeta guardada seleccionada
function checkSelectedCard() {
if (document.getElementById('jet_iframe_card').value != 0){
document.getElementById('toHide').style.display = "none";
document.getElementById('storingStep').style.display = "none";
} else {
if (document.getElementById('toHide')) {
document.getElementById('toHide').style.display = "block";
}
if (document.getElementById('storingStep')) {
document.getElementById('storingStep').style.display = "block";
}
}
document.getElementById('hiddenCardField').value = document.getElementById('jet_iframe_card').value;
};
//Comportamiento cuando se valida el formulario de JetIframe correctamente
function jetIframeValidated(){
if (document.getElementById("jetiframe_savecard") != null) {
document.getElementById("savecard_jetiframe").checked = document.getElementById("jetiframe_savecard").checked;
}
document.getElementById("jetiframe-token").value = document.getElementsByName("paytpvToken")[0].value;
if (jQuery("#jetiframe-token").val() != "") {
jQuery('#place_order').parents('form:first').submit();
}
}
function enablePlaceOrder() {
jQuery('#place_order').prop("disabled",false);
}
// formSubmit
jQuery( function( $ ) {
// Si esta cargado el formulario jetIframe cargamos el js
if ($("#paycometPaymentForm").val() == "") {
$.getScript("https://api.paycomet.com/gateway/paycomet.jetiframe.js?lang=es");
}
$( "#place_order").on('click',function( event ) {
if ($( '#payment_method_paytpv' ).is( ':checked' )) {
event.preventDefault();
new_card = (document.getElementById('jet_iframe_card').value == 0)?true:false;
// New Card
if (new_card) {
jQuery('#place_order').prop("disabled",true);
// jetIframe action
$("#jetiframe-button").click();
} else {
$('#place_order').parents('form:first').submit();
}
setTimeout(() => { enablePlaceOrder() }, 2000);
}
});
setTimeout(() => { checkSelectedCard() }, 100);
});