public function __construct(Shop_Payment_System_Model $oShop_Payment_System_Model)
 {
     $this->_setupLogger();
     \beGateway\Settings::$shopId = $this->_shop_id;
     \beGateway\Settings::$shopKey = $this->_shop_key;
     \beGateway\Settings::$gatewayBase = 'https://' . $this->_gateway_base;
     \beGateway\Settings::$checkoutBase = 'https://' . $this->_checkout_base;
     parent::__construct($oShop_Payment_System_Model);
 }
 function get_pay_button($bill_id, $bill_sum, $bill_payment_sum)
 {
     if ($bill_payment_sum == '') {
         $payment_amount = $bill_sum;
     } else {
         $payment_amount = $bill_payment_sum;
     }
     $user_id = (int) $this->getSessionUserId();
     $language = Multilanguage::get_current_language();
     require_once SITEBILL_DOCUMENT_ROOT . '/apps/begateway/lib/begateway-api-php/lib/beGateway.php';
     require_once SITEBILL_DOCUMENT_ROOT . '/apps/system/lib/system/user/user.php';
     require_once SITEBILL_DOCUMENT_ROOT . '/apps/begateway/classes/currency.php';
     $currency = new begateway_currency();
     $order_currency = $currency->getCurrencyCode(CURRENT_CURRENCY);
     if ($order_currency == 'RUR') {
         $order_currency = 'RUB';
     }
     $user = new User_Object();
     \beGateway\Settings::$shopId = $this->site_id;
     \beGateway\Settings::$shopKey = $this->site_key;
     \beGateway\Settings::$gatewayBase = 'https://' . $this->domain_gateway;
     \beGateway\Settings::$checkoutBase = 'https://' . $this->domain_checkout;
     #\beGateway\Logger::getInstance()->setLogLevel(\beGateway\Logger::DEBUG);
     $transaction = new \beGateway\GetPaymentToken();
     $transaction->money->setCurrency($order_currency);
     $transaction->money->setAmount($payment_amount);
     $transaction->setDescription(sprintf(Multilanguage::_('ORDER_DESCRIPTION', 'begateway'), $bill_id));
     $transaction->setTrackingId($user_id . '|' . $bill_id);
     $transaction->setLanguage($language);
     $sitebill_host = $this->_protocol_scheme() . '://' . $_SERVER['HTTP_HOST'] . SITEBILL_MAIN_URL;
     $notification_url = $sitebill_host . '/apps/begateway/listener.php';
     $notification_url = str_replace('carts.local', 'webhook.begateway.com:8443', $notification_url);
     $transaction->setNotificationUrl($notification_url);
     $transaction->setSuccessUrl($sitebill_host . '/account/balance');
     $transaction->setDeclineUrl($sitebill_host . '/account/balance/?do=add_bill');
     $transaction->setFailUrl($sitebill_host . '/account/balance/?do=add_bill');
     $transaction->setCancelUrl($sitebill_host . '/account/balance');
     $transaction->customer->setEmail($user->getEmail($user_id));
     $transaction->setAddressHidden();
     $response = $transaction->submit();
     if ($response->isSuccess()) {
         $payment_params = array();
         $payment_params['token'] = $response->getToken();
         $payment_params['url'] = \beGateway\Settings::$checkoutBase . '/checkout';
         $this->template->assign('payment_text', sprintf(Multilanguage::_('YOU_HAVE_ORDER', 'begateway'), (string) $payment_amount, $this->getConfigValue('ue_name')));
         $this->template->assign('payment_button', Multilanguage::_('PAYMENT_BUTTON', 'begateway'));
         $this->template->assign('payment_description', $this->description[$language]);
         $this->template->assign('payment_params', $payment_params);
     } else {
         $this->template->assign('payment_error', Multilanguage::_('PAYMENT_ERROR', 'system') . '<br>' . $response->getMessage());
     }
     return $this->template->fetch(SITEBILL_DOCUMENT_ROOT . '/apps/begateway/site/template/pay_form.tpl');
 }
 public function __construct()
 {
     $this->name = 'beGateway';
     $this->tab = 'payments_gateways';
     $this->version = '1.3.8';
     $this->currencies = true;
     $this->currencies_mode = 'checkbox';
     parent::__construct();
     \beGateway\Settings::$gatewayBase = 'https://' . trim(Configuration::get('BEGATEWAY_DOMAIN_GATEWAY'));
     \beGateway\Settings::$checkoutBase = 'https://' . trim(Configuration::get('BEGATEWAY_DOMAIN_CHECKOUT'));
     \beGateway\Settings::$shopId = trim(Configuration::get('BEGATEWAY_SHOP_ID'));
     \beGateway\Settings::$shopKey = trim(Configuration::get('BEGATEWAY_SHOP_PASS'));
     $this->page = basename(__FILE__, '.php');
     $this->displayName = $this->l('beGateway');
     $this->description = $this->l('Accepts credit or debit cards');
     $this->confirmUninstall = $this->l('Are you sure you want to delete your details ?');
 }
 /**
  * constructor
  *
  */
 function __construct()
 {
     global $woocommerce;
     // load form fields
     $this->init_form_fields();
     // initialise settings
     $this->init_settings();
     // variables
     $this->title = $this->settings['title'];
     //admin title
     if (current_user_can('manage_options')) {
         $this->title = $this->settings['admin_title'];
     }
     \beGateway\Settings::$gatewayBase = 'https://' . $this->settings['domain-gateway'];
     \beGateway\Settings::$checkoutBase = 'https://' . $this->settings['domain-checkout'];
     \beGateway\Settings::$shopId = $this->settings['shop-id'];
     \beGateway\Settings::$shopKey = $this->settings['secret-key'];
     //callback URL - hooks into the WP/WooCommerce API and initiates the payment class for the bank server so it can access all functions
     $this->notify_url = str_replace('https:', 'http:', add_query_arg('wc-api', 'BT_beGateway', home_url('/')));
     $this->notify_url = str_replace('carts.local', 'webhook.begateway.com:8443', $this->notify_url);
     $this->method_title = $this->title;
     $this->description = $this->settings['description'];
     $this->transaction_type = $this->settings['tx-type'];
     $this->debug = $this->settings['debug'];
     $this->show_transaction_table = $this->settings['show-transaction-table'] == 'yes' ? true : false;
     // Logs
     if ('yes' == $this->debug) {
         $this->log = new WC_Logger();
     }
     add_action('admin_menu', array($this, 'bt_admin_hide'));
     add_action('admin_notices', array($this, 'bt_admin_error'));
     add_action('admin_notices', array($this, 'bt_admin_message'));
     add_action('woocommerce_receipt_begateway', array($this, 'receipt_page'));
     add_action('woocommerce_api_bt_begateway', array($this, 'check_ipn_response'));
     add_action('woocommerce_update_options_payment_gateways', array($this, 'process_admin_options'));
     add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
     // display transaction table
     if (is_admin() && $this->show_transaction_table) {
         add_action('add_meta_boxes', array($this, 'create_order_transactions_meta_box'));
         //$this->create_order_transactions_meta_box();
     }
 }
 public function executeComponent()
 {
     global $APPLICATION;
     try {
         $this->checkToken();
         \beGateway\Settings::$shopId = (int) \Bitrix\Main\Config\Option::get($this->module_id, "shop_id");
         \beGateway\Settings::$shopKey = \Bitrix\Main\Config\Option::get($this->module_id, "shop_key");
         \beGateway\Settings::$gatewayBase = "https://" . \Bitrix\Main\Config\Option::get($this->module_id, "domain_gateway");
         \beGateway\Settings::$checkoutBase = "https://" . \Bitrix\Main\Config\Option::get($this->module_id, "domain_payment_page");
         $query = new \beGateway\QueryByToken();
         $query->setToken($this->arParams["TOKEN"]);
         $response = $query->submit()->getResponse();
         if (!isset($response->checkout)) {
             throw new Exception(Loc::getMessage("DEVTM_BEGATEWAY_FAIL_TOKEN_QUERY"));
         }
         $response->checkout->order->amount = $this->floatAmount($response->checkout->order->amount);
         $this->arResult = $response->checkout;
         $this->IncludeComponentTemplate();
     } catch (Exception $e) {
         ShowError($e->getMessage());
     }
 }
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
$module_id = "devtm.begateway";
if (!\Bitrix\Main\Loader::includeModule($module_id) || !$GLOBALS["USER"]->IsAuthorized()) {
    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");
$out_summ = number_format(floatval($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["SHOULD_PAY"]), 2, ".", "");
$currency = $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["CURRENCY"];
$order_id = IntVal($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["ID"]);
$transaction = new \beGateway\GetPaymentToken();
$transaction->money->setCurrency($currency);
$transaction->money->setAmount($out_summ);
$transaction->setTrackingId(SITE_ID . "_" . $order_id);
$transaction->setDescription(Loc::getMessage("DEVTM_BEGATEWAY_ORDER_TITLE") . " #" . $order_id);
$transaction->setLanguage(LANGUAGE_ID);
if (\Bitrix\Main\Config\Option::get($module_id, "transaction_type") == "authorization") {
    $transaction->setAuthorizationTransactionType();
} else {
    $transaction->setPaymentTransactionType();
}
$notification_url = \Bitrix\Main\Config\Option::get($module_id, "notification_url");
$notification_url = str_replace('bitrix.local', 'bitrix.webhook.begateway.com:8443', $notification_url);
	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() );
		}
	}
