Search by

voyanara / rekvizit

voyanara

Russian requisites for PHP: offline Bank of Russia BIC directory (ED807) and validation of INN, KPP, OGRN, OGRNIP, SNILS and bank accounts. Framework-agnostic, with Laravel and Symfony bridges.

Package info

github.com/Voyanara/rekvizit

pkg:composer/voyanara/rekvizit

Statistics

Installs: 7

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.2.0 2026-11-30 14:37 UTC

This package is auto-updated.

Last update: 2026-11-30 14:48:16 UTC


README

Rekvizit

CI Latest version PHP version Downloads License

English · Русский

Validation of Russian requisites and an offline Bank of Russia BIC directory for PHP 8.4+. A framework-agnostic core with bridges for Laravel and Symfony.

  • INN, KPP, OGRN, OGRNIP, SNILS — format, control digits, normalisation of user input.
  • Bank accounts — the control key against the BIK (Bank of Russia order N 515), including cash settlement centres, correspondent accounts and clearing currency letters, where most implementations go wrong.
  • BIC directory — bank name, correspondent account, SWIFT, address, licence status and restrictions from the official Bank of Russia file (ED807), stored locally: no paid APIs, no request per lookup. Search by BIK or by name.
  • Self-employed status — asks the FNS service whether a person pays the professional income tax (НПД), with a cache that respects its limit of 2 requests a minute.
  • Laravel — validation rules, a facade, artisan commands and a daily scheduled update.
  • Symfony — #[Inn], #[Bik], #[BankAccount] and other constraints.

Contents

Installation

composer require voyanara/rekvizit

Requirements: PHP 8.4+ with xmlreader. Downloading the BIC directory also needs the zip extension and any PSR-18 HTTP client (Guzzle, Symfony HttpClient, ...); it is discovered automatically.

Validation

Every requisite is an immutable value object. An invalid one cannot be created.

use Voyanara\Rekvizit\Banking\Domain\AccountNumber;
use Voyanara\Rekvizit\Banking\Domain\Bik;
use Voyanara\Rekvizit\Requisites\Domain\Inn;
use Voyanara\Rekvizit\Requisites\Domain\Kpp;
use Voyanara\Rekvizit\Requisites\Domain\Snils;

Inn::isValid('7707083893');                       // true
Inn::tryFrom('7707083894');                       // null: wrong control digit

$inn = Inn::fromString(' 7707 083 893 ');         // spaces and hyphens are removed
$inn->value;                                      // "7707083893"
$inn->isLegalEntity();                            // true (12 digits = individual)

Kpp::fromString('7736ab001')->reasonCode();       // "AB": Latin letters are allowed in positions 5-6
Snils::fromString('11223344595')->format();       // "112-233-445 95"

AccountNumber::isValidFor('40702810938000000001', '044525225');  // true
AccountNumber::isValidFor('40102810545370000003', '004525988');  // true: single treasury account of a treasury office
AccountNumber::forBik('30101810400000000225', Bik::fromString('044525225'))->isCorrespondentAccount(); // true
Class What is checked
Inn 10 digits (organisation) or 12 digits (individual), FNS control digits
Kpp NNNNPPXXX, positions 5-6 may be Latin capital letters
Ogrn 13 digits, starts with 1 or 5, control digit (mod 11)
Ogrnip 15 digits, starts with 3, control digit (mod 13)
Snils 11 digits, control number (not checked for numbers up to 001-001-998)
Bik 9 digits
AccountNumber 20 characters, clearing currency letter in position 6, control key against a BIK (including correspondent accounts and treasury accounts held at the Bank of Russia)

Every class has fromString(), tryFrom(), isValid(), equals() and casts to string. fromString() throws InvalidRequisite that tells what is wrong:

use Voyanara\Rekvizit\Shared\Domain\InvalidReason;
use Voyanara\Rekvizit\Shared\Domain\InvalidRequisite;

try {
    Inn::fromString('7707083894');
} catch (InvalidRequisite $e) {
    $e->type;         // RequisiteType::Inn
    $e->reason;       // InvalidReason::Checksum (also Empty, Characters, Length, Format)
    $e->getMessage(); // Invalid INN "7707083894": the control digits do not match.
}

BIC directory

The directory is not shipped with the package: it changes every business day. Download it once and refresh it daily. The package never goes to the network on its own.

