PHPackages                             mitigoa/kra-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. mitigoa/kra-php-sdk

ActiveLibrary[API Development](/categories/api)

mitigoa/kra-php-sdk
===================

KRA GavaConnect PHP SDK - Unofficial PHP client for Kenya Revenue Authority GavaConnect APIs

1.0.0(4mo ago)532MITPHPPHP ^8.1

Since Feb 22Pushed 4mo agoCompare

[ Source](https://github.com/Mitigoa/kra-php-sdk)[ Packagist](https://packagist.org/packages/mitigoa/kra-php-sdk)[ Docs](https://github.com/Mitigoa/kra-php-sdk)[ RSS](/packages/mitigoa-kra-php-sdk/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (12)Versions (2)Used By (0)

KRA GavaConnect PHP SDK (Unofficial)
====================================

[](#kra-gavaconnect-php-sdk-unofficial)

> Unofficial PHP SDK for Kenya Revenue Authority (KRA) GavaConnect APIs

[![PHP](https://camo.githubusercontent.com/39f5e2ad558177c644205b9c54297bc4d8f9ee8b02602e17d8da016227287c60/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6b72612d7068702f73646b)](https://packagist.org/packages/mitigoa/kra-php-sdk)[![License](https://camo.githubusercontent.com/6af33cd36616e8cf52bf5c8919f63c25b11128e14c831217c473022796d3fb53/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6b72612d7068702f73646b)](https://packagist.org/packages/mitigoa/kra-php-sdk)[![Version](https://camo.githubusercontent.com/be17ad717275ad85a3e35deb494316ddc3c39efcca2f7dc28b2a310bfc1d4efd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b72612d7068702f73646b)](https://packagist.org/packages/mitigoa/kra-php-sdk)

Overview
--------

[](#overview)

The KRA GavaConnect PHP SDK is a comprehensive, PSR-compliant PHP library for interacting with the Kenya Revenue Authority's GavaConnect APIs. It provides a clean, type-safe interface for:

- PIN Validation
- Tax Compliance Certificate (TCC) Verification
- Taxpayer Obligations &amp; Liabilities
- NIL Return Filing
- eTIMS Invoice Submission
- e-Slip Verification
- Excise License Checks

Features
--------

[](#features)

- **Framework-agnostic core** - Zero Laravel/Symfony dependencies
- **PSR compliance** - PSR-4 autoloading, PSR-7 HTTP messages, PSR-18 HTTP client, PSR-6 caching
- **Auto token management** - OAuth2 client credentials with silent refresh
- **Typed responses** - Every API returns strongly-typed DTOs
- **Granular exceptions** - `AuthException`, `ApiException`, `RateLimitException`
- **Offline testable** - Full sandbox mode + Mockery-ready interfaces
- **Plugin ecosystem** - Laravel, WordPress, WooCommerce, Symfony, Filament

Requirements
------------

[](#requirements)

- PHP 8.1+
- Composer

Installation
------------

[](#installation)

```
composer require kra-php/sdk
```

Quick Start
-----------

[](#quick-start)

```
use KraPHP\KraClient;

$kra = new KraClient([
    'client_id'     => getenv('KRA_CLIENT_ID'),
    'client_secret' => getenv('KRA_CLIENT_SECRET'),
    'environment'   => 'sandbox', // or 'production'
]);

// Validate a PIN
$pin = $kra->pin()->validate('A000000010');
echo $pin->taxpayerName;    // "ACME KENYA LIMITED"
echo $pin->pinStatus;       // "ACTIVE"

// Validate TCC
$tcc = $kra->tcc()->validate('A000000010', 'TCC-2024-XXXXX');
echo $tcc->isValid;         // true
echo $tcc->expiryDate;     // "2024-12-31"

// Get tax obligations
$obligations = $kra->taxpayer()->getObligations('A000000010');

// File NIL return
$result = $kra->returns()->fileNil([
    'pin'         => 'A000000010',
    'obligation'  => 'VAT',
    'period'      => '2024-10',
    'reason'      => 'No taxable supplies',
]);

// Submit eTIMS invoice
$invoice = new EtimsInvoice([
    'invoiceNumber' => 'INV-2024-001',
    'buyerPin'      => 'A000000020',
    'buyerName'     => 'BUYER COMPANY LTD',
    'invoiceDate'   => '2024-11-01',
    'currency'      => 'KES',
    'items'         => [
        [
            'description' => 'Web Development Services',
            'quantity'    => 1,
            'unitPrice'   => 50000.00,
            'vatRate'     => 16,
            'vatAmount'   => 8000.00,
        ],
    ],
    'totalExclVat'  => 50000.00,
    'totalVat'      => 8000.00,
    'totalInclVat'  => 58000.00,
]);

$response = $kra->etims()->submitInvoice($invoice);
echo $response->invoiceId;
echo $response->controlUnit;
echo $response->qrCode;
```

Configuration
-------------

[](#configuration)

```
$config = [
    // Required
    'client_id'     => 'your-client-id',
    'client_secret' => 'your-client-secret',

    // Environment
    'environment'   => 'sandbox', // 'sandbox' | 'production'

    // Base URLs (optional - defaults provided)
    'sandbox_base_url' => 'https://api-sandbox.developer.go.ke',
    'prod_base_url'    => 'https://api.developer.go.ke',
    'etims_sandbox_url' => 'https://etims-api-sbx.kra.go.ke',
    'etims_prod_url'   => 'https://etims-api.kra.go.ke/etims-api',

    // Cache (optional)
    'cache_driver'  => 'file', // 'file' | 'redis' | 'memcached' | 'array'
    'cache_ttl'     => 3300,  // seconds

    // HTTP (optional)
    'timeout'       => 30,    // seconds
    'retry_attempts' => 3,

    // eTIMS mTLS (optional)
    'etims_cert_path' => '/path/to/client.crt',
    'etims_key_path'  => '/path/to/client.key',
];

$kra = new KraClient($config);
```

Environment Variables
---------------------

[](#environment-variables)

```
# OAuth2 Credentials
KRA_CLIENT_ID=your-client-id
KRA_CLIENT_SECRET=your-client-secret

# Environment
KRA_ENVIRONMENT=sandbox

# Cache
KRA_CACHE_DRIVER=redis
KRA_CACHE_TTL=3300

# HTTP
KRA_TIMEOUT=30
KRA_RETRY_ATTEMPTS=3

# eTIMS
KRA_ETIMS_CERT_PATH=/path/to/client.crt
KRA_ETIMS_KEY_PATH=/path/to/client.key
```

Error Handling
--------------

[](#error-handling)

```
use KraPHP\Exceptions\AuthException;
use KraPHP\Exceptions\ApiException;
use KraPHP\Exceptions\RateLimitException;

try {
    $pin = $kra->pin()->validate('A000000010');
} catch (AuthException $e) {
    // Authentication failed
    echo $e->getMessage();
    echo $e->getKraErrorCode(); // e.g., 'INVALID_CREDENTIALS'
} catch (ApiException $e) {
    // API error response
    echo $e->getHttpStatusCode(); // e.g., 404
    echo $e->getKraErrorCode();   // e.g., 'PIN_NOT_FOUND'
} catch (RateLimitException $e) {
    // Rate limit exceeded
    echo $e->getRetryAfter(); // seconds until retry
}
```

Testing
-------

[](#testing)

```
# Install dependencies
composer install

# Run unit tests
vendor/bin/phpunit --testsuite unit

# Run with coverage
vendor/bin/phpunit --coverage-html coverage/

# Run static analysis
vendor/bin/phpstan analyse

# Fix code style
vendor/bin/php-cs-fixer fix
```

API Coverage
------------

[](#api-coverage)

APIEndpointMethodPIN Validator`/pin/validate`GETPIN by ID`/pin/check-by-id`GETTCC Checker`/tcc/validate`GETTaxpayer Obligations`/taxpayer/obligations`GETTaxpayer Liabilities`/taxpayer/liabilities`GETNIL Return`/returns/nil`POSTe-Slip Verify`/eslip/verify`GETExcise License`/excise/check`GETeTIMS Invoice`/etims/invoice`POSTeTIMS Stock IO`/etims/stock`POSTeTIMS Purchase`/etims/purchase`POSTDocumentation
-------------

[](#documentation)

- [KRA Developer Portal](https://developer.go.ke)
- [API Documentation](https://developer.go.ke/docs)

License
-------

[](#license)

MIT License - see [LICENSE](LICENSE) file.

Support
-------

[](#support)

- Email:
- GitHub Issues:

---

Built for Kenya. Open to the world.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance76

Regular maintenance activity

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

131d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a27eaf3d2ba621fa2c6469dee1cdc9d3d3260dff8a7be368858d50d52ac028fc?d=identicon)[Mitigoa](/maintainers/Mitigoa)

---

Top Contributors

[![Mitigoa](https://avatars.githubusercontent.com/u/28347794?v=4)](https://github.com/Mitigoa "Mitigoa (6 commits)")

---

Tags

oauth2pintaxkenyatcckraetimsgavaconnect

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mitigoa-kra-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/mitigoa-kra-php-sdk/health.svg)](https://phpackages.com/packages/mitigoa-kra-php-sdk)
```

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M737](/packages/sylius-sylius)[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[google/auth

Google Auth Library for PHP

1.4k294.2M219](/packages/google-auth)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
