A payment gateway is the software that collects your payment on a website or an app and sends it to the banks. Say you are buying a school bag on a shop's website. When you click Pay, you reach a page that asks for your card details, UPI ID or net banking login. That page usually belongs to the payment gateway, not to the shop. Razorpay, PayU and Cashfree are among the best-known payment gateways in India.
A payment gateway does four main jobs.
First, it collects your payment details safely. The shop never sees your full card number. The gateway stores a token instead. A token is a different number that represents your card, and it works only for that one shop.
Second, it sends the payment to the shop's bank. In payments, the shop's bank is called the acquiring bank, or acquirer. It receives card and UPI payments on behalf of the shop. The acquiring bank then asks your bank to approve the payment.
Third, it checks that the payment is safe. It asks a fraud detection system whether the payment shows signs of fraud. It may also send an OTP to your phone. Entering the OTP proves that you are the one paying.
Fourth, it tells the shop whether the payment was approved or declined, usually within two seconds. The shop then confirms your order.
For UPI payments, the gateway shows you a QR code, or it sends a payment request to your UPI app. You approve the payment in the app by entering your UPI PIN.
Some shops, such as online marketplaces, sell products from many sellers. For them, the gateway can split one payment between the different sellers.
A payment gateway charges the shop a small fee for each payment. Engineers who work on payment gateways spend much of their time on three things. First, they keep the system working during very big sales, such as Diwali sales. Second, they choose the bank route that is most likely to approve each payment. Third, they check that every rupee received matches the right order. If a payment fails, the shop may lose the sale. So shops prefer the gateways that complete the most payments without failure.