<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die();?><?
use Bitrix\Sale\Order;
use Bitrix\Main\Localization\Loc;
Loc::loadMessages(__FILE__);

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

\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");

$payment_id = CSalePaySystemAction::GetParamValue("ORDER_PAYMENT_ID");
$order_id = IntVal($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["ID"]);

$tracking_id = $order_id . ":" . $payment_id;

set_time_limit(0);

$query = new \beGateway\QueryByTrackingId;
$query->setTrackingId($tracking_id);

$response = $query->submit();

if ($response && $response != 'error') {
  $money = new \beGateway\Money;
  $money->setCurrency($response->getResponse()->transaction->currency);
  $money->setCents($response->getResponse()->transaction->amount);

	if($response->getTrackingId() == $tracking_id) {
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;
 function _init_pm($pmconfigs)
 {
     \beGateway\Settings::$gatewayBase = 'https://' . $pmconfigs['domain_gateway'];
     \beGateway\Settings::$checkoutBase = 'https://' . $pmconfigs['domain_checkout'];
     \beGateway\Settings::$shopId = $pmconfigs['shop_id'];
     \beGateway\Settings::$shopKey = $pmconfigs['shop_secret_key'];
 }
<?php

\beGateway\Settings::$shopId = 361;
\beGateway\Settings::$shopKey = 'b8647b68898b084b836474ed8d61ffe117c9a01168d867f24953b776ddcb134d';