<?php  
/*
##################################################################
#                       PHP 4&5 MySQL 4&5                        #
##################################################################
#           Copyright (c) 2004-2008 Armia Systems Inc            #
##################################################################
#               This file is part of Cybermatch site             #
##################################################################
#    Developed By: simi (simi@armia.com)                         #

##################################################################
#               Developed On:   03-23-2009                       #
##################################################################
#               Modified By:                                     #
##################################################################
#               Modified On:                                     #
##################################################################
# This script may not be distributed, sold, given away for free  #
# to third party, or used as a part of any internet services 	 #
# such as webdesign etc.                                         #
##################################################################
*/

require_once ("config.inc.php");
require_once ("includes/userlogincheck.inc.php");
require_once ("includes/mysql.inc.php");
require_once ("includes/arrays.inc.php");
require_once ("classes/settings.class.php");
require_once ("classes/userside.class.php");
require_once ("classes/misc.class.php");

$message	= "";
$script		= "";
$product	= isset($_REQUEST['product'])	?	trim($_REQUEST['product'])	:	"0";
$amount		= 0;
$_SESSION['sess_product']=$product;

if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {
	$objU			= new userside($objDB);
	$objS			= new settings($objDB);
        $objM		= new misc($objDB);
	$objS->set_variables();
	
	if (isset($_POST['PYN'])) {
		$objU->set_values($_POST);
		$objU->set_BCIDV($_SESSION['idverify']);
		
		//for payment process
		$_SESSION['sess_register_stype']=$_POST['chkMethod'];		
		$message	= $objU->buy_real_products($_SESSION['user_id'], $product);
		if ($message == "") {
			header("Location:purchase_success_one.php?product=$product");
			exit();
		}
		
	} else {
		$objU->set_values($_POST);
		$objU->set_creditcard($_SESSION['user_id']);
		//fetch user details
		$user_array=$objU->select($_SESSION['user_id']); 
		$objU->set_values($user_array);
		
	}
        $objU->set_creditcard($_SESSION['user_id']);        
	$amount		= $objU->get_product_amount($product);
	$script		= $objU->get_script($message);
	$message	= $objU->remove_script($message);
}

//setting variable
$showmsgtype=($_POST['showmsgtype']!='')?$_POST['showmsgtype']:$_GET['showmsgtype'];
$objST	= new settings($objDB);
$siteSettings=$objST->select();
//seting messgae to show payment made for which
switch($showmsgtype)
{
	case "profile_writing";
	$ShowMsg='Click below to complete the purchase of your profile writing';
	break;
	
	case "photography";
	$ShowMsg='Click below to complete the purchase of your profile photo service';
	break;
	
	case "buy_credits";
	$ShowMsg='Click below to complete the purchase of your credits';
        
	$amount=$siteSettings['credit_value']*$_POST['ddlCredits'];
	//set seesion for updates
	$_SESSION['sess_buy_credits']=$_POST['ddlCredits'];
	break;
	
}//end switch

//storing user dob
$_SESSION['sess_echeck_dob']=$objU->dDob;

if(isset($_SESSION['sess_buy_credits']) && $_SESSION['sess_buy_credits']!='')
{
	$amount=$siteSettings['credit_value']*$_SESSION['sess_buy_credits'];
}//end if
include_once ("title.inc.php");
include_once ("tophtml.inc.php");

//storing payment type
$checktypemode=($_POST['chkMethod']!='')?$_POST['chkMethod']:$siteSettings["paymentmethod"];

$txtPaypalEmail = $siteSettings["paypalemail"];
$txtPaypalSandbox = $siteSettings["enablepaypalsandbox"];
$chkPaypal = $siteSettings["enablepaypal"];
$ddlPaymentMethod = $siteSettings["paymentmethod"];
$chkGoogle = $siteSettings["enablegoogle"];
//worldpay details
$txtWorldInstId = $siteSettings["worldpayid"];
$txtWorldEmailId = $siteSettings["worldpayemail"];
$txtWorldTransMode = $siteSettings["worldpaytransmode"];
$txtWorldpaySandbox = $siteSettings["worldpaydemo"];
//propay details
$txtpropaydemo = $siteSettings["propay_demo"];
$txtpropaytoken = $siteSettings["propay_token"];
$txtpropaybillerid = $siteSettings["propay_billerid"];

