/**
 * Резервирование средств через яндекс кассу.
 * 
 * @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;
}
示例#2
0
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;
}
示例#3
0
/**
 * Покупка услуги верификации по банковской карте через ЯКассу
 * в случае успешной покупки делается запрос на возврат 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 array $data
 * @return type
 */
function quickPaymentProAccount($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);
    $complete = $bill->addServiceAndPayFromAccount($opcode);
    if ($complete) {
        $payed_sum = $bill->getOrderPayedSum();
        $_SESSION['quickbuypro_success_opcode'] = $payed_sum;
        $uri = isset($_SESSION['quickbuypro_redirect']) ? $_SESSION['quickbuypro_redirect'] : '';
        $uri .= '?quickpro_ok=1';
        //@todo: ПРОФИ пока игнорируем
        /*
        if ($opcode == 164) {
            $uri = '/profi/?quickprofi_ok=1';
        }
        */
        $objResponse->script("window.location = '{$uri}';");
    }
    return $objResponse;
}
示例#5
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;
}