function ProcessResult()
 {
     $webhook = new \beGateway\Webhook();
     if (!$webhook->isAuthorized() || !$webhook->isSuccess() || $this->_shopOrder->paid || is_null($order_id = intval(Core_Array::getRequest('order_id'))) || $order_id != $webhook->getTrackingId()) {
         return FALSE;
     }
     $sum = $this->getSumWithCoeff();
     $oShop_Currency = Core_Entity::factory('Shop_Currency')->find($this->_begateway_currency_id);
     /* конвертировать RUR код в RUB */
     $currency = $oShop_Currency->code;
     $currency = $currency == 'RUR' ? 'RUB' : $currency;
     $money = new \beGateway\Money();
     $money->setCurrency($currency);
     $money->setAmount($sum);
     if ($money->getCents() == $webhook->getResponse()->transaction->amount && $currency == $webhook->getResponse()->transaction->currency) {
         $this->shopOrderBeforeAction(clone $this->_shopOrder);
         $result = array("Товар оплачен.", "Атрибуты:", "Номер сайта продавца: " . $this->_shop_id, "Внутренний номер покупки продавца: " . $this->_shopOrder->id, "Сумма платежа: " . $sum, "Валюта платежа: " . $oShop_Currency->code, "UID платежа: " . $webhook->getUid(), "Способ оплаты: " . $webhook->getPaymentMethod(), "Статус платежа: успешно");
         if (isset($webhook->getResponse()->transaction->three_d_secure_verification)) {
             $result[] = "3-D Secure: " . $webhook->getResponse()->transaction->three_d_secure_verification->pa_status;
         }
         $this->_shopOrder->system_information = implode($result, "\n");
         $this->_shopOrder->paid();
         $this->setXSLs();
         $this->send();
         ob_start();
         $this->changedOrder('changeStatusPaid');
         ob_get_clean();
     }
 }
