Exemplo n.º 1
0
 function process_payment()
 {
     $order = $this->Order->read(null, $_SESSION['Customer']['order_id']);
     $qiwi_id_data = $this->PaymentMethod->PaymentMethodValue->find(array('key' => 'qiwi_id'));
     $qiwi_id = $qiwi_id_data['PaymentMethodValue']['value'];
     $qiwi_secret_key_data = $this->PaymentMethod->PaymentMethodValue->find(array('key' => 'qiwi_secret_key'));
     $qiwi_secret_key = $qiwi_secret_key_data['PaymentMethodValue']['value'];
     // Выписываем qiwi счёт для покупателя
     //if ($insert_order == true) {
     App::import('Vendor', 'Nusoap', array('file' => 'nusoap' . DS . 'nusoap.php'));
     $client = new nusoap_client("https://mobw.ru/services/ishop", false);
     // создаем клиента для отправки запроса на QIWI
     $error = $client->getError();
     //if ( !empty($error) ) {
     // обрабатываем возможные ошибки и в случае их возникновения откатываем транзакцию в своей системе
     //echo -1;
     //exit();
     //}
     $client->useHTTPPersistentConnection();
     // Параметры для передачи данных о платеже:
     // login - Ваш ID в системе QIWI
     // password - Ваш пароль
     // user - Телефон покупателя (10 символов, например 916820XXXX)
     // amount - Сумма платежа в рублях
     // comment - Комментарий, который пользователь увидит в своем личном кабинете или платежном автомате
     // txn - Наш внутренний уникальный номер транзакции
     // lifetime - Время жизни платежа до его автоматической отмены
     // alarm - Оповещать ли клиента через СМС или звонком о выписанном счете
     // create - 0 - только для зарегистрированных пользователей QIWI, 1 - для всех
     $params = array('login' => $qiwi_id, 'password' => $qiwi_secret_key, 'user' => $_POST['qiwi_telephone'], 'amount' => number_format($order['Order']['total'], 0, '', ''), 'comment' => $_SESSION['Customer']['order_id'], 'txn' => $_SESSION['Customer']['order_id'], 'lifetime' => date("d.m.Y H:i:s", strtotime("+2 weeks")), 'alarm' => 1, 'create' => 1);
     // собственно запрос:
     $result = $client->call('createBill', $params, "http://server.ishop.mw.ru/");
     //if ($client->fault) {
     //echo -1;
     //exit();
     //} else {
     //$err = $client->getError();
     //if ($err) {
     //echo -1;
     //exit();
     //} else {
     //echo $result;
     //exit();
     //}
     //}
     //}
     $this->redirect('/orders/place_order/');
 }
Exemplo n.º 2
0
 */
