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'); }