require_once SITEBILL_DOCUMENT_ROOT . '/apps/system/lib/db/MySQL.php';
require_once SITEBILL_DOCUMENT_ROOT . '/apps/system/lib/sitebill.php';
require_once SITEBILL_DOCUMENT_ROOT . '/apps/system/lib/admin/object_manager.php';
require_once SITEBILL_DOCUMENT_ROOT . '/apps/system/lib/system/multilanguage/multilanguage.class.php';
require_once SITEBILL_DOCUMENT_ROOT . '/apps/begateway/admin/admin.php';
require_once SITEBILL_DOCUMENT_ROOT . '/apps/begateway/site/site.php';
$smarty = new Smarty();
$smarty->cache_dir = SITEBILL_DOCUMENT_ROOT . '/cache/smarty';
$smarty->compile_dir = SITEBILL_DOCUMENT_ROOT . '/cache/compile';
$S = new SiteBill();
$begateway_site = new begateway_site();
if (0 == (int) $S->getConfigValue('apps.begateway.enable')) {
    echo "ERROR 01";
    exit;
}
\beGateway\Settings::$shopId = $begateway_site->site_id;
\beGateway\Settings::$shopKey = $begateway_site->site_key;
$webhook = new \beGateway\Webhook();
if (!$webhook->isAuthorized() || !$webhook->isSuccess()) {
    //$S->writeLog(array('apps_name'=>'apps.', 'method' => __METHOD__, 'message' => 'Подпись не совпадает', 'type' => NOTICE));
    echo "ERROR 02";
    exit;
}
list($user_id, $bill_id) = explode('|', $webhook->getTrackingId());
if ($begateway_site->checkBill($bill_id)) {
    $begateway_site->activateBill($bill_id);
    echo "OK";
} else {
    echo "ERROR 00";
}
exit;
 /**
  *this function is called via the wp-api when the begateway server sends
  *callback data
  */
 function check_ipn_response()
 {
     //check for refund/capture/void
     if (isset($_GET['begateway']) && isset($_GET['uid']) && isset($_GET['oid'])) {
         $this->child_transaction($_GET['begateway'], $_GET['uid'], $_GET['oid'], $_GET['amount'], $_GET['comment']);
         exit;
     }
     //do normal callback response
     global $woocommerce;
     $webhook = new \beGateway\Webhook();
     if ($webhook->isAuthorized()) {
         //log
         if ("yes" == $this->debug) {
             $display = "\n-------------------------------------------\n";
             $display .= "Order No: " . $webhook->getTrackingId();
             $display .= "\nUID: " . $webhook->getUid();
             $display .= "\n--------------------------------------------\n";
             $this->log->add("begateway", $display);
         }
         $this->process_order($webhook);
     } else {
         if ("yes" == $this->debug) {
             $display = "\n----------- Unable to proceed --------------\n";
             $display .= "Order No: " . $webhook->getTrackingId();
             $display .= "\n--------------------------------------------\n";
             $this->log->add("begateway", $display);
         }
         wp_die("beGateway Notify Failure");
     }
 }
 private function _processWebhook()
 {
     $webhook = new \beGateway\Webhook();
     if ($webhook->isAuthorized() && ($webhook->isSuccess() || $webhook->isFailed())) {
         $Status = $webhook->getStatus();
         $Currency = $webhook->getResponse()->transaction->currency;
         $Amount = new \beGateway\Money();
         $Amount->setCurrency($Currency);
         $Amount->setCents($webhook->getResponse()->transaction->amount);
         $TransId = $webhook->getUid();
         $orderno = $webhook->getTrackingId();
         $cart = new Cart((int) $orderno);
         if (!Validate::isLoadedObject($cart)) {
             Logger::addLog($this->l('Webhook: error to load cart'), 4);
             die($this->l('Critical error to load order cart'));
         }
         $customer = new Customer((int) $cart->id_customer);
         if (!Validate::isLoadedObject($customer)) {
             Logger::addLog($this->l('Webhook: error to load customer details'), 4);
             die($this->l('Critical error to load customer'));
         }
         $shop_ptype = trim(Configuration::get('BEGATEWAY_SHOP_PAYTYPE'));
         $payment_status = $webhook->isSuccess() ? Configuration::get('PS_OS_PAYMENT') : Configuration::get('PS_OS_ERROR');
         $this->be_gateway->validateOrder((int) $orderno, $payment_status, $Amount->getAmount(), $this->be_gateway->displayName, $webhook->getMessage(), array('transaction_id' => $TransId), NULL, false, $customer->secure_key);
         $order_new = empty($this->be_gateway->currentOrder) ? $orderno : $this->be_gateway->currentOrder;
         Db::getInstance()->Execute('
     INSERT INTO ' . _DB_PREFIX_ . 'begateway_transaction (type, id_begateway_customer, id_cart, id_order,
       uid, amount, status, currency, date_add)
       VALUES ("' . $shop_ptype . '", ' . $cart->id_customer . ', ' . $orderno . ', ' . $order_new . ', "' . $TransId . '", ' . $Amount->getAmount() . ', "' . $Status . '", "' . $Currency . '", NOW())');
         die('OK');
     }
 }
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
$module_id = "devtm.begateway";
if (!\Bitrix\Main\Loader::includeModule($module_id)) {
    return;
}
use Bitrix\Main\Localization\Loc;
Loc::loadMessages(__FILE__);
\beGateway\Settings::$shopId = (int) \Bitrix\Main\Config\Option::get($module_id, "shop_id");
\beGateway\Settings::$shopKey = \Bitrix\Main\Config\Option::get($module_id, "shop_key");
\beGateway\Settings::$gatewayBase = "https://" . \Bitrix\Main\Config\Option::get($module_id, "domain_gateway");
\beGateway\Settings::$checkoutBase = "https://" . \Bitrix\Main\Config\Option::get($module_id, "domain_payment_page");
$webhook = new \beGateway\Webhook();
list($site_id, $tracking_id) = explode('_', $webhook->getTrackingId());
$arOrder = CSaleOrder::GetByID($tracking_id);
if ($arOrder && $webhook->isAuthorized()) {
    if ($webhook->isSuccess() && $arOrder["PAYED"] != "Y") {
        CSaleOrder::PayOrder($arOrder["ID"], "Y");
        CSaleOrder::StatusOrder($arOrder["ID"], "P");
        $message = array();
        if (isset($webhook->getResponse()->transaction->three_d_secure_verification)) {
            $message[] = "3-D Secure: " . $webhook->getResponse()->transaction->three_d_secure_verification->pa_status;
        }
        $message[] = $webhook->getResponse()->transaction->description;
        $money = new \beGateway\Money();
        $money->setCurrency($webhook->getResponse()->transaction->currency);
        $money->setCents($webhook->getResponse()->transaction->amount);
        $arFields = array("PS_STATUS" => "Y", "PS_STATUS_MESSAGE" => implode("\n", $message), "PS_SUM" => $money->getAmount(), "PS_CURRENCY" => $webhook->getResponse()->transaction->currency, "PS_RESPONSE_DATE" => date("d.m.Y H:i:s", strtotime($webhook->getResponse()->transaction->created_at)), "PS_STATUS_DESCRIPTION" => json_encode(array($webhook->getUid() => $webhook->getResponse()->transaction->type)));
<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die();?><?
use Bitrix\Sale\Order;
use Bitrix\Main\Localization\Loc;

$module_id = "begateway.payment";
if( ! \Bitrix\Main\Loader::includeModule($module_id) ) return;

require_once dirname(__FILE__) . '/common.php';
Loc::loadMessages(__FILE__);

$webhook = new \beGateway\Webhook;

list($order_id, $payment_id) = explode(':', $webhook->getTrackingId());

$order = Order::load($order_id);

if (!$order) {
  _output_message('ERROR: INVALID ORDER ID ' . $order_id);
}

$payment = $order->getPaymentCollection()->getItemById($payment_id);

if (!$payment) {
  _output_message('ERROR: INVALID 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");