PHP code example of kosov / yii2-fns-check

1. Go to this page and download the library: Download kosov/yii2-fns-check 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/ */

    

kosov / yii2-fns-check example snippets


return [
    //....
    'components' => [
        'fnsCheck' => [
            'class' => 'kosov\yii\fnscheck\FnsCheck',
            'username' => '+7XXXXXXXXXX', // Логин пользователя
            'password' => 'XXXXXX', // Пароль пользователя
        ],
    ]
];

/**
 * Страница вывода детальной информации по чеку.
 */
public function actionDetail()
{
    Yii::$app->getResponse()->format = Response::FORMAT_JSON;

    // Данные с QR-кода t=20181109T194700&s=222.58&fn=XXXXXXXXXXXXXXXX&i=XXXXX&fp=XXXXXXXXX&n=1
    $checkData = Yii::$app->fnsCheck->fromQrCode(Yii::$app->getRequest()->getQueryString());
        
    try {
        // Получение детальной информации по реквизитам чека
        $response = Yii::$app->fnsCheck->getCheckDetail(new CheckDetail($checkData));
        
        return Json::decode($response->getContents());
    } catch (FnsCheckApiException $exception) {
        return Json::encode(['error' => $exception->getMessage()]);
    }
}

composer