} elseif (strlen($arPaySys["PSA_RESULT_FILE"]) > 0) { if (file_exists($_SERVER["DOCUMENT_ROOT"].$arPaySys["PSA_RESULT_FILE"]) && is_file($_SERVER["DOCUMENT_ROOT"].$arPaySys["PSA_RESULT_FILE"])) $psResultFile = $_SERVER["DOCUMENT_ROOT"].$arPaySys["PSA_RESULT_FILE"]; } if (strlen($psResultFile) <= 0) $errorMessageTmp .= GetMessage("SOD_NO_PS_SCRIPT").". "; } if (strlen($errorMessageTmp) <= 0) { $ORDER_ID = $ID; CSalePaySystemAction::InitParamArrays($arOrder, $ID, $arPaySys["PSA_PARAMS"]); if (!include($psResultFile)) $errorMessageTmp .= GetMessage("ERROR_CONNECT_PAY_SYS").". "; } if (strlen($errorMessageTmp) <= 0) { $ORDER_ID = IntVal($ORDER_ID); $arOrder = CSaleOrder::GetByID($ORDER_ID); if (!$arOrder) $errorMessageTmp .= str_replace("#ID#", $ORDER_ID, GetMessage("SOD_NO_ORDER")).". "; } if (strlen($errorMessageTmp) <= 0) { if ($arOrder["PS_STATUS"] == "Y" && $arOrder["PAYED"] == "N") {
/** * Function gets pay system info from database, no cache is used here * @return void */ protected function obtainDataPaySystem() { if (empty($this->dbResult["ID"])) { return; } foreach ($this->dbResult['PAYMENT'] as &$payment) { if (intval($payment["PAY_SYSTEM_ID"])) { $payment["PAY_SYSTEM"] = \Bitrix\Sale\PaySystem\Manager::getById($payment["PAY_SYSTEM_ID"]); $payment["PAY_SYSTEM"]['NAME'] = htmlspecialcharsbx($payment["PAY_SYSTEM"]['NAME']); } if ($payment["PAID"] != "Y" && $this->dbResult["CANCELED"] != "Y") { $payment['BUFFERED_OUTPUT'] = ''; $payment['ERROR'] = ''; $service = new \Bitrix\Sale\PaySystem\Service($payment["PAY_SYSTEM"]); if ($service) { $payment["CAN_REPAY"] = "Y"; if ($service->getField("NEW_WINDOW") == "Y") { $payment["PAY_SYSTEM"]["PSA_ACTION_FILE"] = htmlspecialcharsbx($this->arParams["PATH_TO_PAYMENT"]) . '?ORDER_ID=' . urlencode(urlencode($this->dbResult["ACCOUNT_NUMBER"])) . '&PAYMENT_ID=' . $payment['ID']; } else { CSalePaySystemAction::InitParamArrays($this->dbResult, $this->requestData["ID"], '', array(), $payment); // for compatibility $actionFile = $service->getField('ACTION_FILE'); $map = CSalePaySystemAction::getOldToNewHandlersMap(); $oldHandler = array_search($actionFile, $map); if ($oldHandler !== false && !$service->isCustom()) { $actionFile = $oldHandler; } $pathToAction = Main\Application::getDocumentRoot() . $actionFile; $pathToAction = str_replace("\\", "/", $pathToAction); while (substr($pathToAction, strlen($pathToAction) - 1, 1) == "/") { $pathToAction = substr($pathToAction, 0, strlen($pathToAction) - 1); } if (file_exists($pathToAction)) { if (is_dir($pathToAction) && file_exists($pathToAction . "/payment.php")) { $pathToAction .= "/payment.php"; } $payment["PAY_SYSTEM"]["PSA_ACTION_FILE"] = $pathToAction; } $encoding = $service->getField("ENCODING"); if (strlen($encoding) > 0) { define("BX_SALE_ENCODING", $encoding); AddEventHandler("main", "OnEndBufferContent", array($this, "changeBodyEncoding")); } /** @var \Bitrix\Sale\Order $order */ $order = \Bitrix\Sale\Order::load($this->dbResult["ID"]); if ($order) { /** @var \Bitrix\Sale\PaymentCollection $paymentCollection */ $paymentCollection = $order->getPaymentCollection(); if ($paymentCollection) { /** @var \Bitrix\Sale\Payment $paymentItem */ $paymentItem = $paymentCollection->getItemById($payment['ID']); if ($paymentItem) { $initResult = $service->initiatePay($paymentItem, null, \Bitrix\Sale\PaySystem\BaseServiceHandler::STRING); if ($initResult->isSuccess()) { $payment['BUFFERED_OUTPUT'] = $initResult->getTemplate(); } else { $payment['ERROR'] = implode('\\n', $initResult->getErrorMessages()); } } } } } $payment["PAY_SYSTEM"]["PSA_NEW_WINDOW"] = $payment["PAY_SYSTEM"]["NEW_WINDOW"]; } } } unset($payment); // for compatibility $this->dbResult['PAY_SYSTEM'] = $this->dbResult['PAYMENT'][0]['PAY_SYSTEM']; $this->dbResult['CAN_REPAY'] = $this->dbResult['PAYMENT'][0]['CAN_REPAY']; }
if ($_SERVER["REQUEST_METHOD"] == "POST") { $orderId = intval($_POST['LMI_PAYMENT_NO']); $paymentId = intval($_POST['PAYMENT_ID']); $bCorrectPayment = true; /** @var \Bitrix\Sale\Order $order */ $order = Order::load($orderId); if (!$order) { $bCorrectPayment = false; } $payment = $order->getPaymentCollection()->getItemById($paymentId); if (!$payment) { $bCorrectPayment = false; } $arOrder = $order->getFieldValues(); if ($bCorrectPayment) { CSalePaySystemAction::InitParamArrays($arOrder, $arOrder["ID"], '', array(), $payment); } $CNST_SECRET_KEY = CSalePaySystemAction::GetParamValue("CNST_SECRET_KEY"); if (strlen($CNST_SECRET_KEY) <= 0) { $bCorrectPayment = false; } $CNST_PAYEE_PURSE = CSalePaySystemAction::GetParamValue("SHOP_ACCT"); $currency = CSalePaySystemAction::GetParamValue("CURRENCY"); if (strlen($currency) <= 0 || $currency == "RUR") { $currency = "RUB"; } if ($_POST["LMI_PREREQUEST"] == "1" || $_POST["LMI_PREREQUEST"] == "2") { if (CSalePaySystemAction::GetParamValue("SHOULD_PAY") == DoubleVal($_POST["LMI_PAYMENT_AMOUNT"]) && $currency == DoubleVal($_POST["LMI_CURRENCY"]) && $CNST_PAYEE_PURSE == $_POST["LMI_MERCHANT_ID"]) { $APPLICATION->RestartBuffer(); echo "YES"; die;
} } } if ($arParams['PAY_IMMED']) { CSaleBasket::DeleteAll(CSaleBasket::GetBasketUserID()); } CSaleBasket::Add(array('PRODUCT_ID' => $arResult['CURRENCIES'][$arResult['REQUEST_ACCOUNT']]['ID'], 'PRICE' => CCurrencyRates::ConvertCurrency($arResult['MONEY_OFF'], $arResult['REQUEST_ACCOUNT'], $arResult['LANG_CURRENCY']), 'CURRENCY' => $arResult['LANG_CURRENCY'], 'QUANTITY' => 1, 'LID' => LANG, 'DELAY' => 'N', 'CAN_BUY' => 'Y', 'NAME' => GetMessage('SPT_NAME_IN_CART', array('#VALUE#' => SaleFormatCurrency($arResult['REQUEST_AMOUNT'], $arResult['REQUEST_ACCOUNT']))), 'MODULE' => 'asd.money', 'DETAIL_PAGE_URL' => '', 'CATALOG_XML_ID' => $arResult['REQUEST_AMOUNT'] . '@' . $arResult['REQUEST_ACCOUNT'])); if ($arParams['PAY_IMMED']) { $ORDER_ID = CSaleOrder::Add(array('LID' => SITE_ID, 'PERSON_TYPE_ID' => $arParams['PERSON_TYPE'], 'PRICE' => CCurrencyRates::ConvertCurrency($arResult['MONEY_OFF'], $arResult['REQUEST_ACCOUNT'], $arResult['LANG_CURRENCY']), 'CURRENCY' => $arResult['LANG_CURRENCY'], 'PAY_SYSTEM_ID' => $arResult['REQUEST_PAY_SYSTEM'], 'USER_ID' => $USER->getID())); if ($ORDER_ID > 0) { $arOrder = CSaleOrder::GetByID($ORDER_ID); CSaleBasket::OrderBasket($ORDER_ID); } $arPaySysAction = $arResult['PAY_SYSTEMS'][$arResult['REQUEST_PAY_SYSTEM']]; if (strlen($arPaySysAction['ACTION_FILE']) > 0) { CSalePaySystemAction::InitParamArrays($arOrder, $ORDER_ID, $arPaySysAction['PARAMS']); $pathToAction = $_SERVER['DOCUMENT_ROOT'] . $arPaySysAction['ACTION_FILE']; $pathToAction = rtrim(str_replace('\\', '/', $pathToAction), '/'); if (file_exists($pathToAction)) { if (is_dir($pathToAction)) { if (file_exists($pathToAction . '/payment.php')) { include $pathToAction . '/payment.php'; } } else { include $pathToAction; } } if (strlen($arPaySysAction['ENCODING']) > 0) { define('BX_SALE_ENCODING', $arPaySysAction['ENCODING']); AddEventHandler('main', 'OnEndBufferContent', 'ChangeEncoding'); function ChangeEncoding($content)
require_once dirname(__FILE__) . "/../classes/general/cache_html.php"; CHTMLPagesCache::startCaching(); } require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; CModule::IncludeModule('sale'); if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } include GetLangFileName(dirname(__FILE__) . "/", "/ubrir.php"); include dirname(__FILE__) . "/sdk/ubrir_autoload.php"; $orderID = $_REQUEST['OrderId']; $order = CSaleOrder::GetByID($orderID); if (!$order) { // ORDER NOT FOUND die('NOT FOUND'); } CSalePaySystemAction::InitParamArrays($orderID, $orderID); $bankHandler = new ubrir(CSalePaySystemAction::GetParamValue("TERMINAL_ID"), CSalePaySystemAction::GetParamValue("SHOP_SECRET_WORD"), CSalePaySystemAction::GetParamValue("ubrir_PAYMENT_URL")); try { $bankHandler->checkNotification($_POST); } catch (ubrirException $e) { die($e->getMessage()); } if ($bankHandler->isOrderFailed()) { CSaleOrder::PayOrder($orderID, 'N'); } elseif ($bankHandler->isOrderPaid()) { CSaleOrder::PayOrder($orderID, 'Y'); } ?> OK
if (file_exists($psActionPath) && is_dir($psActionPath)) { if (file_exists($psActionPath."/result.php") && is_file($psActionPath."/result.php")) $psResultFile = $psActionPath."/result.php"; } elseif (strlen($arPSAction["RESULT_FILE"]) > 0) { if (file_exists($_SERVER["DOCUMENT_ROOT"].$arPSAction["RESULT_FILE"]) && is_file($_SERVER["DOCUMENT_ROOT"].$arPSAction["RESULT_FILE"])) $psResultFile = $_SERVER["DOCUMENT_ROOT"].$arPSAction["RESULT_FILE"]; } if (strlen($psResultFile) > 0) { $ORDER_ID = $ID; CSalePaySystemAction::InitParamArrays(array(), $ID); if (include($psResultFile)) { $ORDER_ID = IntVal($ORDER_ID); $arOrder = CSaleOrder::GetByID($ORDER_ID); if ($arOrder) { if ($arOrder["PS_STATUS"] == "Y" && $arOrder["PAYED"] == "N") { if ($arOrder["CURRENCY"] == $arOrder["PS_CURRENCY"] && DoubleVal($arOrder["PRICE"]) == DoubleVal($arOrder["PS_SUM"])) { if (!CSaleOrder::PayOrder($arOrder["ID"], "Y", True, True)) { if ($ex = $APPLICATION->GetException())
} if ($arOrder) { foreach (GetModuleEvents("sale", "OnSaleComponentOrderOneStepFinal", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($arResult["ORDER_ID"], &$arOrder, &$arParams)); } } $payment = \Bitrix\Sale\Internals\PaymentTable::getRow(array('select' => array('ID', 'PAY_SYSTEM_ID', 'SUM', 'DATE_BILL'), 'filter' => array('ORDER_ID' => $arResult["ORDER_ID"], '!PAY_SYSTEM_ID' => \Bitrix\Sale\Internals\PaySystemInner::getId()))); if ($arOrder && $arOrder["USER_ID"] == IntVal($USER->GetID())) { if ($payment && IntVal($payment["PAY_SYSTEM_ID"]) > 0 && $arOrder["PAYED"] != "Y") { $arOrder['PAYMENT_ID'] = $payment['ID']; $dbPaySysAction = CSalePaySystemAction::GetList(array(), array("PAY_SYSTEM_ID" => $payment["PAY_SYSTEM_ID"], "PERSON_TYPE_ID" => $arOrder["PERSON_TYPE_ID"]), false, false, array("NAME", "ACTION_FILE", "NEW_WINDOW", "PARAMS", "ENCODING", "LOGOTIP")); if ($arPaySysAction = $dbPaySysAction->Fetch()) { $arPaySysAction["NAME"] = htmlspecialcharsEx($arPaySysAction["NAME"]); if (strlen($arPaySysAction["ACTION_FILE"]) > 0) { if ($arPaySysAction["NEW_WINDOW"] != "Y") { CSalePaySystemAction::InitParamArrays($arOrder, $arOrder["ID"], $arPaySysAction["PARAMS"], array(), $payment); $pathToAction = $_SERVER["DOCUMENT_ROOT"] . $arPaySysAction["ACTION_FILE"]; $pathToAction = str_replace("\\", "/", $pathToAction); while (substr($pathToAction, strlen($pathToAction) - 1, 1) == "/") { $pathToAction = substr($pathToAction, 0, strlen($pathToAction) - 1); } if (file_exists($pathToAction)) { if (is_dir($pathToAction) && file_exists($pathToAction . "/payment.php")) { $pathToAction .= "/payment.php"; } $arPaySysAction["PATH_TO_ACTION"] = $pathToAction; } if (strlen($arPaySysAction["ENCODING"]) > 0) { define("BX_SALE_ENCODING", $arPaySysAction["ENCODING"]); AddEventHandler("main", "OnEndBufferContent", "ChangeEncoding"); function ChangeEncoding($content)
if ($inv_id > 0 && $paymentId > 0) { $bCorrectPayment = True; $out_summ = trim($_REQUEST["OutSum"]); $crc = trim($_REQUEST["SignatureValue"]); /** @var \Bitrix\Sale\Order $order */ $order = Order::load($inv_id); if (!$order) { $bCorrectPayment = false; } $arOrder = $order->getFieldValues(); $payment = $order->getPaymentcollection()->getItemById($paymentId); if (!$payment) { $bCorrectPayment = false; } if ($bCorrectPayment) { CSalePaySystemAction::InitParamArrays($arOrder, $inv_id, '', array(), $payment->getFieldValues()); } $changePayStatus = trim(CSalePaySystemAction::GetParamValue("CHANGE_STATUS_PAY")); $mrh_pass2 = CSalePaySystemAction::GetParamValue("ShopPassword2"); if (strlen($mrh_pass2) <= 0) { $bCorrectPayment = False; } $strCheck = md5($out_summ . ":" . $inv_id . ":" . $mrh_pass2 . ':shp_payment_id=' . $paymentId); if ($bCorrectPayment && ToUpper($crc) != ToUpper($strCheck)) { $bCorrectPayment = False; } if ($bCorrectPayment) { $strPS_STATUS_DESCRIPTION = GetMessage('SALE_RES_NUMBER') . ": " . $inv_id; $strPS_STATUS_DESCRIPTION .= "; " . GetMessage('SALE_RES_DATEPAY') . ": " . date("d.m.Y H:i:s"); if (isset($_REQUEST["IncCurrLabel"]) && strlen($_REQUEST["IncCurrLabel"]) > 0) { $strPS_STATUS_DESCRIPTION .= "; " . GetMessage('SASP_RES_PAY_TYPE') . ": " . $_REQUEST["IncCurrLabel"];
if (count($arBasketItems) <= 0) { $arResult["ERROR_MESSAGE"] = GetMessage("SALE_EMPTY_BASKET"); } $arResult["DISCOUNT_PRICE_ALL"] = $DISCOUNT_PRICE_ALL; $arResult["DISCOUNT_PRICE_ALL_FORMATED"] = SaleFormatCurrency($DISCOUNT_PRICE_ALL, $allCurrency); if ($arParams["USE_PREPAYMENT"] == "Y") { if (doubleval($arResult["allSum"]) > 0) { $personType = array(); $dbPersonType = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("LID" => SITE_ID, "ACTIVE" => "Y")); while ($arPersonType = $dbPersonType->GetNext()) { $personType[] = $arPersonType["ID"]; } if (!empty($personType)) { $dbPaySysAction = CSalePaySystemAction::GetList(array(), array("PS_ACTIVE" => "Y", "HAVE_PREPAY" => "Y", "PERSON_TYPE_ID" => $personType), false, false, array("ID", "PAY_SYSTEM_ID", "PERSON_TYPE_ID", "NAME", "ACTION_FILE", "RESULT_FILE", "NEW_WINDOW", "PARAMS", "ENCODING", "LOGOTIP")); if ($arPaySysAction = $dbPaySysAction->Fetch()) { CSalePaySystemAction::InitParamArrays(false, false, $arPaySysAction["PARAMS"]); $pathToAction = $_SERVER["DOCUMENT_ROOT"] . $arPaySysAction["ACTION_FILE"]; $pathToAction = str_replace("\\", "/", $pathToAction); while (substr($pathToAction, strlen($pathToAction) - 1, 1) == "/") { $pathToAction = substr($pathToAction, 0, strlen($pathToAction) - 1); } if (file_exists($pathToAction)) { if (is_dir($pathToAction) && file_exists($pathToAction . "/pre_payment.php")) { $pathToAction .= "/pre_payment.php"; } include_once $pathToAction; $psPreAction = new CSalePaySystemPrePayment(); if ($psPreAction->init()) { $orderData = array("PATH_TO_ORDER" => $arParams["PATH_TO_ORDER"], "AMOUNT" => $arResult["allSum"]); if (!$psPreAction->BasketButtonAction($orderData)) { if ($e = $APPLICATION->GetException()) {
<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die();?><? include(GetLangFileName(dirname(__FILE__)."/", "/payment.php")); $inv_id = IntVal($_REQUEST["InvId"]); if($inv_id > 0) { $bCorrectPayment = True; $out_summ = trim($_REQUEST["OutSum"]); $crc = trim($_REQUEST["SignatureValue"]); if (!($arOrder = CSaleOrder::GetByID($inv_id))) $bCorrectPayment = False; if ($bCorrectPayment) CSalePaySystemAction::InitParamArrays($arOrder, $inv_id); $changePayStatus = trim(CSalePaySystemAction::GetParamValue("CHANGE_STATUS_PAY")); $mrh_pass2 = CSalePaySystemAction::GetParamValue("ShopPassword2"); $strCheck = md5($out_summ.":".$inv_id.":".$mrh_pass2); if ($bCorrectPayment && ToUpper($crc) != ToUpper($strCheck)) $bCorrectPayment = False; if($bCorrectPayment) { $strPS_STATUS_DESCRIPTION = GetMessage('SALE_RES_NUMBER').": ".$inv_id; $strPS_STATUS_DESCRIPTION .= "; ".GetMessage('SALE_RES_DATEPAY').": ".date("d.m.Y H:i:s"); if (isset($_REQUEST["IncCurrLabel"]) && strlen($_REQUEST["IncCurrLabel"]) > 0) $strPS_STATUS_DESCRIPTION .= "; ".GetMessage('SASP_RES_PAY_TYPE').": ".$_REQUEST["IncCurrLabel"];
public function executeComponent() { global $APPLICATION; try { # verify token is valid $token = $this->checkToken(); # locate order and its payment system $order_id = $_REQUEST['order_id']; $payment_id = $_REQUEST['payment_id']; $uid = $_REQUEST['uid']; $order = Order::load($order_id); if (!$order) throw new Exception( Loc::getMessage("COMPONENT_BEGATEWAY_WRONG_ORDER_ID") . $order_id); $payment = $order->getPaymentCollection()->getItemById($payment_id); if (!$payment) throw new Exception( Loc::getMessage("COMPONENT_BEGATEWAY_WRONG_PAYMENT_ID") . $payment_id); $arOrder = CSaleOrder::GetByID($order_id); CSalePaySystemAction::InitParamArrays($arOrder, $arOrder["ID"], '', array(), $payment->getFieldValues()); \beGateway\Settings::$shopId = CSalePaySystemAction::GetParamValue("SHOP_ID"); \beGateway\Settings::$shopKey = CSalePaySystemAction::GetParamValue("SHOP_KEY"); \beGateway\Settings::$gatewayBase = "https://" . CSalePaySystemAction::GetParamValue("DOMAIN_GATEWAY"); \beGateway\Settings::$checkoutBase = "https://" . CSalePaySystemAction::GetParamValue("DOMAIN_PAYMENT_PAGE"); $query = new \beGateway\QueryByToken(); $query->setToken($token); $response = $query->submit()->getResponse(); if( ! isset( $response->checkout ) ) throw new Exception( Loc::getMessage("COMPONENT_BEGATEWAY_FAIL_TOKEN_QUERY") ); # verify token matches uid $this->arResult = $response->checkout; $type = $this->arResult->transaction_type; if (! isset($this->arResult->gateway_response)) throw new Exception( Loc::getMessage("COMPONENT_BEGATEWAY_NO_TRANS_INFO") ); if ($this->arResult->gateway_response->$type->uid != $uid) throw new Exception( Loc::getMessage("COMPONENT_BEGATEWAY_NO_UID_TOKEN_ACCESS") ); if ($this->arResult->order->tracking_id != $order_id . ':' . $payment_id) throw new Exception( Loc::getMessage("COMPONENT_BEGATEWAY_WRONG_TRACKING_ID") ); $money = new \beGateway\Money; $money->setCents($response->checkout->order->amount); $money->setCurrency($response->checkout->order->currency); $response->checkout->order->amount = CCurrencyLang::CurrencyFormat( $money->getAmount(), $money->getCurrency() ); $this->arResult->order->description = $APPLICATION->ConvertCharset($this->arResult->order->description, 'utf-8', SITE_CHARSET); $this->arResult->gateway_response->$type->billing_descriptor = $APPLICATION->ConvertCharset($this->arResult->gateway_response->$type->billing_descriptor, SITE_CHARSET, 'utf-8'); $this->IncludeComponentTemplate(); } catch(Exception $e) { ShowError( $e->getMessage() ); } }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } // define("NO_KEEP_STATISTIC", true); // define("NOT_CHECK_PERMISSIONS", true); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; if (CModule::IncludeModule("sale")) { if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_GET["server_responce"]) && $_GET["server_responce"] == "Y" && !empty($_POST["cartId"])) { $bCorrect = True; if ($bCorrect && !($arOrder = CSaleOrder::GetByID(IntVal($_POST["cartId"])))) { $bCorrect = False; } if ($bCorrect) { CSalePaySystemAction::InitParamArrays($arOrder); $strCallbackPassword = CSalePaySystemAction::GetParamValue("CALLBACK_PASSWORD"); if (strlen($strCallbackPassword) > 0 && $_POST["callbackPW"] != $strCallbackPassword) { $bCorrect = False; } } if ($bCorrect && isset($_POST["testMode"]) && IntVal($_POST["testMode"]) > 0) { $bCorrect = False; } if ($bCorrect) { $arFields = array("PS_STATUS" => $_POST["transStatus"] == "Y" ? "Y" : "N", "PS_STATUS_CODE" => $_POST["transStatus"], "PS_STATUS_DESCRIPTION" => $_POST["rawAuthMessage"], "PS_STATUS_MESSAGE" => $_POST["transStatus"] == "Y" ? "The WorldPay ID for this transaction: " . $_POST["transId"] . ", Time of this transaction: " . Date("r", $_POST["transTime"]) : "", "PS_SUM" => $_POST["authAmount"], "PS_CURRENCY" => $_POST["authCurrency"], "PS_RESPONSE_DATE" => Date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL", LANG))), "USER_ID" => $arOrder["USER_ID"]); if ($arOrder["CURRENCY"] == $_POST["authCurrency"] && $arOrder["PRICE"] == $_POST["authAmount"]) { $arFields["PAYED"] = "Y"; $arFields["DATE_PAYED"] = Date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL", LANG))); $arFields["EMP_PAYED_ID"] = false; }
if ($CCrmQuote->cPerms->HavePerm('QUOTE', BX_CRM_PERM_NONE, 'READ')) { ShowError(GetMessage('CRM_PERMISSION_DENIED')); return; } global $APPLICATION; $APPLICATION->RestartBuffer(); $quoteID = intval($arParams["QUOTE_ID"]); $dbResult = CCrmQuote::GetList(array(), array('ID' => $quoteID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('*', 'UF_*')); $arQuote = is_object($dbResult) ? $dbResult->Fetch() : null; $paymentData = is_array($arQuote) ? CCrmQuote::PrepareSalePaymentData($arQuote) : null; $paySystemID = isset($_REQUEST['PAY_SYSTEM_ID']) ? intval($_REQUEST['PAY_SYSTEM_ID']) : 0; if (is_array($paymentData) && $paySystemID > 0) { $dbPaySysAction = CSalePaySystemAction::GetList(array(), array("PAY_SYSTEM_ID" => $paySystemID, "PERSON_TYPE_ID" => $arQuote["PERSON_TYPE_ID"]), false, false, array("ACTION_FILE", "PARAMS", "ENCODING")); if ($arPaySysAction = $dbPaySysAction->Fetch()) { if (strlen($arPaySysAction["ACTION_FILE"]) > 0) { CSalePaySystemAction::InitParamArrays($paymentData["ORDER"], 0, $arPaySysAction["PARAMS"], array("PROPERTIES" => $paymentData["PROPERTIES"], "BASKET_ITEMS" => $paymentData["CART_ITEMS"], "TAX_LIST" => $paymentData["TAX_LIST"])); $pathToAction = $_SERVER["DOCUMENT_ROOT"] . $arPaySysAction["ACTION_FILE"]; $pathToAction = str_replace("\\", "/", $pathToAction); while (substr($pathToAction, strlen($pathToAction) - 1, 1) == "/") { $pathToAction = substr($pathToAction, 0, strlen($pathToAction) - 1); } if (file_exists($pathToAction)) { if (is_dir($pathToAction)) { if (file_exists($pathToAction . "/payment.php")) { include $pathToAction . "/payment.php"; } } else { include $pathToAction; } } if (strlen($arPaySysAction["ENCODING"]) > 0) {
} $errorMessage .= $productLimit; $arResult["ERROR_MESSAGE"] = $errorMessage; } else { $arResult["ORDER_BASKET"]["CONFIRM_ORDER"] = "Y"; $arResult["ORDER_BASKET"]["ORDER_ID"] = intval($ORDER_ID); $arResult["ORDER_ID"] = intval($ORDER_ID); $dbOrder = CSaleOrder::GetList(array("DATE_UPDATE" => "DESC"), array("LID" => SITE_ID, "USER_ID" => $currentUserId, "ID" => $arResult["ORDER_BASKET"]["ORDER_ID"])); if ($arOrder = $dbOrder->GetNext()) { if (intval($arOrder["PAY_SYSTEM_ID"]) > 0) { $dbPaySysAction = CSalePaySystemAction::GetList(array(), array("PAY_SYSTEM_ID" => $arOrder["PAY_SYSTEM_ID"], "PERSON_TYPE_ID" => $arOrder["PERSON_TYPE_ID"]), false, false, array("NAME", "ACTION_FILE", "NEW_WINDOW", "PARAMS", "ENCODING")); if ($arPaySysAction = $dbPaySysAction->Fetch()) { $arPaySysAction["NAME"] = htmlspecialcharsEx($arPaySysAction["NAME"]); if (strlen($arPaySysAction["ACTION_FILE"]) > 0) { if ($arPaySysAction["NEW_WINDOW"] != "Y") { CSalePaySystemAction::InitParamArrays($arOrder, $arOrder["ID"], $arPaySysAction["PARAMS"]); $pathToAction = $_SERVER["DOCUMENT_ROOT"] . $arPaySysAction["ACTION_FILE"]; $pathToAction = str_replace("\\", "/", $pathToAction); while (substr($pathToAction, strlen($pathToAction) - 1, 1) == "/") { $pathToAction = substr($pathToAction, 0, strlen($pathToAction) - 1); } if (file_exists($pathToAction)) { if (is_dir($pathToAction) && file_exists($pathToAction . "/payment.php")) { $pathToAction .= "/payment.php"; } $arPaySysAction["PATH_TO_ACTION"] = $pathToAction; } if (strlen($arPaySysAction["ENCODING"]) > 0) { define("BX_SALE_ENCODING", $arPaySysAction["ENCODING"]); AddEventHandler("main", "OnEndBufferContent", "ChangeEncoding"); function ChangeEncoding($content)
$actionFilePath = $_SERVER["DOCUMENT_ROOT"] . $actionFilePath; $actionFilePath = str_replace("\\", "/", $actionFilePath); while (substr($actionFilePath, strlen($actionFilePath) - 1, 1) == "/") { $actionFilePath = substr($actionFilePath, 0, strlen($actionFilePath) - 1); } if (!file_exists($actionFilePath)) { echo CUtil::PhpToJSObject(array('ERROR' => 'COULD NOT FIND PAYMENT SYSTEM ACTION FILE!')); die; } elseif (is_dir($actionFilePath)) { $actionFilePath = $actionFilePath . '/payment.php'; if (!file_exists($actionFilePath)) { echo CUtil::PhpToJSObject(array('ERROR' => 'COULD NOT FIND PAYMENT SYSTEM ACTION FILE!')); die; } } CSalePaySystemAction::InitParamArrays($paymentData['ORDER'], 0, $paySysActionFields['PARAMS'], array("PROPERTIES" => $paymentData['PROPERTIES'], "BASKET_ITEMS" => $paymentData['CART_ITEMS'], "TAX_LIST" => $paymentData["TAX_LIST"])); $pdfContent = (include $actionFilePath); $fileName = "quote_{$quoteID}.pdf"; $fileData = array('name' => $fileName, 'type' => 'file', 'content' => $pdfContent, 'MODULE_ID' => 'crm'); $fileID = CFile::SaveFile($fileData, 'crm'); if ($fileID > 0) { $fileArray = CFile::GetFileArray($fileID); $storageTypeID = \Bitrix\Crm\Integration\StorageType::getDefaultTypeID(); if ($storageTypeID !== \Bitrix\Crm\Integration\StorageType::File) { $storageFileID = \Bitrix\Crm\Integration\StorageManager::saveEmailAttachment($fileArray, $storageTypeID); $fileInfo = $storageFileID > 0 ? \Bitrix\Crm\Integration\StorageManager::getFileInfo($storageFileID, $storageTypeID) : null; if (is_array($fileInfo)) { if ($storageTypeID === \Bitrix\Crm\Integration\StorageType::WebDav) { echo CUtil::PhpToJSObject(array('webdavelement' => $fileInfo)); } elseif ($storageTypeID === \Bitrix\Crm\Integration\StorageType::Disk) { echo CUtil::PhpToJSObject(array('diskfile' => $fileInfo));
/** * Function gets pay system info from database, no cache is used here * @return void */ protected function obtainDataPaySystem() { if (empty($this->dbResult["ID"])) { return; } if (intval($this->dbResult["PAY_SYSTEM_ID"])) { $this->dbResult["PAY_SYSTEM"] = CSalePaySystem::GetByID($this->dbResult["PAY_SYSTEM_ID"], $this->dbResult["PERSON_TYPE_ID"]); } if ($this->dbResult["PAYED"] != "Y" && $this->dbResult["CANCELED"] != "Y") { if (intval($this->dbResult["PAY_SYSTEM_ID"])) { $dbPaySysAction = CSalePaySystemAction::GetList(array(), array("PAY_SYSTEM_ID" => $this->dbResult["PAY_SYSTEM_ID"], "PERSON_TYPE_ID" => $this->dbResult["PERSON_TYPE_ID"]), false, false, array("NAME", "ACTION_FILE", "NEW_WINDOW", "PARAMS", "ENCODING")); if ($arPaySysAction = $dbPaySysAction->Fetch()) { if (strlen($arPaySysAction["ACTION_FILE"])) { $this->dbResult["CAN_REPAY"] = "Y"; if ($arPaySysAction["NEW_WINDOW"] == "Y") { $this->dbResult["PAY_SYSTEM"]["PSA_ACTION_FILE"] = htmlspecialcharsbx($this->arParams["PATH_TO_PAYMENT"]) . '?ORDER_ID=' . urlencode(urlencode($this->dbResult["ACCOUNT_NUMBER"])); } else { CSalePaySystemAction::InitParamArrays($this->dbResult, $this->requestData["ID"], $arPaySysAction["PARAMS"]); $pathToAction = $_SERVER["DOCUMENT_ROOT"] . $arPaySysAction["ACTION_FILE"]; $pathToAction = str_replace("\\", "/", $pathToAction); while (substr($pathToAction, strlen($pathToAction) - 1, 1) == "/") { $pathToAction = substr($pathToAction, 0, strlen($pathToAction) - 1); } if (file_exists($pathToAction)) { if (is_dir($pathToAction) && file_exists($pathToAction . "/payment.php")) { $pathToAction .= "/payment.php"; } $this->dbResult["PAY_SYSTEM"]["PSA_ACTION_FILE"] = $pathToAction; } if (strlen($arPaySysAction["ENCODING"])) { define("BX_SALE_ENCODING", $arPaySysAction["ENCODING"]); AddEventHandler("main", "OnEndBufferContent", array($this, "changeBodyEncoding")); } } } } } } }
protected function updatePaySystemInfoAction() { if ($this->request["orderId"]) { $orderId = $this->request["orderId"]; } else { throw new UserMessageException("Incorrect order ID!"); } if ($this->request["paymentId"]) { $paymentId = $this->request["paymentId"]; } else { throw new UserMessageException("Incorrect payment ID!"); } /** @var \Bitrix\Sale\Order $order */ $order = Sale\Order::load($orderId); if ($order) { /** @var \Bitrix\Sale\PaymentCollection $paymentCollection */ $paymentCollection = $order->getPaymentCollection(); /** @var \Bitrix\Sale\Payment $payment */ $payment = $paymentCollection->getItemById($paymentId); if ($payment) { $psResultFile = ''; $psParams = Admin\Blocks\OrderPayment::getPaySystemParams($payment->getPaymentSystemId(), $order->getPersonTypeId()); $psActionPath = $_SERVER["DOCUMENT_ROOT"] . $psParams["ACTION_FILE"]; $psActionPath = str_replace("\\", "/", $psActionPath); while (substr($psActionPath, strlen($psActionPath) - 1, 1) == "/") { $psActionPath = substr($psActionPath, 0, strlen($psActionPath) - 1); } if (file_exists($psActionPath) && is_dir($psActionPath)) { if (file_exists($psActionPath . "/result.php") && is_file($psActionPath . "/result.php")) { $psResultFile = $psActionPath . "/result.php"; } } elseif (strlen($psParams["RESULT_FILE"]) > 0) { if (file_exists($_SERVER["DOCUMENT_ROOT"] . $psParams["RESULT_FILE"]) && is_file($_SERVER["DOCUMENT_ROOT"] . $psParams["RESULT_FILE"])) { $psResultFile = $_SERVER["DOCUMENT_ROOT"] . $psParams["RESULT_FILE"]; } } if (strlen($psResultFile) > 0) { \CSalePaySystemAction::InitParamArrays($order->getFieldValues(), $orderId, $psParams["PARAMS"], array(), $payment->getFieldValues()); try { if (!(include $psResultFile)) { $this->addResultError(GetMessage("SALE_OA_ERROR_PAY_SYSTEM_INFO")); } } catch (SystemException $e) { $this->addResultError($e->getMessage()); } } } } }
$lmi_sys_trans_no = $_REQUEST['LMI_SYS_TRANS_NO']; $lmi_sys_invs_no = $_REQUEST['LMI_SYS_INVS_NO']; $lmi_sys_trans_date = $_REQUEST['LMI_SYS_TRANS_DATE']; $lmi_hash = $_REQUEST['LMI_HASH']; $lmi_secret_key = $_REQUEST['LMI_SECRET_KEY']; if (CModule::IncludeModule("sale")) { $bCorrectPayment = True; $err = 0; $err_text = ''; if ($arOrder = CSaleOrder::GetByID(IntVal($lmi_payment_no))) { $bCorrectPayment = False; $err = 1; $err_text = 'ERR: НЕТ ТАКОГО ЗАКАЗА'; } if ($bCorrectPayment) { CSalePaySystemAction::InitParamArrays($arOrder, $arOrder["ID"]); } $IdM = CSalePaySystemAction::GetParamValue("ZP_SHOP_ID"); $sk = CSalePaySystemAction::GetParamValue("ZP_MERCHANT_KEY"); $CruR = CSalePaySystemAction::GetParamValue("ZP_CODE_RUR"); // Проверяем, не произошла ли подмена суммы. $order_amount = CCurrencyRates::ConvertCurrency($arOrder["PRICE"], $arOrder["CURRENCY"], $CruR); if ($order_amount != $lmi_payment_amount) { $err = 2; $err_text = 'ERR: НЕВЕРНАЯ СУММА : ' . $lmi_payment_amount; } //проверяем ID магазина if ($lmi_payee_purse != $IdM) { $err = 3; $err_text = 'ERR: НЕВЕРЕН ID МАГАЗИНА : ' . $lmi_payee_purse; }
$order['PRICE'] = (isset($order['PRICE']) ? doubleval($order['PRICE']) : 0) - $order['SUM_PAID']; $personTypeID = isset($order['PERSON_TYPE_ID']) ? intval($order['PERSON_TYPE_ID']) : 0; if ($personTypeID <= 0) { __CrmMobileInvoiceEditEndResonse(array('ERROR' => GetMessage('CRM_INVOICE_COULD_NOT_FIND_SALE_ORDER_PERSON_TYPE'))); } $paySystemID = isset($order['PAY_SYSTEM_ID']) ? intval($order['PAY_SYSTEM_ID']) : 0; if ($paySystemID <= 0) { __CrmMobileInvoiceEditEndResonse(array('ERROR' => GetMessage('CRM_INVOICE_COULD_NOT_FIND_SALE_ORDER_PAY_SYSTEM'))); } $dbPaySysAction = CSalePaySystemAction::GetList(array(), array('PAY_SYSTEM_ID' => $paySystemID, 'PERSON_TYPE_ID' => $personTypeID), false, false, array('ACTION_FILE', 'PARAMS', 'ENCODING')); $paySysAction = $dbPaySysAction ? $dbPaySysAction->Fetch() : null; $actionFile = is_array($paySysAction) && isset($paySysAction['ACTION_FILE']) ? $paySysAction['ACTION_FILE'] : ''; if ($actionFile === '') { __CrmMobileInvoiceEditEndResonse(array('ERROR' => GetMessage('CRM_INVOICE_COULD_NOT_FIND_PAY_SYSTEM_HANDLER'))); } CSalePaySystemAction::InitParamArrays($order, $ID, isset($paySysAction['PARAMS']) ? $paySysAction['PARAMS'] : ''); $actionPath = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT'] . $actionFile); $actionPathLength = strlen($actionPath); while (substr($actionPath, $actionPathLength - 1, 1) === '/') { $actionPathLength -= 1; $actionPath = substr($actionPath, 0, $actionPathLength); } $actionFilePath = "{$actionPath}/payment.php"; if (!(is_dir($actionPath) && file_exists($actionFilePath))) { __CrmMobileInvoiceEditEndResonse(array('ERROR' => GetMessage('CRM_INVOICE_COULD_NOT_FIND_PAY_SYSTEM_HANDLER'))); } //HACK: params for pdf handler $_REQUEST['pdf'] = 'Y'; $_REQUEST['GET_CONTENT'] = 'Y'; $content = (include $actionFilePath); if ($content === '') {