<?php
/*
 * ##################################################################
 * Created on: May 13, 2006
 * File name:  linkpoint.php 
 * ##################################################################
 * This code is a sole property of netenberg.com 
 * ##################################################################
 */
$name           = "LinkPoint";
$linkpoint      = array (
                    array ("StoreName"  , "lp_storename"), 
                    array ("Active"     , "active", "No", "Yes"), 
                    array ("Title"      , "title")
                    );
$send_method    = "POST";
$pay            = new linkpoint($demo_mode);
/*
 * Class to do all linkpoint
 * linkpoint Version 1.0
 */
class linkpoint
{
	/*
	 * Constructor
	 */
	function linkpoint($demo_mode= 0)
	{
		$this->demo_mode  = $demo_mode;
		$this->pay_url    = "https://www.linkpointcentral.com/lpc/servlet/lppay";
		if ($this->demo_mode)
        {
			$this->pay_url= "https://staging.linkpt.net/lpc/servlet/lppay";
        }
	}
	/*
	 * Function to send variables
	 */
	function sendVariables($path_url, $pp_vals)
	{
		$this->_POST1                         = array ();
		$this->_POST1['storename']            = $pp_vals['lp_storename'];
		$this->_POST1['chargetotal']          = number_format($_POST['gross_amount'],2);
		$this->_POST1['authenticateTransaction']= true;
		$this->_POST1['responseSuccessURL']   = $path_url."/OK.php";
        $this->_POST1['responseFailURL']      = $path_url."/NOK.php";
        $this->_POST1['responseURL']          = $path_url."/ipn.php";
		$this->_POST1['item_number']          = time().rand(0, 1000);
		if (isset ($_POST['force_inv_no']))
        {
			$this->_POST1['item_number'] = $_POST['force_inv_no'];
        }
		$this->_POST1['ponumber'] = $this->_POST1['item_number'];
		$this->_POST1['bname']    = $_POST['name'];
		$this->_POST1['baddr1']   = $_POST['address'];
		$this->_POST1['bcity']    = $_POST['city'];
		$this->_POST1['bstate']   = $_POST['state'];
		$this->_POST1['bzip']     = $_POST['zip'];
		$this->_POST1['bcountry'] = $_POST['country'];
		$this->_POST1['phone']    = $_POST['telephone'];
		$this->_POST1['email']    = $_POST['email'];
		$this->_POST1['gateway']  = "linkpoint";
	}
	/*
	 * IPN=Internet Payment Notifier
	 */
	function ipn(& $BL)
	{
		$this->item_number    = $_POST['ponumber'];
		$this->transaction_id = $_POST['oid'];
        $this->payment_status = $_POST['status'];
		if (!empty ($this->item_number) && !empty ($this->transaction_id) && $this->payment_status == "Approved" && $_POST['gateway'] == "linkpoint")
		{
			$BL->processTransaction($this->item_number, $this->transaction_id);
			return true;
		}
		return false;
	}
}
?>