The function of the payment gateway is actually quite easy to understand. When you go to a gas station and pay with your credit card, the attendant inserts your card into a POS machine. In an e-commerce transaction the payment gateway accomplishes the same job as the POS machine, except it’s an online transaction so the information is just sent online. The shopping cart securely encrypts the credit card and order details and sends it to the payment gateway to be processed.
In the background, the payment gateway will then contact the customers card issuing bank and to see if they have sufficient funds to pay for the sale. If so, the card issuing bank will return an authorization and the funds will be debited from the customers card.
When those funds are captured from the customers credit card account, they must go somewhere. This is where the final part of an e-commerce transaction comes in: the merchant account.