<?php

use Bitrix\Main\Application;
define("STOP_STATISTICS", true);
define('NO_AGENT_CHECK', true);
define("DisableEventsCheck", true);
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/header.php";
global $APPLICATION;
if (CModule::IncludeModule("sale")) {
    $context = Application::getInstance()->getContext();
    $request = $context->getRequest();
    $item = Bitrix\Sale\PaySystem\Manager::searchByRequest($request);
    $service = new Bitrix\Sale\PaySystem\Service($item);
    $result = $service->processRequest($request);
}
$APPLICATION->FinalActions();
die;
 protected static function getFullPaySystemList()
 {
     static $result = null;
     if ($result === null) {
         $result = array();
         $dbRes = Bitrix\Sale\PaySystem\Manager::getList(array('filter' => array('ACTIVE' => 'Y')));
         while ($ps = $dbRes->fetch()) {
             $result[] = $ps['ID'];
         }
     }
     return $result;
 }
    echo $id;
    ?>
</td>
		</tr>
	<?php 
}
?>
	<tr class="adm-detail-required-field">
		<td width="40%" valign="top"><?php 
echo Loc::getMessage("SPS_ACT_FILE");
?>
:</td>
		<td width="60%" valign="top">
			<select name="ACTION_FILE" onchange='BX.Sale.PaySystem.getHandlerOptions(this)'>
				<?php 