vendor/bin/rekvizit update   # download from cbr.ru (about 100 KB) and save
vendor/bin/rekvizit status   # date and size of the installed copy
vendor/bin/rekvizit search сбербанк   # find banks by name

By default it is saved to var/rekvizit/bik.json in the project root; set REKVIZIT_DIRECTORY_PATH or pass --path= to change it. Add the file to .gitignore. A cron entry keeps it fresh:

30 21 * * * cd /path/to/project && vendor/bin/rekvizit update
use Voyanara\Rekvizit\Rekvizit;

$banks = Rekvizit::banks();               // or Rekvizit::banks('/custom/path/bik.json')

$bank = $banks->find('044525225');        // null if the BIK is unknown
$bank->name;                              // "ПАО Сбербанк"
$bank->englishName;                       // "SBERBANK"
$bank->correspondentAccount()?->number;   // 30101810400000000225
$bank->swift();                           // "SABRRUMM"
(string) $bank->address;                  // "117312, г. Москва, улица Вавилова, дом 19"
$bank->type()?->label();                  // "Кредитная организация"
$bank->isActive();                        // false if the licence is revoked or the participant is deleted
$bank->restrictions;                      // restrictions with dates and descriptions

$banks->get('044525225');                 // throws BankNotFound instead of returning null
$banks->isActive('043207777');            // false: licence revoked

Search by name

$banks->search('сбербанк');               // list<Bank>, best matches first
$banks->search('альфа екатеринбург', limit: 5); // every word must be in the name
$banks->search('тбанк', includeInactive: true);

Case, the letter "ё", quotes and punctuation are ignored; the English name is searched too, the address is not. Banks are ranked by the better of their two names: a name that starts with the query, then a name where every word of the query starts a word, then the rest; head offices come before their branches. Deleted banks and banks with a revoked licence are skipped unless includeInactive: true. The default limit is 20; a search over the whole directory takes a few milliseconds, and only the banks returned are turned into objects.

Before the first download find() and search() throw BankDirectoryNotInstalled with the command to run. For a UI there are isInstalled(), metadata() (directory date, number of participants, download time) and isStale(days), so an admin page can show a warning and a button that calls Rekvizit::updater()->update().

Servers without internet access: download https://www.cbr.ru/s/newbik elsewhere and import the file: vendor/bin/rekvizit update --from=20261130ED01OSBR.zip.

Storage: one JSON file of about 850 KB, replaced atomically; a bank is turned into an object only when requested. Updating never breaks the installed copy: if the download or parsing fails, the old copy stays. A suspicious directory (older than the installed one, or with less than half of its participants) is refused; add --force to install it anyway. Long-running workers (Octane, queue workers) notice a new file automatically, no restart needed.

Self-employed status

Whether a person is self-employed (pays the professional income tax, НПД) is known only to the FNS. The package asks its public service npd.nalog.ru/check-status: this is an online request, and the INN is sent to the FNS.

use Voyanara\Rekvizit\Rekvizit;

$checker = Rekvizit::selfEmployed();

$checker->isSelfEmployed('500100732259');  // false
$status = $checker->check('500100732259', '2025-06-01');
$status->isSelfEmployed;                   // bool
$status->message;                          // the service's own text

The date is a 'YYYY-MM-DD' string or a DateTimeInterface: a value at midnight is a calendar date, any other moment is converted to Moscow time, so new DateTimeImmutable() means "today in Moscow" in any time zone. Without a date, today in Moscow is checked.

vendor/bin/rekvizit self-employed 500100732259 --date=2025-06-01

Exit codes of self-employed (and rekvizit:self-employed in Laravel): 0 self-employed, 1 not self-employed, 2 invalid arguments, 3 the status is unknown (the service failed or the limit was hit).

  • The limit: 2 requests a minute from one IP address. Answers are cached: "self-employed" for 6 hours, "not self-employed" for 10 minutes (the person may register right after the check). By default the cache is the memory of the process; pass any PSR-16 cache with your application secret to share it: Rekvizit::selfEmployed(cache: $psr16Cache, cacheSecret: $appSecret, cacheTtl: 3600, negativeCacheTtl: 0). cacheTtl: 0 turns the cache off. When the limit is hit (or the service answers HTTP 429), RateLimitExceeded is thrown: retry in a minute, for example from a queued job. Workers that ask about the same person at the same moment may both miss the cache; queue the checks if the limit matters.
  • In a PSR-16 cache the INN is pseudonymised: the key is an HMAC of the INN and the date with the secret, and the INN in the service's text is replaced by a placeholder. Exception messages show the INN masked (5001******59).
  • Arguments the service would reject are rejected before the request, so they do not use up the limit: an invalid INN (InvalidRequisite), an organisation's INN (only a person can be self-employed), a date before 2019-01-01 (the regime start) or in the future. The date defaults to today in Moscow.
  • Any other failure throws StatusCheckFailed (RateLimitExceeded extends it). It means the status is unknown, not "not self-employed".
  • The service asks clients to wait for an answer up to 60 seconds. Without a client, Guzzle is built with a 65-second timeout (10 seconds to connect). A client you pass, Rekvizit::selfEmployed($client), keeps its own settings: give it a timeout, or one hung connection will block the process.

