I know that I can purchase apps, music, movies etc. using the credit that's on my Apple ID. But is it also possible to purchase hardware from the online Apple Store, using that same credit on my Apple ID?
No. The credit shown in the Mac App Store or iTunes App Stores is not spendable from the retail stores or the online store.
There is a physical gift card that can be bought for online store or retail store use, but it's not the same bucket of funds as the iTunes store gift cards. See http://store.apple.com/us/browse/home/giftcards for more details...