Unofficial MoyNalog API client
An unofficial wrapper client for lknpd.nalog.ru API
Install
Via Composer
$ composer require shoman4eg/moy-nalog
Usage
Settings
// If need set timezone use this
date_default_timezone_set('Europe/Kaliningrad');
// or set timezone through new DateTimeZone
$operationTime = new DateTimeImmutable('now', new DateTimeZone('Europe/Kaliningrad'))
Authorization
$apiClient = ApiClient::create();
// If known accessToken skip this step
$accessToken = $apiClient->createNewAccessToken($username, $password);
// Access token MUST contains all json response from method createNewAccessToken()
$accessToken = '...';
$apiClient->authenticate($accessToken);
Create income with default client
$name = 'Предоставление информационных услуг #970/2495';
$amount = 1800.30;
$quantity = 1;
$amount = 1;
$operationTime = new DateTimeImmutable('2020-12-31 12:12:00');
$createdIncome = $apiClient->income()->create($name, $amount, $quantity, $operationTime);
Create income with custom client
$name = 'Предоставление информационных услуг #970/2495';
$amount = 1800.30;
$quantity = 1;
$operationTime = new DateTimeImmutable('2020-12-31 12:12:00');
$client = new Shoman4eg\Nalog\DTO\IncomeClient(); // Default. All fields are empty IncomeType is FROM_INDIVIDUAL
// or
$client = new Shoman4eg\Nalog\DTO\IncomeClient('+79009000000', 'Вася Пупкин', \Shoman4eg\Nalog\Enum\IncomeType::INDIVIDUAL, '390000000000');
// or
$client = new Shoman4eg\Nalog\DTO\IncomeClient(null, 'Facebook Inc.', \Shoman4eg\Nalog\Enum\IncomeType::FOREIGN_AGENCY, '390000000000');
// or
$client = new Shoman4eg\Nalog\DTO\IncomeClient(null, 'ИП Вася Пупкин Валерьевич', \Shoman4eg\Nalog\Enum\IncomeType::LEGAL_ENTITY, '7700000000');
$createdIncome = $apiClient->income()->create($name, $amount, $quantity, $operationTime, $client);
Cancel income
$receiptUuid = "20hykdxbp8"
$comment = \Shoman4eg\Nalog\Enum\CancelCommentType::CANCEL;
$partnerCode = null; // Default null
$operationTime = new DateTimeImmutable('now'); //Default 'now'
$requestTime = new DateTimeImmutable('now'); //Default 'now'
$incomeInfo = $apiClient->income()->cancel($receiptUuid, $comment, $operationTime, $requestTime, $partnerCode);
Create Invoice
// todo
Cancel Invoice
// todo
Change payment type in Invoice
// todo
Get user info
$userInfo = $apiClient->user()->get();
Get receipt info
// $receiptUuid = $createdincome->getApprovedReceiptUuid();
// Get print url
$receipt = $apiClient->receipt()->printUrl($receiptUuid);
// Json data
$receipt = $apiClient->receipt()->json($receiptUuid);
References
Автоматизация для самозанятых: как интегрировать налог с IT проектом
JS lib alexstep/moy-nalog
Changelog
Changelog: A complete changelog
License
The MIT License (MIT). Please see License File for more information.