tarfin-labs/tax-identification-number

API client for validating Tax Identification Number.

v1.2.0 2023-05-11 14:25 UTC

This package is auto-updated.

Last update: 2024-11-11 17:54:21 UTC


README

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 development@tarfin.com instead of using the issue tracker.

Credits

License

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