<?php
/*
 * ##################################################################
 * Created on: Jul 28, 2005
 * File name:  wmtransfer.php 
 * ##################################################################
 * This code is a sole property of netenberg.com 
 * ##################################################################
 */
$name       = "WebMoney Transfer";
$wmtransfer = array (
                array ("Merchant's purse"   , "purse_id"), 
                array ("Active"             , "active", "No", "Yes"), 
                array ("Title"              , "title")
                );
$send_method= "POST";
$pay        = new wmtransfer($demo_mode);
/*
 * Class to do all wmtransfer
 * wmtransfer Version 1.0
 */
class wmtransfer
{
	/*
	 * Constructor
	 */
	function wmtransfer($demo_mode)
	{
		$this->demo_mode  = $demo_mode;
		$this->pay_url    = "https://merchant.wmtransfer.com/lmi/payment.asp";
	}
	/*
	 * Function to send variables
	 */
	function sendVariables($path_url, $pp_vals)
	{
		$this->_POST1                         = array ();
		$this->_POST1['LMI_PAYEE_PURSE']      = $pp_vals['purse_id'];
		$this->_POST1['LMI_PAYMENT_DESC']     = $_POST['desc'];
		$this->_POST1['LMI_PAYMENT_AMOUNT']   = number_format($_POST['gross_amount'],2);
		$this->_POST1['LMI_RESULT_URL']       = $path_url."/ipn.php";
		$this->_POST1['LMI_SUCCESS_URL']      = $path_url."/OK.php";
		$this->_POST1['LMI_FAIL_URL']         = $path_url."/NOK.php";
		$this->_POST1['LMI_SUCCESS_METHOD']   = 1;
		if ($this->demo_mode)
        {
			$this->_POST1['LMI_SIM_MODE'] = 1;
        }
		$this->_POST1['P_METHOD']     = "WMT";
		$this->_POST1['item_number']  = time().rand(0, 1000);
		if (isset ($_POST['force_inv_no']))
        {
			$this->_POST1['item_number'] = $_POST['force_inv_no'];
        }
		$this->_POST1['PP']   = "wmtransfer";
	}
	/*
	 * IPN=Internet Payment Notifier
	 */
	function ipn(& $BL)
	{
		$this->item_number    = $_POST['item_number'];
		$this->transaction_id = $_POST['LMI_SYS_TRANS_NO'];
		$this->payment_status = "OK";
		if (!empty ($this->item_number) && !empty ($this->transaction_id) && $_POST['PP'] == "wmtransfer")
		{
			$BL->processTransaction($this->item_number, $this->transaction_id);
			return true;
		}
		return false;
	}
}
?>