$ProductOrderId=rand('100','345');

if ($txtPaypalSandbox == "Y") 
{
	$paypalurl = "https://www.sandbox.paypal.com/cgi-bin/webscr";
   	$paypalbuttonurl = "https://www.sandbox.paypal.com/en_US/i/btn/x-click-but23.gif";
}//end if
else 
{
    $paypalurl = "https://www.paypal.com/cgi-bin/webscr";
    $paypalbuttonurl = "https://www.paypal.com/en_US/i/btn/x-click-but23.gif";
}//end if

if ($txtWorldpaySandbox == "YES") 
{
	$worldpayserver="https://select-test.worldpay.com/wcc/purchase";
	$txtWorldpaySandbox2='100';
}//end if
else 
{
    $worldpayserver="https://select.worldpay.com/wcc/purchase";
	$txtWorldpaySandbox2='0';
}//end if

//for authorize
if($checktypemode=='CC' || $checktypemode=='PRO')
{
	$display='style="display:;"';
	$display2='style="display:none;"';
	$display3='style="display:none;"';
	$display4='style="display:none;"';
	$display5='style="display:none;"';
}//end if
else if($checktypemode=='UP')
{
	$display='style="display:;"';
	$display2='style="display:none;"';
	$display3='style="display:none;"';
	$display4='style="display:none;"';
	$display5='style="display:none;"';
}//end if
else if($checktypemode=='WP')
{
	$display='style="display:none;"';
	$display2='style="display:none;"';
	$display3='style="display:none;"';
	$display4='style="display:none;"';
	$display5='style="display:;"';
}//end if
else if($checktypemode=='ECHECK')
{
	$display='style="display:none;"';
	$display2='style="display:;"';
	$display3='style="display:none;"';
	$display4='style="display:none;"';
	$display5='style="display:none;"';
}//end else if
else if($checktypemode=='GOOGLE')
{
	$display='style="display:none;"';
	$display2='style="display:none;"';
	$display3='style="display:none;"';
	$display4='style="display:;"';
	$display5='style="display:none;"';
}//end else if
else
{
	$display='style="display:none;"';
	$display2='style="display:none;"';
	$display3='';
	$display4='style="display:none;"';
	$display5='style="display:none;"';
}//end else
$arrCountry	= $objU->get_country_list();
?>
<script type="text/javascript"  src="js/ajax.js"></script>
<script language="javascript" type="text/javascript">
function changeCSS(obj, type)
{
	
}
function clickConfirm(){
	var frm = document.frmPayment;
	var flag = false;
	if (frm.vFirstName.value == "") {
		alert("Please enter your firstname.");
		frm.vFirstName.focus();
		frm.vFirstName.className ='errorinput';
		return false;
	}
	if (frm.vLastName.value == "") {
		alert("Please enter your lastname.");
		frm.vLastName.focus();
		frm.vLastName.className ='errorinput';
		return false;
	}
	//for authorize.net
if(document.getElementById('chkMethodC').checked==true)
{
	
	if (frm.nNumber.value == "") {
		alert("Please enter your cardnumber.");
		frm.nNumber.focus();
		frm.nNumber.className ='errorinput';
		return false;
	}
	if (frm.nCvv2.value == "") {
		alert("Please enter validation code of your card.");
		frm.nCvv2.focus();
		frm.nCvv2.className ='errorinput';
		return false;
	}
	if (frm.vMM.value == "") {
		alert("Please enter month of expiry date of your card.");
		frm.vMM.focus();
		frm.vMM.className ='errorinput';
		return false;
	}
	if (frm.vYYYY.value == "") {
		alert("Please enter year of expiry date of your card.");
		frm.vYYYY.focus();
		frm.vYYYY.className ='errorinput';
		return false;
	}
}//end if
//for echeck
if(document.getElementById('chkMethodE').checked==true)
{
	if (frm.rBank.value == "") {
		alert("Please enter Routing Number of a Bank.");
		frm.rBank.focus();
		frm.rBank.className ='errorinput';
		return false;
	}
	
	if (frm.nAccountNumber.value == "") {
		alert("Please enter Bank Account Number.");
		frm.nAccountNumber.focus();
		frm.nAccountNumber.className ='errorinput';
		return false;
	}
	
	if (frm.txtAccountType.value == "") {
		alert("Please enter Account Type.");
		frm.txtAccountType.focus();
		frm.txtAccountType.className ='errorinput';
		return false;
	}
	
	if (frm.txtBankName.value == "") {
		alert("Please enter Bank Name.");
		frm.txtBankName.focus();
		frm.txtBankName.className ='errorinput';
		return false;
	}
	
	if (frm.txtBankHolderName.value == "") {
		alert("Please enter Bank Holder Name.");
		frm.txtBankHolderName.focus();
		frm.txtBankHolderName.className ='errorinput';
		return false;
	}
}//end echeck if	
	if (frm.vAddress.value == "") {
		alert("Please enter your billing address.");
		frm.vAddress.focus();
		frm.vAddress.className ='errorinput';
		return false;
	}
	
	if (frm.vCity.value == "") {
		alert("Please enter your city address.");
		frm.vCity.focus();
		frm.vCity.className ='errorinput';
		return false;
	}
	if (frm.vState.value == "") {
		alert("Please enter your state address.");
		frm.vState.focus();
		frm.vState.className ='errorinput';
		return false;
	}
	if (frm.vCountry.value == "") {
		alert("Please enter your country.");
		frm.vCountry.focus();
		frm.vCountry.className ='errorinput';
		return false;
	}
	if (frm.vPostCode.value == "") {
		alert("Please enter your postalcode.");
		frm.vPostCode.focus();
		frm.vPostCode.className ='errorinput';
		return false;
	}
	if (frm.vPhone.value == "") {
		alert("Please enter your phone number.");
		frm.vPhone.focus();
		frm.vPhone.className ='errorinput';
		return false;
	}
	if (frm.vEmail.value == "") {
		alert("Please enter your email address.");
		frm.vEmail.focus();
		frm.vEmail.className ='errorinput';
		return false;
	}
	
	return true;
}
function checkValue(t) {
  if(isNaN(t.value) || t.value.substring(0,1) == " " || t.value.length == 0 || parseFloat(t.value) < 0 ) {
	 if(t.name == "nNumber") {
		 t.value = "";
	 } else{
		t.value = "000";
	 }
  }
}

