shridhar Posted August 31, 2014 Share Posted August 31, 2014 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 More sharing options...
JoelWebsites Posted September 2, 2014 Share Posted September 2, 2014 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 Link to comment Share on other sites More sharing options...
shridhar Posted September 2, 2014 Author Share Posted September 2, 2014 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 More sharing options...
JoelWebsites Posted September 2, 2014 Share Posted September 2, 2014 (edited) You will need to check how the code is working on another module..Even I was trying to create a module but I have to still write the code for the response... I could provide you a reference that may be helpful..How do I send you the module for reference here? Edited September 2, 2014 by joeljfernandes (see edit history) Link to comment Share on other sites More sharing options...
prestashopninja Posted September 2, 2014 Share Posted September 2, 2014 (edited) This one might also be helpful: http://www.prestashop.com/forums/topic/139475-modulefree-universal-payment-module/ Edited September 2, 2014 by prestashopninja (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now