Bill Payment Automation System Using Python, Barcode Integration and OCR
Introduction
High-volume utility bill payment operations are often repetitive, time-intensive, and highly error-sensitive. In environments where hundreds of bills are processed daily, even small data-entry mistakes can create financial and operational risk.
To solve this, I built a Bill Payment Automation System that automates utility bill processing through NADRA e-Sahulat using Python, barcode integration, and OCR-based validation.
This project replaced manual entry-heavy workflows with a scan-driven process that improved speed, accuracy, and operational consistency.
Project Overview
The application was developed as a desktop automation solution for utility bill workflows involving providers such as:
- LESCO
- PTCL
- SNGPL
- LWASA
Project snapshot:
| Item | Details |
|---|---|
| Industry | Financial Services / Utility Bill Payment |
| Category | Desktop Application / Automation |
| Duration | 12 weeks |
| Started | June 2019 |
| Role | Full-Stack Python Developer / Automation Engineer |
| Delivery | Desktop application (no public live URL) |
The Problem
The original process required full manual handling for each bill:
- Enter consumer number
- Enter CNIC and mobile details
- Load bill details in portal
- Verify amount against physical bill
- Submit payment manually
At 500 to 700 bills per day, this created major issues:
- High manual workload and staff fatigue
- Slow throughput and long processing windows
- Frequent input errors with irreversible payment consequences
- Difficult quality control under repetitive conditions
An additional technical challenge was that LESCO barcodes were encrypted and required custom decryption logic before values could be used.
The Solution
I engineered an end-to-end automation pipeline that combines barcode extraction, portal automation, and OCR-based amount verification.
1. Barcode-First Data Capture
The system reads bill barcodes to automatically retrieve key fields such as consumer number, due date, and amount. For LESCO bills, a custom decryption workflow was implemented to decode encrypted barcode content.
2. Python-Based Portal Automation
Automation scripts drive the NADRA e-Sahulat payment flow by simulating user actions, reducing repetitive keyboard and mouse operations while maintaining process control.
3. OCR Verification Layer
Tesseract OCR processes portal screenshots to verify displayed amounts against scanned bill data before payment confirmation, adding an automated validation checkpoint.
4. Operator-Friendly Desktop Interface
The desktop app captures common information (such as CNIC and phone details) once, then supports a scan-and-process workflow for each bill, reducing repetitive input burden.
Technology Stack
- Python: Core automation and orchestration
- PyAutoGUI / Mouse and Keyboard SDK: UI interaction automation
- Tesseract OCR: Screenshot text extraction and validation
- Barcode Libraries: Barcode decoding and parsing
- Custom LESCO Decryption Logic: Encrypted barcode handling
Workflow
- Operator scans bill barcode
- System extracts and parses bill data
- App navigates e-Sahulat workflow automatically
- OCR reads portal amount and compares it with scanned bill amount
- If verification passes, payment proceeds
- Status is logged for audit and operational tracking
Impact
The system delivered strong operational improvements:
| Area | Outcome |
|---|---|
| Processing Time | Reduced daily processing window from 4 to 6 hours to under 2 hours on average |
| Error Reduction | Lowered incorrect payments through automated field handling and OCR checks |
| Throughput | Enabled faster bill handling with less operator fatigue |
| Reliability | Improved consistency for high-volume daily payment operations |
Key Engineering Challenges Solved
- Decrypting and parsing encrypted LESCO barcodes
- Building robust UI automation for an external portal workflow
- Maintaining OCR accuracy under real interface conditions
- Creating safe verification checks before irreversible payment actions
Lessons Learned
- Repetitive financial workflows are strong candidates for automation
- Verification layers are critical when operations are irreversible
- Scan-first design can dramatically reduce operator error rates
- Small desktop automation tools can create high operational ROI
Future Enhancements
Planned roadmap items include:
- Broader bill format support across additional providers
- Better OCR confidence scoring and anomaly detection
- Enhanced audit dashboards and reporting exports
- Optional queue-based processing for multi-operator environments
Conclusion
This Bill Payment Automation System demonstrates how Python automation, barcode processing, and OCR can transform a manual, error-prone operation into a faster and more reliable workflow.
By combining practical engineering with operator-focused design, the solution improved daily efficiency, reduced risk, and established a scalable automation foundation for utility payment operations.
Related Projects
Bill Payment Automation System Using Python, Barcode Integration & OCR
A desktop automation system that processes 500-700 utility bills with barcode extraction, OCR-based verification, and automated NADRA e-Sahulat workflow handling to reduce manual effort and payment risk.
COVID-19 Vaccination Card Digitization
This project was initiated to address the logistical and durability challenges of standard-sized COVID-19 vaccination certificates by converting government-issued PDFs into portable, double-sided ID cards.
LESCO Bill Scraper - Automating Utility Bill Verification for Efficiency
The LESCO Bill Scraper is a specialized automation tool developed to streamline utility bill payment verification by extracting consumer numbers from bulk PDFs and checking payment statuses on the LESCO website.
Related Articles
COVID-19 Vaccination Card Digitization: A Python-Powered Transformation
A case study on automating the conversion of Pakistan COVID-19 vaccination PDFs into compact double-sided ID cards using Python, PyPDF2, and Pillow.
LESCO Bill Scraper: Transforming Utility Bill Verification with Automation
A case study on building a Python-based LESCO bill verification automation tool that parses bulk PDFs, checks payment status online, and generates structured reports.
Top Technologies I Use and Why
A practical look at the core technologies I use most often and how each one contributes to building scalable, production-grade systems.