Skip to content

About

Official PHP SDK for TaxLane's free Nigeria tax calculator API (PAYE, VAT, WHT, CIT, CGT & 9 more). Mirror of quineworks/tax-lane's sdk-php/, published to Packagist as quineworks/taxlane.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

quineworks/taxlane

Latest Stable Version Total Downloads PHP Version Require License

Nigeria PAYE, VAT, WHT, CIT, CGT & 9 more tax calculators, as static PHP method calls — no API key, no Guzzle, no account.

use TaxLane\TaxLane;

TaxLane::calculatePaye(['grossAnnualIncome' => 6_000_000])['data'];
// ['taxableIncome' => 6000000, 'payeTax' => 870000, 'monthlyTax' => 72500, ...]
  • Zero Composer dependencies — only the ext-curl PHP extension, which ships with essentially every PHP install (shared hosting, Laravel Forge/Vapor, Docker's official php images). No Guzzle.
  • A single static facade, TaxLane\TaxLane — one camelCase method per endpoint, each taking the request body as a plain associative array (the real camelCase JSON keys, no translation layer) so a call can never drift from the live API's request shape.
  • No API key, no account, no rate-limit tiers to configure — the API itself has none.

Typed constants. Six methods take request fields with a fixed set of valid string values (e.g. calculateVat's mode). Each of those fields now also accepts a case from the matching TaxLane\Enums\* backed enum, for IDE autocomplete and typo-proofing — the raw string this SDK has always accepted still works unchanged, so this is purely additive:

use TaxLane\TaxLane;
use TaxLane\Enums\VatMode;

// New: IDE-autocompleted, typo-proof.
TaxLane::calculateVat(['amount' => 100_000, 'mode' => VatMode::Inclusive]);

// Still works, unchanged: the raw string this SDK has always accepted.
TaxLane::calculateVat(['amount' => 100_000, 'mode' => 'inclusive']);

See src/Enums/ for the full enum list.

Every method returns ['data' => ..., 'rateLimit' => ...] — data is the parsed JSON response as a plain associative array, not a generated class/DTO (see Response shape below for why), and rateLimit is the ceiling that request was measured against (see Rate limits).

Install

composer require quineworks/taxlane

Quickstart

use TaxLane\TaxLane;

$response = TaxLane::calculatePaye([
    'grossAnnualIncome' => 6_000_000,
    'annualRentPaid' => 1_200_000,
]);
$response['data'];
// ['taxableIncome' => 5760000, 'payeTax' => 826800, 'annualTax' => 826800, 'monthlyTax' => 68900,
//  'reliefs' => [...], 'bandBreakdown' => [...]]
$response['rateLimit'];
// ['limit' => 50, 'remaining' => 49, 'reset' => 1757750400]

Every method throws TaxLane\TaxLaneApiException (a \RuntimeException -- getMessage()/getCode() carry the API's error string/HTTP status) on a non-200 response, and accepts an optional trailing $baseUrl argument to point at a local/staging API instead of the production default:

use TaxLane\TaxLane;
use TaxLane\TaxLaneApiException;

try {
    TaxLane::calculatePaye(['grossAnnualIncome' => 'not a number'], 'http://localhost:3000');
} catch (TaxLaneApiException $e) {
    echo $e->getCode() . ' ' . $e->getMessage(); // 400 "grossAnnualIncome is required and must be a number"
    echo $e->getRetryAfter(); // seconds to wait before retrying, only non-null on a 429
}

Endpoints

Method Calculates
calculatePaye PAYE on an employee's gross annual income
calculatePayrollBatch PAYE for up to 1,000 employees in one call
calculateVat VAT on an amount, inclusive or exclusive
calculatePresumptive Presumptive tax on turnover
calculateDirectAssessment Direct Assessment tax on turnover + expenses
calculateCit Companies Income Tax eligibility + liability
calculateWht Withholding tax on a transaction
calculateEmployerCost Full employer cost of a salary package
calculateCgt Capital Gains Tax on a disposal
calculateStampDuty Stamp duty on an instrument
calculateImportDuty Import duty + landed cost on a shipment
calculateNhfContribution NHF contribution on basic salary
calculatePensionContribution Pension contribution + balance projection
calculateCapitalAllowances Taxable profit from assessable profit, capital allowances & loss relief

calculatePaye

use TaxLane\TaxLane;

TaxLane::calculatePaye(['grossAnnualIncome' => 6_000_000, 'annualRentPaid' => 1_200_000])['data'];
// [
//   'taxableIncome' => 5760000,
//   'payeTax' => 826800,
//   'annualTax' => 826800,
//   'monthlyTax' => 68900,
//   'reliefs' => ['rentRelief' => 240000, 'pensionRelief' => 0, 'nhfRelief' => 0, 'nhisRelief' => 0, 'lifeAssurancePremiumRelief' => 0, 'minimumWageExempt' => false, 'taxableTerminationBenefit' => 0],
//   'bandBreakdown' => [
//     ['from' => 800000, 'to' => 3000000, 'rate' => 0.15, 'taxInBand' => 330000],
//     ['from' => 3000000, 'to' => 5760000, 'rate' => 0.18, 'taxInBand' => 496800],
//   ],
// ]

Only grossAnnualIncome is required — every other field defaults to 0.

calculatePayrollBatch

use TaxLane\TaxLane;

TaxLane::calculatePayrollBatch([
    'employees' => [
        ['grossAnnualIncome' => 6_000_000],
        ['grossAnnualIncome' => 900_000, 'annualRentPaid' => 400_000],
    ],
])['data'];
// ['results' => [['taxableIncome' => 6000000, ...], ['taxableIncome' => 820000, ...]]]

Calculates PAYE for up to 1,000 employees in one request — results[i] is exactly what calculatePaye($employees[i]) would return, in the same order. An invalid item throws with an employees[i].-prefixed message; there's no partial-success mode.

calculateVat

TaxLane::calculateVat(['amount' => 100_000, 'mode' => 'exclusive'])['data'];
// ['net' => 100000, 'vat' => 7500, 'gross' => 107500]

calculatePresumptive

TaxLane::calculatePresumptive(['turnover' => 20_000_000])['data'];
// ['turnover' => 20000000, 'taxOwed' => 200000, 'belowFloor' => false, 'monthlySetAside' => 16666.666666666668, 'turnoverToFloor' => 0]

calculateDirectAssessment

TaxLane::calculateDirectAssessment([
    'turnover' => 10_000_000,
    'allowableExpenses' => 3_000_000,
    'qualifyingCapitalExpenditure' => 1_000_000,
    'capitalAllowanceAssetClass' => 'plantAgriculturalEquipmentFurniture',
])['data'];
// ['turnover' => 10000000, 'allowableExpenses' => 3000000, 'capitalAllowance' => 200000, 'taxableProfit' => 6800000, 'taxOwed' => 1014000, 'effectiveRate' => 0.14911764705882352]

calculateCit

TaxLane::calculateCit([
    'turnover' => 30_000_000,
    'fixedAssets' => 100_000_000,
    'isProfessionalServices' => false,
    'taxableProfit' => 5_000_000,
    'assessableProfit' => 8_000_000,
])['data'];
// [
//   'eligibility' => ['turnover' => 30000000, 'fixedAssets' => 100000000, 'isProfessionalServices' => false, 'turnoverEligible' => true, 'fixedAssetsEligible' => true, 'eligible' => true, 'rate' => 0],
//   'standardRate' => ['taxableProfit' => 5000000, 'annualTax' => 1500000],
//   'developmentLevy' => ['assessableProfit' => 8000000, 'developmentLevy' => 320000],
// ]

eligibility is always returned. standardRate is included only when taxableProfit is sent; developmentLevy is included only when assessableProfit is sent — the three are independently computed.

calculateWht

TaxLane::calculateWht(['transactionType' => 'professionalFees', 'amount' => 1_000_000, 'mode' => 'gross'])['data'];
// ['transactionType' => 'professionalFees', 'mode' => 'gross', 'amount' => 1000000, 'rate' => 0.05, 'gross' => 1000000, 'withheld' => 50000, 'net' => 950000]

calculateEmployerCost

TaxLane::calculateEmployerCost([
    'annualBasicSalary' => 6_000_000,
    'annualHousingAllowance' => 1_000_000,
    'annualTransportAllowance' => 500_000,
])['data'];
// ['annualGrossPay' => 7500000, 'pensionablePay' => 7500000, 'employerPensionContribution' => 750000, ..., 'employeePaye' => [...]]

calculateCgt

TaxLane::calculateCgt([
    'taxpayerType' => 'individual',
    'assetType' => 'property',
    'disposalProceeds' => 50_000_000,
    'costBase' => 30_000_000,
])['data'];
// ['chargeableGain' => 20000000, 'exempt' => false, 'cgtLiability' => 3630000]

digitalAssetCategory is required when assetType is 'digital-asset', ignored otherwise.

calculateStampDuty

TaxLane::calculateStampDuty(['instrumentType' => 'tenancy', 'amount' => 12_000_000])['data'];
// ['instrumentType' => 'tenancy', 'amount' => 12000000, 'rate' => 0.0078, 'duty' => 93600, 'exempt' => false]

calculateImportDuty

TaxLane::calculateImportDuty(['fob' => 5_000_000, 'freight' => 300_000, 'insurance' => 100_000, 'band' => '20'])['data'];
// ['fob' => 5000000, 'freight' => 300000, 'insurance' => 100000, 'cif' => 5400000, 'band' => '20', 'dutyRate' => 0.2, 'duty' => 1080000, 'surcharge' => 75600, 'etls' => 27000, 'fcs' => 200000, 'vat' => 508695, 'totalLandedCost' => 7291295]

calculateNhfContribution

TaxLane::calculateNhfContribution(['annualBasicSalary' => 3_000_000])['data'];
// ['annualBasicSalary' => 3000000, 'annualNhfContribution' => 75000, 'monthlyNhfContribution' => 6250]

calculatePensionContribution

TaxLane::calculatePensionContribution(['annualBasicSalary' => 3_000_000, 'yearsToProject' => 10])['data'];
// [
//   'pensionablePay' => 3000000,
//   'employeeContribution' => 240000,
//   'employerContribution' => 300000,
//   'voluntaryContribution' => 0,
//   'totalAnnualContribution' => 540000,
//   'projection' => [['year' => 0, 'balance' => 0], ['year' => 1, 'balance' => 578000], ...],
// ]

Only annualBasicSalary is required — yearsToProject defaults to 10 (clamped to 50) and every other field defaults to 0/0.07.

calculateCapitalAllowances

TaxLane::calculateCapitalAllowances([
    'assessableProfit' => 20_000_000,
    'broughtForwardLossRelief' => 3_000_000,
    'capitalAllowances' => [
        'rate10' => ['qualifyingExpenditure' => 10_000_000],
        'rate25' => ['qualifyingExpenditure' => 6_000_000],
    ],
])['data'];
// [
//   'assessableProfit' => 20000000,
//   'lossReliefApplied' => 3000000,
//   'lossReliefCarriedForward' => 0,
//   'capitalAllowanceApplied' => 2500000,
//   'capitalAllowanceCarriedForward' => 0,
//   'taxableProfit' => 14500000,
// ]

Only assessableProfit is required. Unlike every other method above, this one takes a nested capitalAllowances array (keyed rate10/rate20/ rate25) and flattens it to the API's nine flat wire fields internally, since POST /v1/capital-allowances has never accepted a nested body.

Response shape

Every method returns ['data' => ..., 'rateLimit' => ...]. data is the parsed JSON response body as a plain associative array, not a generated readonly class/DTO. PHP has no structural-typing import across a package boundary the way the JS/TS SDK's cross-package TS type import does, and hand-duplicating every response shape in a third, PHP-only schema would be exactly the kind of extra place to maintain and drift from that SDK avoided in the first place. A plain array is also the common pattern lightweight PHP API-wrapper packages use for response bodies when they don't need strict typing for a stateless, no-auth JSON POST. Each method's PHPDoc block documents data's top-level keys so an IDE isn't left guessing without a shape entirely.

Errors

A missing or non-numeric/non-boolean required field, or an invalid enum value, throws TaxLane\TaxLaneApiException with getCode() of 400 and a getMessage() describing the offending field. See the full field-by-field reference at taxlane.ng/developers or the OpenAPI spec.

Every exception this SDK throws implements the TaxLane\TaxLaneException marker interface, so a single catch (TaxLaneException $e) catches anything the SDK itself threw, API or network:

  • TaxLane\TaxLaneApiException — any non-200 API response. getCode() is the HTTP status, getMessage() is the API's error string.

  • TaxLane\TaxLaneRateLimitException — a TaxLaneApiException subtype, thrown specifically on a 429. Catch this instead of checking getCode() === 429 when you want to special-case rate limiting:

    use TaxLane\TaxLane;
    use TaxLane\TaxLaneApiException;
    use TaxLane\TaxLaneRateLimitException;
    
    try {
        TaxLane::calculatePaye(['grossAnnualIncome' => 6_000_000]);
    } catch (TaxLaneRateLimitException $e) {
        $e->getRateLimit(); // ['limit' => 50, 'remaining' => 0, 'reset' => 1757750400]
        sleep($e->getRetryAfter() ?? 1);
    } catch (TaxLaneApiException $e) {
        echo $e->getCode() . ' ' . $e->getMessage();
    }

    Every TaxLaneApiException (including the 429 subtype) exposes getRateLimit(), the same {limit, remaining, reset} shape a successful call's rateLimit key carries, parsed off that same error response — not just getRetryAfter().

  • TaxLane\TaxLaneConnectionException — a \RuntimeException subtype, thrown instead of the API exceptions above when the request never got a response at all (DNS/TLS/connection failure, or the request timed out — see Timeouts).

Existing code that catches TaxLaneApiException or the bare \RuntimeException keeps working unchanged — both new types are subtypes of what was already thrown, not a replacement for it.

Timeouts

Every request has a 5-second connect timeout and a 30-second total timeout, hardcoded — generous enough that a slow but healthy response never trips it, tight enough that a stalled connection fails fast instead of hanging the calling process forever. Not configurable; this SDK has no constructor/config surface (see Install), and curl's own default is no timeout at all.

User-Agent

Every request sends User-Agent: quineworks-taxlane-php/<version> PHP/<php-version> (e.g. quineworks-taxlane-php/0.1.11 PHP/8.3.1) — not configurable.

Rate limits

Every response's rateLimit key (['limit' => int, 'remaining' => int, 'reset' => int]) is parsed from that response's X-RateLimit-Limit/ X-RateLimit-Remaining/X-RateLimit-Reset headers — present on every successful and 4xx response. On an error, that same shape is available via TaxLaneApiException::getRateLimit() — not just on a successful call's rateLimit key. On a 429, TaxLaneApiException:: getRetryAfter() additionally returns the number of seconds to wait before retrying, parsed from the Retry-After header — see the TaxLaneRateLimitException example in Errors above for the recommended way to catch it.

Limits

No API key required, no daily cap. The underlying API is limited to 50 requests/second (100 burst) at the shared Gateway level to keep the service available for everyone — this SDK does no client-side retry/backoff, since there's no rate limit to work around on a per-caller basis.

Distribution

Published to Packagist as quineworks/taxlane. This README's source of truth is quineworks/tax-lane's sdk-php/ directory — the code here in quineworks/taxlane-php is a public mirror, kept in sync by that repo's sdk-php-publish CI workflow on every tagged release, so that Packagist (which needs anonymous access to a public VCS repo, and can't index a subdirectory of a larger repo) has something to actually publish. Don't edit this copy directly — the next sync will overwrite it.

License

MIT — see LICENSE.

About

Official PHP SDK for TaxLane's free Nigeria tax calculator API (PAYE, VAT, WHT, CIT, CGT & 9 more). Mirror of quineworks/tax-lane's sdk-php/, published to Packagist as quineworks/taxlane.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages