<script>
  $(function() {


      $('#bKash_payment').on('click', function() {        


          var amount = $('#amount').val();



          if (amount != null && amount != '' && amount != 0) {
              $('body').append(
                  '<div style="position: fixed;width:100vw;height:100vh;background: rgba(0,0,0,.5);z-index: 9999999;top: 0;text-align: center;color: #fff;padding-top: 50vh;"><img style="display: block; margin: 0 auto;transform: scale(1.5);" src="https://sandbox.payment.bkash.com/assets/images/processing_gif.svg"></div>'
              );
              var amount = $('#amount').val();
              var token = '{{ csrf_token() }}';
              var customerid = {{ $details['userinfo']->id }}
              $.ajax({
                  url: "{{ route('bkash-create-payment') }}",
                  data: {
                      amount: amount,
                      customerid: customerid
                  },
                  headers: {
                      "X-CSRF-TOKEN": token
                  },
                  type: 'POST',
                  success: function(data) {

                      window.location.href = data.bkashURL;
                  },
                  error: function(err) {
                      // hideLoading();
                      // showErrorMessage(err);
                  }
              });


          } else {
              alert('amount is empty or 0');
          }

      });            

  });
  
</script>