Example #1
0
 function GetHandlerCompability($arOrder, $arHandler, $SITE_ID = SITE_ID)
 {
     if (!defined('SALE_DH_INITIALIZED')) {
         CSaleDeliveryHandler::Initialize();
     }
     $currency = CSaleLang::GetLangCurrency($SITE_ID);
     if ($currency != $arHandler["BASE_CURRENCY"]) {
         $arOrder["PRICE"] = CCurrencyRates::ConvertCurrency($arOrder["PRICE"], $currency, $arHandler["BASE_CURRENCY"]);
     }
     if (is_array($arHandler["PROFILES"])) {
         $arProfilesList = $arHandler["PROFILES"];
         foreach ($arProfilesList as $profile_id => $arProfile) {
             if (is_array($arProfile["RESTRICTIONS_WEIGHT"])) {
                 if (is_array($arProfile["RESTRICTIONS_WEIGHT"]) && count($arProfile["RESTRICTIONS_WEIGHT"]) > 0) {
                     $arOrder["WEIGHT"] = doubleval($arOrder["WEIGHT"]);
                     if ($arOrder["WEIGHT"] < $arProfile["RESTRICTIONS_WEIGHT"][0] || is_set($arProfile["RESTRICTIONS_WEIGHT"], 1) && Doubleval($arProfile["RESTRICTIONS_WEIGHT"][1]) > 0 && $arOrder["WEIGHT"] > $arProfile["RESTRICTIONS_WEIGHT"][1]) {
                         unset($arProfilesList[$profile_id]);
                         continue;
                     }
                 }
                 if (is_array($arProfile["RESTRICTIONS_SUM"]) && count($arProfile["RESTRICTIONS_SUM"]) > 0) {
                     if ($arOrder["PRICE"] < $arProfile["RESTRICTIONS_SUM"][0] || is_set($arProfile["RESTRICTIONS_SUM"], 1) && Doubleval($arProfile["RESTRICTIONS_SUM"][1]) > 0 && $arOrder["PRICE"] > $arProfile["RESTRICTIONS_SUM"][1]) {
                         unset($arProfilesList[$profile_id]);
                         continue;
                     }
                 }
             }
         }
         if (is_callable($arHandler["COMPABILITY"])) {
             $arHandlerProfilesList = call_user_func($arHandler["COMPABILITY"], $arOrder, $arHandler["CONFIG"]["CONFIG"]);
             if (is_array($arHandlerProfilesList)) {
                 foreach ($arProfilesList as $profile_id => $arHandler) {
                     if (!in_array($profile_id, $arHandlerProfilesList)) {
                         unset($arProfilesList[$profile_id]);
                     }
                 }
             } else {
                 return array();
             }
         }
         return $arProfilesList;
     } else {
         return false;
     }
 }
Example #2
0
$sHost = "payments.paysecure.ru";
$sUrl = "/orderstate/orderstate.cfm";
$dtm = AddToTimeStamp(array("MM" => -1), false);
$sVars = "Ordernumber=" . $ORDER_ID . "&Merchant_ID=" . $assist_Shop_IDP . "&login=" . $assist_LOGIN . "&password=" . $assist_PASSWORD . "&FORMAT=3&StartYear=" . date('Y', $dtm) . "&StartMonth=" . date('n', $dtm) . "&StartYDay=" . date('j', $dtm) . "";
$aDesc = array("In Process" => array(GetMessage("SASP_IP"), GetMessage("SASPD_IP")), "Delayed" => array(GetMessage("SASP_D"), GetMessage("SASPD_D")), "Approved" => array(GetMessage("SASP_A"), GetMessage("SASPD_A")), "PartialApproved" => array(GetMessage("SASP_PA"), GetMessage("SASPD_PA")), "PartialDelayed" => array(GetMessage("SASP_PD"), GetMessage("SASPD_PD")), "Canceled" => array(GetMessage("SASP_C"), GetMessage("SASPD_C")), "PartialCanceled" => array(GetMessage("SASP_PC"), GetMessage("SASPD_PC")), "Declined" => array(GetMessage("SASP_DEC"), GetMessage("SASPD_DEC")), "Timeout" => array(GetMessage("SASP_T"), GetMessage("SASPD_T")));
$sResult = QueryGetData($sHost, 80, $sUrl, $sVars, $errno, $errstr, "POST");
if ($sResult != "") {
    require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/xml.php";
    $objXML = new CDataXML();
    $objXML->LoadString($sResult);
    $arResult = $objXML->GetArray();
    if (count($arResult) > 0 && $arResult["result"]["@"]["firstcode"] == "0") {
        $aRes = $arResult["result"]["#"]["order"][0]["#"];
        if (IntVal($aRes["ordernumber"][0]["#"]) == $ORDER_ID) {
            $arFields = array();
            $check = ToUpper(md5(toUpper(md5($password) . md5($assist_Shop_IDP . $aRes["ordernumber"][0]["#"] . $aRes["orderamount"][0]["#"] . $aRes["ordercurrency"][0]["#"] . $aRes["orderstate"][0]["#"]))));
            if ($aRes["checkvalue"][0]["#"] == $check) {
                $arOrder = CSaleOrder::GetByID($ORDER_ID);
                $arFields = array("PS_STATUS" => $aRes["orderstate"][0]["#"] == "Approved" ? "Y" : "N", "PS_STATUS_CODE" => substr($aRes["orderstate"][0]["#"], 0, 5), "PS_STATUS_DESCRIPTION" => $aDesc[$aRes["orderstate"][0]["#"]][0], "PS_STATUS_MESSAGE" => $aDesc[$aRes["orderstate"][0]["#"]][1], "PS_SUM" => DoubleVal($aRes["orderamount"][0]["#"]), "PS_CURRENCY" => $aRes["ordercurrency"][0]["#"], "PS_RESPONSE_DATE" => Date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL", LANG))));
                if ($arOrder["PAYED"] != "Y" && CSalePaySystemAction::GetParamValue("AUTOPAY") == "Y" && $arFields["PS_STATUS"] == "Y" && Doubleval($arOrder["PRICE"]) == DoubleVal($arFields["PS_SUM"])) {
                    CSaleOrder::PayOrder($arOrder["ID"], "Y");
                }
            }
            if (!empty($arFields)) {
                CSaleOrder::Update($ORDER_ID, $arFields);
            }
            return true;
        }
    }
}
return false;