/**
 * Оплата через Плати потом.
 * 
 * @param type $type - тип оплаты
 * @param type $data - данные по параметрам покупаемой услуги
 *
 * @return \xajaxResponse
 */
function quickPaymentTservicebindPlatipotom($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'];
    $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();
        $platipotom = new platipotom();
        $html_form = $platipotom->render($payed_sum, $bill->account->id, $billReserveId);
        if ($html_form) {
            $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;
}
/**
 * Оплата через яндекс кассу.
 * 
 * @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;
}
/**
 * Оплата карусели через Плати потом
 * 
 * @param type $type
 * @param type $data
 * @return \xajaxResponse
 */
function quickPaymentProPlatipotom($type, $data)
{
    $uid = get_uid(false);
    $objResponse = new xajaxResponse();
    if (!($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();
    $platipotom = new platipotom(true);
    if ($sum > 0 && $sum <= $platipotom->getMaxPrice($bill->account->id)) {
        $html_form = $platipotom->render($sum, $bill->account->id, $billReserveId);
        if ($html_form) {
            $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->getRealPayedSum();
            //@todo: функционал из старого попапа оплаты нужен рефакторинг
            $_SESSION['quickbuypro_is_begin'] = 1;
            $_SESSION['quickbuypro_success_opcode'] = $payed_sum;
            $_SESSION['quickbuypro_success_opcode2'] = $opcode;
            //$_SESSION['quickbuypro_redirect'] = $redirect;
        }
    }
    return $objResponse;
}
예제 #4
0
         if (!$tmpPrj->isEdit()) {
             $items['contest']["no_pro"] = 3300;
             $items['contest']["pro"] = 3000;
         }
         $op_code = is_pro() ? new_projects::OPCODE_KON : new_projects::OPCODE_KON_NOPRO;
     }
     $op_code_pay = new_projects::OPCODE_PAYED_KON;
 } else {
     $op_code = new_projects::OPCODE_PAYED;
     $op_code_pay = new_projects::OPCODE_PAYED;
 }
 if ($items) {
     $bill->start();
     // Офис первым делом создаем
     if ($items['office'] > 0) {
         $bill->setPromoCodes('SERVICE_VACANCY', $promo);
         $option['items'] = array('office' => $items['office']);
         $bill->setOptions($option);
         $op_code_vacancy = $tmpPrj->getVacancyOpCode();
         $success = $bill->addServiceToCart($op_code_vacancy);
         $items['office'] = 0;
         $bill->unsetPromoCodes();
     }
     // Конкурс
     if ($items['contest'] > 0) {
         $bill->setPromoCodes('SERVICE_CONTEST', $promo);
         $option['items'] = array('contest' => $items['contest']);
         $bill->setOptions($option);
         $success = $bill->addServiceToCart($op_code);
         $items['contest'] = 0;
         $bill->unsetPromoCodes();
/**
 * Оплата через Плати потом
 * 
 * @param type $type - тип оплаты
 * @param type $data - данные по параметрам покупаемой услуги
 * @return \xajaxResponse
 */
function quickPaymentFrlbindPlatipotom($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'];
    $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();
        $platipotom = new platipotom();
        $html_form = $platipotom->render($payed_sum, $bill->account->id, $billReserveId);
        if ($html_form) {
            $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;
}
/**
 * Оплата карусели через Плати потом
 * 
 * @param type $type
 * @param type $data
 * @return \xajaxResponse
 */
function quickPaymentCaruselPlatipotom($type, $data)
{
    $uid = get_uid(false);
    $objResponse =& new xajaxResponse();
    $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();
    $platipotom = new platipotom();
    $html_form = $platipotom->render($payed_sum, $bill->account->id, $billReserveId);
    if ($html_form) {
        $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;
}
예제 #7
0
/**
 * Оплата через ПлатиПотом сервис
 * 
 * @param type $opcode
 * @param type $redirect
 * @param type $promo_code
 * @return \xajaxResponse
 */
function quickPROGetPlatipotomLink($opcode, $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();
        $platipotom = new platipotom(true);
        if ($sum > 0 && $sum <= $platipotom->getMaxPrice($bill->account->id)) {
            $html_form = $platipotom->render($sum, $bill->account->id, $billReserveId);
            if ($html_form) {
                $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;
}