// function upToPayWallet(){$.ajax({type:"POST",url:"/pay/payToUp/"+$("#slug").val()+"/",data:{csrfmiddlewaretoken:document.getElementsByName("csrfmiddlewaretoken")[0].value,telephone:$("#mytel").val(),type:$("#type").val(),slug:$("#slug").val(),card_number:$("#card-number").val(),card_expire:$("#card-expire").val(),card_cvv:$("#card-cvv").val(),fname:$("#fname").val(),lname:$("#lname").val(),omotp:$("#myotp").val()},beforeSend:function(){$("#r-message").text("Paiement en cours .."),$("#loading").css("display","block")},success:function(e){$("#r-message").text(e.message),"true"==e.data.is_success?($("#loading-anime").css("display","none"),$("#loading-success").css("display","block")):($("#loading-anime").css("display","none"),$("#loading-error").css("display","block")),window.location.href=e.data.redirect}})}


function upToPayWallet() {
    $.ajax({
        type: "POST",
        url: "/pay/payToUp/" + $("#slug").val() + "/",
        data: {
            csrfmiddlewaretoken: document.getElementsByName("csrfmiddlewaretoken")[0].value,
            telephone: $("#mytel").val(),
            type: $("#type").val(),
            slug: $("#slug").val(),
            card_number: $("#card-number").val(),
            card_expire: $("#card-expire").val(),
            card_cvv: $("#card-cvv").val(),
            fname: $("#fname").val(),
            lname: $("#lname").val(),
            omotp: $("#myotp").val()
        },
        beforeSend: function() {
            $("#r-message").text("Votre Paiement est en cours.");
            $("#loading").css("display", "block");
        },
        success: function(response) {
            console.log(response)
            if (response.status === "SUCCES") {
                $("#r-message").text(response.message);

                if (response.data.is_success == "true") {
                    $("#loading-anime").css("display", "none");
                    $("#loading-success").css("display", "block");

                    if (response.data.response.wave_launch_url) {
                        window.location.href = response.data.response.wave_launch_url
                        return;
                    }
                } else {
                    $("#loading-anime").css("display", "none");
                    $("#loading-error").css("display", "block");
                }

                window.location.href = response.data.redirect;
            } else {
                $("#r-message").text("");
                $("#loading").css("display", "none");
                Swal.fire({
                    title: 'Notification!',
                    text: response.message,
                    icon: 'error',
                    confirmButtonText: 'Ok'
                });
                
            }
            
        }
    });
}
