0
I have a problem at hand. I have a credit card form, where the customer will fill in the data and be submitted to the bank evaluation. However, it should perform some operations before to arrive at the function that will send your data to the payment gateway. I will exemplify a step by step of what should be happening:
- User fills in card data;
- Send the form;
- Receives the answer "Wait, analyzing data";
- User receives the reply "Payment approved" or "Payment denied";
But step 3 is not running at all. Here is 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;
});
The POST is dealt with 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 turns out that it already goes through the "echo" above Cs_mundipagg() and goes straight to the answer at the end of the script. As if it "hangs" the script after the user submits the form and brings only the final answer (payment approved or not).
I have tried almost everything, I am not finding a solution. There is hope at the end of the tunnel?
Doesn’t it work? Strange, here it is working. For when it hits the
return false
it does not perform the rest. So much so that the data is not sent to the gateway.– Thiago
I understand Daniel, thank you. But tell me why in your opinion this is a very weak, inconsistent and redundant parole? She somehow doesn’t keep her promises?
– Thiago
Added an example of how to treat more consistently.
– Daniel Omine
I understand Daniel, thank you for the explanations.
– Thiago