well, if you are in this situation. will you return everything? on the one hand there are 2 options before making a deal with each other.
1. refund half ($400) and secure account.
2. if you not otherwise return everything ($800). then your account is reported, tagged with negative trust, that you are dishonest.
It would be completely wrong to keep any amount of money sent to you erroneously unless the sender makes an agreement for you to keep some/all of it (like what happened in your story).
If the sender demands you give it back to him on the other hand, you have a transactional obligation to comply.