The bank takes no loss. They take the money from the merchant.
Banks require merchants to keep a certain amount of money as a deposit with them, specifically for this. The amount varies depending on the type of business the merchant is in (and the size and reliability of the merchant - for example Walmart is probably not required to keep any amount at all).