function crearToken()
{
stripe.createToken(cardNumber).then(function(result) {
if (result.token) {
$("#token").val(result.token.id);
} else {
Swal.fire('Por favor verifica los datos de tu tarjeta', '', 'error');
}
});
}
function funcionSig()
{
crearToken().then(function(){
if($("#token").val() != "")
{
gastoEnvio();
$("#tab-carrito .nav-tabs li:eq(1)").removeClass("active");
$("#tab-carrito #seccion2").removeClass("active");
$("#tab-carrito .nav-tabs li:eq(2)").addClass("active");
$("#tab-carrito #seccion3").addClass("active");
$("#tab-carrito #seccion3").tab("show");
}
});
}
I have those 2 functions, the function crearToken()
executes a stripe api function to create a token and the function funcionSig()
executes the function crearToken()
to create the token and if the token is created then it should go to the next step.
The problem is that if you create the token but do not execute the code that it should do once the function is executedcrearToken()
I think your problem is that your createToken function is not a promise, therefore it does not solve you, you would have to change it to a promise for it to work as you have it.
Promise