There is deliberately no validation rule for it: a form must not depend on an online service with such a limit. Check the status where you can handle a failure, for example in a queued job.

Laravel

The service provider is discovered automatically.

php artisan rekvizit:update     # also: --from=<downloaded archive>, --force
php artisan rekvizit:status
php artisan rekvizit:search сбербанк          # also: --limit=, --all
php artisan rekvizit:self-employed 500100732259 --date=2025-06-01

Its status is shown in php artisan about.

Scheduled update

The package adds rekvizit:update to the Laravel scheduler: every day at 21:30 Moscow time, when the Bank of Russia has published the directory for the next business day. It runs only if the application's scheduler runs (* * * * * php artisan schedule:run in cron, or php artisan schedule:work); check it with php artisan schedule:list.

# .env
REKVIZIT_SCHEDULE="0 */6 * * *"   # another time: any cron expression
REKVIZIT_SCHEDULE=null            # off: update with php artisan rekvizit:update yourself

Without the scheduled update the directory gets stale within days, and Bik::active() stops noticing revoked licences.

use Voyanara\Rekvizit\Laravel\Facades\Banks;
use Voyanara\Rekvizit\Laravel\Facades\SelfEmployed;
use Voyanara\Rekvizit\Laravel\Rules\BankAccount;
use Voyanara\Rekvizit\Laravel\Rules\Bik;
use Voyanara\Rekvizit\Laravel\Rules\Inn;

Banks::find('044525225')?->name;        // "ПАО Сбербанк"
Banks::search('сбер', limit: 10);       // banks by name
SelfEmployed::isSelfEmployed('500100732259');

$request->validate([
    'inn'     => ['required', Inn::legalEntity()],      // or 'inn', 'inn:legal', 'inn:individual'
    'kpp'     => ['required', 'kpp'],
    'ogrn'    => ['required', 'ogrn'],
    'bik'     => ['required', Bik::active()],           // or 'bik', 'bik:exists', 'bik:active'
    'account' => ['required', new BankAccount('bik')],  // or 'bank_account:bik'
]);
Rule String form Notes
new Inn(), Inn::legalEntity(), Inn::individual() inn, inn:legal, inn:individual
new Kpp(), new Ogrn(), new Ogrnip(), new Snils() kpp, ogrn, ogrnip, snils
new Bik(), Bik::exists(), Bik::active() bik, bik:exists, bik:active exists/active use the directory
new BankAccount('bik') bank_account:bik the BIK field, dot notation supported

Messages are in English and Russian. Publish the configuration or the translations to change them:

php artisan vendor:publish --tag=rekvizit-config
php artisan vendor:publish --tag=rekvizit-lang

Configuration

Every setting has an environment variable; you need none of them to start. The values below are the defaults:

# .env

# BIC directory
REKVIZIT_DIRECTORY_PATH=/path/to/storage/app/rekvizit/bik.json   # default: storage_path('app/rekvizit/bik.json')
REKVIZIT_SOURCE_URL=https://www.cbr.ru/s/newbik
REKVIZIT_SCHEDULE="30 21 * * *"          # Moscow time; null turns the scheduled update off
REKVIZIT_MISSING_DIRECTORY=exception     # Bik::exists() before the first download: exception or format

