/** * @param bool $useCache * @return int * @throws \Bitrix\Main\ArgumentException */ public static function getId($useCache = true) { $id = 0; $cacheManager = \Bitrix\Main\Application::getInstance()->getManagedCache(); $ttl = $useCache ? self::TTL : 0; if ($cacheManager->read($ttl, self::CACHE_ID)) { $id = $cacheManager->get(self::CACHE_ID); } if (intval($id) <= 0) { $dbRes = PaySystemActionTable::getList(array('filter' => array('ACTION_FILE' => self::ACTION_FILE_TEXT), 'select' => array('PAY_SYSTEM_ID'))); if ($res = $dbRes->fetch()) { $id = $res['PAY_SYSTEM_ID']; $cacheManager->set(self::CACHE_ID, $id); } } return intval($id); }
/** * @param $paySystemId * @param $personTypeId * @return mixed * @throws Main\ArgumentException */ public static function getPaySystemParams($paySystemId, $personTypeId) { static $result = array(); if (!isset($result[$paySystemId])) { $data = array(); if ($paySystemId > 0) { $params = array('select' => array('NAME', 'LOGOTIP', 'HAVE_RESULT', 'RESULT_FILE', 'ACTION_FILE'), 'filter' => array("LOGIC" => "AND", array('PAY_SYSTEM_ID' => $paySystemId), array("LOGIC" => "OR", array('PERSON_TYPE_ID' => $personTypeId), array('PERSON_TYPE_ID' => 0)))); $res = PaySystemActionTable::getList($params); $data = $res->fetch(); } $path = ""; $result[$paySystemId] = $data; if (intval($data["LOGOTIP"]) > 0) { $path = \CFile::GetPath(intval($data['LOGOTIP'])); } $result[$paySystemId]["LOGOTIP_PATH"] = !empty($path) ? $path : '/bitrix/images/sale/nopaysystem.gif'; } return $result[$paySystemId]; }
public static function GetList($arOrder = array("SORT" => "ASC", "NAME" => "ASC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array()) { if (array_key_exists("PSA_PERSON_TYPE_ID", $arFilter)) { $arFilter['PERSON_TYPE_ID'] = $arFilter['PSA_PERSON_TYPE_ID']; unset($arFilter["PSA_PERSON_TYPE_ID"]); } $salePaySystemFields = array('ID', 'NAME', 'ACTIVE', 'SORT', 'DESCRIPTION'); $ignoredFields = array('LID', 'CURRENCY', 'PERSON_TYPE_ID'); if (!$arSelectFields) { $select = array('ID', 'NAME', 'ACTIVE', 'SORT', 'DESCRIPTION'); } else { $select = array(); foreach ($arSelectFields as $key => $field) { if (in_array($field, $ignoredFields)) { continue; } $select[$key] = self::getAlias($field); } } $filter = array(); foreach ($arFilter as $key => $value) { if (in_array($key, $ignoredFields)) { continue; } $filter[self::getAlias($key)] = $value; } if (isset($arFilter['PERSON_TYPE_ID'])) { $select = array_merge($select, array('PSA_ID' => 'ID', 'PSA_NAME', 'ACTION_FILE', 'RESULT_FILE', 'NEW_WINDOW', 'PERSON_TYPE_ID', 'PARAMS', 'TARIF', 'HAVE_PAYMENT', 'HAVE_ACTION', 'HAVE_RESULT', 'HAVE_PREPAY', 'HAVE_RESULT_RECEIVE', 'ENCODING', 'LOGOTIP')); } if (in_array('PARAMS', $select) && !array_key_exists('PSA_ID', $select)) { $select['PSA_ID'] = 'ID'; } if (in_array('PARAMS', $select) && !in_array('PERSON_TYPE_ID', $select)) { $select[] = 'PERSON_TYPE_ID'; } $order = array(); foreach ($arOrder as $key => $value) { $order[self::getAlias($key)] = $value; } $groupBy = array(); if ($arGroupBy !== false) { $arGroupBy = !is_array($arGroupBy) ? array($arGroupBy) : $arGroupBy; foreach ($arGroupBy as $key => $value) { $groupBy[$key] = self::getAlias($value); } } $dbRes = PaySystemActionTable::getList(array('select' => $select, 'filter' => $filter, 'order' => $order, 'group' => $groupBy)); $limit = null; if (is_array($arNavStartParams) && isset($arNavStartParams['nTopCount'])) { if ($arNavStartParams['nTopCount'] > 0) { $limit = $arNavStartParams['nTopCount']; } } $result = array(); while ($data = $dbRes->fetch()) { if ($limit !== null && !$limit) { break; } $dbRestriction = \Bitrix\Sale\Internals\ServiceRestrictionTable::getList(array('filter' => array('SERVICE_ID' => $data['ID'], 'SERVICE_TYPE' => \Bitrix\Sale\Services\PaySystem\Restrictions\Manager::SERVICE_TYPE_PAYMENT))); while ($restriction = $dbRestriction->fetch()) { if (!CSalePaySystemAction::checkRestriction($restriction, $arFilter)) { continue 2; } } if (isset($data['ACTION_FILE'])) { $oldHandler = array_search($data['ACTION_FILE'], CSalePaySystemAction::getOldToNewHandlersMap()); if ($oldHandler !== false) { $data['ACTION_FILE'] = $oldHandler; } } if (array_key_exists('PARAMS', $data)) { $params = CSalePaySystemAction::getParamsByConsumer('PAYSYSTEM_' . $data['PSA_ID'], $data['PERSON_TYPE_ID']); $params['BX_PAY_SYSTEM_ID'] = array('TYPE' => '', 'VALUE' => $data['PSA_ID']); $data['PARAMS'] = serialize($params); } foreach ($data as $key => $value) { if (!in_array($key, $salePaySystemFields)) { $newKey = self::getAliasBack($key); if ($newKey != $key) { $data[$newKey] = $value; unset($data[$key]); } } } $result[] = $data; $limit--; } $dbRes = new \CDBResult(); $dbRes->InitFromArray($result); return $dbRes; }
public static function convertPsBusVal() { if (\Bitrix\Main\Config\Option::get('main', '~sale_paysystem_converted') == 'Y') { return ''; } \Bitrix\Main\Config\Option::set('main', '~sale_paysystem_converted', 'Y'); if (!\Bitrix\Main\Loader::includeModule('sale')) { return ''; } global $DB; if ($DB->TableExists('b_sale_pay_system_map') || $DB->TableExists('B_SALE_PAY_SYSTEM_MAP')) { return ''; } $dbRes = \Bitrix\Sale\Internals\PaySystemActionTable::getList(); $oldActionFiles = self::getOldToNewHandlersMap(); $paySystems = array(); while ($paySystem = $dbRes->fetch()) { $codesAliases = array(); $params = unserialize($paySystem['PARAMS']); if (is_array($params)) { if (isset($oldActionFiles[$paySystem['ACTION_FILE']])) { $codesAliases = self::getCodesAliases($oldActionFiles[$paySystem['ACTION_FILE']]); } foreach ($params as $key => $value) { if (isset($oldActionFiles[$paySystem['ACTION_FILE']])) { if ($key == 'IS_TEST' || $key == 'CHANGE_STATUS_PAY' || $key == 'TEST' || $key == 'DEMO' || $key == 'AUTOPAY') { $keyValue = $value['VALUE'] != 'Y' && $value['VALUE'] != 'N' ? 'N' : $value['VALUE']; $value = array('TYPE' => 'INPUT', 'VALUE' => $keyValue); } if ($key == 'TEST_MODE') { $value = array('TYPE' => 'INPUT', 'VALUE' => $value['VALUE'] == 'TEST' ? 'Y' : 'N'); } } if ($value['TYPE'] == 'SELECT' || $value['TYPE'] == 'FILE') { $value['TYPE'] = 'INPUT'; } if (isset($codesAliases[$key])) { $params[$codesAliases[$key]] = $value; unset($params[$key]); } else { $params[$key] = $value; } } } if (isset($oldActionFiles[$paySystem['ACTION_FILE']]) && !IsModuleInstalled('intranet')) { if (isset($params['PAYMENT_ID'])) { $value = $params['PAYMENT_ID']['VALUE'] == 'ACCOUNT_NUMBER' ? 'ACCOUNT_NUMBER' : 'ID'; $params['PAYMENT_ID'] = array('TYPE' => 'PAYMENT', 'VALUE' => $value); } if (isset($params['PAYMENT_CURRENCY'])) { $params['PAYMENT_CURRENCY'] = array('TYPE' => 'PAYMENT', 'VALUE' => 'CURRENCY'); } if (isset($params['PAYMENT_DATE_INSERT'])) { if ($params['PAYMENT_DATE_INSERT']['VALUE'] == 'DATE_INSERT_DATE' || $params['PAYMENT_DATE_INSERT']['VALUE'] == 'DATE_BILL_DATE') { $date = 'DATE_BILL_DATE'; } else { $date = 'DATE_BILL'; } $params['PAYMENT_DATE_INSERT'] = array('TYPE' => 'PAYMENT', 'VALUE' => $date); } if (isset($params['PAYMENT_SHOULD_PAY'])) { $params['PAYMENT_SHOULD_PAY'] = array('TYPE' => 'PAYMENT', 'VALUE' => 'SUM'); } if (isset($params['PAYMENT_VALUE'])) { $paySystem['PS_MODE'] = $params['PAYMENT_VALUE']['VALUE']; } } if (isset($oldActionFiles[$paySystem['ACTION_FILE']])) { $paySystem['ACTION_FILE'] = $oldActionFiles[$paySystem['ACTION_FILE']]; } $paySystem['PARAMS'] = $params; if (!isset($paySystems[$paySystem['PAY_SYSTEM_ID']])) { $paySystems[$paySystem['PAY_SYSTEM_ID']] = array(); } if (!isset($paySystems[$paySystem['PAY_SYSTEM_ID']][$paySystem['ACTION_FILE']])) { $paySystems[$paySystem['PAY_SYSTEM_ID']][$paySystem['ACTION_FILE']] = array(); } $paySystems[$paySystem['PAY_SYSTEM_ID']][$paySystem['ACTION_FILE']][] = $paySystem; } $codes = array(); foreach ($paySystems as $items) { foreach ($items as $psItem) { foreach ($psItem as $item) { $params = $item['PARAMS']; if ($params) { foreach ($params as $code => $value) { if ($value['VALUE'] == '') { continue; } if ($value['TYPE'] == '') { $key = 'VALUE|' . $value['VALUE']; } else { $key = $value['TYPE'] . '|' . $value['VALUE']; } if (!isset($codes[$code][$key])) { $codes[$code][$key] = 0; } $codes[$code][$key]++; } } } } } $generalBusVal = array(); foreach ($codes as $code => $values) { $generalBusVal[$code] = null; foreach ($values as $i => $cnt) { if ($generalBusVal[$code] === null || $values[$generalBusVal[$code]] < $cnt) { $generalBusVal[$code] = $i; } } } //set general foreach ($generalBusVal as $code => $param) { list($type, $value) = explode('|', $param); \Bitrix\Sale\BusinessValue::setMapping($code, null, null, array('PROVIDER_KEY' => $type, 'PROVIDER_VALUE' => $value)); } $mustDeleted = array(); $duplicateRecords = array(); foreach ($paySystems as $actions) { foreach ($actions as $items) { $firstItem = current($items); if (!array_key_exists($firstItem['ID'], $duplicateRecords)) { $duplicateRecords[$firstItem['ID']] = array(); } if (!array_key_exists('PERSON_TYPE_ID', $duplicateRecords[$firstItem['ID']])) { $duplicateRecords[$firstItem['ID']]['PERSON_TYPE_ID'] = array(); } if ($firstItem['PERSON_TYPE_ID'] > 0) { $duplicateRecords[$firstItem['ID']]['PERSON_TYPE_ID'][] = $firstItem['PERSON_TYPE_ID']; } $duplicateRecords[$firstItem['ID']]['EXTERNAL_ID'] = $firstItem['PAY_SYSTEM_ID']; foreach ($items as $ps) { if (in_array($ps['ACTION_FILE'], array('yandex', 'roboxchange')) && $firstItem['PS_MODE'] && $firstItem['PS_MODE'] != $ps['PS_MODE']) { if (!array_key_exists($ps['ID'], $duplicateRecords)) { $duplicateRecords[$ps['ID']] = array(); } if (!array_key_exists('PERSON_TYPE_ID', $duplicateRecords[$firstItem['ID']])) { $duplicateRecords[$ps['ID']]['PERSON_TYPE_ID'] = array(); } if ($ps['PERSON_TYPE_ID'] > 0) { $duplicateRecords[$ps['ID']]['PERSON_TYPE_ID'][] = $ps['PERSON_TYPE_ID']; } $duplicateRecords[$ps['ID']]['EXTERNAL_ID'] = $ps['PAY_SYSTEM_ID']; $duplicateRecords[$ps['ID']]['NEW_PS'] = 'Y'; } else { if ($ps['ID'] == $firstItem['ID']) { continue; } if ($ps['PERSON_TYPE_ID'] > 0) { $duplicateRecords[$firstItem['ID']]['PERSON_TYPE_ID'][] = $ps['PERSON_TYPE_ID']; } if (!isset($mustDeleted[$firstItem['ID']])) { $mustDeleted[$firstItem['ID']] = array(); } $mustDeleted[$firstItem['ID']][] = $ps['ID']; } } foreach ($items as $item) { $itemParams = array(); if ($item['PARAMS']) { $itemParams = $item['PARAMS']; if ($itemParams) { foreach ($itemParams as $code => $param) { $type = $param['TYPE'] ?: 'VALUE'; $pT = null; $pS = null; if (in_array($item['ACTION_FILE'], array('yandex', 'roboxchange')) && $firstItem['PS_MODE'] && $firstItem['PS_MODE'] != $item['PS_MODE']) { $consumer = 'PAYSYSTEM_' . $item['ID']; } else { $consumer = 'PAYSYSTEM_' . $firstItem['ID']; } $cases = array(1 => array('PS' => null, 'PT' => null), 2 => array('PS' => $consumer, 'PT' => $item['PERSON_TYPE_ID'])); foreach ($cases as $case) { if (\Bitrix\Sale\BusinessValue::isSetMapping($code, $case['PS'], $case['PT'])) { $map = \Bitrix\Sale\BusinessValue::getMapping($code); if ($map && $map['PROVIDER_KEY'] == $type && $map['PROVIDER_VALUE'] == $param['VALUE']) { continue 2; } } else { $pT = $case['PT']; $pS = $case['PS']; break; } } $value = is_array($param['VALUE']) ? key($param['VALUE']) : $param['VALUE']; \Bitrix\Sale\BusinessValue::setMapping($code, $pS, $pT, array('PROVIDER_KEY' => $type, 'PROVIDER_VALUE' => $value), true); } } } if (!isset($mustDeleted[$firstItem['ID']][$item['ID']])) { $itemParams['BX_PAY_SYSTEM_ID'] = array('TYPE' => '', 'VALUE' => $item['ID']); $item['PARAMS'] = serialize($itemParams); $itemId = $item['ID']; unset($item['ID']); \Bitrix\Sale\Internals\PaySystemActionTable::update($itemId, $item); } } } } global $DB; if ($DB->TableExists('b_sale_pay_system_map')) { $DB->Query('DROP TABLE b_sale_pay_system_map'); } if ($DB->type == 'MYSQL') { $DB->Query(' create table if not exists b_sale_pay_system_map ( PS_ID_OLD int null, PS_ID int null, PT_ID int null, NEW_PS char(1) not null default \'N\' )'); } if ($DB->type == 'MSSQL') { $DB->Query(' CREATE TABLE B_SALE_PAY_SYSTEM_MAP ( PS_ID int NULL, PS_ID_OLD int NULL, PT_ID int NULL, NEW_PS char(1) NOT NULL DEFAULT \'N\' )'); } if ($DB->type == 'ORACLE') { $DB->Query(' CREATE TABLE B_SALE_PAY_SYSTEM_MAP ( PS_ID NUMBER(18) NULL, PS_ID_OLD NUMBER(18) NULL, PT_ID NUMBER(18) NULL, NEW_PS CHAR(1 CHAR) DEFAULT \'N\' NOT NULL )'); } foreach ($duplicateRecords as $id => $data) { if ($data['PERSON_TYPE_ID']) { $params = array('filter' => array("SERVICE_ID" => $id, "SERVICE_TYPE" => \Bitrix\Sale\Services\PaySystem\Restrictions\Manager::SERVICE_TYPE_PAYMENT, "=CLASS_NAME" => '\\Bitrix\\Sale\\Services\\PaySystem\\Restrictions\\PersonType')); $dbRes = \Bitrix\Sale\Internals\ServiceRestrictionTable::getList($params); if (!$dbRes->fetch()) { $fields = array("SERVICE_ID" => $id, "SERVICE_TYPE" => \Bitrix\Sale\Services\PaySystem\Restrictions\Manager::SERVICE_TYPE_PAYMENT, "SORT" => 100, "PARAMS" => array('PERSON_TYPE_ID' => $data['PERSON_TYPE_ID'])); \Bitrix\Sale\Services\PaySystem\Restrictions\PersonType::save($fields); } } } foreach ($duplicateRecords as $id => $data) { if ($data['EXTERNAL_ID'] <= 0) { continue; } $newPs = $data['NEW_PS'] ?: 'N'; foreach ($data['PERSON_TYPE_ID'] as $personTypeId) { $DB->Query('INSERT INTO b_sale_pay_system_map(PS_ID, PS_ID_OLD, PT_ID, NEW_PS) VALUES(' . $id . ', ' . $data['EXTERNAL_ID'] . ', ' . $personTypeId . ', \'' . $newPs . '\' )'); } } $DB->Query(' UPDATE b_sale_order SET PAY_SYSTEM_ID = ( SELECT bspm.PS_ID FROM b_sale_pay_system_map bspm WHERE bspm.PT_ID=PERSON_TYPE_ID AND bspm.PS_ID_OLD=PAY_SYSTEM_ID )'); if ($DB->type == 'MYSQL' || $DB->type == 'ORACLE') { $DB->Query(' UPDATE b_sale_order_payment bsop SET PAY_SYSTEM_ID = ( SELECT bspm.PS_ID FROM b_sale_pay_system_map bspm, b_sale_order bso WHERE bspm.PS_ID_OLD = bsop.PAY_SYSTEM_ID AND bso.ID = bsop.ORDER_ID AND bspm.PT_ID = bso.PERSON_TYPE_ID )'); } elseif ($DB->type == 'MSSQL') { $DB->Query(' UPDATE bsop SET PAY_SYSTEM_ID = ( SELECT bspm.PS_ID FROM b_sale_pay_system_map bspm, b_sale_order bso WHERE bspm.PS_ID_OLD = bsop.PAY_SYSTEM_ID AND bso.ID = bsop.ORDER_ID AND bspm.PT_ID = bso.PERSON_TYPE_ID ) FROM b_sale_order_payment bsop'); } // \Bitrix\Main\Config\Option::set('main', '~sale_paysystem_converted', 'Y'); foreach ($mustDeleted as $items) { foreach ($items as $id) { PaySystemActionTable::delete($id); } } /** DELIVERY2PAYSYSTEM */ if ($DB->type == 'MYSQL') { $DB->Query(' UPDATE b_sale_delivery2paysystem bsd2p SET bsd2p.PAYSYSTEM_ID=(SELECT bspm.PS_ID FROM b_sale_pay_system_map bspm WHERE bspm.PS_ID_OLD=bsd2p.PAYSYSTEM_ID AND bspm.NEW_PS=\'N\' LIMIT 1)'); } if ($DB->type == 'ORACLE') { $DB->Query(' UPDATE b_sale_delivery2paysystem bsd2p SET bsd2p.PAYSYSTEM_ID=(SELECT bspm.PS_ID FROM b_sale_pay_system_map bspm WHERE bspm.PS_ID_OLD=bsd2p.PAYSYSTEM_ID AND bspm.NEW_PS=\'N\' AND ROWNUM=1)'); } if ($DB->type == 'MSSQL') { $DB->Query(' UPDATE bsd2p SET bsd2p.PAYSYSTEM_ID=(SELECT TOP(1) bspm.PS_ID FROM b_sale_pay_system_map bspm WHERE bspm.PS_ID_OLD=bsd2p.PAYSYSTEM_ID AND bspm.NEW_PS=\'N\') FROM b_sale_delivery2paysystem bsd2p'); } $DB->Query(' INSERT INTO b_sale_delivery2paysystem(DELIVERY_ID, PAYSYSTEM_ID, LINK_DIRECTION) SELECT d2p.DELIVERY_ID, pm1.PS_ID, d2p.LINK_DIRECTION FROM b_sale_delivery2paysystem d2p INNER JOIN b_sale_pay_system_map pm ON d2p.PAYSYSTEM_ID = pm.PS_ID AND pm.NEW_PS = \'N\' INNER JOIN b_sale_pay_system_map pm1 ON pm1.PS_ID_OLD = pm.PS_ID_OLD AND pm1.NEW_PS = \'Y\''); /** ORDER_PROPS_REL */ if ($DB->type == 'MYSQL') { $DB->Query(' UPDATE b_sale_order_props_relation bsopr SET bsopr.ENTITY_ID=(SELECT bspm.PS_ID FROM b_sale_pay_system_map bspm WHERE bspm.PS_ID_OLD=bsopr.ENTITY_ID AND bspm.NEW_PS=\'N\' LIMIT 1) WHERE bsopr.ENTITY_TYPE=\'P\''); } if ($DB->type == 'ORACLE') { $DB->Query(' UPDATE b_sale_order_props_relation bsopr SET bsopr.ENTITY_ID=(SELECT bspm.PS_ID FROM b_sale_pay_system_map bspm WHERE bspm.PS_ID_OLD=bsopr.ENTITY_ID AND bspm.NEW_PS=\'N\' AND ROWNUM=1) WHERE bsopr.ENTITY_TYPE=\'P\''); } if ($DB->type == 'MSSQL') { $DB->Query(' UPDATE bsopr SET bsopr.ENTITY_ID=(SELECT TOP(1) bspm.PS_ID FROM b_sale_pay_system_map bspm WHERE bspm.PS_ID_OLD=bsopr.ENTITY_ID AND bspm.NEW_PS=\'N\') FROM b_sale_order_props_relation bsopr WHERE bsopr.ENTITY_TYPE=\'P\''); } $DB->Query(' INSERT INTO b_sale_order_props_relation(ENTITY_ID, ENTITY_TYPE, PROPERTY_ID) SELECT pm1.PS_ID, opr.ENTITY_TYPE, opr.PROPERTY_ID FROM b_sale_order_props_relation opr INNER JOIN b_sale_pay_system_map pm ON pm.PS_ID = opr.ENTITY_ID AND pm.NEW_PS = \'N\' INNER JOIN b_sale_pay_system_map pm1 ON pm1.PS_ID_OLD = pm.PS_ID_OLD AND pm1.NEW_PS = \'Y\' WHERE opr.ENTITY_TYPE = \'P\''); $DB->Query(' INSERT INTO b_sale_service_rstr(SERVICE_ID, SORT, CLASS_NAME, PARAMS, SERVICE_TYPE) SELECT bsd2p.PAYSYSTEM_ID, 100, \'Bitrix\\\\Sale\\\\Services\\\\PaySystem\\\\Restrictions\\\\Delivery\', \'a:0:{}\', 1 FROM b_sale_delivery2paysystem bsd2p GROUP BY bsd2p.PAYSYSTEM_ID'); $DB->Query('UPDATE b_sale_pay_system_action SET psa_name=name'); if ($DB->type == 'MYSQL' || $DB->type == 'ORACLE') { $DB->Query('UPDATE b_sale_pay_system_action psa SET psa.name=( SELECT name FROM b_sale_pay_system ps WHERE ps.ID=psa.PAY_SYSTEM_ID )'); } else { if ($DB->type == 'MSSQL') { $DB->Query('UPDATE psa SET psa.name=( SELECT name FROM b_sale_pay_system ps WHERE ps.ID=psa.PAY_SYSTEM_ID ) FROM b_sale_pay_system_action psa'); } } return ''; }
if (!$result->isSuccess()) { if ($result->getErrorMessages()) { $lAdmin->AddGroupError(join(', ', $result->getErrorMessages()), $id); } else { $lAdmin->AddGroupError(GetMessage("SPSAN_ERROR_UPDATE"), $id); } } break; } } } $params = array('select' => array('ID', 'NAME', 'SORT', 'DESCRIPTION', 'ACTIVE', 'ACTION_FILE', 'LOGOTIP'), 'filter' => $filter); if (ToUpper($by) != 'LID' && ToUpper($by) != 'CURRENCY') { $params['order'] = array(ToUpper($by) => ToUpper($order)); } $dbRes = \Bitrix\Sale\Internals\PaySystemActionTable::getList($params); $result = array(); while ($paySystem = $dbRes->fetch()) { if (!empty($filter_person_type) && !in_array("NOT_REF", $filter_person_type)) { $filter_person_type['PERSON_TYPE_ID'] = $filter_person_type; $dbRestriction = \Bitrix\Sale\Internals\ServiceRestrictionTable::getList(array('filter' => array('SERVICE_ID' => $paySystem['ID'], 'SERVICE_TYPE' => \Bitrix\Sale\Services\PaySystem\Restrictions\Manager::SERVICE_TYPE_PAYMENT, '=CLASS_NAME' => '\\Bitrix\\Sale\\Services\\PaySystem\\Restrictions\\PersonType'))); while ($restriction = $dbRestriction->fetch()) { if (!CSalePaySystemAction::checkRestriction($restriction, $filter_person_type)) { continue 2; } } } $result[] = $paySystem; } $dbRes = new CDBResult(); $dbRes->InitFromArray($result);