21 $settings = $this->
getField(
"SETTINGS");
22 return $settings[
"REST"][
"REST_CODE"];
35 return $handlerList[$handlerCode];
49 $result = $handlerParams[
"SETTINGS"][
"CONFIG"];
57 "VALUE" => $handlerCode,
95 private function getPrintUrl()
99 return $handlerParams[
"SETTINGS"][
"PRINT_URL"];
105 private function getRequestOptions(): array
111 if (isset($handlerParams[
'SETTINGS'][
'HTTP_VERSION']))
113 $options[
'HTTP_CLIENT_OPTIONS'] = [
114 'version' => $handlerParams[
'SETTINGS'][
'HTTP_VERSION'],
127 private function getCheckUrl()
131 return $handlerParams[
"SETTINGS"][
"CHECK_URL"];
149 $data = $check->getDataForCheck();
151 $data[
"uuid"] = static::buildUuid(static::UUID_TYPE_CHECK, $data[
'unique_id']);
154 $dateTime = $data[
"date_create"];
155 $dateTimestamp = $dateTime->getTimestamp();
156 $data[
"date_create"] = $dateTimestamp;
158 $data[
"operation"] = $check::getCalculatedSign();
161 if (is_array($data[
"items"])) {
162 foreach ($data[
"items"] as $index => $item) {
163 $data[
"items"][$index][
'payment_method'] = $checkTypeMap[$check::getType()];
167 $data[
"number_kkm"] = $this->
getField(
'NUMBER_KKM');
168 $data[
"service_email"] = $this->
getField(
'EMAIL');
169 $cashboxParams = $this->
getField(
"SETTINGS");
172 unset($cashboxParams[
"REST"]);
173 $data[
"cashbox_params"] = $cashboxParams;
206 if (empty($checkInfo))
211 if ($data[
'STATUS'] ===
'ERROR')
214 'TYPE' => Errors\Error::TYPE,
215 'MESSAGE' => $data[
'ERROR'],
219 $result[
'ID'] = $checkInfo[
'ID'];
220 $result[
'CHECK_TYPE'] = $checkInfo[
'TYPE'];
223 $dateTime = Main\Type\DateTime::createFromTimestamp($data[
"PRINT_END_TIME"]);
224 $result[
'LINK_PARAMS'] = [
249 $url = $this->getCheckUrl();
250 $checkUUID = $check->
getField(
'EXTERNAL_UUID');
251 $queryResult = Sale\Helpers\Rest\Http::sendRequest(
253 [
"uuid" => $checkUUID],
254 $this->getRequestOptions()
256 $response = $queryResult->getData();
258 if ($response ===
false)
260 return $result->addError(
new Errors\
Error(
Loc::getMessage(
"SALE_CASHBOX_REST_DATA_ERROR_CHECK_CHECK")));
263 $response[
'UUID'] = $checkUUID;
265 if ($response[
'STATUS'] ===
'WAIT')
267 $result = $result->addError(
new Main\
Error(
Loc::getMessage(
'SALE_CASHBOX_REST_PRINT_IN_PROGRESS')));
272 return static::applyCheckResult($response);
290 $url = $this->getPrintUrl();
291 $printResult = Sale\Helpers\Rest\Http::sendRequest(
294 $this->getRequestOptions()
297 if (!$printResult->isSuccess())
302 $printData = $printResult->getData();
303 if (isset($printData[
'ERRORS']) && is_array($printData[
'ERRORS']))
305 foreach ($printData[
'ERRORS'] as $errorMessage)
307 $printResult->addError(
new Errors\
Error($errorMessage));
322 $result = parent::validate();
327 if (!isset($handlerList[$handlerCode]))
332 "SALE_CASHBOX_REST_HANDLER_NOT_FOUND",
333 [
"#HANDLER_CODE#" => $handlerCode]
static getMessage($code, $replace=null, $language=null)