<?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');

  	if (!tep_session_is_registered("customer_id")){
		tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
	}
	
	$checkID=(isset($HTTP_SESSION_VARS["checkID"])?$HTTP_SESSION_VARS["checkID"]:'');
	$payment_page=(isset($HTTP_SESSION_VARS["payment_page"])?$HTTP_SESSION_VARS["payment_page"]:'');
	$error_text=(isset($HTTP_POST_VARS["err"])?(tep_db_prepare_input($HTTP_POST_VARS["err"])):'');
	
	switch($payment_page){
		case "wallet":
			if($error_text=="") { //approved transaction
				tep_redirect(tep_href_link(FILENAME_WALLET_CHECKOUT_PROCESS, 'validID=' . $checkID, 'SSL'));
			}else{
				tep_redirect(tep_href_link(FILENAME_WALLET_CHECKOUT_PAYMENT, 'payment_error=virtualpay&error=' . urlencode($error_text), 'SSL'));
			}
		default:
			if($error_text=="") { //approved transaction
				tep_redirect(tep_href_link(FILENAME_CHECKOUT_PROCESS, '' , 'SSL'));
			}else{
				tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=virtualpay&error=' . urlencode($error_text), 'SSL'));
			}
	}
?>