Download the PHP package flavytech/laravel-etims without Composer
On this page you can find all versions of the php package flavytech/laravel-etims. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-etims
🇰🇪 Laravel eTIMS SDK
Production-grade Laravel SDK for Kenya's KRA eTIMS / Gava Connect API. Built for POS systems, ERP platforms, and SaaS products operating in Kenya and East Africa.
Why This SDK?
Integrating with KRA eTIMS is non-trivial in real production environments:
- The API goes down. Your invoices must not be lost.
- Networks in Kenya are intermittent. Retries must be smart, not dumb.
- POS systems process hundreds of transactions per hour. Your queue must be resilient.
- You may serve multiple businesses from one Laravel installation. Multi-tenancy must be first-class.
This SDK handles all of that so you can focus on your product.
Features
| Feature | Status |
|---|---|
| Invoice submission (sync + async) | ✅ Phase 1 |
| Auth token management + auto-refresh | ✅ Phase 1 |
| Exponential backoff retry | ✅ Phase 1 |
| Idempotency protection | ✅ Phase 1 |
| Audit trail (DB) | ✅ Phase 1 |
| Laravel event system integration | ✅ Phase 1 |
| Sandbox/production mode switching | ✅ Phase 1 |
| Testing fake + assertion API | ✅ Phase 1 |
| KRA PIN validation | ✅ Phase 1 |
| Dead letter queue + failed invoice recovery | ✅ Phase 1 |
| Multi-tenant SaaS support | ✅ Phase 1 |
| Stock synchronization | 🔜 Phase 2 |
| Credit/debit note handling | 🔜 Phase 2 |
| Webhook handling | 🔜 Phase 2 |
| QR code + thermal receipt support | 🔜 Phase 3 |
| Branch management | 🔜 Phase 3 |
Installation
Publish the configuration and migrations:
Configuration
Add these variables to your .env file:
Never commit real credentials to version control. Use
.envonly.
Quick Start
Submitting an Invoice Synchronously
Use this when you need an immediate KRA response (e.g. a POS checkout flow):
InvoiceDTO::make() accepts both the original snake_case keys and the KRA field names shown above.
Queuing an Invoice (Recommended for Most Cases)
This is the preferred approach for production. The invoice is dispatched to a durable background job with automatic retries:
Listen to the outcome events in your EventServiceProvider:
Validating a KRA PIN
Checking Invoice Status
Working with Failed Invoices
Invoice Types
| Code | Description | Use Case |
|---|---|---|
S |
Sale | Standard sales invoice |
R |
Credit Note | Refund / reversal of a sale |
D |
Debit Note | Additional charge on a sale |
Tax Type Codes
| Code | Description | VAT Rate |
|---|---|---|
A |
Standard rated | 16% |
B |
Zero rated | 0% |
C |
VAT exempt | N/A |
D |
Non-VATable | N/A |
E |
Excisable (with VAT) | 16% + Excise |
Payment Type Codes
| Code | Description |
|---|---|
CASH |
Cash payment |
CREDIT |
Credit terms |
MPESA |
M-Pesa mobile money |
BANK |
Bank transfer |
CHEQUE |
Cheque |
OTHER |
Other payment methods |
Multi-Tenant SaaS Setup
When serving multiple KRA-registered businesses from one Laravel installation:
Step 1: Enable multi-tenancy in config:
Step 2: Implement the TenantResolverContract:
Step 3: Bind it in your AppServiceProvider:
That's it. Every SDK call now automatically uses the correct credentials for the active tenant.
Testing
The SDK provides a first-class fake for testing without any real HTTP calls.
Stubbing Specific Responses
Running the SDK Test Suite
Queue Worker Setup
Run a dedicated worker for the eTIMS queue in production:
For failed job monitoring:
Architecture Overview
Error Handling Reference
| Exception | Cause | Retryable |
|---|---|---|
EtimsApiException |
KRA API error or network failure | Depends on HTTP status |
EtimsAuthException |
Invalid credentials or expired token | No — fix credentials |
EtimsValidationException |
Invalid DTO data (client-side) | No — fix data |
EtimsIdempotencyException |
Duplicate invoice detected | No — already submitted |
EtimsConfigException |
Missing or invalid SDK config | No — fix config |
Changelog
See CHANGELOG.md.
Contributing
Contributions welcome. Please read CONTRIBUTING.md first.
License
MIT. See LICENSE.
Built with care for the Kenyan and East African developer ecosystem. 🇰🇪
All versions of laravel-etims with dependencies
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/queue Version ^10.0|^11.0|^12.0|^13.0
illuminate/events Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
illuminate/console Version ^10.0|^11.0|^12.0|^13.0
guzzlehttp/guzzle Version ^7.8
spatie/laravel-package-tools Version ^1.16