require_once '../lib/nusoap.php';
$proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
$proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
$proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
$proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
$useCURL = isset($_POST['usecurl']) ? $_POST['usecurl'] : '0';
$client = new nusoap_client("http://soap.amazon.com/onca/soap2", false, $proxyhost, $proxyport, $proxyusername, $proxypassword);
$err = $client->getError();
if ($err) {
    echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
    echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
    exit;
}
$client->setUseCurl($useCURL);
$client->useHTTPPersistentConnection();
$param = array('manufacturer' => "O'Reilly", 'page' => '1', 'mode' => 'books', 'tag' => 'trachtenberg-20', 'type' => 'lite', 'devtag' => 'Your tag here');
$params = array('ManufacturerSearchRequest' => new soapval('ManufacturerSearchRequest', 'ManufacturerRequest', $param, false, 'http://soap.amazon.com'));
$result = $client->call('ManufacturerSearchRequest', $params, 'http://soap.amazon.com', 'http://soap.amazon.com');
if ($client->fault) {
    echo '<h2>Fault</h2><pre>';
    print_r($result);
    echo '</pre>';
} else {
    $err = $client->getError();
    if ($err) {
        echo '<h2>Error</h2><pre>' . $err . '</pre>';
    } else {
        echo '<h2>Result</h2><pre>';
        print_r($result);
        echo '</pre>';
 /**
  * 
  * __run
  *
  * @access protected	
  * @param
  * @return	
  */
 protected function __run($xml_request, $soap_action, $GSD_err = FALSE)
 {
     //get service status
     $status_service = $this->CI->model_admin_system->check_service("OWS");
     $this->response_success = FALSE;
     $client = new nusoap_client($this->endpoint_url, true);
     $client->soap_defencoding = 'utf-8';
     $client->useHTTPPersistentConnection();
     //$proxy = $client->getProxy();
     $this->response = $client->send($xml_request, $this->base_request_file . $soap_action);
     if ($client->fault) {
         $this->response_success = FALSE;
     } else {
         // Check for errors
         $err = $client->getError();
         if ($err) {
             $this->response_error = $err;
             $this->response_success = FALSE;
             error_log("server encounter a problem while sending a request to " . $this->endpoint_url, 0);
             //if notification has not been sent
             if ($status_service->status == "active") {
                 $data["service"] = "OWS";
                 $data["status"] = "down";
                 $data["message"] = "server encounter a problem while sending a request";
                 $data["err"] = $err;
                 $email_cotent = $this->CI->load->view("email/OWS/server_system_health_error", $data, TRUE);
                 $this->CI->load->library('NY_emailer');
                 $this->CI->ny_emailer->set_message($email_cotent);
                 //notify administrators
                 $this->CI->ny_emailer->send("*****@*****.**", "SYSTEM NOTIFICATION - SERVICE OWS DOWN");
                 $this->CI->ny_emailer->send("*****@*****.**", "SYSTEM NOTIFICATION - SERVICE OWS DOWN");
                 $this->CI->model_admin_system->Update("OWS", "down");
             }
         } else {
             //if service is restore
             if ($status_service->status == "down") {
                 $data["service"] = "OWS";
                 $data["status"] = "active";
                 $data["message"] = "service OWS restored";
                 $email_cotent = $this->CI->load->view("email/OWS/server_system_health_error", $data, TRUE);
                 $this->CI->load->library('NY_emailer');
                 $this->CI->ny_emailer->set_message($email_cotent);
                 //notify administrators
                 $this->CI->ny_emailer->send("*****@*****.**", "SYSTEM NOTIFICATION - SERVICE OWS RESTORED");
                 $this->CI->ny_emailer->send("*****@*****.**", "SYSTEM NOTIFICATION - SERVICE OWS DOWN");
                 $this->CI->model_admin_system->Update("OWS", "active");
             }
             if (key_exists("!resultStatusFlag", $this->response["Result"])) {
                 if ($this->response["Result"]["!resultStatusFlag"] == "SUCCESS") {
                     $this->response_success = TRUE;
                 }
             }
             if (!$this->response_success) {
                 if (!key_exists("Text", $this->response["Result"])) {
                     $GSD_err = TRUE;
                 }
                 if ($GSD_err) {
                     if (key_exists("GDSError", $this->response["Result"])) {
                         $this->response_error = "<b>Error (code " . $this->response["Result"]["GDSError"]["!errorCode"] . ") </b><br />" . $this->response["Result"]["GDSError"]["!"];
                     } else {
                         $this->response_error = $this->response["Result"]["Text"]["TextElement"];
                     }
                 } else {
                     $this->response_error = $this->response["Result"]["Text"]["TextElement"];
                 }
             }
         }
     }
 }
 /**
  * 
  * __run
  *
  * @access protected	
  * @param
  * @return	
  */
 protected function __run($xml_request, $soap_action)
 {
     $client = new nusoap_client($this->endpoint_url, true);
     $client->soap_defencoding = 'utf-8';
     $client->useHTTPPersistentConnection();
     $proxy = $client->getProxy();
     $this->response = $proxy->send($xml_request, $soap_action);
     if ($client->fault) {
         $this->response_success = FALSE;
     } else {
         // Check for errors
         $err = $client->getError();
         if ($err) {
             $this->response_error = $err;
             $this->response_success = FALSE;
         } else {
             $this->response_success = TRUE;
         }
     }
 }
Exemplo n.º 5
0
 function order_registerdomain($DomainName, $ServiceDetails, $ContactDetails)
 {
     //parametri dell'ordine
     $params = array('LoginEmail' => $this->LoginEmail, 'LoginPassword' => $this->LoginPassword, 'DomainName' => $DomainName, 'ServiceDetails' => $ServiceDetails, 'ContactDetails' => $ContactDetails);
     //Connection parameters
     //do not modify  -   non modificare
     $proxyhost = '';
     $proxyport = '';
     $proxyusername = '';
     $proxypassword = '';
     $useCURL = '0';
     $client = new nusoap_client("http://api.dominiofaidate.com/xml/Order.asmx?WSDL", true);
     $client->soap_defencoding = 'UTF-8';
     $err = $client->getError();
     if ($err) {
         echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
         echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
         exit;
     }
     $client->setUseCurl($useCURL);
     $client->useHTTPPersistentConnection();
     $result = $client->call('RegisterDomain', $params);
     if ($client->fault) {
         echo '<h2>Fault</h2><pre>';
         print_r($result);
         echo '</pre>';
     } else {
         $err = $client->getError();
         if ($err) {
             echo '<h2>Error</h2><pre>' . $err . '</pre>';
         }
     }
     return $result;
 }
Exemplo n.º 6
0
function set_soap_clent($ws_remote_url, $ws_wsdl_file, $user, $password)
{
    $remote_url = parse_url($ws_remote_url);
    $soapclient = new nusoap_client($remote_url['scheme'] . '://' . ($user && $password ? $user . ":" . $password . "@" : '') . $remote_url['host'] . ':' . $remote_url['port'] . "/" . $remote_url['path'] . '/' . $ws_wsdl_file, true);
    $soapclient->setCredentials($user, $password, 'basic');
    $soapclient->useHTTPPersistentConnection();
    return $soapclient;
}
Exemplo n.º 7
0
 /**
  * Internal utility methods
  */
 private function call($service, $method, $params)
 {
     ini_set('memory_limit', '1024M');
     ini_set('max_execution_time', 1800);
     set_time_limit(0);
     $url = $this->wsdl_root . $service . '.asmx?wsdl';
     $timeout = 3000;
     $cache = new nusoap_wsdlcache($this->cache_dir, $timeout);
     $wsdl = $cache->get($url);
     // Set the WSDL
     if (is_null($wsdl)) {
         $wsdl = new wsdl($url, NULL, NULL, NULL, NULL, 0, $timeout, NULL, TRUE);
         $error = $wsdl->getError();
         $debug = $wsdl->getDebug();
         $wsdl->clearDebug();
         // Check for SOAP errors
         if (!empty($error)) {
             $this->errors[] = $error;
             if ($debug) {
                 $this->errors[] = '<pre>' . print_r($debug, TRUE) . '</pre>';
             }
             return FALSE;
         }
         $cache->put($wsdl);
     }
     // Send the SOAP request
     $params['securityPassword'] = $this->wsdl_keys[$service];
     $client = new nusoap_client($wsdl, 'wsdl', FALSE, FALSE, FALSE, FALSE, 0, $timeout);
     $client->setDebugLevel(0);
     // 0 - 9, where 0 is off
     $client->useHTTPPersistentConnection();
     if ($service == 'DataAccess' && $method == 'ExecuteStoredProcedure') {
         /*
          * See http://www.codingforums.com/archive/index.php/t-85260.html
          * and http://users.skynet.be/pascalbotte/rcx-ws-doc/nusoapadvanced.htm
          * for how to thwart the "got wsdl error: phpType is struct, but value is not an array"
          * error returned by nusoap when processing the response from $client->call()
          *
          * */
         $request = $client->serializeEnvelope(vsprintf('<ExecuteStoredProcedure xmlns="http://ibridge.isgsolutions.com/%s/">
                   <securityPassword>%s</securityPassword>
                   <name>%s</name>
                   <parameters>%s</parameters>
                   </ExecuteStoredProcedure>', array($service, $params['securityPassword'], $params['name'], $params['parameters'])));
         $response = $client->send($request, 'http://ibridge.isgsolutions.com/' . $service . '/' . $method, 0, $timeout);
     } else {
         $response = $client->call($method, $params);
     }
     $error = $client->getError();
     $debug = $client->getDebug();
     $client->clearDebug();
     // Check for SOAP errors
     if (!empty($error)) {
         $this->errors[] = $error;
         if ($debug) {
             $this->errors[] = '<pre>' . print_r($debug, TRUE) . '</pre>';
         }
         return FALSE;
     }
     // Process response
     $response = $response[$method . 'Result'];
     $data = NULL;
     if (strpos($response, '<') == 0) {
         // Some ISGweb methods return strings instead of XML
         libxml_use_internal_errors(TRUE);
         $response = preg_replace('/(<\\?xml[^?]+?)utf-16/i', '$1utf-8', $response);
         // Change encoding string to UTF8
         $response = utf8_encode($response);
         $response = $this->strip_invalid_xml($response);
         $obj = simplexml_load_string($response);
         $data = $response;
         $error = libxml_get_errors();
         // Check for XML parsing errors
         if (!empty($error)) {
             foreach ($error as $e) {
                 $this->errors[] = $e;
             }
             libxml_clear_errors();
             return FALSE;
         }
         $data = $this->object_to_array($obj);
         // Check for ISGweb errors (e.g. invalid data input, failure of service, etc.)
         if (array_key_exists('Errors', $data)) {
             $error = $data['Errors'];
             foreach ($error as $e) {
                 $this->errors[] = $e['@attributes']['Description'];
             }
             return FALSE;
         }
     } else {
         $data = $response;
     }
     return $data;
 }
Exemplo n.º 8
0
 function confirmation()
 {
     global $cartID, $customer_id, $languages_id, $order, $order_total_modules;
     if (isset($_SESSION['cartID'])) {
         $insert_order = false;
         if (isset($_SESSION['cart_qiwi_id'])) {
             $order_id = substr($_SESSION['cart_qiwi_id'], strpos($_SESSION['cart_qiwi_id'], '-') + 1);
             $curr_check = vam_db_query("select currency from " . TABLE_ORDERS . " where orders_id = '" . (int) $order_id . "'");
             $curr = vam_db_fetch_array($curr_check);
             if ($curr['currency'] != $order->info['currency'] || $cartID != substr($_SESSION['cart_qiwi_id'], 0, strlen($cartID))) {
                 $check_query = vam_db_query('select orders_id from ' . TABLE_ORDERS_STATUS_HISTORY . ' where orders_id = "' . (int) $order_id . '" limit 1');
                 if (vam_db_num_rows($check_query) < 1) {
                     vam_db_query('delete from ' . TABLE_ORDERS . ' where orders_id = "' . (int) $order_id . '"');
                     vam_db_query('delete from ' . TABLE_ORDERS_TOTAL . ' where orders_id = "' . (int) $order_id . '"');
                     vam_db_query('delete from ' . TABLE_ORDERS_STATUS_HISTORY . ' where orders_id = "' . (int) $order_id . '"');
                     vam_db_query('delete from ' . TABLE_ORDERS_PRODUCTS . ' where orders_id = "' . (int) $order_id . '"');
                     vam_db_query('delete from ' . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . ' where orders_id = "' . (int) $order_id . '"');
                     vam_db_query('delete from ' . TABLE_ORDERS_PRODUCTS_DOWNLOAD . ' where orders_id = "' . (int) $order_id . '"');
                 }
                 $insert_order = true;
             }
         } else {
             $insert_order = true;
         }
         if ($insert_order == true) {
             $order_totals = array();
             if (is_array($order_total_modules->modules)) {
                 reset($order_total_modules->modules);
                 while (list(, $value) = each($order_total_modules->modules)) {
                     $class = substr($value, 0, strrpos($value, '.'));
                     if ($GLOBALS[$class]->enabled) {
                         for ($i = 0, $n = sizeof($GLOBALS[$class]->output); $i < $n; $i++) {
                             if (vam_not_null($GLOBALS[$class]->output[$i]['title']) && vam_not_null($GLOBALS[$class]->output[$i]['text'])) {
                                 $order_totals[] = array('code' => $GLOBALS[$class]->code, 'title' => $GLOBALS[$class]->output[$i]['title'], 'text' => $GLOBALS[$class]->output[$i]['text'], 'value' => $GLOBALS[$class]->output[$i]['value'], 'sort_order' => $GLOBALS[$class]->sort_order);
                             }
                         }
                     }
                 }
             }
             if ($_SESSION['customers_status']['customers_status_ot_discount_flag'] == 1) {
                 $discount = $_SESSION['customers_status']['customers_status_ot_discount'];
             } else {
                 $discount = '0.00';
             }
             if ($_SERVER["HTTP_X_FORWARDED_FOR"]) {
                 $customers_ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
             } else {
                 $customers_ip = $_SERVER["REMOTE_ADDR"];
             }
             $sql_data_array = array('customers_id' => $_SESSION['customer_id'], 'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'], 'customers_cid' => $order->customer['csID'], 'customers_vat_id' => $_SESSION['customer_vat_id'], 'customers_company' => $order->customer['company'], 'customers_status' => $_SESSION['customers_status']['customers_status_id'], 'customers_status_name' => $_SESSION['customers_status']['customers_status_name'], 'customers_status_image' => $_SESSION['customers_status']['customers_status_image'], 'customers_status_discount' => $discount, 'customers_street_address' => $order->customer['street_address'], 'customers_suburb' => $order->customer['suburb'], 'customers_city' => $order->customer['city'], 'customers_postcode' => $order->customer['postcode'], 'customers_state' => $order->customer['state'], 'customers_country' => $order->customer['country']['title'], 'customers_telephone' => $order->customer['telephone'], 'customers_email_address' => $order->customer['email_address'], 'customers_address_format_id' => $order->customer['format_id'], 'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'], 'delivery_company' => $order->delivery['company'], 'delivery_street_address' => $order->delivery['street_address'], 'delivery_suburb' => $order->delivery['suburb'], 'delivery_city' => $order->delivery['city'], 'delivery_postcode' => $order->delivery['postcode'], 'delivery_state' => $order->delivery['state'], 'delivery_country' => $order->delivery['country']['title'], 'delivery_address_format_id' => $order->delivery['format_id'], 'billing_name' => $order->billing['firstname'] . ' ' . $order->billing['lastname'], 'billing_company' => $order->billing['company'], 'billing_street_address' => $order->billing['street_address'], 'billing_suburb' => $order->billing['suburb'], 'billing_city' => $order->billing['city'], 'billing_postcode' => $order->billing['postcode'], 'billing_state' => $order->billing['state'], 'billing_country' => $order->billing['country']['title'], 'billing_address_format_id' => $order->billing['format_id'], 'payment_method' => $order->info['payment_method'], 'payment_class' => $order->info['payment_class'], 'shipping_method' => $order->info['shipping_method'], 'shipping_class' => $order->info['shipping_class'], 'language' => $_SESSION['language'], 'comments' => $order->info['comments'], 'customers_ip' => $customers_ip, 'orig_reference' => $order->customer['orig_reference'], 'login_reference' => $order->customer['login_reference'], 'cc_type' => $order->info['cc_type'], 'cc_owner' => $order->info['cc_owner'], 'cc_number' => $order->info['cc_number'], 'cc_expires' => $order->info['cc_expires'], 'date_purchased' => 'now()', 'orders_status' => $order->info['order_status'], 'currency' => $order->info['currency'], 'currency_value' => $order->info['currency_value']);
             vam_db_perform(TABLE_ORDERS, $sql_data_array);
             $insert_id = vam_db_insert_id();
             $customer_notification = SEND_EMAILS == 'true' ? '1' : '0';
             $sql_data_array = array('orders_id' => $insert_id, 'orders_status_id' => $order->info['order_status'], 'date_added' => 'now()', 'customer_notified' => $customer_notification, 'comments' => $order->info['comments']);
             vam_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
             for ($i = 0, $n = sizeof($order_totals); $i < $n; $i++) {
                 $sql_data_array = array('orders_id' => $insert_id, 'title' => $order_totals[$i]['title'], 'text' => $order_totals[$i]['text'], 'value' => $order_totals[$i]['value'], 'class' => $order_totals[$i]['code'], 'sort_order' => $order_totals[$i]['sort_order']);
                 vam_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);
             }
             for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
                 $sql_data_array = array('orders_id' => $insert_id, 'products_id' => vam_get_prid($order->products[$i]['id']), 'products_model' => $order->products[$i]['model'], 'products_name' => $order->products[$i]['name'], 'products_price' => $order->products[$i]['price'], 'final_price' => $order->products[$i]['final_price'], 'products_tax' => $order->products[$i]['tax'], 'products_quantity' => $order->products[$i]['qty']);
                 vam_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
                 $order_products_id = vam_db_insert_id();
                 $attributes_exist = '0';
                 if (isset($order->products[$i]['attributes'])) {
                     $attributes_exist = '1';
                     for ($j = 0, $n2 = sizeof($order->products[$i]['attributes']); $j < $n2; $j++) {
                         if (DOWNLOAD_ENABLED == 'true') {
                             $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename, pad.products_attributes_is_pin\n                                       from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n                                       left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad\n                                       on pa.products_attributes_id=pad.products_attributes_id\n                                       where pa.products_id = '" . $order->products[$i]['id'] . "'\n                                       and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'\n                                       and pa.options_id = popt.products_options_id\n                                       and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'\n                                       and pa.options_values_id = poval.products_options_values_id\n                                       and popt.language_id = '" . $_SESSION['languages_id'] . "'\n                                       and poval.language_id = '" . $_SESSION['languages_id'] . "'";
                             $attributes = vam_db_query($attributes_query);
                         } else {
                             $attributes = vam_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $_SESSION['languages_id'] . "' and poval.language_id = '" . $_SESSION['languages_id'] . "'");
                         }
                         // update attribute stock
                         vam_db_query("UPDATE " . TABLE_PRODUCTS_ATTRIBUTES . " set\n\t\t\t\t\t\t                               attributes_stock=attributes_stock - '" . $order->products[$i]['qty'] . "'\n\t\t\t\t\t\t                               where\n\t\t\t\t\t\t                               products_id='" . $order->products[$i]['id'] . "'\n\t\t\t\t\t\t                               and options_values_id='" . $order->products[$i]['attributes'][$j]['value_id'] . "'\n\t\t\t\t\t\t                               and options_id='" . $order->products[$i]['attributes'][$j]['option_id'] . "'\n\t\t\t\t\t\t                               ");
                         $attributes_values = vam_db_fetch_array($attributes);
                         $sql_data_array = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'products_options' => $attributes_values['products_options_name'], 'products_options_values' => $attributes_values['products_options_values_name'], 'options_values_price' => $attributes_values['options_values_price'], 'price_prefix' => $attributes_values['price_prefix']);
                         vam_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);
                         if (DOWNLOAD_ENABLED == 'true' && (isset($attributes_values['products_attributes_filename']) && vam_not_null($attributes_values['products_attributes_filename']) or $attributes_values['products_attributes_is_pin'])) {
                             //PIN add
                             for ($pincycle = 0; $pincycle < $order->products[$i]['qty']; $pincycle++) {
                                 if ($attributes_values['products_attributes_is_pin']) {
                                     $pin_query = vam_db_query("SELECT products_pin_id, products_pin_code FROM " . TABLE_PRODUCTS_PINS . " WHERE products_id = '" . $order->products[$i]['id'] . "' AND products_pin_used='0' LIMIT 1");
                                     if (vam_db_num_rows($pin_query) == '0') {
                                         // We have no PIN for this product
                                         // insert some error notifying here
                                         $pin = PIN_NOT_AVAILABLE;
                                     } else {
                                         $pin_res = vam_db_fetch_array($pin_query);
                                         $pin = $pin_res['products_pin_code'];
                                         vam_db_query("UPDATE " . TABLE_PRODUCTS_PINS . " SET products_pin_used='" . $insert_id . "' WHERE products_pin_id = '" . $pin_res['products_pin_id'] . "'");
                                     }
                                 }
                                 //PIN
                                 $sql_data_array = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'orders_products_filename' => $attributes_values['products_attributes_filename'], 'download_maxdays' => $attributes_values['products_attributes_maxdays'], 'download_count' => $attributes_values['products_attributes_maxcount'], 'download_is_pin' => $attributes_values['products_attributes_is_pin'], 'download_pin_code' => $pin);
                                 vam_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);
                             }
                         }
                     }
                 }
             }
             $_SESSION['cart_qiwi_id'] = $cartID . '-' . $insert_id;
         }
         // Выписываем qiwi счёт для покупателя
         if ($insert_order == true) {
             require_once DIR_WS_CLASSES . 'nusoap/nusoap.php';
             $client = new nusoap_client("https://mobw.ru/services/ishop", false);
             // создаем клиента для отправки запроса на QIWI
             $error = $client->getError();
             //if ( !empty($error) ) {
             // обрабатываем возможные ошибки и в случае их возникновения откатываем транзакцию в своей системе
             //echo -1;
             //exit();
             //}
             $client->useHTTPPersistentConnection();
             // Параметры для передачи данных о платеже:
             // login - Ваш ID в системе QIWI
             // password - Ваш пароль
             // user - Телефон покупателя (10 символов, например 916820XXXX)
             // amount - Сумма платежа в рублях
             // comment - Комментарий, который пользователь увидит в своем личном кабинете или платежном автомате
             // txn - Наш внутренний уникальный номер транзакции
             // lifetime - Время жизни платежа до его автоматической отмены
             // alarm - Оповещать ли клиента через СМС или звонком о выписанном счете
             // create - 0 - только для зарегистрированных пользователей QIWI, 1 - для всех
             $params = array('login' => MODULE_PAYMENT_QIWI_ID, 'password' => MODULE_PAYMENT_QIWI_SECRET_KEY, 'user' => $_SESSION['qiwi_telephone'] == '' ? $_POST['qiwi_telephone'] : $_SESSION['qiwi_telephone'], 'amount' => number_format($order->info['total'], 0, '', ''), 'comment' => substr($_SESSION['cart_qiwi_id'], strpos($_SESSION['cart_qiwi_id'], '-') + 1), 'txn' => substr($_SESSION['cart_qiwi_id'], strpos($_SESSION['cart_qiwi_id'], '-') + 1), 'lifetime' => date("d.m.Y H:i:s", strtotime("+2 weeks")), 'alarm' => 1, 'create' => 1);
             // собственно запрос:
             $result = $client->call('createBill', $params, "http://server.ishop.mw.ru/");
             //if ($client->fault) {
             //echo -1;
             //exit();
             //} else {
             //$err = $client->getError();
             //if ($err) {
             //echo -1;
             //exit();
             //} else {
             //echo $result;
             //exit();
             //}
             //}
             vam_db_query("INSERT INTO " . TABLE_PERSONS . " (orders_id, name, address) VALUES ('" . vam_db_prepare_input((int) substr($_SESSION['cart_qiwi_id'], strpos($_SESSION['cart_qiwi_id'], '-') + 1)) . "', '" . vam_db_prepare_input($_SESSION['kvit_name']) . "', '" . vam_db_prepare_input($_SESSION['qiwi_telephone']) . "')");
         }
     }
     return array('title' => MODULE_PAYMENT_QIWI_TEXT_DESCRIPTION);
 }