What kind of book? I have most experience with novels... I think things are a bit different for non-fiction, but I can't say for sure.
For novels...
Authors don't get paid per word. That applies to some short story markets, and, I think to non-fiction articles, but not novels.
For novels, authors are paid royalties based on sales. This can be either net sales, in which case the percentage is generally higher, or cover price, in which case the percentage is generally lower. So, for example, a publisher might pay 50% of net sales, but that means that for a $5 e-book, the publisher would only receive $3.50, and the author would get $1.75. Or the publisher might pay 15% of cover price, so if the book had a $10 cover price the author would get $1.50 per book sold.
There are also advances that come into play. When a publisher buys a book, they give the author an advance on royalties, which is essentially an advance payment of royalties that will hopefully be received down the line. So the author might get a $10K advance (often divided into 1/3 payments for when the contract is signed, the MS is received, and the book is released), and won't receive any royalties on that title until the advance is paid off.