You must be young.
Buy the bed.
You can type on anything and you can sleep on anything, and you may even spend more hours per day on your keyboard that you do on your bed, but you need a really good bed and solid reliable sleep. And go for a hard mattress, find the hardest one you think you could be comfortable with, and then buy at least one level harder.