Skip to content

A library to get tax offices by city plate and verify tax numbers.

License

Notifications You must be signed in to change notification settings

tarfin-labs/tax-identification-number

Repository files navigation

API Client for Validating Tax Identification Number.

Latest Version on Packagist Total Downloads GitHub Actions

Introduction

With this package you can get tax offices by city plates and validate tax identification numbers on GIB (Gelir İdaresi Başkanlığı).

This package requires PHP 7.4 or higher.

Installation

You can install the package via composer:

composer require tarfin-labs/tax-identification-number

Usage

Listing tax offices by city plate:

use TarfinLabs\TaxIdentificationNumber\Validation;
use TarfinLabs\TaxIdentificationNumber\Exceptions\NotFoundException;

try {
    $offices = Validation::init()->getTaxOfficesByCityPlate(34);
} catch (NotFoundException $e) {
    echo $e->getMessage();
}

Output:

[
    [
        "code" => "034XXX",
        "name" => "TAX OFFICE NAME 1",
    ],
    [
        "code" => "034XXY",
        "name" => "TAX OFFICE NAME 2
    ],
]

Validating a tax identification number:

use TarfinLabs\TaxIdentificationNumber\Validation;

try {
    $response = Validation::init()->validate(1234567890, '034455');
    
    $response->isValid(); // boolean
    $response->getStatus(); // "1"
    $response->getTckn(); // ""
    $response->getStatusText(); // "FAAL"
    $response->getTaxNumber(); // "123123123"
    $response->getTaxOfficeNumber(); // "034455"
    $response->getCompanyTitle(); // "ACME INC."
} catch (\Throwable $e) {
    echo $e->getMessage();
}

If you want to validate a TCKN for a sole proprietorship, you need to give TCKN (11 characters) as first parameter to validate() method.

use TarfinLabs\TaxIdentificationNumber\Validation;

try {
    $response = Validation::init()->validate(12345678902, '034455');
    
    $response->isValid(); // boolean
    $response->getStatus(); // "1"
    $response->getTckn(); // "12345678902"
    $response->getStatusText(); // "FAAL"
    $response->getTaxNumber(); // "9999999999"
    $response->getTaxOfficeNumber(); // "034455"
    $response->getCompanyTitle(); // "METİN KAYA"
} catch (\Throwable $e) {
    echo $e->getMessage();
}

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

A library to get tax offices by city plate and verify tax numbers.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages