tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); $customer_notified = '1'; } tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . (int) $oID . "', '" . tep_db_input($status) . "', now(), '" . tep_db_input($customer_notified) . "', '" . tep_db_input($comments) . "')"); $order_updated = true; } if ($order_updated == true) { $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success'); } else { $messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning'); } tep_redirect(tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('action')) . 'action=edit')); break; case 'deleteconfirm': $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']); tep_remove_order($oID, $HTTP_POST_VARS['restock']); tep_redirect(tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action')))); break; } } if ($action == 'edit' && isset($HTTP_GET_VARS['oID'])) { $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']); $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int) $oID . "'"); $order_exists = true; if (!tep_db_num_rows($orders_query)) { $order_exists = false; $messageStack->add(sprintf(ERROR_ORDER_DOES_NOT_EXIST, $oID), 'error'); } } include DIR_WS_CLASSES . 'order.php'; ?>
$customer_notified = '1'; } } tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . (int) $oID . "', '" . tep_db_input($status) . "', now(), '" . tep_db_input($customer_notified) . "', '" . tep_db_input($comments) . "')"); $order_updated = true; } if ($order_updated == true) { $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success'); } else { $messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning'); } tep_redirect(tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('action')) . 'action=edit')); break; case 'deleteconfirm': $oID = tep_db_prepare_input($_GET['oID']); tep_remove_order($oID, $_POST['restock']); tep_redirect(tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action')))); break; } } if ($action == 'edit' && isset($_GET['oID'])) { $oID = tep_db_prepare_input($_GET['oID']); $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int) $oID . "'"); $order_exists = true; if (!tep_db_num_rows($orders_query)) { $order_exists = false; $messageStack->add(sprintf(ERROR_ORDER_DOES_NOT_EXIST, $oID), 'error'); } } // BOF: MOD - Downloads Controller - Extra order info // Look up things in orders
require 'bitpay/remove_order.php'; $response = bpVerifyNotification(MODULE_PAYMENT_BITPAY_APIKEY); if (is_string($response)) { bpLog('bitpay callback error: ' . $response); } else { $order_id = $response['posData']; switch ($response['status']) { case 'paid': case 'confirmed': case 'complete': if (function_exists('tep_db_query')) { tep_db_query("update " . TABLE_ORDERS . " set orders_status = " . MODULE_PAYMENT_BITPAY_PAID_STATUS_ID . " where orders_id = " . intval($order_id)); } else { bpLog('FATAL: tep_db_query function is missing. Cannot update order_id = ' . $order_id . ' as ' . $response['status']); } break; case 'invalid': case 'expired': if (function_exists('tep_remove_order')) { tep_remove_order($order_id, $restock = true); } else { bpLog('FATAL: tep_remove_order function is missing. Cannot update order_id = ' . $order_id . ' as ' . $response['status']); } break; case 'new': break; default: bpLog('INFO: Receieved unknown IPN status of ' . $response['status'] . ' for order_id = ' . $order_id); break; } }
$Qupdate->bindInt(':customer_notified', isset($_POST['notify_customer']) && $_POST['notify_customer'] == 'on' ? '1' : '0'); $Qupdate->bindValue(':comments', $_POST['comment']); $Qupdate->execute(); $osC_MessageStack->add_session('header', SUCCESS_DB_ROWS_UPDATED, 'success'); } else { $osC_MessageStack->add_session('header', ERROR_DB_ROWS_NOT_UPDATED, 'error'); } } else { $osC_MessageStack->add_session('header', WARNING_DB_ROWS_NOT_UPDATED, 'warning'); } } } tep_redirect(tep_href_link(FILENAME_ORDERS, (isset($_GET['search']) ? 'search=' . $_GET['search'] . '&' : '') . (isset($_GET['status']) ? 'status=' . $_GET['status'] . '&' : '') . (isset($_GET['cID']) ? 'cID=' . $_GET['cID'] . '&' : '') . 'page=' . $_GET['page'] . '&oID=' . $_GET['oID'] . '&action=oEdit§ion=statusHistory')); break; case 'deleteconfirm': tep_remove_order($_GET['oID'], isset($_POST['restock']) && $_POST['restock'] == 'on' ? true : false); tep_redirect(tep_href_link(FILENAME_ORDERS, (isset($_GET['search']) ? 'search=' . $_GET['search'] . '&' : '') . (isset($_GET['status']) ? 'status=' . $_GET['status'] . '&' : '') . (isset($_GET['cID']) ? 'cID=' . $_GET['cID'] . '&' : '') . 'page=' . $_GET['page'])); break; } } require '../includes/classes/currencies.php'; $osC_Currencies = new osC_Currencies(); require 'includes/classes/order.php'; switch ($action) { case 'oEdit': $page_contents = 'orders_edit.php'; break; default: $page_contents = 'orders.php'; } require 'templates/default.php';
/** * @return false */ function after_process() { global $insert_id, $order; require_once 'bitpay/bp_lib.php'; $lut = array("High-0 Confirmations" => 'high', "Medium-1 Confirmations" => 'medium', "Low-6 Confirmations" => 'low'); // change order status to value selected by merchant tep_db_query("update " . TABLE_ORDERS . " set orders_status = " . intval(MODULE_PAYMENT_BITPAY_UNPAID_STATUS_ID) . " where orders_id = " . intval($insert_id)); $options = array('physical' => $order->content_type == 'physical' ? 'true' : 'false', 'currency' => $order->info['currency'], 'buyerName' => $order->customer['firstname'] . ' ' . $order->customer['lastname'], 'fullNotifications' => 'true', 'notificationURL' => tep_href_link('bitpay_callback.php', '', 'SSL', true, true), 'redirectURL' => tep_href_link(FILENAME_ACCOUNT), 'transactionSpeed' => $lut[MODULE_PAYMENT_BITPAY_TRANSACTION_SPEED], 'apiKey' => MODULE_PAYMENT_BITPAY_APIKEY); $invoice = bpCreateInvoice($insert_id, $order->info['total'], $insert_id, $options); if (is_array($invoice) && array_key_exists('error', $invoice)) { // error bpLog('Error creating invoice: ' . var_export($invoice, true)); tep_remove_order($insert_id, $restock = true); tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, 'error_message=' . urlencode($invoice['error']['message']), 'SSL')); } else { if (!is_array($invoice)) { // error bpLog('Error creating invoice: ' . var_export($invoice, true)); tep_remove_order($insert_id, $restock = true); tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, 'error_message=' . urlencode('There was a problem processing your payment: invalid response returned from gateway.'), 'SSL')); } else { if (is_array($invoice) && array_key_exists('url', $invoice)) { // success $_SESSION['cart']->reset(true); tep_redirect($invoice['url']); } else { // unknown problem bpLog('Error creating invoice: ' . var_export($invoice, true)); tep_remove_order($insert_id, $restock = true); tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, 'error_message=' . urlencode('There was a problem processing your payment: unknown error or response.'), 'SSL')); } } } return false; }