# Self-employed check
REKVIZIT_SELF_EMPLOYED_CACHE_TTL=21600         # seconds a "self-employed" answer is kept; 0 turns the cache off
REKVIZIT_SELF_EMPLOYED_NEGATIVE_CACHE_TTL=600  # seconds a "not self-employed" answer is kept; 0 does not cache it
REKVIZIT_SELF_EMPLOYED_CACHE_STORE=            # a store from config/cache.php; empty means the default store
REKVIZIT_SELF_EMPLOYED_TIMEOUT=65              # seconds to wait for the FNS service
REKVIZIT_SELF_EMPLOYED_URL=https://statusnpd.nalog.ru/api/v1/tracker/taxpayer_status

The same settings are in config/rekvizit.php after php artisan vendor:publish --tag=rekvizit-config; the time zone of the schedule (schedule_timezone, default Europe/Moscow) is set only there. Cache keys of the self-employed check are made with APP_KEY. A Psr\Http\Client\ClientInterface bound in the container is used instead of the built-in client, and then REKVIZIT_SELF_EMPLOYED_TIMEOUT does not apply.

Symfony

The constraints work with symfony/validator 7.3+ and 8.x.

use Voyanara\Rekvizit\Symfony\Constraint as Rekvizit;

final class CompanyForm
{
    #[Rekvizit\Inn(kind: Rekvizit\Inn::LEGAL_ENTITY)]
    public string $inn = '';

    #[Rekvizit\Kpp]
    public string $kpp = '';

    #[Rekvizit\Bik(check: Rekvizit\Bik::ACTIVE)]
    public string $bik = '';

    #[Rekvizit\BankAccount(bikProperty: 'bik')]
    public string $account = '';
}

Constraints: Inn, Kpp, Ogrn, Ogrnip, Snils, Bik (check: Bik::EXISTS|Bik::ACTIVE), BankAccount (bikProperty, read directly or through a getter). Empty values are left to NotBlank; every message can be changed with message:. Violation codes are public constants (Inn::INVALID_ERROR, Bik::NOT_FOUND_ERROR, ...).

Bik(check: ...) reads the directory from var/rekvizit/bik.json (Symfony already ignores /var/ in git). To use another path, register the validator as a service:

# config/services.yaml
services:
    Voyanara\Rekvizit\Banking\Application\BankDirectory:
        factory: ['Voyanara\Rekvizit\Rekvizit', 'banks']
        arguments: ['%kernel.project_dir%/var/rekvizit/bik.json']

    Voyanara\Rekvizit\Symfony\Constraint\BikValidator:
        arguments: ['@Voyanara\Rekvizit\Banking\Application\BankDirectory']
        tags: ['validator.constraint_validator']

Refresh the directory with vendor/bin/rekvizit update from cron or Symfony Scheduler.

The self-employed check as a service, with the application cache (needs symfony/cache):

services:
    rekvizit.self_employed_cache:
        class: Symfony\Component\Cache\Psr16Cache
        arguments: ['@cache.app']

    Voyanara\Rekvizit\SelfEmployed\Application\SelfEmployedChecker:
        factory: ['Voyanara\Rekvizit\Rekvizit', 'selfEmployed']
        arguments:
            $cache: '@rekvizit.self_employed_cache'
            $cacheSecret: '%kernel.secret%'

Where the rules and data come from

  • BIC directory: the Bank of Russia, cbr.ru/s/newbik, format ED807 of УФЭБС; code descriptions from its "Кодовые значения" document.
  • Account key: «Порядок расчета контрольного ключа в номере лицевого счета», Bank of Russia, 08.09.1997 N 515.
  • INN and KPP: FNS orders ЕД-7-14/559@ and ММВ-7-6/435@.
  • Self-employed status: the FNS API description «Проверка статуса налогоплательщика налога на профессиональный доход (самозанятого)», npd.nalog.ru/check-status.
  • The parser is tested on real directory entries, and a weekly CI job downloads the live directory and checks every account in it.

FAQ

Does it check that a company really exists? No. Offline validation catches typos and invalid numbers; whether an INN belongs to a registered company is answered only by the FNS (online). The only online check in the package is the self-employed status, and it runs only when you call it.

Why is the directory not bundled with the package? It changes every business day; a bundled copy would be stale between releases.

How fast is a lookup? The first lookup in a process (or a PHP-FPM request) reads the JSON file: about 10–15 ms and 5 MB of memory. Further lookups in the same process take microseconds. Validation of INN, KPP, accounts and other requisites does not touch the directory at all.

Contributing and security

See CONTRIBUTING.md and SECURITY.md. Changes are listed in CHANGELOG.md.

License

MIT, see LICENSE.