<?php

/*

  osCommRes, Services Online
  http://www.oscommres.com

  Copyright (c) 2005 osCommRes

  Released under the GNU General Public License
  Freeway eCommerce from ZacWare
http://www.zac-ware.com/freeway

Copyright 2007 ZacWare Pty. Ltd
*/
// Set flag that this is a parent file
	define( '_FEXEC', 1 );
    require('includes/application_top.php');
	
	$checkID=(isset($HTTP_SESSION_VARS["checkID"])?$HTTP_SESSION_VARS["checkID"]:'');
	$payment_page=(isset($HTTP_SESSION_VARS["payment_page"])?$HTTP_SESSION_VARS["payment_page"]:'');
	$afrestext="";
	$afrescode="";
	$afrescode=(isset($HTTP_POST_VARS["rescode"])?tep_db_prepare_input($HTTP_POST_VARS["rescode"]):'');
	$afrestext=(isset($HTTP_POST_VARS["restext"])?tep_db_prepare_input($HTTP_POST_VARS["restext"]):'');
	
	//print_r ($HTTP_GET_VARS);
	//echo "code:".$afrescode;
		
	switch($payment_page){
	case "wallet":
			if($afrescode=="00" || $afrescode=="08") { //approved transaction
				tep_redirect(tep_href_link(FILENAME_WALLET_PROCESS, 'validID=' . $checkID, 'SSL'));
			}else{
				tep_redirect(tep_href_link(FILENAME_WALLET_PAYMENT, 'payment_error=westpac&error=' . urlencode($afrestext), 'SSL'));
			} 
			break;
		default:
			if($afrescode=="00" || $afrescode=="08") { //approved transaction
					tep_redirect(tep_href_link(FILENAME_CHECKOUT_PROCESS, '' , 'SSL'));
			}else{
					tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=westpac&error=' . urlencode($afrestext), 'SSL'));
			}
			break;
	}
?>