I have a problem at hand. I have a credit card form, where the customer will fill out the data and be submitted to the bank's evaluation. However, it should run some operations before from reaching the function that will send its data to the payment gateway. I will illustrate a step by step of what should be happening:
But step 3 is not running at all. Here's my code:
$('#credit_card_form').submit(function() {
$.post($("#credit_card_form").attr('action'), $("#credit_card_form").serialize(), function(data){
$("#retorno_form").html(data);
});
return false;
});
POST is treated here:
if ($_POST['f'] == 'pay_credit_card') {
$bandeira_cartao = $_POST['card_brand'];
$numero_cartao = $_POST['card_number'];
$vecto_mes = $_POST['card_valid_month'];
$vecto_ano = $_POST['card_valid_year'];
$cod_seguranca = $_POST['card_security'];
$nome_cartao = $_POST['card_name'];
if ($_POST['card_number'] == '') {
echo "Preencha o campo X"
return false;
}
// d_none = display: none;
echo "<script>$('#aviso_carregando_cartao').removeClass('d_none'); $('#div_formulario_cartao').addClass('d_none');</script>";
$retorno_pagamento = CS_MundiPagg($bandeira_cartao, $numero_cartao, $vecto_mes, $vecto_ano, $cod_seguranca, $nome_cartao);
if ($retorno_pagamento == 'Captured') {
echo "<script>$('#sucesso_cartao').removeClass('d_none'); $('#modal-close').addClass('d_none');</script>";
}
}
It happens that it already passes the "echo" above CS_MundiPagg () and goes straight to the answer, at the end of the script. As if it "locked" the script after the user submitted the form and brought only the final answer (payment approved or not).
I've tried almost everything, I'm not finding a solution. Is there hope at the end of the tunnel?