How do I detect a double-spend in real-time, like Bitpay? By Bitpay to pay only take 10 seconds to complete.

How do they do it?
If you want to detect a double spend, you need to listen to all transactions broadcasted to the network, and write some code to detect if the address that sent you Bitcoins also sends a transaction to another address (until 1+ confirmations).

To answer your other question, Bitpay cannot guarantee the transactions not to be double spent. In an effort to promote usage of Bitcoin as a payment solution, they take on the risk of a potential double spend, and if one happens, they eat the balance (no risk to the merchant). This is a vanishingly small occurrence in practice, so any fees (or venture capital) paid to them more than cover that possibility.