/** * Резервирование средств через яндекс кассу. * * @param type $type * @param type $data * * @return \xajaxResponse */ function quickPaymentReserveYandexKassa($type, $data) { $uid = get_uid(false); $objResponse =& new xajaxResponse(); $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; } $reserve_id = intval(@$data['quick_payment_reserve_form']); $reserveInstance = ReservesModelFactory::getInstanceById($reserve_id); if (!$reserveInstance) { return $objResponse; } $reserve_data = $reserveInstance->getReserveData(); if ($reserve_data['emp_id'] != $uid || !$reserveInstance->isEmpAllowFinance()) { return $objResponse; } //Если уже был платеж то обновляем страницу if (!$reserveInstance->isStatusNew()) { $objResponse->script('window.location.reload()'); return $objResponse; } //Формируем заказ $bill = new billing($uid); $billReserveId = $bill->addServiceAndCheckout(ReservesModel::OPCODE_RESERVE, array('acc_sum' => $reserve_data['reserve_price'], 'reserve_data' => $reserve_data)); $payment = $pay_methods[$type]; $yandex_kassa = new yandex_kassa(); $yandex_kassa->setShop(yandex_kassa::SHOPID_SBR); $html_form = $yandex_kassa->render($bill->getOrderPayedSum(), $bill->getAccId(), $payment, $billReserveId); $objResponse->script("\n var qp_form_wrapper = \$\$('#quick_payment_reserve .__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 "); $_SESSION[quickPaymentPopup::QPP_REDIRECT] = $reserveInstance->getTypeUrl(); return $objResponse; }
function quickPRJGetYandexKassaLink($payment) { $objResponse = new xajaxResponse(); $bill = new billing(get_uid(false)); $billReserveId = $bill->checkoutOrder(); $sum = $bill->getRealPayedSum(); $payed_sum = $bill->getOrderPayedSum(); if ($sum > 0) { $_SESSION['quickprj_is_begin'] = 1; $yandex_kassa = new yandex_kassa(); $html_form = $yandex_kassa->render($sum, $bill->account->id, $payment, $billReserveId); $objResponse->script('$("quick_pro_div_wait_txt").set("html", \'' . $html_form . '\');'); $objResponse->script("\$('quick_pro_div_wait_txt').getElements('form')[0].submit();"); } return $objResponse; }
/** * Пополнение счета через яндекс кассу. * * @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; }
/** * Оплата карусели через яндекс кассу * * @param type $type * @param type $data * @return \xajaxResponse */ function quickPaymentProYandexKassa($type, $data) { $uid = get_uid(false); $objResponse = new xajaxResponse(); $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]) || !($uid > 0)) { return $objResponse; } $is_emp = is_emp(); $form = new ProForm($is_emp); if (!$form->isValid($data)) { $objResponse->script("\n var qp = window.quick_ext_payment_factory.getQuickPayment('pro');\n if(qp) qp.show_error('К сожалению, в процессе оплаты произошла ошибка, и платеж не был завершен. Попробуйте провести оплату еще раз.');\n "); return $objResponse; } $data = $form->getValues(); $opcode = $data['type']; $promo_code = isset($data['promo']) ? $data['promo'] : ""; $bill = new billing($uid); //Допустимо использование промокодов $bill->setPromoCodes('SERVICE_PRO', $promo_code); //Формируем заказ $billReserveId = $bill->addServiceAndCheckout($opcode); $sum = $bill->getRealPayedSum(); if ($sum > 0) { $payment = $pay_methods[$type]; $yandex_kassa = new yandex_kassa(); $html_form = $yandex_kassa->render($sum, $bill->account->id, $payment, $billReserveId); $objResponse->script("\n var qp = window.quick_ext_payment_factory.getQuickPayment('pro');\n if (qp) qp.sendPaymentForm('{$html_form}');\n "); //сохранаем в сессию куда перейти при успешной покупке $_SESSION[quickPaymentPopup::QPP_REDIRECT] = urldecode($_SESSION['ref_uri']); $payed_sum = $bill->getOrderPayedSum(); //@todo: функционал из старого попапа оплаты нужен рефакторинг $_SESSION['quickbuypro_is_begin'] = 1; $_SESSION['quickbuypro_success_opcode'] = $payed_sum; $_SESSION['quickbuypro_success_opcode2'] = $opcode; //$_SESSION['quickbuypro_redirect'] = urldecode($_SESSION['ref_uri']); } return $objResponse; }
/** * Оплата карусели через яндекс кассу * * @param type $type * @param type $data * @return \xajaxResponse */ function quickPaymentCaruselYandexKassa($type, $data) { $uid = get_uid(false); $objResponse =& new xajaxResponse(); $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]) || !$uid || is_emp()) { return $objResponse; } $promo = isset($data['promo']) ? $data['promo'] : ""; $form = new CaruselForm(); if (!$form->isValid($data)) { $params = addslashes(urldecode(http_build_query($form->getAllMessages('<br/>')))); $objResponse->script("\n var qp = window.quick_ext_payment_factory.getQuickPayment('carusel');\n if(qp) qp.showElementsError('{$params}');\n "); return $objResponse; } $data = $form->getValues(); $bill = new billing($uid); $bill->setPromoCodes('SERVICE_CARUSEL', $promo); $options = array('ad_header' => $data['title'], 'ad_text' => $data['description'], 'num' => $data['num']); if ($data['num'] > 1) { $options['hours'] = $data['hours']; } //Каталог //@todo: неиспользуется разделение платный мест в картусели //$tarif = 73; //Главная //@todo: сейчас общий раздел для всех $tarif = 65; //Формируем заказ $billReserveId = $bill->addServiceAndCheckout($tarif, $options); $payed_sum = $bill->getRealPayedSum(); $payment = $pay_methods[$type]; $yandex_kassa = new yandex_kassa(); $html_form = $yandex_kassa->render($payed_sum, $bill->account->id, $payment, $billReserveId); $objResponse->script("\n var qp = window.quick_ext_payment_factory.getQuickPayment('carusel');\n if (qp) qp.sendPaymentForm('{$html_form}');\n "); //сохранаем в сессию куда перейти при успешной покупке $_SESSION[quickPaymentPopup::QPP_REDIRECT] = urldecode($_SESSION['ref_uri']); return $objResponse; }
/** * Покупка ПРО через ЯД Кассу * * @param type $opcode * @param type $payment * @param type $redirect * @return \xajaxResponse */ function quickPROGetYandexKassaLink($opcode, $payment, $redirect, $promo_code) { $objResponse = new xajaxResponse(); $pro = 0; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/payed.php"; $proList = payed::getAvailablePayedList(is_emp()); foreach ($proList as $proItem) { if ($proItem['opcode'] == $opcode) { $pro = $proItem; break; } } if ($pro) { $uid = get_uid(false); $bill = new billing($uid); //Допустимо использование промокодов $bill->setPromoCodes('SERVICE_PRO', $promo_code); //Формируем заказ $billReserveId = $bill->addServiceAndCheckout($opcode); $sum = $bill->getRealPayedSum(); $payed_sum = $bill->getOrderPayedSum(); if ($sum > 0) { $yandex_kassa = new yandex_kassa(); $html_form = $yandex_kassa->render($sum, $bill->account->id, $payment, $billReserveId); $html_form = preg_replace('/^[^\\/]+\\/\\*!?/', '', $html_form); $html_form = preg_replace('/\\*\\/[^\\/]+$/', '', $html_form); $_SESSION['quickbuypro_is_begin'] = 1; $_SESSION['quickbuypro_success_opcode'] = $payed_sum; $_SESSION['quickbuypro_success_opcode2'] = $opcode; $_SESSION['quickbuypro_redirect'] = $redirect; $_SESSION['referer'] = $_SERVER['HTTP_REFERER']; $objResponse->script('$("quick_pro_div_wait_txt").set("html", \'' . $html_form . '\');'); $objResponse->script("\$('quick_pro_div_wait_txt').getElements('form')[0].submit();"); } } return $objResponse; }
/** * Оплата через яндекс кассу. * * @param type $type - тип оплаты * @param type $data - данные по параметрам покупаемой услуги * * @return \xajaxResponse */ function quickPaymentMasssendingYandexKassa($type, $data) { $is_error = true; $uid = get_uid(false); $objResponse =& new xajaxResponse(); $send_id = (int) $data['send_id']; $promo_code = (string) @$data['promo']; $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; } $masssending = new masssending(); $params = $masssending->getAccepted($send_id, $uid); if ($params) { $is_error = false; $bill = new billing(get_uid(false)); //Допустимо использование промокодов $bill->setPromoCodes('SERVICE_MASSSENDING', $promo_code); $option = array('amount' => $params['pre_sum'], 'masssending_id' => $params['id']); //Формируем заказ $billReserveId = $bill->addServiceAndCheckout(masssending::OPER_CODE, $option); $payed_sum = $bill->getRealPayedSum(); $payment = $pay_methods[$type]; $yandex_kassa = new yandex_kassa(); $html_form = $yandex_kassa->render($payed_sum, $bill->account->id, $payment, $billReserveId); $objResponse->script("\n var qp_form_wrapper = \$\$('#quick_payment_masssending .__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 "); //сохранаем в сессию куда перейти при успешной покупке $_SESSION[quickPaymentPopup::QPP_REDIRECT] = '/bill/history/?period=3'; } // Показываем предупреждение в случае ошибки if ($is_error) { $objResponse->script("\n var qp = window.quick_payment_factory.getQuickPayment('masssending');\n if(qp) qp.show_error('Возникла ошибка при оплате рассылки!');\n "); } return $objResponse; }
function quickMASGetYandexKassaLink($frm, $payment, $promo_code) { $objResponse = new xajaxResponse(); if (is_emp()) { global $DB, $host; $masssending = new masssending(); //@todo: не используюутся? //$countries = country::GetCountries(TRUE); //$prof_groups = professions::GetAllGroupsLite(TRUE); //$professions = professions::GetProfList(); //$exrates = project_exrates::GetAll(); $uid = get_uid(false); //$params['msg'] = stripslashes($frm['msg']); $params['msg'] = "Здравствуйте!\n\nПриглашаю ознакомиться с проектом '" . change_q_x(stripslashes($frm['title']), false, false, 'b|i|p|ul|li|s|h[1-6]{1}', false, false) . "' " . str_replace('www.n.fl.ru', 'n.fl.ru', $host) . $frm['link'] . " \n\n\n" . LenghtFormatEx(change_q_x(stripslashes($frm['msg']), false, false, 'b|i|p|ul|li|s|h[1-6]{1}', false, false), 300); $params['max_users'] = intval($frm['max_users']); $params['max_cost'] = intval($frm['max_cost']); $params['is_pro'] = stripslashes($frm['pro']); $params['favorites'] = stripslashes($frm['favorites']); $params['free'] = stripslashes($frm['free']); $params['sbr'] = stripslashes($frm['bs']); $params['portfolio'] = stripslashes($frm['withworks']); $params['inoffice'] = stripslashes($frm['office']); $params['opi_is_verify'] = stripslashes($frm['ver']); $tmp = array(); if ($frm['mass_location_columns'][0] != '0' || $frm['mass_location_columns'][1] != '0') { $tmp[] = intval($frm['mass_location_columns'][0]) . ':' . intval($frm['mass_location_columns'][1]); $params['locations'] = $tmp; } if ($frm['f_cats']) { $frm['f_cats'] = preg_replace('/,$/', '', $frm['f_cats']); $acats = explode(',', $frm['f_cats']); $cats_data = array(); foreach ($acats as $v) { $v = preg_replace('/^mass_cat_span_/', '', $v); $c = explode('_', $v); if ($c[1] == 0) { $sql = 'SELECT prof_group FROM professions WHERE id=?i'; $p = $DB->val($sql, $c[0]); $cats_data[] = $p . ':' . $c[0]; } else { $cats_data[] = $c[0] . ':0'; } } } $params['professions'] = $cats_data; if ($calc = $masssending->Add($uid, $params)) { $masssending->ClearTempFiles(session_id()); //Допустимо использование промокодов $masssending->billing->setPromoCodes('SERVICE_MASSSENDING', $promo_code); $billReserveId = $masssending->Accept($calc['massid'], false); if ($billReserveId) { $_SESSION['quickmas_is_begin'] = 1; $_SESSION['quickmas_count_u'] = $calc['count']; $_SESSION['referer'] = $_SERVER['HTTP_REFERER']; $sum = $masssending->billing->getRealPayedSum(); $yandex_kassa = new yandex_kassa(); $html_form = $yandex_kassa->render($sum, $masssending->billing->account->id, $payment, $billReserveId); $html_form = preg_replace('/^[^\\/]+\\/\\*!?/', '', $html_form); $html_form = preg_replace('/\\*\\/[^\\/]+$/', '', $html_form); $objResponse->script('$("quick_mas_div_wait").set("html", \'' . $html_form . '\');'); $objResponse->script("\$('quick_mas_div_wait').getElements('form')[0].submit();"); } } } return $objResponse; }
/** * Покупка услуги верификации по банковской карте через ЯКассу * в случае успешной покупки делается запрос на возврат 10 рублей. * * @return \xajaxResponse */ function quickYandexKassaAC($fname, $lname) { $objResponse = new xajaxResponse(); require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/billing.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/yandex_kassa.php'; $uid = get_uid(false); $bill = new billing($uid); //@todo: нужна проверка текущей верификации $option = array('uname' => change_q(substr(trim($fname), 0, 21)), 'usurname' => change_q(substr(trim($lname), 0, 21))); $billReserveId = $bill->addServiceAndCheckout(Verification::YKASSA_AC_OP_CODE, $option); $sum = $bill->getOrderPayedSum(); $yandex_kassa = new yandex_kassa(); $html_form = $yandex_kassa->render($sum, $bill->account->id, yandex_kassa::PAYMENT_AC, $billReserveId); $objResponse->script("\n if (window.verification_popup) {\n window.verification_popup.openWindowYandexKassaAC('{$html_form}');\n }\n "); $_SESSION['quickver_is_begin'] = 1; return $objResponse; }
/** * Резервирование средств через яндекс кассу. * * @param type $type - тип оплаты * @param type $data - данные по параметрам покупаемой услуги * * @return \xajaxResponse */ function quickPaymentTservicebindYandexKassa($type, $data) { $is_error = true; $uid = get_uid(false); $objResponse =& new xajaxResponse(); $kind = (int) @$data['kind']; $tservice_id = (int) @$data['tservice_text_db_id']; $prof_id = (int) @$data['prof_id']; $is_prolong = (bool) @$data['is_prolong']; $promo_code = (string) @$data['promo']; $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; } $tservices_binds = new tservices_binds($kind); $tservices = new tservices($uid); $allow = $tservices_binds->isAllowBind($uid, $tservice_id, $kind, $prof_id); $valid = $tservices->isExists($tservice_id) && ($is_prolong ? !$allow : $allow); if ($valid) { $is_error = false; $bill = new billing($uid); //Допустимо использование промокодов $bill->setPromoCodes('SERVICE_TSERVICEBIND', $promo_code); $op_code = $tservices_binds->getOpCode(); $option = array('weeks' => (int) @$data['weeks'], 'prof_id' => $prof_id, 'tservice_id' => $tservice_id, 'is_prolong' => $is_prolong); //Формируем заказ $billReserveId = $bill->addServiceAndCheckout($op_code, $option); $payed_sum = $bill->getRealPayedSum(); $payment = $pay_methods[$type]; $yandex_kassa = new yandex_kassa(); $html_form = $yandex_kassa->render($payed_sum, $bill->account->id, $payment, $billReserveId); $idx = quickPaymentPopupTservicebind::getPopupId($is_prolong ? $tservice_id : 0); $objResponse->script("\n var qp_form_wrapper = \$\$('#" . $idx . " .__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 "); //сохранаем в сессию куда перейти при успешной покупке $redirect = (string) @$data['redirect']; $_SESSION[quickPaymentPopup::QPP_REDIRECT] = $redirect; } // Показываем предупреждение в случае ошибки if ($is_error) { $idx = quickPaymentPopupTservicebind::getPopupId($is_prolong ? $tservice_id : 0); $action = $is_prolong ? 'продлении закрепления' : 'закреплении'; $objResponse->script("\n var qp = window.quick_payment_factory.getQuickPaymentById('tservicebind', '" . $idx . "');\n if(qp) qp.show_error('Возникла ошибка при {$action} услуги!');\n "); } return $objResponse; }
<?php define('NO_CSRF', 1); require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/stdf.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/yandex_kassa.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/log.php"; $yandex_kassa = new yandex_kassa(); $log = new log('ykassa/%d%m%Y.log'); $log->writeln('----- ' . date('d.m.Y H:i:s')); $log->writevar($_POST); $action = __paramInit('string', null, 'action'); //@todo: выставляем тестовый режим для валидации по IP //после тестирования резерва БС убрать /* $scid = __paramInit('string', null, 'scid'); $is_test = $scid == yandex_kassa::SCID_SBR_TEST; if($is_test) $yandex_kassa->setTest($is_test); */ $result = array(); if ($action == 'checkOrder') { $result = $yandex_kassa->order(false); } if ($action == 'paymentAviso') { $result = $yandex_kassa->order(true); } $log->writeln('----- ' . (isset($result['message']) ? $result['message'] : 'YES')); $log->writeln(); echo "<?xml version=\"1.0\" encoding=\"windows-1251\"?>"; ?> <<?php
/** * Оплата через яндекс кассу * * @param type $type - тип оплаты * @param type $data - данные по параметрам покупаемой услуги * @return \xajaxResponse */ function quickPaymentFrlbindYandexKassa($type, $data) { $is_error = true; $uid = get_uid(false); $objResponse =& new xajaxResponse(); $prof_id = (int) @$data['prof_id']; $is_spec = (bool) @$data['is_spec']; $is_prolong = (bool) @$data['is_prolong']; $promo_code = (string) @$data['promo']; $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; } $freelancer_binds = new freelancer_binds(); $valid = $is_prolong ? $freelancer_binds->isUserBinded($uid, $prof_id, $is_spec) : $freelancer_binds->isAllowBind($uid, $prof_id, $is_spec); if ($valid) { $is_error = false; $bill = new billing($uid); //Допустимо использование промокодов $bill->setPromoCodes('SERVICE_FRLBIND', $promo_code); $op_code = $freelancer_binds->getOpCode($prof_id, $is_spec, $is_prolong); $option = array('weeks' => (int) @$data['weeks'], 'prof_id' => $prof_id); //Формируем заказ $billReserveId = $bill->addServiceAndCheckout($op_code, $option); $payed_sum = $bill->getRealPayedSum(); $payment = $pay_methods[$type]; $yandex_kassa = new yandex_kassa(); $html_form = $yandex_kassa->render($payed_sum, $bill->account->id, $payment, $billReserveId); $objResponse->script("\n var qp_form_wrapper = \$\$('#quick_payment_frlbind .__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 = '/freelancers/'; if ($prof_id) { if ($is_spec) { $link .= professions::GetProfLink($prof_id) . '/'; } else { $group = professions::GetGroup($prof_id, $error); $link .= $group['link'] . '/'; } } //сохранаем в сессию куда перейти при успешной покупке $_SESSION[quickPaymentPopup::QPP_REDIRECT] = $link; } // Показываем предупреждение в случае ошибки if ($is_error) { $action = $is_prolong ? 'продлении закрепления' : 'закреплении'; $objResponse->script("\n var qp = window.quick_payment_factory.getQuickPayment('frlbind');\n if(qp) qp.show_error('Возникла ошибка при {$action} в каталоге!');\n "); } return $objResponse; }