The merchant bank contacts the appropriate credit card network (Visa, MasterCard, American Express, or Discover) to get authorization for the credit card purchase. Then, the payment network contacts the credit card issuer to make sure the credit card is valid and there's enough available credit for the transaction.
American Express and Discover are the payment network and the credit card issuer, so they approve credit card transactions themselves. Visa and MasterCard, however, do not issue credit cards and must contact the credit card issuer.
The credit card issuer sends back an authorization code for the transaction. If your credit card is declined, you won't get a reason at the point of sale, just a message that the card was declined. You'll have to contact your card issuer directly to find out why your card was declined.
The store’s bank sends their communications electronically either through the phone line or through the internet. You may have been to a store or restaurant and heard the screeching and static from the credit card terminal communicating with merchant bank. Now you know what’s going on.