Code: Select all
<?php
$PAGE = 'store';
require 'includes/master.inc.php';
require_once 'includes/vlib/vlibTemplate.php';
require_once 'includes/vlib/vlibDate.php';
if($_GET['type']==4)
{}
else{
$Auth->requireUser('process_payment.php');}
$tmpl = new vlibTemplate('tmpl/process_payment.htm');
$tmpl->setvar('siteurl', $Config->siteurl);
$tmpl->setvar('page_title', $Config->title . " :".$tmpl->get_lstring('CHECKOUT'));
$db = Database::getDatabase();
$tmpl->setvar('debug','');
$tmpl->setvar('disable','');
$err=0;
$tmpl->setvar('hide_account',0);
if(!isset($_GET['type']))
{
redirect('home.php');
}
else
{
if(($_GET['type']==1) || ($_GET['type']==4) || ($_GET['type']==6))
{
$tmpl->setvar('hide_account',1);
}
}
$this_script = $Config->siteurl."/call_back.php";
$payza_recurring_script = $Config->siteurl."/payzacall_back.php";
if(($_GET['type']==1) || ($_GET['type']==2) || ($_GET['type']==3) || ($_GET['type']==6))
{
$username= $_SESSION['un'];
}
else
{
$username= "";
}
$timestamp = date('Y-m-d H:i:s');
$balance=get_member_balance($username);
$amount = get_usd_amount($_SESSION['carttotal']+get_config('shipping_charge'));
$frm = $_POST;
$to = adminemailid();
$page_content = "";
if(isset($_SESSION['carttotal']))
{
$amount = get_usd_amount($_SESSION['carttotal']+get_config('shipping_charge'));
$cart_amount=$_SESSION['carttotal']+get_config('shipping_charge');
$tmpl->setvar('total_in_local',$_SESSION['carttotal']+get_config('shipping_charge'));
$tmpl->setvar('usd_total',$amount);
}
elseif(isset($_SESSION['fee_amt']))
{
$amount = get_usd_amount($_SESSION['fee_amt']);
$fee=$_SESSION['fee_amt'];
$tmpl->setvar('total_in_local',$_SESSION['fee_amt']);
$tmpl->setvar('usd_total',$amount);
}
$tmpl->setvar('hide_content',0);
if($frm['submit'] )
{
$payment=$frm['payment'];
if(isset($payment))
{
//Throught E-wallent Balance
if($payment=='account')
{
if($balance < $cart_amount)
{
$err=1;
$msg=$tmpl->get_lstring('YOU HAVE INSUFFICIENT ACCOUNT BALANCE');
$tmpl->setvar('msg_err',$msg);
}
else
{
$comment='Debited for product purchase';
$orderid = add_new_order($username,'account');
debit_member($username, $cart_amount, $comment, $timestamp);
change_order_status($orderid, 'paid', "auto-debited from eWallet balance", 1);
unset($_SESSION['cart']);
unset($_SESSION['carttotal']);
$tmpl->setvar('debug',"<h2>".$tmpl->get_lstring('ORDER COMPLETE')."!</h2><br /><b>".$tmpl->get_lstring('YOU ACCOUNT IS DEBITED')." ".$Config->currencysymbol.$cart_amount." <br /><a href='myorders.php'>".$tmpl->get_lstring('VIEW ORDER DETAILS')."</a>");
$tmpl->setvar('ordercomplete',1);
}
}
else if($payment=='bank')
{
$payment_type = $_GET['type'];
if($payment_type==1 || $payment_type==2)
{
$res=$db->getRows("select * from settings_bank");
$debug ="";
$debug .="<h2>Thank You!</h2>You can transfer or deposit the amount to any of the accounts mentioned below. After making the payment send transaction details with Order ID to support team. <br />
<br />";
foreach($res as $row){
$debug .="<b>".$tmpl->get_lstring('BANK').":</b> ".$row['bank']." <br />";
$debug .="<b>".$tmpl->get_lstring('ACCOUNT NO').":</b> ".$row['accountnumber']." <br />";
$debug .="<b>".$tmpl->get_lstring('PAYEE').":</b> ".$row['payee']." <br />----------------<br />";
}
$tmpl->setvar('debug',$debug);
$tmpl->setvar('ordercomplete',1);
}
if($payment_type==3)
{
add_new_order($username,'offline');
unset($_SESSION['cart']);
$res=$db->getRows("select * from settings_bank");
$debug ="";
$debug .="<h2>".$tmpl->get_lstring('ORDER COMPLETE')."!</h2>You can transfer or deposit the amount to any of the accounts mentioned below. After making the payment send transaction details with Order ID to support team. <br />
<br />";
foreach($res as $row){
$debug .="<b>".$tmpl->get_lstring('BANK').":</b> ".$row['bank']." <br />";
$debug .="<b>".$tmpl->get_lstring('ACCOUNT NO').":</b> ".$row['accountnumber']." <br />";
$debug .="<b>".$tmpl->get_lstring('PAYEE').":</b> ".$row['payee']." <br />----------------<br />";
}
$tmpl->setvar('debug',$debug);
$tmpl->setvar('ordercomplete',1);
}
if($payment_type==4)
{
add_new_order(0,'offline');
unset($_SESSION['cart']);
$res=$db->getRows("select * from settings_bank");
$debug ="";
$debug .="<h2>".$tmpl->get_lstring('ORDER COMPLETE')."!</h2>You can transfer or deposit the amount to any of the accounts mentioned below. After making the payment send transaction details with Order ID to support team. <br />
<br />";
foreach($res as $row){
$debug .="<b>".$tmpl->get_lstring('BANK').":</b> ".$row['bank']." <br />";
$debug .="<b>".$tmpl->get_lstring('ACCOUNT NO').":</b> ".$row['accountnumber']." <br />";
$debug .="<b>".$tmpl->get_lstring('PAYEE').":</b> ".$row['payee']." <br />----------------<br />";
}
$tmpl->setvar('debug',$debug);
$tmpl->setvar('ordercomplete',1);
}
}
elseif($payment=='cashsense')
{
$cashsense_form="";
$payment_type = $_GET['type'];
if($payment_type==1)
{
$fee_amt=round(($fee + get_module_config('cashsense','cashsense_fee_fixed'))/(100/(100 + get_module_config('cashsense','cashsense_fee') )) , 2);
$cashsense_form .="<fieldset><legend>Cashsense Payment</legend><form action='https://merchantapi.cashsense.com/MerchantFormPost.aspx' method='post'>
<input id='fxMerchantID' type='hidden' name='fxMerchantID' value='".get_module_config('cashsense','cashsense_id')."' />
<input id='fcusername' type='hidden' name='fcusername' value='".get_module_config('cashsense','cashsense_username')."'/>
<input id='fcpassword' type='hidden' name='fcpassword' value='".get_module_config('cashsense','cashsense_pwd')."'/>
<table border='0' cellpadding='3' cellspacing='3'>
<tr><td><b><span style='color:red;'>*</span> Username: </b></td><td><input id='fcCustomerName' type='text' name='fcCustomerName' value='".$_SESSION['m_user']['username']."' readonly='readonly'/><td></tr>
<tr><td><b><span style='color:red;'>*</span> Email:</b> </td><td><input id='Text1' type='text' name='fcEmailAddress' value='".$_SESSION['m_user']['email']."' readonly='readonly'/></td></tr>
<tr><td><b><span style='color:red;'>*</span> Amount: </b></td><td><input id='fnAmount' type='text' name='fnAmount' value='".$fee_amt."' readonly='readonly'/></td></tr>
<input id='fcMerchantTxnID' type='hidden' name='fcMerchantTxnID' value='".generate_txnid()."'/>
<input id='fxProdID' type='hidden' name='fxProdID' value='0'/>
<input id='fcProductCode' type='hidden' name='fcProductCode' value='' />
<input id='fnProdQty' type='hidden' name='fnProdQty' value='0' />
<input id='fcDescription' type='hidden' name='fcDescription' value='Membership Fee'/>
<tr><td colspan='2' align='center'><input type='submit' value='submit' class='subbutton button'/></td></tr></table>
</form></fieldset>";
$tmpl->setvar('debug',$cashsense_form);
$tmpl->setvar('ordercomplete',1);
}
if($payment_type==2)
{
$fee_amt=round(($fee + get_module_config('cashsense','cashsense_fee_fixed'))/(100/(100 + get_module_config('cashsense','cashsense_fee') )) , 2);
$cashsense_form .="<fieldset><legend>Cashsense Payment</legend><form action='https://merchantapi.cashsense.com/MerchantFormPost.aspx' method='post'>
<input id='fxMerchantID' type='hidden' name='fxMerchantID' value='".get_module_config('cashsense','cashsense_id')."' />
<input id='fcusername' type='hidden' name='fcusername' value='".get_module_config('cashsense','cashsense_username')."'/>
<input id='fcpassword' type='hidden' name='fcpassword' value='".get_module_config('cashsense','cashsense_pwd')."'/>
<table border='0' cellpadding='3' cellspacing='3'>
<tr><td><b><span style='color:red;'>*</span> Username: </b></td><td><input id='fcCustomerName' type='text' name='fcCustomerName' value='".$_SESSION['m_user']['username']."' readonly='readonly'/><td></tr>
<tr><td><b><span style='color:red;'>*</span> Email:</b> </td><td><input id='Text1' type='text' name='fcEmailAddress' value='".$_SESSION['m_user']['email']."' readonly='readonly'/></td></tr>
<tr><td><b><span style='color:red;'>*</span> Amount: </b></td><td><input id='fnAmount' type='text' name='fnAmount' value='".$fee_amt."' readonly='readonly'/></td></tr>
<input id='fcMerchantTxnID' type='hidden' name='fcMerchantTxnID' value='".generate_txnid()."'/>
<input id='fxProdID' type='hidden' name='fxProdID' value='0'/>
<input id='fcProductCode' type='hidden' name='fcProductCode' value='' />
<input id='fnProdQty' type='hidden' name='fnProdQty' value='0' />
<input id='fcDescription' type='hidden' name='fcDescription' value='Membership Renewal Fee'/>
<tr><td colspan='2' align='center'><input type='submit' value='submit' class='subbutton button'/></td></tr></table>
</form></fieldset>";
$tmpl->setvar('debug',$cashsense_form);
$tmpl->setvar('ordercomplete',1);
}
if($payment_type==3)
{
$orderid = add_new_order($username,'cashsense');
unset($_SESSION['cart']);
$cartamt=round(($cart_amount + get_module_config('cashsense','cashsense_fee_fixed'))/(100/(100 + get_module_config('cashsense','cashsense_fee') )) , 2);
$cashsense_form .="<fieldset><legend>Cashsense Payment</legend><form action='https://merchantapi.cashsense.com/MerchantFormPost.aspx' method='post'>
<input id='fxMerchantID' type='hidden' name='fxMerchantID' value='".get_module_config('cashsense','cashsense_id')."' />
<input id='fcusername' type='hidden' name='fcusername' value='".get_module_config('cashsense','cashsense_username')."'/>
<input id='fcpassword' type='hidden' name='fcpassword' value='".get_module_config('cashsense','cashsense_pwd')."'/>
<table border='0' cellpadding='3' cellspacing='3'>
<tr><td><b><span style='color:red;'>*</span> Username: </b></td><td><input id='fcCustomerName' type='text' name='fcCustomerName' value='".$_SESSION['m_user']['username']."' readonly='readonly'/><td></tr>
<tr><td><b><span style='color:red;'>*</span> Email:</b> </td><td><input id='Text1' type='text' name='fcEmailAddress' value='".$_SESSION['m_user']['email']."' readonly='readonly'/></td></tr>
<tr><td><b><span style='color:red;'>*</span> Amount: </b></td><td><input id='fnAmount' type='text' name='fnAmount' value='".$cartamt."' readonly='readonly'/></td></tr>
<input id='fcMerchantTxnID' type='hidden' name='fcMerchantTxnID' value='".generate_txnid()."'/>
<input id='fxProdID' type='hidden' name='fxProdID' value='0'/>
<input id='fcProductCode' type='hidden' name='fcProductCode' value='' />
<input id='fnProdQty' type='hidden' name='fnProdQty' value='0' />
<input id='fcDescription' type='hidden' name='fcDescription' value='Membership Product Purchase'/>
<tr><td colspan='2' align='center'><input type='submit' value='submit' class='subbutton button'/></td></tr></table>
</form></fieldset>";
$tmpl->setvar('debug',$cashsense_form);
$tmpl->setvar('ordercomplete',1);
}
if($payment_type==4)
{
$orderid = add_new_order(0,'cashsense');
unset($_SESSION['cart']);
$cartamt=round(($cart_amount + get_module_config('cashsense','cashsense_fee_fixed'))/(100/(100 + get_module_config('cashsense','cashsense_fee') )) , 2);
$cashsense_form .="<fieldset><legend>Cashsense Payment</legend><form action='https://merchantapi.cashsense.com/MerchantFormPost.aspx' method='post'>
<input id='fxMerchantID' type='hidden' name='fxMerchantID' value='".get_module_config('cashsense','cashsense_id')."' />
<input id='fcusername' type='hidden' name='fcusername' value='".get_module_config('cashsense','cashsense_username')."'/>
<input id='fcpassword' type='hidden' name='fcpassword' value='".get_module_config('cashsense','cashsense_pwd')."'/>
<table border='0' cellpadding='3' cellspacing='3'>
<tr><td><b><span style='color:red;'>*</span> Username: </b></td><td><input id='fcCustomerName' type='text' name='fcCustomerName' value='' /><td></tr>
<tr><td><b><span style='color:red;'>*</span> Email:</b> </td><td><input id='Text1' type='text' name='fcEmailAddress' value='' /></td></tr>
<tr><td><b><span style='color:red;'>*</span> Amount: </b></td><td><input id='fnAmount' type='text' name='fnAmount' value='".$cartamt."' readonly='readonly'/></td></tr>
<input id='fcMerchantTxnID' type='hidden' name='fcMerchantTxnID' value='".generate_txnid()."'/>
<input id='fxProdID' type='hidden' name='fxProdID' value='0'/>
<input id='fcProductCode' type='hidden' name='fcProductCode' value='' />
<input id='fnProdQty' type='hidden' name='fnProdQty' value='0' />
<input id='fcDescription' type='hidden' name='fcDescription' value='Guest Product Purchase'/>
<tr><td colspan='2' align='center'><input type='submit' value='submit' class='subbutton button'/></td></tr></table>
</form></fieldset>";
$tmpl->setvar('debug',$cashsense_form);
$tmpl->setvar('ordercomplete',1);
}
}
else
{
require "includes/payment/".$payment.".php";
require "includes/order.php";
require "includes/user.php";
$classname=$payment;
$obj=new $payment();
$ord=new order();
$usr=new userinfo();
$userid = $_SESSION['m_user']['id'];
$username = $_SESSION['m_user']['username'];
$payment_type = $_GET['type'];
if($payment_type==1)
{
if($payment=='paypal_recurring')
{
$item_name="Membership paypal monthly recurring fee";
$custom="userid-".$_SESSION['m_user']['id']."|type-5|mode-paypal_recurring";
$obj->process($item_name,$fee,$custom,$this_script);
$tmpl->setvar('hide_content',1);
}
elseif($payment=='payza_recurring')
{
$item_name="Membership payza monthly recurring fee";
$custom="userid-".$_SESSION['m_user']['id']."|type-5|mode-payza_recurring";
$obj->process($item_name,$fee,$custom,$payza_recurring_script);
$tmpl->setvar('hide_content',1);
}
else
{
$item_name="Membership Fee";
$custom="userid-".$_SESSION['m_user']['id']."|type-".$payment_type."|mode-".$payment;
$obj->process($item_name,$fee,$custom,$this_script);
$tmpl->setvar('hide_content',1);
}
}
if($payment_type==2)
{
if($payment=='paypal_recurring')
{
$item_name="Membership paypal monthly recurring renewal fee";
$custom="userid-".$_SESSION['m_user']['id']."|type-5|mode-paypal_recurring";
$obj->process($item_name,$fee,$custom,$this_script);
$tmpl->setvar('hide_content',1);
}
elseif($payment=='payza_recurring')
{
$item_name="Membership payza monthly recurring renewal fee";
$custom="userid-".$_SESSION['m_user']['id']."|type-5|mode-payza_recurring";
$obj->process($item_name,$fee,$custom,$payza_recurring_script);
$tmpl->setvar('hide_content',1);
}
else
{
$item_name="Membership Renewal Fee";
$custom="userid-".$_SESSION['m_user']['id']."|type-".$payment_type."|mode-".$payment;
$obj->process($item_name,$fee,$custom,$this_script);
$tmpl->setvar('hide_content',1);
}
}
if($payment_type==3)
{
if($payment=='payza'){ $payment_method='alertpay';}
elseif($payment=='liberty_reserve'){$payment_method='lr'; }
elseif($payment=='money_booker'){$payment_method='skrill'; }
else{$payment_method=$payment;}
$item_name="Product Purchase";
$order_id = $ord->add_new_order($_SESSION['m_user']['username'],$payment_method);
$custom="userid-".$_SESSION['m_user']['id']."|type-".$payment_type."|orderid-".$order_id."|mode-".$payment;
$obj->process($item_name,$amount,$custom,$this_script);
unset($_SESSION['cart']);
unset($_SESSION['carttotal']);
$tmpl->setvar('hide_content',1);
}
if($payment_type==4)
{
if($payment=='payza'){ $payment_method='alertpay';}
elseif($payment=='liberty_reserve'){$payment_method='lr'; }
elseif($payment=='money_booker'){$payment_method='skrill'; }
else{$payment_method=$payment;}
$item_name="Guest Product Purchase";
$order_id = $ord->add_new_order(0,$payment_method);
$custom="userid-0|type-".$payment_type."|orderid-".$order_id."|mode-".$payment;
$obj->process($item_name,$amount,$custom,$this_script);
unset($_SESSION['cart']);
unset($_SESSION['carttotal']);
$tmpl->setvar('hide_content',1);
}
if($payment_type==6)
{
$item_name="Membership Plan upgrade";
$custom="userid-".$_SESSION['m_user']['id']."|type-".$payment_type."||mode-".$payment;
$obj->process($item_name,$fee,$custom,$this_script);
$tmpl->setvar('hide_content',1);
}
}
}
else
{
$err=1;
$msg="<b style='color:#F00'>".$tmpl->get_lstring('SELECT ANY PAYMENT OPTION')."</b>";
$tmpl->setvar('debug',$msg);
}
}
if($_GET['type']==6)
{
//Get all Installed payment gateways
$res=$db->getRows("select * from module
where
type='payment'
and enabled ='1'
and name!='paypal_recurring'
and name!='payza_recurring'
and name!='bank'
order by `order` asc");
}
else
{
//Get all Installed payment gateways
$res=$db->getRows("select * from module where `enabled`='1' and `type`='payment' order by `order` asc");
}
$payment_list ="";
if(count($res) >0)
{
$payment_list .='<tr>';
$i=1;
foreach($res as $row)
{
if($row['name']=='bank')
{
$hide='onclick="return show_details_bank()"';
if(file_exists(DOC_ROOT."/images/logo/".$row['name'].".jpg"))
{
$payment_logo="<img src='images/logo/".$row['name'].".jpg' width='140px' />";
}
else
{
$payment_logo="";
}
}
else
{
$hide='onclick="return hide_details();"';
$file=get_module_config($row['name'],$row['name'].'_logo');
if($file)
{
if(file_exists(DOC_ROOT."/images/logo/".$file))
{
$payment_logo="<img src='images/logo/".$file."' width='140px' />";
}
else
{
$payment_logo="";
}
}
else
{
$payment_logo="";
}
}
$payment_list .='<td width="50px;" align="right">
<input type="radio" name="payment" value='.$row['name'].' '.$hide.'>
</td>
<td width="220px;" style="padding-left:10px;"><b>'.ucwords(str_replace('_',' ',$row['name'])).'</b>
<br />'.$payment_logo;
if($row['name']=='cashsense')
{
$payment_list .='<br />(Charges :P'.sprintf("%1\$.2f",get_module_config($row['name'],$row['name'].'_fee_fixed')).'+'.sprintf("%1\$.2f",get_module_config($row['name'],$row['name'].'_fee')).'%)';
}
elseif($row['name']!=='bank')
{
$payment_list .='<br />(Charges :$'.sprintf("%1\$.2f",get_module_config($row['name'],$row['name'].'_fee_fixed')).'+'.sprintf("%1\$.2f",get_module_config($row['name'],$row['name'].'_fee')).'%)';
}
$payment_list .='</td>';
if (($i % 2) == 0)
{
$payment_list .='</tr><tr>';
}
else
{
$payment_list .='';
}
$i++;
}
$payment_list .='<tr>';
}
$tmpl->setvar('payment_list',$payment_list);
$account_msg="<fieldset><legend>".$tmpl->get_lstring('ACCOUNT DETAILS')."</legend><table><tr><td><b>".$tmpl->get_lstring('YOUR ACCOUNT BALANCE').": </td><td>".str_replace('Â','',$Config->currencysymbol)."".$balance."</b></td></tr></table></fieldset>";
$tmpl->setvar('account_msg',$account_msg);
$bank_details=$db->getRow("select * from settings_bank");
$page_content.=$tmpl->get_lstring('CHECKOUT_A')."
<!-- <b>".$tmpl->get_lstring('BANK').":</b> ".$bank_details['bank']." <br />
<b>".$tmpl->get_lstring('ACCOUNT NO').":</b> ".$bank_details['accountnumber']." <br />
<b>".$tmpl->get_lstring('PAYEE').":</b> ".$bank_details['payee']."--><table>";
$bankoptions = "";
$res = $db->getRows("select * from settings_bank");
foreach($res as $row)
{
$page_content .="<tr>";
$bankoptions .= "<option value=\"".$row['bank']."\">". $row['bank']."</option>";
$page_content .= "<td style='padding-right:20px;'><br /><strong>". $row['bank']."</strong><br /></td>";
if($row['bankimage']) $page_content .= "<td style='padding-right:20px;'><img src=\"".$Config->siteurl."/images/".$row['bankimage']."\" style='float:left;margin-right:10px;'></td>";
$page_content .= "<td>A/c No: <strong>".$row['accountnumber']."</strong><br />". htmlspecialchars_decode(stripslashes($row['payee'])) . "<br /><br /><br /></td>";
$page_content .="</tr>";
}
$page_content.="</table></fieldset>";
$tmpl->setvar('page_content',$page_content);
$tmpl->pparse();
?>