<?php
/*
 * ##################################################################
 * Created on: Jul 28, 2005
 * File name:  quantumgateway.php 
 * ##################################################################
 * This code is a sole property of netenberg.com 
 * ##################################################################
 */
$name   = "Quantum Gateway";
$quantumgateway = array (
            array ("Gateway Login" , "quantumgateway_gwlogin"), 
            array ("Active" , "active", "No", "Yes"), 
            array ("Title" , "title")
            );
$send_method = "POST";
$pay         = new quantumgateway($demo_mode);
/*
 * Class to do all quantumgateway
 * quantumgateway Version 
 */
class quantumgateway
{
	/*
	 * Constructor
	 */
	function quantumgateway($demo_mode= 0)
	{
		$this->demo_mode = $demo_mode;
		$this->pay_url   = "https://www.quantumgateway.com/cgi/qgwdbe.php";
	}
	/*
	 * Function to send variables
	 */
	function sendVariables($path_url, $pp_vals)
	{
		$this->_POST1            = array ();
		$this->_POST1['gwlogin'] = $pp_vals['quantumgateway_gwlogin'];
        $this->_POST1['post_return_url_approved'] = $path_url."/ipn.php";
        $this->_POST1['post_return_url_declined'] = $path_url."/NOK.php";
		$this->_POST1['amount'] = number_format($_POST['gross_amount'],2);       
		$this->_POST1['item_number'] = time().rand(0, 1000);
		if (isset ($_POST['force_inv_no']))
        {
			$this->_POST1['item_number'] = $_POST['force_inv_no'];
        }            
        $this->_POST1['ID'] = $this->_POST1['item_number'];    
        $this->_POST1['BADDR1']  = $_POST['address'];
        $this->_POST1['BZIP1'] = $_POST['city'];
        $this->_POST1['BCUST_EMAIL'] = $_POST['email'];
	}
	/*
	 * IPN=Internet Payment Notifier
	 */
	function ipn(& $BL)
	{
		$this->item_number    = $_POST['ID'];
		$this->transaction_id = $_POST['transID'];
		$this->payment_status = $_POST['trans_result'];
		if (!empty ($this->item_number) && !empty ($this->transaction_id) && $this->payment_status=="APPROVED")
		{
			$BL->processTransaction($this->item_number, $this->transaction_id);
			return true;
		}
		return false;
	}
}
?>