function zen_visitors_purchase_clean_up_visitors_ordrs() { global $db; if (defined('MODULE_VISITORS_PURCHASE_ORDERS_DATA_KEEP_DAYS') && trim(MODULE_VISITORS_PURCHASE_ORDERS_DATA_KEEP_DAYS) != '') { $query = "\r\n select\r\n orders_id, visitors_id, last_modified, date_purchased\r\n from\r\n " . TABLE_VISITORS_ORDERS . "\r\n where\r\n date_purchased < subdate(now(),INTERVAL " . MODULE_VISITORS_PURCHASE_ORDERS_DATA_KEEP_DAYS . " DAY)\r\n and (\r\n last_modified is null\r\n or last_modified < subdate(now(),INTERVAL " . MODULE_VISITORS_PURCHASE_ORDERS_DATA_KEEP_DAYS . " DAY)\r\n )\r\n ;"; $result = $db->Execute($query); while (!$result->EOF) { zen_remove_order($result->fields['orders_id'], false); zen_visitors_purchase_delete_visitors_order($result->fields['orders_id']); $result->MoveNext(); } } }
email_latest_status($oID, $customer_notified); } if ($status == DOWNLOADS_ORDERS_STATUS_UPDATED_VALUE) { // adjust download_maxdays based on current date $zc_max_days = date_diff($check_status->fields['date_purchased'], date('Y-m-d H:i:s', time())) + DOWNLOAD_MAX_DAYS; $update_downloads_query = "update " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " set download_maxdays='" . $zc_max_days . "', download_count='" . DOWNLOAD_MAX_COUNT . "' where orders_id='" . (int) $oID . "'"; $db->Execute($update_downloads_query); } $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success'); } else { $messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning'); } zen_redirect(zen_href_link(FILENAME_SUPER_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', $request_type)); break; case 'deleteconfirm': zen_remove_order($oID, $_POST['restock']); $so->delete_all_data(); zen_redirect(zen_href_link(FILENAME_SUPER_ORDERS, zen_get_all_get_params(array('oID', 'action')), $request_type)); break; } } if ($action == 'edit' && isset($_GET['oID'])) { $orders = $db->Execute("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . $oID . "'"); $order_exists = true; if ($orders->RecordCount() <= 0) { $order_exists = false; $messageStack->add(sprintf(ERROR_ORDER_DOES_NOT_EXIST, $oID), 'error'); zen_redirect(zen_href_link(FILENAME_SUPER_ORDERS, zen_get_all_get_params(array('oID', 'action')), $request_type)); } } require DIR_WS_CLASSES . 'currencies.php';
function after_process() { global $insert_id, $order, $currencies; require_once 'tinklit/tinklit_lib.php'; // change order status to value selected by merchant tep_db_query("update " . TABLE_ORDERS . " set orders_status = " . $this->order_status . " where orders_id = " . intval($insert_id)); $options = array('price' => $currencies->currencies['EUR']['value'] * $order->info['total'], 'currency' => 'EUR', 'order_id' => $insert_id, 'notification_url' => HTTP_SERVER . DIR_WS_CATALOG . 'tinklit_callback.php', 'redirect_url' => tep_href_link(FILENAME_ACCOUNT, 'tinklit=update_status')); //echo '<pre>'; print_r($options); echo '</pre>'; exit(); $post = json_encode($options); // create invoice //$invoice = tinklitCurl('https://api-staging.tinkl.it/v1/invoices', MODULE_PAYMENT_TINKLIT_CLIENTID, MODULE_PAYMENT_TINKLIT_TOKEN, $post); $invoice = tinklitCurl('https://api.tinkl.it/v1/invoices', MODULE_PAYMENT_TINKLIT_CLIENTID, MODULE_PAYMENT_TINKLIT_TOKEN, $post); //echo '<pre>'; print_r($invoice); echo '</pre>'; exit(); if (!is_array($invoice) or array_key_exists('error', $invoice)) { $this->log('createInvoice error ' . var_export($invoice['error'], true)); zen_remove_order($insert_id, $restock = true); // unfortunately, there's not a good way of telling the customer that it's hosed. Their cart is still full so they can try again w/ a different payment option. } else { $insert_sql = "INSERT INTO " . TABLE_TINKLIT . "\n (order_id, guid, status, btc_price, invoice_time, payment_confidence, time_created)\n VALUES ('" . $invoice['order_id'] . "', '" . $invoice['guid'] . "', '" . $invoice['status'] . "', '" . $invoice['btc_price'] . "', '" . $invoice['invoice_time'] . "', '" . $invoice['payment_confidence'] . "', now())"; tep_db_query($insert_sql); $_SESSION['cart']->reset(true); tep_redirect($invoice['url']); } return false; }
function after_process() { global $insert_id, $order, $db; require_once 'bitpay/bp_lib.php'; // change order status to value selected by merchant $db->Execute("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' => zen_href_link('bitpay_callback.php', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true, $static = true), 'redirectURL' => zen_href_link('account'), 'transactionSpeed' => MODULE_PAYMENT_BITPAY_TRANSACTION_SPEED, 'apiKey' => MODULE_PAYMENT_BITPAY_APIKEY); $invoice = bpCreateInvoice($insert_id, $order->info['total'], $insert_id, $options); if (!is_array($invoice) or array_key_exists('error', $invoice)) { $this->log('createInvoice error ' . var_export($invoice['error'], true)); zen_remove_order($insert_id, $restock = true); // unfortunately, there's not a good way of telling the customer that it's hosed. Their cart is still full so they can try again w/ a different payment option. } else { $_SESSION['cart']->reset(true); zen_redirect($invoice['url']); } return false; }
*/ require 'bitpay/bp_lib.php'; require 'includes/application_top.php'; function bplog($contents) { if (true === isset($contents)) { if (true === is_resource($contents)) { error_log(serialize($contents)); } else { error_log(var_export($contents, true)); } } } $response = bpVerifyNotification(MODULE_PAYMENT_BITPAY_APIKEY); if (true === is_string($response)) { bplog(date('H:i') . " bitpay callback error: " . $response . "\n"); } else { global $db; $order_id = $response['posData']; switch ($response['status']) { case 'confirmed': case 'complete': $db->Execute("update " . TABLE_ORDERS . " set orders_status = " . MODULE_PAYMENT_BITPAY_PAID_STATUS_ID . " where orders_id = " . intval($order_id)); break; case 'expired': if (true === function_exists('zen_remove_order')) { zen_remove_order($order_id, $restock = true); } break; } }