Explaining the principles of QR code operation and their role in UPI payments
Read more
The Better India
thebetterindia.com

Explaining the principles of QR code operation and their role in UPI payments

Once, paying for inexpensive ice cream required finding change in your wallet, and buying vegetables might end with searching for the nearest store. Today, the ice cream vendor, as well as vegetable sellers, tea stalls, local shops, and street vendors use a small black and white square next to their stall.

The user simply points their phone camera at this square, enters their UPI PIN, and the money is transferred within seconds. However, the question arises: what exactly happens between scanning these small squares and receiving the message 'Payment successful'?

This square is more than just an image

What looks like a random arrangement of black and white cells is actually a carefully structured way of storing information. The QR code, which stands for Quick Response code, was invented in Japan in 1994 by engineer Masahiro Hara. It was originally intended for tracking auto parts in factories. Unlike traditional barcodes, which store data along a single horizontal line, a QR code arranges information in a two-dimensional grid.

These small black and white squares are called modules. Depending on the amount of information stored, QR codes can have different versions, ranging from 21 × 21 modules to 177 × 177. The more data that needs to be encoded, the more modules are required. For UPI payment, the encoded information can include the seller's UPI ID or virtual payment address, the seller's name, a transaction link, and, depending on the type of QR code, the amount to be paid. Thus, a QR code is not a photograph of the shop owner or their bank account, but a compact, machine-readable package of payment instructions.

First, the phone must find the code

Have you noticed the three large squares located at the corners of the QR code? They are known as finder patterns. They can be seen as indicators that tell the phone camera: 'This is a QR code. Start reading here.' Their distinctive black and white pattern allows the camera to quickly identify the code and determine its orientation, even if it is scanned at an angle. The phone can then correct the perspective and calculate the grid of modules that needs to be read. Thanks to these position detection patterns, QR codes are designed to be readable from various angles.

Additionally, there is a small empty area around the QR code, called the quiet zone. This helps the scanner distinguish the code from the surrounding poster, sticker, or shop counter.

Your camera is actually decoding the data

Once the camera detects the grid, it doesn't just 'see' black and white. QR code reading software converts the pattern of modules into digital data—essentially, a sequence of encoded bits and bytes. The QR format also contains information that tells the decoder how this data is structured. In the case of a UPI QR code, the decoded information can direct the payment application to a specific recipient. Your UPI app reads these parameters and translates them into something useful on the screen: who you are paying and sometimes how much.

This is why scanning a QR code can instantly open a payment screen with pre-filled seller details.

Static or dynamic? There is a difference

A familiar QR code permanently affixed to a small shop counter is often a static QR code. The seller's payment details are embedded in the code itself, while the user enters the amount manually. A dynamic QR code, conversely, can contain transaction-specific information. For example, the amount and transaction link can be generated for a specific purchase. NPCI specifications differentiate these types of QR codes and define parameters such as the recipient's address, transaction link, and amount. This is why you might see a QR code that appears on a restaurant bill screen or a digital order page with the amount already specified.

Why does a damaged QR code still work?

Here, mathematics becomes particularly ingenious. A QR code does not just store the necessary information; it also contains additional data that serves as a mathematical backup. This is called error correction. QR codes use Reed-Solomon error correction, which adds extra information to the original data. If some modules become unreadable due to dirt, scratches, or damage, the decoder can use this extra information to restore missing data. There are four levels of error correction, with higher levels providing greater recovery capability at the cost of increasing the code size. This is why a QR code stuck to a shop counter might look like it has survived years of dust, rain, and fingerprints—and still accept your payment of 50 rupees.

From scan to bank transfer

Now comes the stage where the QR code passes the task to UPI. As soon as your app decodes the payment information, it displays the recipient and the amount. The user verifies the details and authorizes the transaction using their UPI PIN. The QR code itself does not transfer or hold your money. It essentially provides the information needed to initiate the payment. UPI then handles the actual transaction between participating banks and payment service providers. Your bank account is debited, and the recipient's account is credited, while the payment application shows you the result.

So, in simple terms: the QR code tells the app where and how to pay; UPI moves the money.

A small square doing a very big job

Next time you scan a QR code at a street stall, take a second to look at it. These seemingly random black and white squares combine data encoding, image recognition, geometry, and error correction mathematics, all within a tiny square. And somewhere between the seller's phrase 'UPI kar do' and your phone's sound 'Payment successful,' the tiny square did an amazing job—it identified the pattern, decoded the data, verified the payment details, and connected you to the digital payment network. All this science, packaged in a few centimeters of black and white squares, works quietly in the background and takes only a few seconds.

Popular