Don't deliver before you have seen your money.
Case 1: You deliver first) The client got your work and could use the money on something else.
Case 2: The client pays first) The client doesn't have your work yet, but once they pay, you have no reason not to give it to them, you can possibly not just sell it to another person and if it's software you could just sell a copy (legal or not).
Case 2 should be seen as the most reasonable for all parts. You can always set up a server they can see the work on before they pay, of course. Also consider asking for an 1/3 upfront payment.