26 private $fields = array();
34 public static function init()
36 $handlers = static::getHandlerList();
37 Main\Loader::registerAutoLoadClasses(
null, $handlers);
42 $className = (new \ReflectionClass(static::class))->getShortName();
43 return mb_strtolower($className);
49 public static function getHandlerList()
51 static $handlerList = array();
56 $isCloud = Main\Loader::includeModule(
"bitrix24");
59 $zone = \CBitrix24::getLicensePrefix();
61 elseif (Main\Loader::includeModule(
'intranet'))
63 $zone = \CIntranetUtils::getPortalZone();
65 if ($zone ===
'ru' && $isCloud)
68 '\Bitrix\Sale\Cashbox\CashboxAtolFarm' =>
'/bitrix/modules/sale/lib/cashbox/cashboxatolfarm.php',
69 '\Bitrix\Sale\Cashbox\CashboxAtolFarmV4' =>
'/bitrix/modules/sale/lib/cashbox/cashboxatolfarmv4.php',
70 '\Bitrix\Sale\Cashbox\CashboxAtolFarmV5' =>
'/bitrix/modules/sale/lib/cashbox/cashboxatolfarmv5.php',
71 '\Bitrix\Sale\Cashbox\CashboxOrangeData' =>
'/bitrix/modules/sale/lib/cashbox/cashboxorangedata.php',
72 '\Bitrix\Sale\Cashbox\CashboxOrangeDataFfd12' =>
'/bitrix/modules/sale/lib/cashbox/cashboxorangedataffd12.php',
73 '\Bitrix\Sale\Cashbox\CashboxBusinessRu' =>
'/bitrix/modules/sale/lib/cashbox/cashboxbusinessru.php',
74 '\Bitrix\Sale\Cashbox\CashboxBusinessRuV5' =>
'/bitrix/modules/sale/lib/cashbox/cashboxbusinessruv5.php',
77 elseif ($zone ===
'ua')
80 '\Bitrix\Sale\Cashbox\CashboxCheckbox' =>
'/bitrix/modules/sale/lib/cashbox/cashboxcheckbox.php',
86 '\Bitrix\Sale\Cashbox\CashboxAtolFarm' =>
'/bitrix/modules/sale/lib/cashbox/cashboxatolfarm.php',
87 '\Bitrix\Sale\Cashbox\CashboxAtolFarmV4' =>
'/bitrix/modules/sale/lib/cashbox/cashboxatolfarmv4.php',
88 '\Bitrix\Sale\Cashbox\CashboxAtolFarmV5' =>
'/bitrix/modules/sale/lib/cashbox/cashboxatolfarmv5.php',
89 '\Bitrix\Sale\Cashbox\CashboxOrangeData' =>
'/bitrix/modules/sale/lib/cashbox/cashboxorangedata.php',
90 '\Bitrix\Sale\Cashbox\CashboxOrangeDataFfd12' =>
'/bitrix/modules/sale/lib/cashbox/cashboxorangedataffd12.php',
91 '\Bitrix\Sale\Cashbox\CashboxBitrixV2' =>
'/bitrix/modules/sale/lib/cashbox/cashboxbitrixv2.php',
92 '\Bitrix\Sale\Cashbox\CashboxBitrixV3' =>
'/bitrix/modules/sale/lib/cashbox/cashboxbitrixv3.php',
93 '\Bitrix\Sale\Cashbox\CashboxBitrix' =>
'/bitrix/modules/sale/lib/cashbox/cashboxbitrix.php',
94 '\Bitrix\Sale\Cashbox\Cashbox1C' =>
'/bitrix/modules/sale/lib/cashbox/cashbox1c.php',
95 '\Bitrix\Sale\Cashbox\CashboxCheckbox' =>
'/bitrix/modules/sale/lib/cashbox/cashboxcheckbox.php',
96 '\Bitrix\Sale\Cashbox\CashboxBusinessRu' =>
'/bitrix/modules/sale/lib/cashbox/cashboxbusinessru.php',
97 '\Bitrix\Sale\Cashbox\CashboxBusinessRuV5' =>
'/bitrix/modules/sale/lib/cashbox/cashboxbusinessruv5.php',
101 $handlerList[
'\Bitrix\Sale\Cashbox\CashboxRest'] =
'/bitrix/modules/sale/lib/cashbox/cashboxrest.php';
103 $handlerList[
'\Bitrix\Sale\Cashbox\CashboxRobokassa'] =
'/bitrix/modules/sale/lib/cashbox/cashboxrobokassa.php';
104 $handlerList[
'\Bitrix\Sale\Cashbox\CashboxYooKassa'] =
'/bitrix/modules/sale/lib/cashbox/cashboxyookassa.php';
106 $event =
new Main\Event(
'sale', static::EVENT_ON_GET_CUSTOM_CASHBOX_HANDLERS);
108 $resultList = $event->getResults();
110 if (is_array($resultList) && !empty($resultList))
112 foreach ($resultList as $eventResult)
115 if ($eventResult->getType() === Main\EventResult::SUCCESS)
117 $params = $eventResult->getParameters();
118 if (!empty($params) && is_array($params))
119 $handlerList = array_merge($handlerList, $params);
133 public static function create(array $settings)
137 $handler = $settings[
'HANDLER'];
138 if (class_exists($handler))
139 return new $handler($settings);
148 private function __construct($settings)
150 $this->fields = $settings;
159 return $this->fields[$name];
167 if ($this->ofd ===
null)
203 $map = $this->fields[
'SETTINGS'];
204 if (isset($map[$name]))
206 if (is_array($map[$name]))
208 if (isset($map[$name][$code]))
209 return $map[$name][$code];
217 $settings = static::getSettings($this->
getField(
'KKM_ID'));
219 return $settings[$name][
'ITEMS'][$code][
'VALUE'] ??
null;
226 public function getCheckLink(array $linkParams)
231 $ofd = $this->getOfd();
233 return $ofd->generateCheckLink($linkParams);
275 $result = static::extractCheckData($data);
277 $checkId = $result[
'ID'] ?? 0;
279 return CheckManager::savePrintResult($checkId, $result);
288 $result = static::extractZReportData($data);
307 $fields = $this->fields;
308 unset($fields[
'OFD_SETTINGS']);
315 $r = $ofd->validate();
316 if (!$r->isSuccess())
318 $result->addErrors($r->getErrors());
329 foreach ($fields as $code => $value)
331 if (is_array($value))
334 if (!$r->isSuccess())
336 $result->addErrors($r->getErrors());
347 $requiredFields = $this->getRequiredFields();
352 'SALE_CASHBOX_VALIDATE_ERROR',
353 [
'#FIELD_ID#' => $requiredFields[$code]]
365 $requiredFields = $this->getRequiredFields();
367 return isset($requiredFields[$field]);
374 public static function extractSettingsFromRequest(Main\
HttpRequest $request)
377 $settings = $request->get(
'SETTINGS');
386 private function getRequiredFields()
388 $result = static::getGeneralRequiredFields();
390 $settings = static::getSettings($this->getField(
'KKM_ID'));
391 foreach ($settings as $groupId => $group)
393 foreach ($group[
'ITEMS'] as $code => $item)
396 isset($group[
'REQUIRED']) && $group[
'REQUIRED'] ===
'Y'
397 || isset($item[
'REQUIRED']) && $item[
'REQUIRED'] ===
'Y'
401 $result[$code] = $item[
'LABEL'];
414 $map = CashboxTable::getMap();
417 'NAME' => $map[
'NAME'][
'title'],
418 'EMAIL' => $map[
'EMAIL'][
'title'],
419 'HANDLER' => $map[
'HANDLER'][
'title']
430 $context = Main\Application::getInstance()->getContext();
431 $server = $context->getServer();
432 $domain = $server->getServerName();
434 return $type.static::UUID_DELIMITER.$domain.static::UUID_DELIMITER.$id;
443 $info = explode(static::UUID_DELIMITER, $uuid);
445 return array(
'type' => $info[0],
'id' => $info[2]);
471 && $this::isCorrectionOn()
498 return static::getFfdVersion() >= 1.05;
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)