function checkMethod(ttype)
{
	if(ttype==='c')
	{
		for(var i=1;i<26;i++)
		{
			document.getElementById('showVal'+i).style.display='';
			if(i>=4 && i<=10)
			{
				document.getElementById('showVal'+i).style.display='none';
			}//end if
			if(i>=23 && i<=25)
			{
				document.getElementById('showVal'+i).style.display='none';
			}//end if
		}//end for loop
	}// end if
	if(ttype==='e')
	{
		for(var i=1;i<26;i++)
		{
			document.getElementById('showVal'+i).style.display='none';
			if(i>=4 && i<=8)
			{
				document.getElementById('showVal'+i).style.display='';
			}//end if
			if(i>=11 && i<=23)
			{
				document.getElementById('showVal'+i).style.display='';
			}//end if
		}//end for loop
	}//end else
	if(ttype==='p')
	{
		for(var i=1;i<26;i++)
		{
			document.getElementById('showVal'+i).style.display='none';
			if(i>=9 && i<=10)
			{
				document.getElementById('showVal'+i).style.display='block';
			}//end if
		}//end for loop
	}//end else
	if(ttype==='g')
	{
		for(var i=1;i<26;i++)
		{
			document.getElementById('showVal'+i).style.display='none';
			if(i==23)
			{
				document.getElementById('showVal'+i).style.display='';
			}//end if
		}//end for loop
	}//end else
	if(ttype==='w')
	{
		for(var i=1;i<26;i++)
		{
			document.getElementById('showVal'+i).style.display='none';
			if(i>=24 && i<=25)
			{
				document.getElementById('showVal'+i).style.display='';
			}//end if
		}//end for loop
	}//end else
}//end function

