Jump to content

Creating a Payment Gateway Module For my Company -Billdesk


shridhar

Recommended Posts

Hi,

 

I am looking for guide to create a payment module for my company

 

I want to know all the factors that are to be kept in mind while creating the module , also i want to know the complete process of transaction that happens with prestashop.

 

here is the code that i have done till now.

 

Please guide me through the next steps and please suggest if there are any other changes that are to be done in the current code.

<?php 


class billdesk extends PaymentModule

{

	private	$_html = '';

	private $_postErrors = array();

	static $params1;

	public function __construct()

	{

		$this->name = 'billdesk';

		$this->tab = 'payments_gateways';

		$this->version = '1.0';

		$this->author = "Shridhar";

		$this->currencies = true;

		$this->currencies_mode = 'radio';



		parent::__construct();

		$this->page = basename(__FILE__, '.php');

		$this->displayName = $this->l('BillDESK');

        $this->description = $this->l('Accepts payments by BillDesk');

		$this->confirmUninstall = $this->l('Are you sure you want to delete your details ?');

	}

	public function install()

	{

		if (!parent::install()

			OR !$this->createPaymentcardtbl() 

            OR !$this->registerHook('invoice')

			OR !$this->registerHook('payment')

			OR !$this->registerHook('paymentReturn'))

			return false;

		return true;

	}

	public function uninstall()

	{

		if (!parent::uninstall())

			return false;

		return true;

	}
	public function getcustomerid()

	{

		$id = (int)$this->context->cookie->id_customer;

		return $id;

	}	

	public function getbilldeskUrl()

	{

		return "billdesk uri";

	}

	public function getContent()

	{

		$this->_html = '<h2>Global Business Center Payment Dev - BillDesk</h2>';

		if (isset($_POST['submitbilldesk']))

		{

			if (empty($_POST['business']))

				$this->_postErrors[] = $this->l('BillDesk Merchant id is required.');

			if (!sizeof($this->_postErrors))

			{

				$this->displayConf();

			}

			else

				$this->displayErrors();

		}



		

		$this->displayFormSettings();

		return $this->_html;

	}

	public function displayConf()

	{

		$this->_html .= '

		<div class="conf confirm">

			<img src="../img/admin/ok.gif" alt="'.$this->l('Confirmation').'" />

			'.$this->l('Settings updated').'

		</div>';

	}

	public function displayErrors()

	{

		$nbErrors = sizeof($this->_postErrors);

		$this->_html .= '

		<div class="alert error">

			<h3>'.($nbErrors > 1 ? $this->l('There are') : $this->l('There is')).' '.$nbErrors.' '.($nbErrors > 1 ? $this->l('errors') : $this->l('error')).'</h3>

			<ol>';

		foreach ($this->_postErrors AS $error)

			$this->_html .= '<li>'.$error.'</li>';

		$this->_html .= '

			</ol>

		</div>';

	}

	public function displayFormSettings()

	{

		//$conf = Configuration::getMultiple(array('BILLDESK_MERCHANT_ID'));

		//$business = array_key_exists('business', $_POST) ? $_POST['business'] : (array_key_exists('BILLDESK_MERCHANT_ID', $conf) ? $conf['BILLDESK_MERCHANT_ID'] : '');

		

		$this->_html .= '

		<form action="'.$_SERVER['REQUEST_URI'].'" method="post" style="clear: both;">

		<fieldset>

			<legend><img src="../img/admin/contact.gif" />'.$this->l('Settings').'</legend>

			<label>'.$this->l('BillDesk merchant id').'</label>

			<div class="margin-form"><input type="text" size="33" name="business" value="'.htmlentities($business, ENT_COMPAT, 'UTF-8').'" /></div>

			<br /><center><input type="submit" name="submitbilldesk" value="'.$this->l('Update settings').'" class="button" /></center>

		</fieldset>

		</form><br /><br />

		';

	}

	function hookPayment($params)

	{

		global $smarty;
 	

		$smarty->assign(array(

		            'this_path' => $this->_path,

		            'this_path_ssl' => Configuration::get('PS_FO_PROTOCOL').$_SERVER['HTTP_HOST'].__PS_BASE_URI__."modules/{$this->name}/"));

 

	return $this->display(__FILE__, 'payment.tpl');

	}
	

}



 ?>
Link to comment
Share on other sites

You will need to send the variables to your payment gateway ...and once the payment is sucessful they wil send you some response variables....you will need to update your orders also you will have to empty the user cart

 

 

Also will you please tell me the exact process to update the orders and empty the cart any example that i can see to make it work

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...