Example #1
0
// | license@zen-cart.com so we can mail you a copy immediately.					|
// +----------------------------------------------------------------------+
// $Id$
//
require_once DIR_FS_MODULES . 'require_languages.php';
// if the customer is not logged on, redirect them to the time out page
if (!$_SESSION['customer_id']) {
    zen_redirect(zen_href_link(FILENAME_TIME_OUT));
}
// confirm where link came from
if (!strstr($_SERVER['HTTP_REFERER'], FILENAME_CHECKOUT_CONFIRMATION)) {
    //		zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT,'','SSL'));
}
// load selected payment module
require BITCOMMERCE_PKG_PATH . 'classes/CommercePaymentManager.php';
$paymentManager = new CommercePaymentManager($_SESSION['payment']);
// load the selected shipping module
require BITCOMMERCE_PKG_PATH . 'classes/CommerceShipping.php';
$shipping_modules = new CommerceShipping($_SESSION['shipping']);
require BITCOMMERCE_PKG_PATH . 'classes/CommerceOrder.php';
$order = new order();
require DIR_FS_CLASSES . 'order_total.php';
$order_total_modules = new order_total();
$order_totals = $order_total_modules->process($_REQUEST);
$gBitDb->mDb->StartTrans();
// load the before_process function from the payment modules
if ($order->hasPaymentDue() && !$paymentManager->processPayment($_REQUEST, $order)) {
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, NULL, 'SSL', true, false));
}
$newOrderId = $order->create($order_totals, 2);
$order->create_add_products($newOrderId);
if (!empty($_POST['comments'])) {
    $_SESSION['comments'] = zen_db_prepare_input($_POST['comments']);
}
if (DISPLAY_CONDITIONS_ON_CHECKOUT == 'true') {
    if (!isset($_POST['conditions']) || $_POST['conditions'] != '1') {
        $messageStack->add_session('checkout_payment', ERROR_CONDITIONS_NOT_ACCEPTED, 'error');
    }
}
require_once BITCOMMERCE_PKG_PATH . 'classes/CommerceOrder.php';
$order = new order();
require_once DIR_FS_CLASSES . 'order_total.php';
$order_total_modules = new order_total();
$order_total_modules->collect_posts();
// load the selected payment module
require_once BITCOMMERCE_PKG_PATH . 'classes/CommercePaymentManager.php';
$paymentManager = new CommercePaymentManager($_SESSION['payment']);
$paymentManager->update_status($_REQUEST);
if ($order->hasPaymentDue() && is_array($paymentManager->modules) && sizeof($paymentManager->modules) > 1 && (empty(${$_SESSION}['payment']) || !is_object(${$_SESSION}['payment']))) {
    $messageStack->add_session('checkout_payment', ERROR_NO_PAYMENT_MODULE_SELECTED, 'error');
}
if ($messageStack->size('checkout_payment') > 0) {
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}
//echo $messageStack->size('checkout_payment');
//die('here');
if (is_array($paymentManager->modules)) {
    if (!$paymentManager->verifyPayment($_REQUEST, $order)) {
        zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, NULL, 'SSL', true, false));
    }
}
// load the selected shipping module
Example #3
0
        $order->billing = $order->delivery;
        $_SESSION['billto'] = $_SESSION['sendto'];
    } elseif ($defaultAddressId = $gBitCustomer->getDefaultAddress()) {
        $order->billing = $gBitCustomer->getAddress($defaultAddressId);
        $_SESSION['billto'] = $defaultAddressId;
    }
}
if (isset($_REQUEST['change_address']) || !$gBitCustomer->isValidAddress($order->billing)) {
    if ($addresses = $gBitCustomer->getAddresses()) {
        $gBitSmarty->assign('addresses', $addresses);
    }
    $gBitSmarty->assign('changeAddress', TRUE);
} else {
    // load all enabled payment modules
    require BITCOMMERCE_PKG_PATH . 'classes/CommercePaymentManager.php';
    $paymentManager = new CommercePaymentManager();
    echo $paymentManager->javascript_validation();
    $gBitSmarty->assign('paymentSelection', $paymentManager->selection());
    // Load the selected shipping module(needed to calculate tax correctly)
    require BITCOMMERCE_PKG_PATH . 'classes/CommerceShipping.php';
    $shipping_modules = new CommerceShipping($_SESSION['shipping']);
    require_once DIR_FS_MODULES . 'require_languages.php';
    if (isset($_GET['payment_error']) && is_object(${$_GET['payment_error']}) && ($error = ${$_GET['payment_error']}->get_error())) {
        $messageStack->add('checkout_payment', $error['error'], 'error');
    }
    $breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
    $breadcrumb->add(NAVBAR_TITLE_2);
    $gBitSmarty->assign('order', $order);
    require DIR_FS_CLASSES . 'order_total.php';
    $order_total_modules = new order_total();
    $order_total_modules->process();