2 Tests (the wirst one was caught by you, I describe it nevertheless because the user experience could be improved) with the second one I was however able to withdraw more funds than I had on your side:
So I had a balance of 40 Satoshi. My first test was to widthdraw 41 Satoshi using this invoice:
This did not work. However I did not receive any error message. In case people make a typo this is bad. I suggest once people enter an invoice you decode the invoice and show them how many satoshi they are about to withdraw and what their balance will be afterwards. and ask them then to confirm the widthdraw process (as long as the invoice is smaller than their balance)
Aftwerwards I widthdrew 38 satoshi with the following invoice
(Worked like a charm) leaving me a balance of 2 satoshi.
starting with a blance of 2 staoshi I created two invoices
For your reference both invoices have the same description widthdraw2satoshiconcurrently
I opened the withdraw dialog in two windows. I added the first invoice to the first dialog and the second one to the other one. Now I quickly pressed both widthdraw buttons. I was able to withdraw 4 satoshi even though my balance was only 2 satoshi.
I guess after clicking the button you check the balance and if it is fine you initiate a payment with lightning (which of course takes some time) in this time I could pass your check if sufficient funds were there with the second request to withdraw funds.
There are many fixes to this and should be implemented before the site starts to grow (: You have to take care to not create deadlocks however.
also the rest of your application logic seems to work fine (c.f. this screenshot) Though I expected my balance to be -2 statoshi which also did not happen.
If you give me an invoice I will send you back the two satoshis!
It is the first application that I tested but I guess there will be more lightning applications running into similar problems. So if you agree on this I would use this example (in particular with your website) in an educational video about how to handle concurrent payment requests.