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.
Screenshots
Overview
Project Overview Title: Bill Payment Automation System Using Python, Barcode Integration & OCR
Industry: Financial Services / Utility Bill Payment
Project Category: Desktop Application / Automation
Project Duration: Approximately 2 months
Project Cost: ~$2,500
Project Started On: September 2024
Role: Full-Stack Python Developer / Automation Engineer
Live URL: N/A (Desktop Application)
Tags: • Python • OCR (Tesseract) • Barcode Scanning • Automation • NADRA e-Sahulat • Desktop Application
Challenges • High Volume of Bills: Processing 500-700 bills per day manually was time-consuming and physically exhausting. • Human Error & Irreversible Mistakes: A single wrong digit in the consumer number meant a non-refundable payment to the wrong account. • Encrypted Barcodes for LESCO: While other bills had straightforward barcode information, LESCO used an encryption mechanism that required an official decryption technique from the LESCO head office. • Integration with NADRA e-Sahulat: To automate data entry in the e-Sahulat portal, the system needed robust simulation of keyboard input, mouse clicks, and real-time verification of on-screen status messages and amounts.
Solution 1. Decrypting LESCO Barcodes The first breakthrough came from contacting LESCO head office to obtain their custom decryption technique. Once available, this logic was incorporated into the Python script, enabling parsing of encrypted data for consumer numbers, due dates, and amounts.
2. Barcode Scanning & Data Extraction For other bills (PTCL, SNGPL, LWASA, etc.), barcodes were not encrypted, allowing straightforward data retrieval. Using a barcode scanning SDK in Python, the system extracted: • Consumer Number • Due Date • Bill Amount
The system then auto-populated corresponding fields in the NADRA e-Sahulat portal, eliminating manual data entry.
3. Python Automation Scripts To simulate user actions in the NADRA e-Sahulat portal, Python Mouse and Keyboard SDK tooling (for example PyAutoGUI) was used. The automated process included: • Opening the portal and moving cursor to correct text fields. • Entering CNIC and mobile number once (saved as variables). • Filling in the consumer number from barcode data. • Clicking Show Bill and taking screenshot for amount confirmation. • Verifying amount by reading on-screen value using Tesseract OCR. • Comparing OCR value with barcode-extracted amount. • Automating payment when amounts match. • Skipping payment on mismatch to avoid financial errors. • Monitoring prompts like Payment in Progress and Your bill has been paid, then returning to main menu for next bill.
4. OCR (Tesseract) for Accuracy The portal displays a waiting message before final bill amount appears. OCR checks this state and waits until the amount is fully visible before proceeding. This prevents premature payment actions and incorrect captures.
5. Desktop Application The entire flow was wrapped in a user-friendly desktop application: • Single Input for CNIC and Mobile Number. • Scan & Pay interface triggering full automation. • Real-time logs for successful and skipped payments.
Technologies Used • Python: Core logic and scripting. • PyAutoGUI / Mouse & Keyboard SDK: Automated clicks and keystrokes. • Tesseract OCR: Read amounts, status messages, and confirmations from screenshots. • Barcode Libraries: Decode and parse consumer data. • Custom Decryption (LESCO): Handle LESCO encrypted barcodes. • Desktop Application Framework (such as PyQt or Tkinter): User-friendly interface.
Results & Impact Reduced Time & Effort • Processes up to 700 bills in under 2 hours, down from 4-6 hours manual work. • Greatly reduced eye strain and hand fatigue.
Lowered Financial Risk • Amount matching before payment nearly eliminates incorrect payments. • Mismatches trigger automatic cancel to prevent non-refundable losses.
Scalable & Efficient • Handles higher bill volume without additional manpower. • A small team or even one person can oversee hundreds of payments.
Error Reduction • Repetitive typing errors are largely eliminated because critical fields are auto-filled from barcode scans.
Enhanced Accuracy & Transparency • Real-time logs simplify tracking and audit review. • OCR gates prevent unsafe steps until the correct state is detected.
Lessons Learned • Decryption Challenges: Obtaining LESCO decryption details was a critical dependency and showed the importance of official collaboration with proprietary systems. • Robust Error Handling: Screenshot-based checks and fallback logic improved resilience against lag and portal issues. • Usability Matters: Desktop GUI significantly improved adoption compared to command-line only workflows. • Testing & Iteration: Cross-provider testing (LESCO, PTCL, SNGPL, LWASA) was essential for production reliability.
Conclusion The Bill Payment Automation System combined barcode decryption, OCR validation, and GUI automation into one dependable workflow. By using Python and verification-first processing, the solution delivered faster operations, higher accuracy, and far lower human error under high daily volume.
Key Highlights
- Automated 500-700 daily utility bill payments with verification-first workflow
- Custom LESCO barcode decryption integrated after official head-office collaboration
- OCR-based on-screen amount and status validation before any pay action
- Reduced processing time from 4-6 hours to under 2 hours for high-volume cycles
- Automatic mismatch skip logic prevented non-refundable wrong-account payments
- Desktop Scan & Pay interface with real-time logs improved transparency and adoption
Tech Stack
Related Projects
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.

LetzChat – Enterprise Multilingual Translation & Communication Platform
Complete enterprise translation ecosystem — featuring real-time analytics (300M+ events/month), AI-powered chat, voice/video dubbing, live call translation, podcast/Zoom integration, glossary management, subtitle generation, and comprehensive analytics — breaking language barriers across all communication channels.
Related Blog Posts
Bill Payment Automation System Using Python, Barcode Integration and OCR
A case study on automating high-volume utility bill payments through NADRA e-Sahulat using Python, barcode parsing, and OCR-based verification.
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.