PHP code example of totkt26 / yii2-fns-openapi
1. Go to this page and download the library: Download totkt26/yii2-fns-openapi library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
totkt26 / yii2-fns-openapi example snippets
'components' => [
'fnsClient' => [
'class' => dicr\fns\openapi\FNSClient::class,
'masterToken' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
]
];
use dicr\fns\openapi\FNSClient;
use dicr\fns\openapi\types\GetTicketInfo;
use dicr\fns\openapi\types\GetTicketResult;
use dicr\fns\openapi\types\TypeOperation;
/** @var FNSClient $fnsClient получаем клиент API */
$fnsClient = Yii::$app->get('fnsClient');
// данные чека
$ticketInfo = new GetTicketInfo([
'Sum' => 99100,
'Date' => '2020-10-03T15:27:00',
'Fn' => '9280440300430432',
'TypeOperation' => TypeOperation::INCOME,
'FiscalDocumentId' => 29127,
'FiscalSign' => 266252041
]);
/** @var GetTicketResult $result получаем данные по чеку */
$result = $fnsClient->getTicket($ticketInfo);
// проверяем код возвраща
if ($result->Code !== 200) {
throw new \yii\base\Exception($result->Message);
}
// данные билета в $result->Ticket
print_r($result->Ticket);