/** * Пополнение счета через яндекс кассу. * * @param type $type - тип оплаты * @param type $data - данные по параметрам покупаемой услуги * * @return \xajaxResponse */ function quickPaymentAccountYandexKassa($type, $data) { $is_error = true; $uid = get_uid(false); $objResponse =& new xajaxResponse(); $price = (int) @$data['price']; $pay_methods = array(quickPaymentPopup::PAYMENT_TYPE_CARD => yandex_kassa::PAYMENT_AC, quickPaymentPopup::PAYMENT_TYPE_YA => yandex_kassa::PAYMENT_YD, quickPaymentPopup::PAYMENT_TYPE_WM => yandex_kassa::PAYMENT_WM, quickPaymentPopup::PAYMENT_TYPE_ALFACLICK => yandex_kassa::PAYMENT_AB, quickPaymentPopup::PAYMENT_TYPE_SBERBANK => yandex_kassa::PAYMENT_SB); if (!isset($pay_methods[$type])) { return $objResponse; } $allow = !sbr_meta::isFtJuri($uid); if ($allow) { $is_error = false; $billReserveId = null; $bill = new billing($uid); $minPrice = quickPaymentPopupAccount::PRICE_MIN; if ($bill->getAccSum() < 0) { $debt = abs($bill->getAccSum()); $minPrice = $debt > $minPrice ? $debt : $minPrice; if ($price >= $minPrice) { $option = array('acc_sum' => $minPrice); //Автоматическая покупка услуги погашения задолженности $billReserveId = $bill->addServiceAndCheckout(135, $option); } } $payment = $pay_methods[$type]; if ($price < $minPrice || $price > quickPaymentPopupAccount::PRICE_MAX || $payment == yandex_kassa::PAYMENT_WM && $price > quickPaymentPopupAccount::PRICE_MAX_WM) { $is_error = true; } if (!$is_error) { $yandex_kassa = new yandex_kassa(); $html_form = $yandex_kassa->render($price, $bill->account->id, $payment, $billReserveId); $objResponse->script("\n var qp_form_wrapper = \$\$('#quick_payment_account .__quick_payment_form');\n if(qp_form_wrapper){ \n qp_form_wrapper.set('html','{$html_form}');\n qp_form_wrapper.getElement('form')[0].submit();\n }\n "); $link = '/bill/history/?period=3'; //сохраняем в сессию куда перейти при успешной покупке $_SESSION[quickPaymentPopup::QPP_REDIRECT] = $link; } } // Показываем предупреждение в случае ошибки if ($is_error) { $objResponse->script("\n var qp = window.quick_payment_factory.getQuickPayment('account');\n if(qp) qp.show_error('Возникла ошибка при пополнении счета!');\n "); } return $objResponse; }
if ((int) $historyItem["sbrId"]) { $historyItem['comments'] = sbr_meta::parseOpComment($historyItem['comments'], null, null, $sbrSchemes[$historyItem["sbrId"]]); } } } } unset($historyItem); // делаем уведомления прочитанными $barNotify = new bar_notify($_SESSION['uid']); $barNotify->delNotifies(array('page' => 'bill')); if ($page > 1 && $page > $history['pagesCount']) { header_location_exit('/404.php'); } $events = account::searchBillEvent($startTime ? $startTime : '2000-01-01', time()); $js_file = array('billing.js'); $is_jury = sbr_meta::isFtJuri($uid); $is_emp = is_emp(); $isAllowAddFunds = !$is_emp && !$is_jury; if ($isAllowAddFunds) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/quick_payment/quickPaymentPopupAccount.php'; quickPaymentPopupAccount::getInstance()->init(array('acc_sum' => $bill->getAccSum())); } //Пользователь юрик с заполненными реквизитами? $isAllowBillInvoice = $is_jury; if ($isAllowBillInvoice) { $isValidBillInvoice = sbr_meta::isValidUserReqvs($uid, $is_emp); if ($isValidBillInvoice) { //Попап пополнения счета по безналу путем генерации счета require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/quick_payment/quickPaymentPopupBillInvoice.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/bill/models/BillInvoicesModel.php'; quickPaymentPopupBillInvoice::getInstance()->init();