<?php
/*

	osCommRes, Services Oline 
	http://www.oscommres.com 
	Copyright (c) 2005 osCommRes 
	
	Freeway eCommerce 
	http://www.zac-ware.com/freeway 
	Copyright (c) 2007 ZacWare
	
	Released under the GNU General Public License
*/


// Set flag that this is a parent file
	define( '_FEXEC', 1 );
	
  require('includes/application_top.php');
  require(DIR_WS_CLASSES . "object_info.php");  

	// if the customer is not logged on, redirect them to the login page
	if (!tep_session_is_registered('customer_id')) {
	    $navigation->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_WALLET_CHECKOUT_PAYMENT));
		tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
	}
	
	
	if (!tep_session_is_registered('payment')) tep_session_register('payment');
	if (isset($HTTP_POST_VARS['payment'])) $payment = tep_db_prepare_input($HTTP_POST_VARS['payment']);
	
	if(!tep_session_is_registered('wallet_amount')) tep_session_register('wallet_amount');
	$wallet_amount=0;
	if (isset($HTTP_POST_VARS['wallet_amount'])) $wallet_amount=tep_db_prepare_input($HTTP_POST_VARS['wallet_amount']);
	
	if (!tep_session_is_registered('comments')) tep_session_register('comments');
	if (tep_not_null($HTTP_POST_VARS['comments'])) {
		$comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
	}

	if($wallet_amount=="" || ((float)$wallet_amount<=0))  {
		tep_redirect(tep_href_link(FILENAME_WALLET_CHECKOUT_PAYMENT, 'error_message=' .urlencode(ERROR_NO_PAYMENT_MODULE_UPLOADS), 'SSL'));
	}

	// load the selected payment module
	require(DIR_WS_CLASSES . 'payment.php');
	$payment_modules = new payment($payment);
  
	//$payment_modules->update_status();
	
	if ( (is_array($payment_modules->modules)) && (sizeof($payment_modules->modules) > 1) && (!is_object($$payment))){// && (!$credit_covers) ) {
		tep_redirect(tep_href_link(FILENAME_WALLET_CHECKOUT_PAYMENT, 'error_message=' .urlencode(ERROR_UPLOAD_NO_PAYMENT_MODULE_SELECTED), 'SSL'));
	}
   
	if (is_array($payment_modules->modules)) {
		$payment_modules->pre_confirmation_check();
	}

	require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_WALLET_CHECKOUT_CONFIRMATION);
	
	$breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_WALLET_CHECKOUT_PAYMENT, '', 'SSL'));
	$breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_WALLET_CHECKOUT_CONFIRMATION, '', 'SSL'));
	
	$content = CONTENT_WALLET_CHECKOUT_CONFIRMATION;
	
	require(DIR_WS_TEMPLATES . TEMPLATE_NAME . '/' . TEMPLATENAME_MAIN_PAGE);
	
	require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
