• Модуль: crmmobile
  • Путь к файлу: ~/bitrix/modules/crmmobile/lib/Controller/ReceivePayment/PaySystemMode.php
  • Класс: BitrixCrmMobileControllerReceivePaymentPaySystemMode
  • Вызов: PaySystemMode::getPaySystemModeListAction
public function getPaySystemModeListAction(string $handlerName): array
{
	[$className] = Manager::includeHandler($handlerName);

	if (!class_exists($className))
	{
		return [];
	}

	$modeList = $className::getHandlerModeList();

	/** @var BitrixSalePaySystemManager $paySystemManager */
	$paySystemManager = ServiceLocator::getInstance()->get('sale.paysystem.manager');
	$configuredModes = $paySystemManager::getList([
		'select' => ['ID', 'PS_MODE', 'ACTIVE'],
		'filter' => [
			'=ACTION_FILE' => $handlerName,
			'=ENTITY_REGISTRY_TYPE' => 'ORDER',
		],
	])->fetchAll();

	$enabledModes = array_filter($configuredModes, static function($mode) {
		return $mode['ACTIVE'] === 'Y';
	});

	// reindex by the 'PS_MODE' column for easier access
	$enabledModes = array_column($enabledModes, null, 'PS_MODE');
	$configuredModes = array_column($configuredModes, null, 'PS_MODE');

	$result = [];
	foreach ($modeList as $modeId => $modeTitle)
	{
		$id = $enabledModes[$modeId]['ID'] ?? 0;
		if (!$id)
		{
			$id = $configuredModes[$modeId]['ID'] ?? 0;
		}

		$result[$modeId] = [
			'modeId' => $modeId,
			'id' => (int)$id,
			'title' => $modeTitle,
			'enabled' => isset($enabledModes[$modeId]),
		];
	}

	return $this->sortModes($handlerName, $result);
}