shahidneermunda / kseb-sdk
A Laravel SDK to fetch and calculate KSEB utility bills.
Package info
github.com/shahidneermunda/kseb-sdk-utility-in-php
pkg:composer/shahidneermunda/kseb-sdk
v1
2026-04-15 14:48 UTC
Requires
- php: ^8.1
- illuminate/support: ^10.0|^11.0
- symfony/css-selector: ^6.0|^7.0
- symfony/dom-crawler: ^6.0|^7.0
README
A lightweight Laravel package to fetch and parse KSEB utility bill information.
Features
- Laravel auto-discovery for provider and facade
- Simple facade and container-based usage
- Configurable endpoint, timeout, and CSS selector
- Safe amount parsing with consistent response format
- Bill payment request support through configurable payment endpoint
Requirements
- PHP
^8.1 - Laravel
^10.0or^11.0
Installation
Install with Composer:
composer require shahidneermunda/kseb-sdk
The package supports Laravel auto-discovery, so no manual provider registration is required in normal setups.
Configuration
Publish the package config:
php artisan vendor:publish --tag=config
Then update config/kseb.php as needed:
return [ 'quickpay_url' => env('KSEB_QUICKPAY_URL', 'https://wss.kseb.in/selfservices/quickpay'), 'payment_url' => env('KSEB_PAYMENT_URL', 'https://wss.kseb.in/selfservices/quickpay/pay'), 'timeout' => (int) env('KSEB_TIMEOUT', 15), 'bill_amount_selector' => env('KSEB_BILL_AMOUNT_SELECTOR', '#billAmount'), ];
You can also place these values in your .env:
KSEB_QUICKPAY_URL=https://wss.kseb.in/selfservices/quickpay KSEB_PAYMENT_URL=https://wss.kseb.in/selfservices/quickpay/pay KSEB_TIMEOUT=15 KSEB_BILL_AMOUNT_SELECTOR=#billAmount
Usage
Using the Facade
use Kseb; $bill = Kseb::getBill('1234567890'); return response()->json($bill);
Bill Payment
use Kseb; $payment = Kseb::payBill('1234567890', 1240.50, [ 'payment_mode' => 'UPI', 'payer_name' => 'John Doe', 'mobile' => '9876543210', ]); return response()->json($payment);
Using Dependency Injection
use Shahid\KsebSdk\KsebClient; class BillController { public function show(KsebClient $kseb) { $bill = $kseb->getBill('1234567890'); return response()->json($bill); } }
Response Format
[
'consumer_number' => '1234567890',
'amount' => 0.0,
'currency' => 'INR',
'status' => 'ok', // or 'error'
'error' => null, // error message when status is 'error'
'fetched_at' => '2026-04-15 12:34:56',
]
Bill Payment Response Format
[
'consumer_number' => '1234567890',
'amount' => 1240.50,
'currency' => 'INR',
'status' => 'ok', // or 'error'
'error' => null, // error message when status is 'error'
'transaction_id' => 'TXN12345',
'payment_status' => 'submitted', // e.g. submitted, success, failed
'response' => [], // raw response payload from payment endpoint
'paid_at' => '2026-04-15 12:40:00',
]
When an upstream request fails, status is returned as error and a short failure reason is included in error.
Notes
- Current implementation fetches the quick pay page and parses the configured bill amount selector.
- Depending on KSEB portal behavior, you may need to extend request flow (for example, posting consumer details) to fetch live bill amounts.
License
MIT