While the process behind any online transaction is complex and would appear to take hours to complete, it's all done in a matter of seconds.
A consumer visits a website and adds their selected items to the shopping cart. Upon checkout, the merchant's shopping cart submits a credit card transaction to a payment gateway on behalf of the customer. When the payment gateway receives the transaction information, it pases the data through the businesses merchant account to the credit card processing bank. (The processing bank is connected to a series of financial networks that work to manage processing, clearing, and settlement of credit card transactions.)
The processing bank then sends the transaction to the customer's credit card issuer, who returns an approved or declined response. If approved, the appropriate funds and transaction information is sent back to the processing bank, where the funds are secured from the cardholder and scheduled to be deposited into the merchant's bank account. If declined, a response is sent back to the processing bank.
Transaction results are then relayed back to the payment gateway, which stores the results and sends them to the customer and the merchant for the confirmation and verification. This is when, as a customer, you receive a receipt. The funds from the transaction are verified upon the merchant batching, and later depositing into their bank account.