public function pay() { //инициализируем URL для HG (тестовы/рабочий) $this->language->load('payment/hutkigrosh'); if (!isset($this->session->data['order_id'])) { $this->redirect($this->url->link('checkout/checkout')); return false; } $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); $this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('pending_status_id')); //----------------------------------------------------------------------------------------------------------------------------------------------- $order_id = $order_info["order_id"]; $this->_login = $this->config->get('hutkigrosh_login'); // имя пользователя $this->_pwd = $this->config->get('hutkigrosh_pswd'); // пароль $name = $this->_login; $pwd = $this->_pwd; $this->test = $this->config->get('hutkigrosh_test'); $hg = new \Alexantr\HootkiGrosh\HootkiGrosh($this->config->get('hutkigrosh_test')); $res = $hg->apiLogIn($name, $pwd); // Ошибка авторизации if (!$res) { echo $hg->getError(); $hg->apiLogOut(); // Завершаем сеанс exit; } /// создаем заказ $line_items = $this->cart->getProducts(); if (is_array($line_items)) { foreach ($line_items as $line_item) { $arItem['invItemId'] = $line_item['key']; $arItem['desc'] = $line_item['name'] . ' ' . $line_item['model']; $arItem['count'] = round($line_item['quantity']); $arItem['amt'] = $line_item['total']; $arItems[] = $arItem; unset($arItem); } } // $total = $order_info['total']; $data = array('eripId' => $this->config->get('hutkigrosh_storeid'), 'invId' => $order_id, 'fullName' => $order_info['firstname'] . ' ' . $order_info['lastname'], 'mobilePhone' => $order_info['telephone'], 'email' => $order_info['email'], 'fullAddress' => $order_info['payment_address_1'] . ' ' . $order_info['payment_address_2'] . ' ' . $order_info['payment_zone'], 'amt' => $total, 'curr' => $order_info['currency_code'], 'products' => $arItems); $this->_billID = $hg->apiBillNew($data); if (!$this->_billID) { echo $hg->getError(); $hg->apiLogOut(); // Завершаем сеанс exit; } // выставляем счет в другие системы ------------------------------------------------------------------------------------------ $dataBgpb = array('billId' => $this->_billID, 'eripId' => $this->config->get('hutkigrosh_storeid'), 'spClaimId' => $order_id, 'amount' => $total, 'currency' => 933, 'clientFio' => $order_info['firstname'] . ' ' . $order_info['lastname'], 'clientAddress' => $order_info['payment_address_1'] . ' ' . $order_info['payment_address_2'] . ' ' . $order_info['payment_zone'], 'returnUrl' => $this->url->link('payment/hutkigrosh/notify'), 'cancelReturnUrl' => $this->url->link('payment/hutkigrosh/fail')); $this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('cod_order_status_id')); echo '<h1>Спасибо за заказ!</h2>'; echo '<h1>Счет для оплаты в системе ЕРИП: ' . $order_id . '</h2>'; echo '<hr>'; echo $hg->apiBgpbPay($dataBgpb); ?> <br> <hr> <div class="alfaclick"> <input type="hidden" value="<?php echo $this->_billID; ?> " id="billID"> <input type="hidden" value="<?php echo $this->base_url; ?> " id="cookie"> <input type="text" maxlength="20" value="<?php echo $order_info['telephone']; ?> " id="phone"> <button>Выставить счет в AlfaClick</button> </div> <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.11.0.min.js"></script> <script> $(document).ready(function(){ $(document).on('click','button',function(){ console.log('click'); var phone = $('#phone').val(); var billid = $('#billID').val(); var coockie = $('#cookie').val(); var is_test = <?php echo $this->test; ?> ; var login = "******"; var pwd = "<?php echo $pwd; ?> "; $.post('/hgrosh/alfaclick.php', { phone : phone, billid : billid, coockie : coockie, is_test : is_test, login : login, pwd : pwd } ).done(function(data){ console.log(data); if(data == '0'){ alert('Не удалось выставить счет в системе AlfaClick'); }else{ alert('Выставлен счет в системе AlfaClick'); } }); }); }); </script> <?php $hg->apiLogOut(); //------------------------------------------------------------------------------------------------------------------------------------------------------------------ }
function showEndForm($pmconfigs, $order) { require 'HootkiGrosh.php'; $is_test = $pmconfigs['hgrosh_test'] == 1 ? true : false; // тестовый api $hg = new \Alexantr\HootkiGrosh\HootkiGrosh($is_test); // ?> <!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>--> <!-- --><?php // $order_id = $order->order_id; $this->_login = $pmconfigs['hgrosh_login']; // имя пользователя $this->_pwd = $pmconfigs['hgrosh_pswd']; // пароль $name = $this->_login; $pwd = $this->_pwd; $res = $hg->apiLogIn($name, $pwd); $_SESSION['hg_login'] = $this->_login; $_SESSION['hg_pwd'] = $this->_pwd; $_SESSION['hg_test'] = $is_test; // Ошибка авторизации if (!$res) { echo $hg->getError(); $hg->apiLogOut(); // Завершаем сеанс exit; } /// создаем заказ $line_items = $order->getAllItems(); if (is_array($line_items)) { foreach ($line_items as $line_item) { $arItem['invItemId'] = $line_item->product_name; $arItem['desc'] = $line_item->product_name; $arItem['count'] = round($line_item->product_quantity); $arItem['amt'] = $line_item->product_item_price; $arItems[] = $arItem; unset($arItem); } } $data = array('eripId' => $pmconfigs['hgrosh_store_id'], 'invId' => $order_id, 'fullName' => $order->f_name . ' ' . $order->l_name, 'mobilePhone' => $order->phone, 'email' => $order->email, 'fullAddress' => $order->city . ' ' . $order->state . ' ' . $order->street, 'amt' => $order->order_total, 'curr' => $order->currency_code, 'products' => $arItems); $this->_billID = $hg->apiBillNew($data); if (!$this->_billID) { echo $hg->getError(); $hg->apiLogOut(); // Завершаем сеанс exit; } $dataBgpb = array('billId' => $this->_billID, 'eripId' => $pmconfigs['hgrosh_store_id'], 'spClaimId' => $order_id, 'amount' => $order->order_total, 'currency' => 933, 'clientFio' => $order->f_name . ' ' . $order->l_name, 'clientAddress' => $order->city . ' ' . $order->state . ' ' . $order->street, 'returnUrl' => $pmconfigs['hgrosh_return_url'], 'cancelReturnUrl' => $pmconfigs['hgrosh_cancel_return_url']); echo '<h1>Спасибо за заказ!</h2>'; echo '<h1>Счет для оплаты в системе ЕРИП: ' . $order_id . '</h2>'; echo $hg->apiBgpbPay($dataBgpb); ?> <br> <hr> <div class="alfaclick"> <input type="hidden" value="<?php echo $this->_billID; ?> " id="billID"> <input type="hidden" value="<?php echo $this->base_url; ?> " id="cookie"> <input type="text" maxlength="20" value="<?php echo $order->phone; ?> " id="phone"> <button>Выставить счет в AlfaClick</button> </div> <script> jQuery(document).on('click','button',function(){ jQuery.post('/hgrosh/alfaclick.php', { phone : jQuery('#phone').val(), billid : jQuery('#billID').val() } ).done(function(data){ if(data == '0') alert('Не удалось выставить счет в системе AlfaClick'); else alert('Выставлен счет в системе AlfaClick'); }); }); </script><?php $hg->apiLogOut(); }
} /// создаем заказ if (is_array($arBasketItems)) { $totalSummOrder = 0; foreach ($arBasketItems as $line_item) { $arItem['invItemId'] = $line_item['ID']; $arItem['desc'] = $line_item['NAME']; $arItem['count'] = round($line_item['QUANTITY']); $arItem['amt'] = $line_item['QUANTITY'] * $line_item['PRICE']; $totalSummOrder += $arItem['amt']; $arItems[] = $arItem; unset($arItem); } } $data = array('eripId' => $arPropPS['ERIP'], 'invId' => $ORDER_ID, 'fullName' => $GLOBALS["SALE_INPUT_PARAMS"]['USER']['NAME'] . ' ' . $GLOBALS["SALE_INPUT_PARAMS"]['USER']['LAST_NAME'], 'mobilePhone' => $GLOBALS["SALE_INPUT_PARAMS"]['PROPERTY']['PHONE'], 'email' => $GLOBALS["SALE_INPUT_PARAMS"]['PROPERTY']['EMAIL'], 'fullAddress' => $GLOBALS["SALE_INPUT_PARAMS"]['PROPERTY']['CITY'] . ' ' . $GLOBALS["SALE_INPUT_PARAMS"]['PROPERTY']['ADDRESS'], 'amt' => $totalSummOrder, 'curr' => 'BYN', 'products' => $arItems); $billID = $hg->apiBillNew($data); if (!$billID) { echo $hg->getError(); $hg->apiLogOut(); // Завершаем сеанс exit; } else { $_SESSION['HG_LOGIN'] = $arPropPS['LOGIN']; $_SESSION['HG_PWD'] = $arPropPS['PWD']; $_SESSION['BILL_ID'] = $billID; } //// выставляем счет в другие системы ------------------------------------------------------------------------------------------ $dataBgpb = array('billId' => $billID, 'eripId' => $arPropPS['ERIP'], 'spClaimId' => $ORDER_ID, 'amount' => $totalSummOrder, 'currency' => 933, 'clientFio' => $GLOBALS["SALE_INPUT_PARAMS"]['USER']['NAME'] . ' ' . $GLOBALS["SALE_INPUT_PARAMS"]['USER']['LAST_NAME'], 'clientAddress' => $GLOBALS["SALE_INPUT_PARAMS"]['PROPERTY']['CITY'] . ' ' . $GLOBALS["SALE_INPUT_PARAMS"]['PROPERTY']['ADDRESS'], 'returnUrl' => $arPropPS['HG_RETURN_URL'], 'cancelReturnUrl' => $arPropPS['HG_CANCEL_RETURN_URL']); // echo '<h2>Спасибо за заказ!</h2>'; echo '<h2>Счет для оплаты в системе ЕРИП: ' . $ORDER_ID . '</h2>';
function gateway_hutkigrosh($separator, $sessionid) { global $wpdb, $wpsc_cart, $wpsc_gateways; $purchase_log_sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $sessionid . " LIMIT 1"; $purchase_log = $wpdb->get_results($purchase_log_sql, ARRAY_A); $order_id = $purchase_log[0]["id"]; $amount_ceil = $purchase_log[0]["totalprice"]; $cart_sql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`='" . $order_id . "'"; $cart = $wpdb->get_results($cart_sql, ARRAY_A); $submited_form_data = "SELECT * FROM `wp_wpsc_submited_form_data` WHERE `log_id`=" . $order_id; $submited_form_data_value = $wpdb->get_results($submited_form_data, ARRAY_A); $checkout_forms = "SELECT * FROM `wp_wpsc_checkout_forms`"; $checkout_forms_value = $wpdb->get_results($checkout_forms, ARRAY_A); foreach ($submited_form_data_value as $check_form) { $submit_form[$check_form['form_id']] = $check_form; } foreach ($checkout_forms_value as $form_val) { $arForm[$form_val['unique_name']] = $submit_form[$form_val['id']]['value']; } $pathSSL = strlen(get_option("uc_hutkigrosh_ssl")) > 0 ? get_option("uc_hutkigrosh_ssl") : 'http://' . $_SERVER['SERVER_NAME'] . '/hutkigrosh/ssl/cacert.pem'; //инициализация класса $test_mode = get_option('hutkigrosh_debug'); $hg = new \Alexantr\HootkiGrosh\HootkiGrosh($test_mode); $arParams['ap_storeid'] = get_option('hutkigrosh_storeid'); $arParams['ap_order_num'] = $order_id; $arParams['ap_currency_id'] = "974"; $arParams['ap_return_url'] = htmlspecialchars(get_option('hutkigrosh_return_url')); $arParams['ap_cancel_return_url'] = htmlspecialchars(get_option('hutkigrosh_cancel_return_url') . "&hutkigrosh_session=" . $sessionid); $arParams['ap_system_url'] = htmlspecialchars(get_option('hutkigrosh_system_url')); $arParams['ap_test'] = get_option('hutkigrosh_debug'); $arParams['ap_total'] = $amount_ceil; $arParams['login'] = get_option('hutkigrosh_login'); $arParams['pswd'] = get_option('hutkigrosh_pswd'); //логинимся //------------------------------------------------------------------------------------------------------------------ // $checkout_forms2 = "show tables"; // $checkout_forms_value2 = $wpdb->get_results($checkout_forms2,ARRAY_A); // $checkout_forms23 = "SELECT * FROM `ga1f6_jshopping_payment_method`"; // $checkout_forms_value23 = $wpdb->get_results($checkout_forms23,ARRAY_A); // echo '<pre>'; // print_r(get_option('hutkigrosh_login')); // echo '<pre>'; // print_r($checkout_forms_value2); // exit(); //------------------------------------------------------------------------------------------------------------------ $res = $hg->apiLogIn($arParams['login'], $arParams['pswd']); // Ошибка авторизации if (!$res) { echo $hg->getError(); $hg->apiLogOut(); // Завершаем сеанс exit; } $arItems = array(); /// создаем заказ if (is_array($cart)) { foreach ($cart as $line_item) { $arItem['invItemId'] = $line_item['prodid']; $arItem['desc'] = $line_item['name']; $arItem['count'] = round($line_item['quantity']); $arItem['amt'] = $line_item['price']; $arItems[] = $arItem; unset($arItem); } } // $total = $purchase_log[0]["totalprice"]; $data = array('eripId' => $arParams['ap_storeid'], 'invId' => $order_id, 'fullName' => $arForm['billingfirstname'] . ' ' . $arForm['billinglastname'], 'mobilePhone' => $arForm['billingphone'], 'email' => $arForm['billingemail'], 'fullAddress' => $arForm['billingstate'] . ' ' . $arForm['billingcity'] . ' ' . $arForm['billingaddress'], 'amt' => $total, 'curr' => 'BYN', 'products' => $arItems); $billID = $hg->apiBillNew($data); if (!$billID) { echo $hg->getError(); $hg->apiLogOut(); // Завершаем сеанс exit; } // выставляем счет в другие системы ------------------------------------------------------------------------------------------ $dataBgpb = array('billId' => $billID, 'eripId' => $arParams['ap_storeid'], 'spClaimId' => $order_id, 'amount' => $total, 'currency' => 933, 'clientFio' => $arForm['billingfirstname'] . ' ' . $arForm['billinglastname'], 'clientAddress' => $arForm['billingstate'] . ' ' . $arForm['billingcity'] . ' ' . $arForm['billingaddress'], 'returnUrl' => $arParams['ap_return_url'], 'cancelReturnUrl' => $arParams['ap_cancel_return_url']); echo '<h1>Спасибо за заказ!</h2>'; echo '<h1>Счет для оплаты в системе ЕРИП: ' . $order_id . '</h2>'; echo '<hr>'; echo '<h2>Для оплаты через карту, в системе БелГазПромБанка</h2>'; print_r($hg->apiBgpbPay($dataBgpb)); ?> <hr> <a href="/">Вернуться на сайт.</a> <hr> <?php $hg->apiLogOut(); exit; }