2021-11-20 16:19:35 +00:00
|
|
|
|
<?php
|
2022-12-14 16:19:55 +00:00
|
|
|
|
|
2021-11-20 16:19:35 +00:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
|
|
|
|
|
*
|
|
|
|
|
* This code is licensed under MIT.
|
|
|
|
|
* Этот код распространяется по лицензии MIT.
|
|
|
|
|
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
|
|
|
|
|
*/
|
|
|
|
|
|
2022-12-14 16:19:55 +00:00
|
|
|
|
declare(strict_types=1);
|
2021-11-20 16:19:35 +00:00
|
|
|
|
|
|
|
|
|
namespace AtolOnline\Api;
|
|
|
|
|
|
|
|
|
|
use AtolOnline\{
|
2022-12-14 16:19:55 +00:00
|
|
|
|
Constraints,
|
2021-12-18 06:45:00 +00:00
|
|
|
|
TestEnvParams};
|
|
|
|
|
use AtolOnline\Entities\{
|
|
|
|
|
Correction,
|
|
|
|
|
Receipt};
|
|
|
|
|
use AtolOnline\Exceptions\{
|
|
|
|
|
AuthFailedException,
|
|
|
|
|
EmptyGroupException,
|
|
|
|
|
EmptyLoginException,
|
|
|
|
|
EmptyPasswordException,
|
|
|
|
|
InvalidCallbackUrlException,
|
|
|
|
|
InvalidEntityInCollectionException,
|
|
|
|
|
InvalidInnLengthException,
|
|
|
|
|
InvalidPaymentAddressException,
|
|
|
|
|
InvalidUuidException,
|
|
|
|
|
TooLongCallbackUrlException,
|
|
|
|
|
TooLongLoginException,
|
|
|
|
|
TooLongPasswordException,
|
|
|
|
|
TooLongPaymentAddressException};
|
2021-11-20 16:19:35 +00:00
|
|
|
|
use GuzzleHttp\Exception\GuzzleException;
|
2021-12-18 06:45:00 +00:00
|
|
|
|
use JetBrains\PhpStorm\Pure;
|
2021-11-20 16:19:35 +00:00
|
|
|
|
use Ramsey\Uuid\Uuid;
|
|
|
|
|
|
|
|
|
|
/**
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* Класс фискализатора для регистрации документов на ККТ
|
2021-11-20 16:19:35 +00:00
|
|
|
|
*/
|
2021-12-19 14:50:52 +00:00
|
|
|
|
final class Fiscalizer extends AtolClient
|
2021-11-20 16:19:35 +00:00
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @var string|null Группа ККТ
|
|
|
|
|
*/
|
|
|
|
|
private ?string $group = null;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string|null URL для приёма POST-запроса от API АТОЛ с результатом регистрации документа
|
|
|
|
|
*/
|
|
|
|
|
private ?string $callback_url = null;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Конструктор
|
|
|
|
|
*
|
|
|
|
|
* @param bool $test_mode
|
|
|
|
|
* @param string|null $login
|
|
|
|
|
* @param string|null $password
|
|
|
|
|
* @param string|null $group
|
|
|
|
|
* @param array $config
|
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws TooLongLoginException
|
|
|
|
|
* @throws TooLongPasswordException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws EmptyGroupException
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @see https://guzzle.readthedocs.io/en/latest/request-options.html
|
|
|
|
|
*/
|
|
|
|
|
public function __construct(
|
|
|
|
|
bool $test_mode = true,
|
|
|
|
|
?string $login = null,
|
|
|
|
|
?string $password = null,
|
|
|
|
|
?string $group = null,
|
|
|
|
|
array $config = []
|
|
|
|
|
) {
|
|
|
|
|
parent::__construct($test_mode, $login, $password, $config);
|
|
|
|
|
!is_null($group) && $this->setGroup($group);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-18 06:45:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* Возвращает группу доступа к ККТ в соответствии с флагом тестового режима
|
|
|
|
|
*
|
|
|
|
|
* @return string|null
|
|
|
|
|
*/
|
|
|
|
|
#[Pure]
|
|
|
|
|
public function getGroup(): ?string
|
|
|
|
|
{
|
|
|
|
|
return $this->isTestMode()
|
|
|
|
|
? TestEnvParams::FFD105()['group']
|
|
|
|
|
: $this->group;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-20 16:19:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливает группу доступа к ККТ
|
|
|
|
|
*
|
|
|
|
|
* @param string $group
|
|
|
|
|
* @return $this
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws EmptyGroupException
|
2021-11-20 16:19:35 +00:00
|
|
|
|
*/
|
|
|
|
|
public function setGroup(string $group): self
|
|
|
|
|
{
|
|
|
|
|
// критерии к длине строки не описаны ни в схеме, ни в документации
|
2021-12-18 06:45:00 +00:00
|
|
|
|
empty($group = trim($group)) && throw new EmptyGroupException();
|
2021-11-20 16:19:35 +00:00
|
|
|
|
$this->group = $group;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* Возвращает URL для приёма колбеков
|
2021-11-20 16:19:35 +00:00
|
|
|
|
*
|
|
|
|
|
* @return string|null
|
|
|
|
|
*/
|
2021-12-18 06:45:00 +00:00
|
|
|
|
public function getCallbackUrl(): ?string
|
2021-11-20 16:19:35 +00:00
|
|
|
|
{
|
2021-12-18 06:45:00 +00:00
|
|
|
|
return $this->callback_url;
|
2021-11-20 16:19:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Устанавливает URL для приёма колбеков
|
|
|
|
|
*
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @param string|null $url
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @return $this
|
|
|
|
|
* @throws TooLongCallbackUrlException
|
|
|
|
|
* @throws InvalidCallbackUrlException
|
|
|
|
|
*/
|
2021-12-18 06:45:00 +00:00
|
|
|
|
public function setCallbackUrl(?string $url = null): self
|
2021-11-20 16:19:35 +00:00
|
|
|
|
{
|
2021-12-18 06:45:00 +00:00
|
|
|
|
$url = trim((string)$url);
|
2021-11-20 16:19:35 +00:00
|
|
|
|
if (mb_strlen($url) > Constraints::MAX_LENGTH_CALLBACK_URL) {
|
2021-12-18 06:45:00 +00:00
|
|
|
|
throw new TooLongCallbackUrlException($url);
|
|
|
|
|
} elseif (!empty($url) && !preg_match(Constraints::PATTERN_CALLBACK_URL, $url)) {
|
|
|
|
|
throw new InvalidCallbackUrlException();
|
2021-11-20 16:19:35 +00:00
|
|
|
|
}
|
2021-12-18 06:45:00 +00:00
|
|
|
|
$this->callback_url = $url ?: null;
|
2021-11-20 16:19:35 +00:00
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Регистрирует документ прихода
|
|
|
|
|
*
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @param Receipt $receipt Объект документа
|
|
|
|
|
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @return AtolResponse|null
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws AuthFailedException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
* @throws InvalidEntityInCollectionException
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws InvalidInnLengthException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws InvalidPaymentAddressException
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws TooLongPaymentAddressException
|
|
|
|
|
*/
|
2021-12-19 14:29:17 +00:00
|
|
|
|
public function sell(Receipt $receipt, ?string $external_id = null): ?AtolResponse
|
2021-11-20 16:19:35 +00:00
|
|
|
|
{
|
2021-12-18 06:45:00 +00:00
|
|
|
|
return $this->registerDocument('sell', $receipt, $external_id);
|
2021-11-20 16:19:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Регистрирует документ возврата прихода
|
|
|
|
|
*
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @param Receipt $receipt Объект документа
|
|
|
|
|
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @return AtolResponse|null
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws AuthFailedException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
* @throws InvalidEntityInCollectionException
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws InvalidInnLengthException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws InvalidPaymentAddressException
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws TooLongPaymentAddressException
|
|
|
|
|
*/
|
2021-12-19 14:29:17 +00:00
|
|
|
|
public function sellRefund(Receipt $receipt, ?string $external_id = null): ?AtolResponse
|
2021-11-20 16:19:35 +00:00
|
|
|
|
{
|
2021-12-18 06:45:00 +00:00
|
|
|
|
return $this->registerDocument('sell_refund', $receipt, $external_id);
|
2021-11-20 16:19:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Регистрирует документ коррекции прихода
|
|
|
|
|
*
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @param Correction $correction Объект документа
|
|
|
|
|
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @return AtolResponse|null
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws AuthFailedException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
* @throws InvalidEntityInCollectionException
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws InvalidInnLengthException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws InvalidPaymentAddressException
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws TooLongPaymentAddressException
|
|
|
|
|
*/
|
2021-12-19 14:29:17 +00:00
|
|
|
|
public function sellCorrect(Correction $correction, ?string $external_id = null): ?AtolResponse
|
2021-11-20 16:19:35 +00:00
|
|
|
|
{
|
2021-12-18 06:45:00 +00:00
|
|
|
|
return $this->registerDocument('sell_correction', $correction, $external_id);
|
2021-11-20 16:19:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Регистрирует документ расхода
|
|
|
|
|
*
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @param Receipt $receipt Объект документа
|
|
|
|
|
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @return AtolResponse|null
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws AuthFailedException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
* @throws InvalidEntityInCollectionException
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws InvalidInnLengthException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws InvalidPaymentAddressException
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws TooLongPaymentAddressException
|
|
|
|
|
*/
|
2021-12-19 14:29:17 +00:00
|
|
|
|
public function buy(Receipt $receipt, ?string $external_id = null): ?AtolResponse
|
2021-11-20 16:19:35 +00:00
|
|
|
|
{
|
2021-12-18 06:45:00 +00:00
|
|
|
|
return $this->registerDocument('buy', $receipt, $external_id);
|
2021-11-20 16:19:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Регистрирует документ возврата расхода
|
|
|
|
|
*
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @param Receipt $receipt Объект документа
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан UUID)
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @return AtolResponse|null
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws AuthFailedException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
* @throws InvalidEntityInCollectionException
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws InvalidInnLengthException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws InvalidPaymentAddressException
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws TooLongPaymentAddressException
|
|
|
|
|
*/
|
2021-12-19 14:29:17 +00:00
|
|
|
|
public function buyRefund(Receipt $receipt, ?string $external_id = null): ?AtolResponse
|
2021-11-20 16:19:35 +00:00
|
|
|
|
{
|
2021-12-18 06:45:00 +00:00
|
|
|
|
return $this->registerDocument('buy_refund', $receipt, $external_id);
|
2021-11-20 16:19:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Регистрирует документ коррекции расхода
|
|
|
|
|
*
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @param Correction $correction Объект документа
|
|
|
|
|
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @return AtolResponse|null
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws AuthFailedException
|
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws GuzzleException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws InvalidEntityInCollectionException
|
|
|
|
|
* @throws InvalidInnLengthException
|
|
|
|
|
* @throws InvalidPaymentAddressException
|
|
|
|
|
* @throws TooLongPaymentAddressException
|
2021-11-20 16:19:35 +00:00
|
|
|
|
*/
|
2021-12-19 14:29:17 +00:00
|
|
|
|
public function buyCorrect(Correction $correction, ?string $external_id = null): ?AtolResponse
|
2021-11-20 16:19:35 +00:00
|
|
|
|
{
|
2021-12-18 06:45:00 +00:00
|
|
|
|
return $this->registerDocument('buy_correction', $correction, $external_id);
|
2021-11-20 16:19:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Проверяет статус чека на ККТ один раз
|
|
|
|
|
*
|
|
|
|
|
* @param string $uuid UUID регистрации
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @return AtolResponse|null
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws AuthFailedException
|
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
* @throws InvalidUuidException
|
|
|
|
|
*/
|
2021-12-19 14:29:17 +00:00
|
|
|
|
public function getDocumentStatus(string $uuid): ?AtolResponse
|
2021-11-20 16:19:35 +00:00
|
|
|
|
{
|
2021-12-18 06:45:00 +00:00
|
|
|
|
!Uuid::isValid($uuid = trim($uuid)) && throw new InvalidUuidException($uuid);
|
|
|
|
|
return $this->auth()
|
|
|
|
|
? $this->sendRequest('GET', $this->getFullUrl('report/' . $uuid))
|
|
|
|
|
: null;
|
2021-11-20 16:19:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Проверяет статус чека на ККТ нужное количество раз с указанным интервалом.
|
|
|
|
|
* Вернёт результат как только при очередной проверке сменится статус регистрации документа.
|
|
|
|
|
*
|
|
|
|
|
* @param string $uuid UUID регистрации
|
|
|
|
|
* @param int $retry_count Количество попыток
|
|
|
|
|
* @param int $timeout Таймаут в секундах между попытками
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @return AtolResponse|null
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws AuthFailedException
|
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
* @throws InvalidUuidException
|
|
|
|
|
*/
|
2021-12-19 14:29:17 +00:00
|
|
|
|
public function pollDocumentStatus(string $uuid, int $retry_count = 5, int $timeout = 1): ?AtolResponse
|
2021-11-20 16:19:35 +00:00
|
|
|
|
{
|
|
|
|
|
$try = 0;
|
|
|
|
|
do {
|
|
|
|
|
$response = $this->getDocumentStatus($uuid);
|
2021-12-19 14:29:17 +00:00
|
|
|
|
if ($response->isSuccessful() && $response->getContent()->status == 'done') {
|
2021-11-20 16:19:35 +00:00
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
sleep($timeout);
|
|
|
|
|
}
|
|
|
|
|
++$try;
|
|
|
|
|
} while ($try < $retry_count);
|
|
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Отправляет документ на регистрацию
|
|
|
|
|
*
|
|
|
|
|
* @param string $api_method Метод API
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @param Receipt|Correction $document Документ
|
|
|
|
|
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @return AtolResponse|null
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws AuthFailedException
|
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
2021-11-20 16:19:35 +00:00
|
|
|
|
* @throws GuzzleException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws InvalidEntityInCollectionException
|
|
|
|
|
* @throws InvalidInnLengthException
|
|
|
|
|
* @throws InvalidPaymentAddressException
|
|
|
|
|
* @throws TooLongPaymentAddressException
|
2021-11-20 16:19:35 +00:00
|
|
|
|
*/
|
|
|
|
|
protected function registerDocument(
|
|
|
|
|
string $api_method,
|
2022-12-14 16:19:55 +00:00
|
|
|
|
Receipt | Correction $document,
|
2021-11-20 16:19:35 +00:00
|
|
|
|
?string $external_id = null
|
2021-12-19 14:29:17 +00:00
|
|
|
|
): ?AtolResponse {
|
2021-12-18 06:45:00 +00:00
|
|
|
|
$this->isTestMode() && $document->getCompany()
|
|
|
|
|
->setInn(TestEnvParams::FFD105()['inn'])
|
|
|
|
|
->setPaymentAddress(TestEnvParams::FFD105()['payment_address']);
|
|
|
|
|
$this->isTestMode() && $document instanceof Receipt
|
|
|
|
|
&& $document->getClient()->setInn(TestEnvParams::FFD105()['inn']);
|
|
|
|
|
$this->getCallbackUrl() && $data['service'] = ['callback_url' => $this->getCallbackUrl()];
|
|
|
|
|
return $this->auth()
|
|
|
|
|
? $this->sendRequest(
|
|
|
|
|
'POST',
|
|
|
|
|
$this->getFullUrl($api_method),
|
|
|
|
|
array_merge($data ?? [], [
|
|
|
|
|
'timestamp' => date('d.m.Y H:i:s'),
|
|
|
|
|
'external_id' => $external_id ?: Uuid::uuid4()->toString(),
|
|
|
|
|
$document::DOC_TYPE => $document->jsonSerialize(),
|
|
|
|
|
])
|
|
|
|
|
)
|
|
|
|
|
: null;
|
2021-11-20 16:19:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @inheritDoc
|
|
|
|
|
*/
|
2021-12-18 06:45:00 +00:00
|
|
|
|
#[Pure]
|
2021-11-20 16:19:35 +00:00
|
|
|
|
protected function getAuthEndpoint(): string
|
|
|
|
|
{
|
|
|
|
|
return $this->isTestMode()
|
2021-12-18 06:45:00 +00:00
|
|
|
|
? 'https://testonline.atol.ru/possystem/v4/getToken'
|
|
|
|
|
: 'https://online.atol.ru/possystem/v4/getToken';
|
2021-11-20 16:19:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @inheritDoc
|
|
|
|
|
*/
|
2021-12-18 06:45:00 +00:00
|
|
|
|
#[Pure]
|
2021-11-20 16:19:35 +00:00
|
|
|
|
protected function getMainEndpoint(): string
|
|
|
|
|
{
|
|
|
|
|
return $this->isTestMode()
|
|
|
|
|
? 'https://testonline.atol.ru/possystem/v4/'
|
|
|
|
|
: 'https://online.atol.ru/possystem/v4/';
|
|
|
|
|
}
|
2021-12-18 06:45:00 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Возвращает полный URL метода API
|
|
|
|
|
*
|
|
|
|
|
* @param string $api_method
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
#[Pure]
|
|
|
|
|
protected function getFullUrl(string $api_method): string
|
|
|
|
|
{
|
|
|
|
|
return $this->getMainEndpoint() . $this->getGroup() . '/' . trim($api_method);
|
|
|
|
|
}
|
2021-11-20 16:19:35 +00:00
|
|
|
|
}
|