//DokuMan - 2012-06-19 - move billsafe to external directory if ($_SESSION['language_charset'] == 'iso-8859-1' || $_SESSION['language_charset'] == 'iso-8859-15') { $bs->setUtf8Mode(false); } else { $bs->setUtf8Mode(true); } if (MODULE_PAYMENT_BILLSAFE_2_SERVER == 'Live') { $bs->setMode('LIVE'); } else { $bs->setMode('SANDBOX'); } $bs->setCredentials(array('merchantId' => MODULE_PAYMENT_BILLSAFE_2_MERCHANT_ID, 'merchantLicenseSandbox' => MODULE_PAYMENT_BILLSAFE_2_MERCHANT_LICENSE, 'merchantLicenseLive' => MODULE_PAYMENT_BILLSAFE_2_MERCHANT_LICENSE, 'applicationSignature' => $ini['applicationSignature'], 'applicationVersion' => $ini['applicationVersion'])); $orders_query = xtc_db_query('SELECT id, transactionid, billsafeStatus, type FROM billsafe_orders_2 WHERE orderid = "' . xtc_db_input($order_id) . '"'); $billsafe_orders = xtc_db_fetch_array($orders_query); $paramsIns = array('transactionId' => $billsafe_orders['transactionid']); $responseInstruction = $bs->callMethod('getPaymentInstruction', $paramsIns); $smarty->assign('BillsafeType', $billsafe_orders['type']); if ($billsafe_orders['type'] == 'invoice') { if ($responseInstruction->ack == 'OK') { $url = substr(HTTP_SERVER, 7) . DIR_WS_CATALOG; $ins = $responseInstruction->instruction; $smarty->assign('BillsafeText', $ins->legalNote); $smarty->assign('BillsafeText2', '<b>' . $ins->note . '</b>'); $smarty->assign('recipient', MODULE_PAYMENT_BILLSAFE_2_RECIPIENT . ':'); $smarty->assign('recipientValue', $ins->recipient); $smarty->assign('account', MODULE_PAYMENT_BILLSAFE_2_ACCOUNT_NUMBER . ':'); $smarty->assign('accountValue', $ins->accountNumber); $smarty->assign('bankcode', MODULE_PAYMENT_BILLSAFE_2_BANK_CODE . ':'); $smarty->assign('bankcodeValue', $ins->bankCode); $smarty->assign('bank', MODULE_PAYMENT_BILLSAFE_2_BANK_NAME . ':'); $smarty->assign('bankValue', $ins->bankName);
function after_process() { global $order, $insert_id; unset($_SESSION['discount_value']); unset($_SESSION['discount_name']); unset($_SESSION['voucher_value']); unset($_SESSION['voucher_name']); unset($_SESSION['coupon_value']); unset($_SESSION['coupon_name']); unset($_SESSION['lofee_value']); unset($_SESSION['lofee_name']); $token = $_GET['token']; if ($this->response->ack == 'OK' && $this->response->status == 'ACCEPTED') { if ($this->order_status) { xtc_db_query('UPDATE ' . TABLE_ORDERS . ' SET orders_status = "' . xtc_db_input($this->order_status) . '" WHERE orders_id = "' . xtc_db_input($insert_id) . '"'); } $customer = $this->response->customer; xtc_db_query('INSERT INTO billsafe_orders_2 (id, orderid, transactionid, token, billsafeStatus, type, paymentStatus, date) VALUES (NULL,"' . xtc_db_input($insert_id) . '", "' . xtc_db_input($this->response->transactionId) . '", "' . $token . '", "' . xtc_db_input($this->response->status) . '", "installment", NULL, "' . date('Y-m-d H:i:s') . '")'); $resultQuery = xtc_db_query('SELECT id FROM billsafe_orders_2 WHERE transactionId = "' . xtc_db_input($this->response->transactionId) . '"'); $result = xtc_db_fetch_array($resultQuery); xtc_db_query('INSERT INTO billsafe_orders_user_2 (id, bsorders_id, gender, company, firstname, lastname, street, housenumber, postcode, city, country, dateofbirth, email, phone) VALUES (NULL, "' . xtc_db_input($result['id']) . '", "' . xtc_db_input($customer->gender) . '", "' . xtc_db_input($customer->firstname) . '", "' . xtc_db_input($customer->company) . '", "' . xtc_db_input($customer->lastname) . '", "' . xtc_db_input($customer->street) . '", "' . xtc_db_input($customer->housenumber) . '", "' . xtc_db_input($customer->postcode) . '", "' . xtc_db_input($customer->city) . '", "' . xtc_db_input($customer->country) . '", "0000-00-00", "' . xtc_db_input($customer->email) . '", "' . xtc_db_input($customer->phone) . '")'); $bs = new Billsafe_Sdk(DIR_FS_CATALOG . 'includes/external/billsafe/classes/billsafe_2/ini.php'); //DokuMan - 2012-06-19 - move billsafe to external directory if ($_SESSION['language_charset'] == 'iso-8859-1' || $_SESSION['language_charset'] == 'iso-8859-15') { $bs->setUtf8Mode(false); } else { $bs->setUtf8Mode(true); } if (MODULE_PAYMENT_BILLSAFE_2HP_SERVER == 'Live') { $bs->setMode("LIVE"); } else { $bs->setMode("SANDBOX"); } $bs->setCredentials(array('merchantId' => MODULE_PAYMENT_BILLSAFE_2HP_MERCHANT_ID, 'merchantLicenseSandbox' => MODULE_PAYMENT_BILLSAFE_2HP_MERCHANT_LICENSE, 'merchantLicenseLive' => MODULE_PAYMENT_BILLSAFE_2HP_MERCHANT_LICENSE, 'applicationSignature' => $this->applicationSignature, 'applicationVersion' => $this->application_version)); $params = array('transactionId' => $this->response->transactionId); $response = $bs->callMethod('getArticleList', $params); $article = $response->articleList; for ($i = 0, $n = sizeof($article); $i < $n; $i++) { for ($ii = 0, $nn = intval($article[$i]->quantity); $ii < $nn; $ii++) { $article[$i]->name = str_replace("\"", "\\\"", $article[$i]->name); $article[$i]->name = str_replace("\\'", "\\\\'", $article[$i]->name); xtc_db_query('INSERT INTO billsafe_orders_details_2 (ordernumber, product_id, articletype, articlenumber, articlename, articleprice, articletax, bsorders_id) values("' . xtc_db_input($insert_id) . '", "' . xtc_db_input($order->products[$i]['id']) . '", "' . xtc_db_input($article[$i]->type) . '", "' . xtc_db_input($article[$i]->number) . '", "' . xtc_db_input($article[$i]->name) . '", "' . xtc_db_input($article[$i]->grossPrice) . '", "' . xtc_db_input($article[$i]->tax) . '", "' . xtc_db_input($result['id']) . '")'); } } $comments = MODULE_PAYMENT_BILLSAFE_2HP_STATUS_TEXT . ': ' . $this->response->status . '; ' . MODULE_PAYMENT_BILLSAFE_2HP_TRANSACTIONID . ': ' . $this->response->transactionId; xtc_db_query('INSERT INTO orders_status_history (orders_status_history_id, orders_id, orders_status_id, date_added, customer_notified, comments) VALUES (NULL, "' . xtc_db_input($insert_id) . '", "1", "' . date('Y-m-d H:i:s') . '", "0", "' . xtc_db_input($comments) . '")'); $params = array('transactionId' => xtc_db_input($this->response->transactionId), 'orderNumber' => xtc_db_input($insert_id)); $response = $bs->callMethod('setOrderNumber', $params); if ($response->ack == 'OK') { } else { } } else { $_SESSION['billsafe_status'] = 'declined'; $message = $this->get_error_message($response); xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error_message=' . stripslashes(urlencode(html_entity_decode($message))), 'SSL')); } return false; }
$message = MODULE_PAYMENT_BILLSAFE_2_NO_ORDERID; } $billsafe_orders = xtc_db_fetch_array($orders_query); $currency = $order->info['currency']; $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE)); $tax_class_query = xtc_db_query('SELECT tax_class_id, tax_class_title FROM ' . xtc_db_input(TABLE_TAX_CLASS) . ' ORDER BY tax_class_title'); while ($tax_class = xtc_db_fetch_array($tax_class_query)) { $tax_class_array[] = array('id' => $tax_class['tax_class_id'], 'text' => $tax_class['tax_class_title']); } $sql_order_id = 'SELECT id, articlenumber FROM billsafe_orders_details_2 WHERE ordernumber = "' . $order_id . '"'; $articleList = array(); $orderArticles = array(); $orderIDArr = array(); if (isset($_POST['reportShipmentFull'])) { $paramsShipment = array('transactionId' => $billsafe_orders['transactionid']); $responseShipment = $bs->callMethod('reportShipment', $paramsShipment); if ($responseShipment->ack == 'OK' && $full_shipment_count == 0) { insDB_trans($order, $order_id, 'reportShipmentFull', $billsafe_orders['id'], $sql_order_id); xtc_db_query('UPDATE billsafe_orders_details_2 SET shipped = 1 WHERE ordernumber = "' . xtc_db_input($order_id) . '"'); $messageBox = 'SUCCESS'; $message = MODULE_PAYMENT_BILLSAFE_2_MESSAGE_FSHIPMENT; } else { if (is_array($responseShipment->errorList)) { respError($responseShipment); } } } elseif (isset($_POST['reportShipmentPart'])) { $orderIDArr = $_POST['shipped']; updDB_art_part('shipped', $orderIDArr); $queryLeftArticles = xtc_db_query('SELECT * FROM billsafe_orders_details_2 WHERE ordernumber = "' . xtc_db_input($order_id) . '" AND articletype = "goods" AND shipped = 0 AND storno = 0'); $countArticles = xtc_db_num_rows($queryLeftArticles);