$handlerList = Bitrix\Sale\PaySystem\Manager::getHandlerList();
if ($request->get('ACTION_FILE') !== null) {
    $handlerName = $request->get('ACTION_FILE');
} else {
    $handlerName = $paySystem['ACTION_FILE'];
}
$pathToDesc = '';
$pathToHandler = PaySystem\Manager::getPathToHandlerFolder($handlerName);
if (\Bitrix\Main\IO\File::isFileExists($documentRoot . $pathToHandler . '/.description.php')) {
    $pathToDesc = $documentRoot . $pathToHandler . '/.description.php';
}
if ($pathToDesc !== '') {
    include $pathToDesc;
}
$selected = false;
?>
 $arStatuses = array("" => GetMessage("SALE_1C_NO"));
 $dbStatus = CSaleStatus::GetList(array("SORT" => "ASC"), array("LID" => LANGUAGE_ID));
 while ($arStatus = $dbStatus->Fetch()) {
     $arStatuses[$arStatus["ID"]] = "[" . $arStatus["ID"] . "] " . $arStatus["NAME"];
 }
 $arUGroupsEx = array();
 $dbUGroups = CGroup::GetList($by = "c_sort", $order = "asc");
 while ($arUGroups = $dbUGroups->Fetch()) {
     $arUGroupsEx[$arUGroups["ID"]] = $arUGroups["NAME"];
 }
 $arPaySystems = array("" => GetMessage("SALE_1C_NO"));
 $dbPaySystems = CSalePaySystem::GetList(array("SORT" => "ASC"), array("ACTIVE" => "Y"), false, false, array("ID", "NAME"));
 $arPaySystemsWithoutInner = array("" => GetMessage("SALE_1C_NO"));
 while ($arPaySystem = $dbPaySystems->Fetch()) {
     $arPaySystems[$arPaySystem["ID"]] = "[" . $arPaySystem["ID"] . "] " . $arPaySystem["NAME"];
     if ($arPaySystem["ID"] != Bitrix\Sale\PaySystem\Manager::getInnerPaySystemId()) {
         $arPaySystemsWithoutInner[$arPaySystem["ID"]] = "[" . $arPaySystem["ID"] . "] " . $arPaySystem["NAME"];
     }
 }
 $shipmentServices = array("" => GetMessage("SALE_1C_NO"));
 $deliveryList = \Bitrix\Sale\Delivery\Services\Manager::getActiveList();
 foreach ($deliveryList as $shipmentService) {
     $shipmentServices[$shipmentService["ID"]] = "[" . $shipmentService["ID"] . "] " . $shipmentService["NAME"];
 }
 $arAllOptions = array(array("1C_SALE_SITE_LIST", GetMessage("SALE_1C_SITE_LIST"), "", array("list", $arSites)), array("1C_IMPORT_NEW_ORDERS", GetMessage("SALE_1C_IMPORT_NEW_ORDERS"), "N", array("checkbox")), array("1C_SITE_NEW_ORDERS", GetMessage("SALE_1C_SITE_NEW_ORDERS"), "s1", array("list", $arSites)), array("1C_SALE_ACCOUNT_NUMBER_SHOP_PREFIX", GetMessage("SALE_1C_SALE_ACCOUNT_NUMBER_SHOP_PREFIX"), "", array("text")), array("1C_EXPORT_PAYED_ORDERS", GetMessage("SALE_1C_EXPORT_PAYED_ORDERS"), "", array("checkbox")), array("1C_EXPORT_ALLOW_DELIVERY_ORDERS", GetMessage("SALE_1C_EXPORT_ALLOW_DELIVERY_ORDERS"), "", array("checkbox")), array("1C_CHANGE_STATUS_FROM_1C", GetMessage("SALE_1C_CHANGE_STATUS_FROM_1C"), "", array("checkbox")), array("1C_EXPORT_FINAL_ORDERS", GetMessage("SALE_1C_EXPORT_FINAL_ORDERS"), "", array("list", $arStatuses)), array("1C_FINAL_STATUS_ON_DELIVERY", GetMessage("SALE_1C_FINAL_STATUS_ON_DELIVERY"), "F", array("list", $arStatuses)), array("1C_REPLACE_CURRENCY", GetMessage("SALE_1C_REPLACE_CURRENCY"), GetMessage("SALE_1C_RUB"), array("text")), array("1C_IMPORT_DEFAULT_PS", GetMessage("SALE_1C_IMPORT_DEFAULT_PS_C"), "", array("list", $arPaySystems)), array("1C_IMPORT_DEFAULT_PS_B", GetMessage("SALE_1C_IMPORT_DEFAULT_PS_B"), "", array("list", $arPaySystems)), array("1C_IMPORT_DEFAULT_PS_A", GetMessage("SALE_1C_IMPORT_DEFAULT_PS_A"), "", array("list", $arPaySystems)), array("1C_IMPORT_DEFAULT_PS_ORDER_PAID", GetMessage("SALE_1C_IMPORT_DEFAULT_PS_ORDER_PAID"), "", array("list", $arPaySystemsWithoutInner)), array("1C_IMPORT_DEFAULT_SHIPMENT_SERVICE", GetMessage("SALE_1C_IMPORT_DEFAULT_SHIPMENT_SERVICE"), "", array("list", $shipmentServices)), array("1C_IMPORT_UPDATE_BASKET_QUANTITY", GetMessage("SALE_1C_IMPORT_UPDATE_BASKET_QUANTITY"), "", array("checkbox")), array("1C_IMPORT_NEW_PAYMENT", GetMessage("SALE_1C_IMPORT_NEW_PAYMENT"), "", array("checkbox")), array("1C_IMPORT_NEW_SHIPMENT", GetMessage("SALE_1C_IMPORT_NEW_SHIPMENT"), "", array("checkbox")), array("1C_IMPORT_NEW_ORDER_NEW_SHIPMENT", GetMessage("SALE_1C_IMPORT_NEW_ORDER_NEW_SHIPMENT"), "", array("checkbox")), array("1C_SALE_GROUP_PERMISSIONS", GetMessage("SALE_1C_GROUP_PERMISSIONS"), "1", array("mlist", 5, $arUGroupsEx)), array("1C_SALE_USE_ZIP", GetMessage("SALE_1C_USE_ZIP"), "Y", array("checkbox")), array("1C_INTERVAL", GetMessage("SALE_1C_INTERVAL"), 30, array("text", 20)), array("1C_FILE_SIZE_LIMIT", GetMessage("SALE_1C_FILE_SIZE_LIMIT"), 200 * 1024, array("text", 20)));
 if ($REQUEST_METHOD == "POST" && strlen($Update) > 0 && $CAT_RIGHT >= "W" && check_bitrix_sessid()) {
     $allOptionCount = count($arAllOptions);
     for ($i = 0; $i < $allOptionCount; $i++) {
         $name = $arAllOptions[$i][0];
         $val = $_REQUEST[$name];
         if ($arAllOptions[$i][3][0] == "checkbox" && $val != "Y") {