引脚验证对话框

I am triyng to make PIN Verification dialog with PHP, BOOTSTRAP, AND AJAX. If the function returns 1 then execute the code. I tried to make two functions: 1. Open the modal dialog and get the pin. 2. Make ajax request to the server to verify the pin. I call the first function inside the second function to get the pin. Here is the code:

function PinProverka() {
    var rez;
    var pin = GetPin();

        $.ajax({
            method: "POST",
            url: "/includes/procesi.php",
            data: {
                proces: "proverka-pin",
                pin: pin
            },
            async: false,
            success: function(data) {
                rez = data;
            }
        });
       return rez;

}
function GetPin() {
    $("#pin-dialog").modal({backdrop: "static"}).on('click', '#pin-ok',function() {
       var pinkod = $("#pinkod").val();
       $("#pin-dialog").modal('hide');
       return pinkod;
   });

}

How to force the PinProverka function to wait for GetPin then executes the AJAX call and return the vaule?

You can add submit or other button for handling when user entered pin.