var ajax = new Array();
var sajax = new Array();
function getStateList(sel)
{
    
	var stateCode = sel.options[sel.selectedIndex].value;
        
	document.getElementById('girish_state').options.length = 0;	// Empty city select box
	if(stateCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'get_state_list.php?id='+stateCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createStateList(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}
function createStateList(index)
{
	var obj = document.getElementById('girish_state');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}

function getCountyList(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('girish_county').options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'get_county_list.php?id='+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCountyList(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createCountyList(index)
{
	var obj = document.getElementById('girish_county');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}
</script>

<div class="row">
	<div class="eight columns">
		<div class="search-rslts">
			<div class="row"><div class="inenr-hd"><h2>Make Payment</h2></div></div>
			<div class="row">
				<h2 class="headings2"><?php echo $ShowMsg;?></h2>
			</div>
			<div class="row">
				<form name="frmPayment" method="post" action="<?php echo $_SERVER['PHP_SELF']?>" onSubmit="return clickConfirm();">
					<div class="newdesignforinput maintext1">
						<?php if(isset($message) && trim($message)!='')
							  {
						?>
						<div class="full_row">
							<div class="maintext1 warning"><?php echo $message;?></div>
						</div>
						<?php }//end if?>
												
						<div class="full_row">
							<div class="three columns">Payment Method</div>
							<div class="five columns margin_R_200">
								<?php
								if($ddlPaymentMethod=="CC" || $ddlPaymentMethod=="PRO")
								{
								?>
								<input type="radio" name="chkMethod" value="CC" onClick="checkMethod('c');"<?php if($_POST['chkMethod']=='CC'){echo 'checked';}if($_POST['chkMethod']==''){echo 'checked';}?> id="chkMethodC">Credit Card
								<?php
								}//end if
								if($ddlPaymentMethod=="UP")
								{
								?>
								<input type="radio" name="chkMethod" value="UP" onClick="checkMethod('c');"<?php if($_POST['chkMethod']=='UP'){echo 'checked';}if($_POST['chkMethod']==''){echo 'checked';}?> id="chkMethodC">Yourpay					   
								<?php
								}//end if
								if($ddlPaymentMethod=="WP")
								{
								?>
								<input type="radio" name="chkMethod" value="WP" onClick="checkMethod('w');"<?php if($_POST['chkMethod']=='WP'){echo 'checked';}if($_POST['chkMethod']==''){echo 'checked';}?> id="chkMethodW">Worldpay					   
								<?php
								}//end if
								if($chkPaypal == "Y")
								{
								?>
								<input type="radio" name="chkMethod" value="PAYPAL" onClick="checkMethod('p');" <?php if($_POST['chkMethod']=='PAYPAL'){echo 'checked';}?> id="chkMethodP">PayPal
								<?php
								}//end if
								if($chkGoogle == "Y")
								{
								?>
								<input type="radio" name="chkMethod" value="GOOGLE" onClick="checkMethod('g');" <?php if($_POST['chkMethod']=='GOOGLE'){echo 'checked';}?> id="chkMethodG">Google Checkout
								<?php }//end if?>
							</div>
						</div>
												
						<div class="full_row">
							<div class="three columns">Amount to Pay</div>
							<div class="five columns margin_R_200">$ <?php echo $amount?></div>
						</div>
												
						<div class="full_row" id="showVal12" <?php echo $display;?>>
							<div class="three columns">First Name <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="vFirstName" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo htmlspecialchars($objU->vFirstName)?>" size="30" maxlength="200">
							</div>
						</div>
												
						<div class="full_row" id="showVal13" <?php echo $display;?>>
							<div class="three columns">Middle Name</div>
							<div class="five columns margin_R_200">
								<input name="vMiddleName" type="text" class="textbox txt-bx01" value="<?php echo htmlspecialchars($objU->vMiddleName)?>" size="30" maxlength="100">
							</div>
						</div>
												
						<div class="full_row" id="showVal14" <?php echo $display;?>>
							<div class="three columns">Last Name <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="vLastName" type="text" class="textbox txt-bx01"  onKeyDown="changeCSS(this, 'text');" value="<?php echo htmlspecialchars($objU->vLastName)?>" size="30" maxlength="200">
							</div>
						</div>
												
						<div class="full_row" id="showVal1" <?php echo $display;?>>
							<div class="three columns">Card Number <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<div class="twelve">
									<div class="four columns">
										<input name="nNumber" type="text" class="textbox txt-bx01" onBlur="javascript:checkValue(this);"  onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->nNumber?>" size="30" maxlength="16">
									</div>
									<div class="seven columns">
										<img src="images/logo_ccAmex.gif" width="37" height="23" border="0" alt="Amex" title="Amex">
										<img src="images/logo_ccBank.gif" width="37" height="23" border="0" alt="Bank" title="Bank">
										<img src="images/logo_ccDiscover.gif" width="37" height="23" border="0" alt="Discover" title="Discover">
										<img src="images/logo_ccMC.gif" width="37" height="23" border="0" alt="MC" title="MC">
										<img src="images/logo_ccVisa.gif" width="37" height="23" border="0" alt="Visa" title="Visa">
									</div>
								</div>
							</div>
						</div>
						<?php if($ddlPaymentMethod=="PRO"){ ?>
												
						<div class="full_row" id="showVal2" <?php echo $display;?>>
							<div class="three columns">Card Type <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<select name="vPaymentMethodType" class="textbox txt-bx01">
									<option value="Visa">Visa</option>
									<option value="MasterCard">MasterCard</option>
									<option value="AMEX">AMEX</option>
									<option value="Discover">Discover</option>
									<option value="DinersClub">DinersClub</option>
									<!-- <option value="JCB">JCB</option>
									<option value="ProPayToProPay">ProPay To ProPay</option>
									<option value="Checking">Checking</option>
									<option value="Savings">Savings</option>-->
								</select>
							</div>
						</div>
												
						<?php } ?>
						<div class="full_row" id="showVal2" <?php echo $display;?>>
							<div class="two columns">Card Validation Code <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="nCvv2" type="text" class="textbox txt-bx01"  onBlur="javascript:checkValue(this);"  onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->nCvv2?>" size="30" maxlength="3">
							</div>
						</div>
												
						<div class="full_row" id="showVal3" <?php echo $display;?>>
							<div class="two columns">Expiration Date (MM/YYYY) <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
                                                            <div class="twelve">
                                                                <div class="five columns"><input name="vMM" type="text" class="select-small" onKeyDown="changeCSS(this, 'text');" value="<?php echo addslashes($objU->vMM)?>" size="2" maxlength="2"></div>
                                                                <div class="two columns" align="center"> / </div>
                                                                <div class="five columns"><input name="vYYYY" type="text" class="select-small" onKeyDown="changeCSS(this, 'text');" value="<?php echo ($_POST['vYYYY'])?htmlspecialchars($_POST['vYYYY']):addslashes($objU->vYYYY)?>" size="4" maxlength="4"></div>
                                                        </div>
							</div>
						</div>
												
						<div class="full_row" id="showVal4" <?php echo $display2;?>>
							<div class="three columns">Routing Number of a Bank <span class="warning">*</span>.</div>
							<div class="five columns margin_R_200">
								<input name="rBank" type="text" class="textbox txt-bx01" onBlur="javascript:checkValue(this);"  onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->rBank?>" size="30" maxlength="16">
							</div>
						</div>
												
						<div class="full_row" id="showVal5" <?php echo $display2;?>>
							<div class="three columns">Bank Account Number <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="nAccountNumber" type="text" class="textbox txt-bx01"  onBlur="javascript:checkValue(this);"  onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->nAccountNumber?>" size="30" maxlength="50">
							</div>
						</div>
												
						<div class="full_row" id="showVal6" <?php echo $display2;?>>
							<div class="three columns">Account Type <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="txtAccountType" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo addslashes($objU->txtAccountType)?>" size="25" maxlength="50">
							</div>
						</div>
												
						<div class="full_row" id="showVal7" <?php echo $display2;?>>
							<div class="three columns">Bank Name <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="txtBankName" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->txtBankName?>" size="30" maxlength="50">
							</div>
						</div>
												
						<div class="full_row" id="showVal8" <?php echo $display2;?>>
							<div class="three columns">Bank Holder Name <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="txtBankHolderName" type="text" class="textbox txt-bx01"  onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->txtBankHolderName?>" size="30" maxlength="50">
							</div>
						</div>
												
						<div class="full_row" id="showVal15" <?php echo $display;?>>
							<div class="three columns">Address <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="vAddress" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->vAddress?>" size="30" maxlength="100">
							</div>
						</div>
                                                <div class="full_row" id="showVal16" <?php echo $display;?>>
							<div class="two columns">City <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="vCity" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo htmlspecialchars($objU->vCity)?>" size="30" maxlength="100">
							</div>
						</div>
						<?php if($ddlPaymentMethod!="PRO"){?>
						<div class="full_row" id="showVal17" <?php echo $display;?>>
							<div class="two columns">State/Province <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="vState" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->vState?>"  size="30" maxlength="100">
							</div>
						</div>						
						<div class="full_row" id="showVal18" <?php echo $display;?>>
							<div class="three columns">Country <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<select name="vCountry" class="textbox txt-bx01" id="girish_country" onchange="getStateList(this);">
									<?php foreach ($arrCountry as $key => $value) {
									$selected = '';
									if($objU->vCountry == $value)
									$selected = 'selected';
									?>									
									<option value="<?php echo $value?>" <?php echo $selected;?>>
									<?php echo $value?>
									</option>
									<?php } ?>
									</select>
							</div>
						</div>						
						<?php }else{?>
												
						<div class="full_row" id="showVal18" <?php echo $display;?>>
							<div class="three columns">State/Province <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="vState" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->vState?>"  size="30" maxlength="100">
							</div>
						</div>
						
						<?php }?>				
						<div class="full_row" id="showVal19" <?php echo $display;?>>
							<div class="three columns">Postal Code <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="vPostCode" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->vPostCode?>"  size="30" maxlength="100">
							</div>
						</div>
												
						<div class="full_row" id="showVal20" <?php echo $display;?>>
							<div class="three columns">Phone <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="vPhone" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->vPhone?>" size="30" maxlength="100">
							</div>
						</div>
												
						<div class="full_row" id="showVal21" <?php echo $display;?>>
							<div class="three columns">Email <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="vEmail" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->vEmail?>" size="30" maxlength="200">
							</div>
						</div>
												
						<div class="full_row" id="showVal22" <?php echo $display;?>>
							<div class="three columns">&nbsp;</div>
							<div class="five columns margin_R_200">
								&nbsp;
							</div>
						</div>
												
						<div class="full_row" id="showVal11" <?php echo $display;?>>
							<div class="three columns">&nbsp;</div>
							<div class="five columns margin_R_200">
								<input name="PYN" type="submit" class="loginbutton" value="Pay Now">
								<input type="hidden" name="step" value="3">
								<input type="hidden" name="product" value="<?php echo $product?>">
							</div>
						</div>
						
					</div>
				</form>
				<div class="newdesignforinput maintext1">
					<div class="full_row" id="showVal9" <?php echo $display3;?>>
						<div class="twelve columns">
							<b>Make payments with PayPal <img src="./images/pp.jpg" title="Make payments with PayPal - it's fast, free and secure! " border="0"></b>
						</div>
					</div>
				
					<div class="full_row" id="showVal10" <?php echo $display3;?>>
						<div class="twelve columns">
							<form action="<?php echo $paypalurl;?>" method="post" name="frmPayment">
								<input type="hidden" name="cmd" value="_xclick">
								<input type="hidden" name="business" value="<?php echo $txtPaypalEmail?>">
								<input type="hidden" name="item_name" value="<?php echo $siteSettings['sitename'];?> : <?php echo $showmsgtype;?>">
								<input type="hidden" name="item_number" value="<?php echo $ProductOrderId;?>">
								<input type="hidden" name="amount" value="<?php echo round($amount,2);?>">
								<input type="hidden" name="no_shipping" value="1">
								<input type="hidden" name="custom" value="<?php echo $_SESSION['user_login'];?>">
								<input type="hidden" name="return" value="<?php echo $siteSettings['site_normal_url'] ."/ppsuccess_one.php"; ?>">
								<input type="hidden" name="cancel_return" value="<?php echo $siteSettings['site_normal_url'] ."/ppfailure.php"; ?>">
								<input type="hidden" name="no_note" value="1">
								<input type="hidden" name="currency_code" value="USD">
								<input type="hidden" name="bn" value="armiasystems_shoppingcart_wps_us">
								<div align="center"><input type="image" src="<?php echo $paypalbuttonurl;?>" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"></div>
							</form>
						</div>
					</div>
				
				<?php
require_once('gc/library/googlecart.php');
require_once('gc/library/googleitem.php');
require_once('gc/library/googleshipping.php');
require_once('gc/library/googletax.php');
require_once('gc/library/googleresponse.php');
require_once('gc/library/googlemerchantcalculations.php');
require_once('gc/library/googleresult.php');

$_SESSION['txtGoogleId']=$siteSettings["googleid"];
$_SESSION['txtGoogleKey']=$siteSettings["googlekey"];
$_SESSION['chkGoogleSandbox']=$siteSettings["enablegooglesandbox"];
$_SESSION['sess_product']=$product;
$_SESSION['sess_gc_amount']=$amount;
$_SESSION['sess_register_stype']=$_SESSION['sess_register_stype'];
$_SESSION['sess_site_name']=$siteSettings["sitename"];
$_SESSION['sess_pass_msg']='Payment for '.$showmsgtype;
$_SESSION['sess_site_secure_url']=$siteSettings["site_secure_url"];

$gc_status=($_GET['gc_status']!='')?$_GET['gc_status']:'failure';

function UseCase1() 
{
	$google_id		= $_SESSION['txtGoogleId']; // Merchant ID
	$google_key		= $_SESSION['txtGoogleKey']; // Merchant Key
	$google_demo	= $_SESSION['chkGoogleSandbox']; // "YES" if in test mode, "NO" if in live mode
	$cost			= $_SESSION['sess_gc_amount']; // price
	$currency 		= 'USD';

	$product=$_SESSION['sess_product'];
	$amount=$_SESSION['sess_gc_amount'];
	$_SESSION['sess_register_stype']=$_SESSION['sess_register_stype'];

	if ($google_demo == "YES")
		$server_type	= "sandbox";
	else
		$server_type	= "checkout";

	// Create a new shopping cart object
	$cart = new GoogleCart($google_id, $google_key, $server_type, $currency);

	// Add items to the cart
	$item_1 = new GoogleItem($_SESSION['sess_site_name'], // Item name
						 $_SESSION['sess_pass_msg'], // Item description
						 1, // Quantity
						 $cost); // Unit price


	$cart->AddItem($item_1);

	// continue link page
	$cart->SetContinueShoppingUrl($_SESSION['sess_site_secure_url']."/buy_now.php?paytype=gc&product=".$product."&gc_status=success");

	$cart->AddRoundingPolicy("HALF_UP", "PER_LINE");

	$cart->SetMerchantPrivateData('buynow-'.$product.'-'.$amount.'-'.$_SESSION['sess_register_stype'].'-'.$_SESSION['user_id']);

	// Display Google Checkout button
	echo $cart->CheckoutButtonCode("LARGE");
}//end google usecase


	//calculation starts here
	if(isset($gc_status) && $gc_status=='success')
	{
   		$gc_flag = true;
    	$gc_err = "";
		if ($google_demo == "YES")
    		$gc_tran = "TEST-".time();
		else
			$gc_tran = time();

		$_SESSION['sess_TransId']=$gc_tran;
    
    	if ($gc_flag==true) 
		{
        	// Start of the transaction  for adding a user since payment is successfull
        	$txnid = $gc_tran;
       		// ////////////////////////////////////////////////////////////////////////////////////
        	// check if txnid alredy there to prevent refresh
        	$sql="select * from ".TABLEPREFIX."payments where vTxn_Id='".addslashes($txnid)."' and vMethod='GC'";
       	    $result = mysql_query($sql) or die(mysql_error());
        	if(mysql_num_rows($result)==0)
			{
				$_SESSION['sess_Paymode']='GC';
                                $message	= $objU->buy_real_products($_SESSION['user_id'], $product);

				if ($message == "") 
				{
					$_SESSION['txtGoogleId']='';
					$_SESSION['txtGoogleKey']='';
					$_SESSION['chkGoogleSandbox']='';
					$_SESSION['sess_site_name']='';
					$_SESSION['sess_pass_msg']='';
					$_SESSION['sess_site_secure_url']='';

					header("Location:purchase_success_one.php?product=$product");
					exit();
				}//end if
            }//end if
			else 
			{
                $gc_flag = false;
				$gc_err="Transaction Error .Please contact <a href='mailto:".$config['adminMail']."'>".$config['adminMail']."</a>";
            }//end else
        }//end if
		else 
		{
            $gc_flag = false;
			$gc_err='Payment process not completed successfully.';
        }//end else
    }//end if
?>

				
					<div class="full_row" id="showVal23" <?php echo $display4;?>>
						<div class="twelve columns">
							<?php if($gc_flag == false && $gc_err!='')
							{
							echo '<span class="warning">'.$gc_err.'</span><br><br>';
							}//end if
							if(isset($gc_status) && $gc_status!='success')
							{
							?>	
							While using Google CheckOut as payment option, you have to wait for the approval from Administrator of the site for further steps even after successful payment. <br>
							<br>
							<b>Waiting for the secure payment interface ....</b><br>
							<br><br>
							<?php UseCase1(); ?>
							<?php
							}//end else
							?>
						</div>
					</div>
				
					<div class="full_row" id="showVal24" <?php echo $display5;?>>
						<div class="twelve columns"><b>Make payments with Worldpay</b></div>
					</div>
				
					<div class="full_row" id="showVal25" <?php echo $display5;?>>
						<div class="twelve columns">
							<form action="<?php echo $worldpayserver;?>" name="BuyForm" method="POST">
								<input type="hidden" name="instId"  value="<?php echo $txtWorldInstId;?>">
								<input type="hidden" name="cartId" value="<?php echo $product;?>">
								<input type="hidden" name="currency" value="USD">
								<input type="hidden" NAME="email" VALUE="<?php echo $txtWorldEmailId;?>">
								<input type="hidden" name="amount"  value="<?php echo round($amount,2);?>">
								<input type="hidden" name="testMode" value="<?php echo $txtWorldpaySandbox2;?>">
								<input type="hidden" NAME="MC_ORDERID" VALUE="<?php echo $ProductOrderId;?>">
								<input type='hidden' name='authMode' value="<?php echo $txtWorldTransMode;?>">
								<input type="hidden" name="MC_callback" value="<?php echo $siteSettings['site_normal_url']."/wpsuccess_one.php";?>">
								<input name="imageField" type="image" src="./images/worldpay.gif" width="139" height="33" border="0"  title="Make payments with Worldpay - it's fast, free and secure!" alt="Make payments with Worldpay - it's fast, free and secure!">
							</form>
						</div>
						<div id="hide"><?php echo $script?></div>
					</div>
					
				</div>
								
			</div>
		</div>
	</div>
	<div class="four columns right search_result_R">
		<?php include_once ("left.inc.php");?>
	</div>
</div>

<?php include_once('bottomhtml.inc.php');?>