Zaakpay Payment Gateway Integration – OpenCart Part 1 |
X

Congrats, You are Subscribed to Receive Updates.

Zaakpay Payment Gateway Integration – OpenCart Part 1


You can buy Premium Modules for Your OpenCart Store.  But here I just give you a simple way of integrating Zaakpay With your  OpenCart Online store. First and before going to initiate the tutorials Please feel free to donate some money for my time to prepare this tutorial to you.

zaakpay_opencart

And now, you are going to integrate Zaakpay to your opencart store. The very first step is to creating required files for your our new payment module.

/admin/controller/payment/zaakpay.php

/admin/language/english/payment/zaakpay.php

/admin/view/template/payment/zaakpay.tpl

/catalog/controller/payment/zaakpay.php

/catalog/controller/common/zaakpay.php

/catalog/model/payment/zaakpay.php

/catalog/language/english/payment/zaakpay.php

/catalog/language/english/common/zaakpay.php

/catalog/view/theme/default/template/payment/zaakpay.tpl

/catalog/view/theme/default/template/common/zaakpay.tpl

 

These are all the necessary files for our payment gateway integration. Than as-usual start writing of coding’s one by one.

First we are going to write admin sections, than followed to catalog(Front-End ) section. Open controller class file

<?php 
/*-------------------------------------------------------+
| Zaakpay Payment gateway integration - Opencart  
| https://www.kvcodes.com//2014/01/zaakpay-payment-gateway-integration-opencart/
+--------------------------------------------------------+
| Author: Varadharaj V  
| Email: varadharajv@kvcodes.com
+--------------------------------------------------------+*/
class ControllerPaymentZaakpay extends Controller {
	private $error = array(); 

	public function index() { 
		$this->load->language('payment/Zaakpay');

	$this->data['heading_title'] = $this->language->get('heading_title');
	$this->load->model('setting/setting');

		if (($this->request->server['REQUEST_METHOD'] == 'POST') && ($this->validate())) {
			$this->load->model('setting/setting');
			$this->model_setting_setting->editSetting('Zaakpay', $this->request->post);

			$this->session->data['success'] = $this->language->get('text_success');

			$this->redirect(HTTPS_SERVER .'index.php?route=extension/payment&token=' . $this->session->data['token']);
		}

		$this->data['heading_title'] = $this->language->get('heading_title');

		$this->data['text_enabled'] = $this->language->get('text_enabled');
		$this->data['text_disabled'] = $this->language->get('text_disabled');

		$this->data['entry_status'] = $this->language->get('entry_status');
		$this->data['merchantIdentifier'] = $this->language->get('merchantIdentifier');
		$this->data['secret_key'] = $this->language->get('secret_key');
		$this->data['mode'] = $this->language->get('mode');
		$this->data['log'] = $this->language->get('log');

		$this->data['entry_geo_zone'] = $this->language->get('entry_geo_zone');
		$this->data['text_all_zones'] = $this->language->get('text_all_zones');

$this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
		if (isset($this->request->post['merchantIdentifier'])) {
			$this->data['Zaakpay_merchantIdentifier'] = $this->request->post['Zaakpay_merchantIdentifier'];
		} else {
			$this->data['Zaakpay_merchantIdentifier'] = $this->config->get('Zaakpay_merchantIdentifier');
		}
		if (isset($this->request->post['Zaakpay_secret_key'])) {
			$this->data['Zaakpay_secret_key'] = $this->request->post['Zaakpay_secret_key'];
		} else {
			$this->data['Zaakpay_secret_key'] = $this->config->get('Zaakpay_secret_key');
		}

		if (isset($this->request->post['Zaakpay_test'])) {
			$this->data['Zaakpay_test'] = $this->request->post['Zaakpay_test'];
		} else {
			$this->data['Zaakpay_test'] = $this->config->get('Zaakpay_test');
		}
		if (isset($this->request->post['Zaakpay_log'])) {
			$this->data['Zaakpay_log'] = $this->request->post['Zaakpay_log'];
		} else {
			$this->data['Zaakpay_log'] = $this->config->get('Zaakpay_log');
		}
			if (isset($this->request->post['Zaakpay_status'])) {
			$this->data['Zaakpay_status'] = $this->request->post['Zaakpay_status'];
		} else {
			$this->data['Zaakpay_status'] = $this->config->get('Zaakpay_status');
		}
// newly added code for zone status for guest checkout
		if (isset($this->request->post['Zaakpay_geo_zone_id'])) {
			$this->data['Zaakpay_geo_zone_id'] = $this->request->post['Zaakpay_geo_zone_id'];
		} else {
			$this->data['Zaakpay_geo_zone_id'] = $this->config->get('Zaakpay_geo_zone_id'); 
		} 

		$this->load->model('localisation/geo_zone');

		$this->data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();
//end

		$this->data['text_yes'] = $this->language->get('text_yes');
		$this->data['text_no'] = $this->language->get('text_no');
		$this->data['button_save'] = $this->language->get('button_save');
		$this->data['button_cancel'] = $this->language->get('button_cancel');

		$this->data['tab_general'] = $this->language->get('tab_general');

	//	$this->data['error_warning'] = @$this->error['warning'];
if (isset($this->error['warning'])) {
			$this->data['error_warning'] = $this->error['warning'];
		} else {
			$this->data['error_warning'] = '';
		}

  		$this->document->breadcrumbs = array();

   		$this->document->breadcrumbs[] = array(
       		'href'      => HTTPS_SERVER .'index.php?route=common/home&token=' . $this->session->data['token'],
       		'text'      => $this->language->get('text_home'),
      		'separator' => FALSE
   		);

   		$this->document->breadcrumbs[] = array(
       		'href'      => 'https://api.zaakpay.com/transact',
       		'text'      => $this->language->get('text_payment'),
      		'separator' => ' :: '
   		);

   		$this->document->breadcrumbs[] = array(
       		'href'      => HTTPS_SERVER .'index.php?route=payment/Zaakpay&token=' . $this->session->data['token'],
       		'text'      => $this->language->get('heading_title'),
      		'separator' => ' :: '
   		);

		$this->data['action'] = HTTPS_SERVER .'index.php?route=payment/Zaakpay&token=' . $this->session->data['token'];

		$this->data['cancel'] = HTTPS_SERVER .'index.php?route=extension/payment&token=' . $this->session->data['token'];	

		//$this->id       = 'content';
		$this->template = 'payment/Zaakpay.tpl';
		$this->layout   = 'common/layout';
		$this->children = array(
			'common/header',	
			'common/footer'	
		);

			$this->response->setOutput($this->render(TRUE));
	}

	private function validate() {
		if (!$this->user->hasPermission('modify', 'payment/Zaakpay')){
			$this->error['warning'] = $this->language->get('error_permission');
		}
		if (!$this->error) {
			return TRUE;
		} else {
			return FALSE;
		}	
	}
}
?>

Than open language class and copy paste the following code

<?php
/*-------------------------------------------------------+
| Zaakpay Payment gateway integration - Opencart  
| https://www.kvcodes.com//2014/01/zaakpay-payment-gateway-integration-opencart/
+--------------------------------------------------------+
| Author: Varadharaj V  
| Email: varadharajv@kvcodes.com
+--------------------------------------------------------+*/

// Heading
$_['heading_title']   = 'Zaakpay';

// Entry
$_['text_payment']		            	   = 'Payment';
$_['entry_status']                         = 'Status:';
$_['text_success']      				   = 'Success: You have modified Zaakpay payment module!';
$_['text_Zaakpay']	            		   = '<a onclick="window.open(\'http://www.zaakpay.com\');"><img src="https://www.zaakpay.com/images/zaakpaylogo.gif" alt="Zaakpay" title="Zaakpay" style="border: 1px solid #EEEEEE;" height=40 /></a>';

$_['merchantIdentifier']		 		   = 'Merchant Identifier:';
$_['secret_key']					 	   = 'Secret Key: ';
$_['mode']						   		   = 'Test Mode: ';
$_['log']     							   = 'Do you want to log:';
$_['entry_geo_zone']   					   = 'Geo Zone:';
// Error
$_['error_permission']                     = 'Warning: You do not have permission to modify payment Zaakpay!';

?>

 

Than open your View class Template file and copy paste the following codes into it.

 

<?php echo $header; ?>
<?php if ($error_warning) { ?>
<div class="warning"><?php echo $error_warning; ?></div>
<?php } ?>
<div class="heading">
  <h1><?php echo $heading_title; ?></h1>
 <div class="buttons"><a onclick="$('#form').submit();" class="button"><span class="button_left button_save"></span><span class="button_middle"><?php echo $button_save; ?></span><span class="button_right"></span></a><a onclick="location='<?php echo $cancel; ?>';" class="button"><span class="button_left button_cancel"></span><span class="button_middle"><?php echo $button_cancel; ?></span><span class="button_right"></span></a></div> 
</div>
<div class="tabs"><a tab="#tab_general"><?php echo $tab_general; ?></a></div>
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
  <div id="tab_general" class="page">
    <table class="form">

      <tr>
        <td><?php echo $entry_status; ?></td>
        <td><select name="Zaakpay_status">
            <?php if ($Zaakpay_status) { ?>
            <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
            <option value="0"><?php echo $text_disabled; ?></option>
            <?php } else { ?>
            <option value="1"><?php echo $text_enabled; ?></option>
            <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
            <?php } ?>
          </select></td>
      </tr>
      <tr>
        <td><?php echo $merchantIdentifier; ?></td>
        <td><input type="text" name="Zaakpay_merchantIdentifier" value="<?php echo $Zaakpay_merchantIdentifier; ?>" /></td>
      </tr>
	  <tr>
        <td><?php echo $secret_key; ?></td>
        <td><input type="text" name="Zaakpay_secret_key" value="<?php echo $Zaakpay_secret_key; ?>"  /></td>
      </tr>

       <tr>
        <td><?php echo $mode; ?></td> 

        <td> 
		<?php if($Zaakpay_test) { ?>
		<input type="checkbox" name="Zaakpay_test" checked=checked />
		<?php } else { ?>
		<input type="checkbox" name="Zaakpay_test" />
		<?php } ?>
		</td>
      </tr>
	   <tr>
        <td><?php echo $log; ?></td> 

        <td> 
		<?php if($Zaakpay_log) { ?>
		<input type="checkbox" name="Zaakpay_log" checked=checked />
		<?php } else { ?>
		<input type="checkbox" name="Zaakpay_log" />
		<?php } ?>
		</td>
      </tr>
	<tr>
            <td><?php echo $entry_geo_zone; ?></td>
            <td><select name="Zaakpay_geo_zone_id">
                <option value="0"><?php echo $text_all_zones; ?></option>
                <?php foreach ($geo_zones as $geo_zone) { ?>
                <?php if ($geo_zone['geo_zone_id'] == $Zaakpay_geo_zone_id) { ?>
                <option value="<?php echo $geo_zone['geo_zone_id']; ?>" selected="selected"><?php echo $geo_zone['name']; ?></option>
                <?php } else { ?>
                <option value="<?php echo $geo_zone['geo_zone_id']; ?>"><?php echo $geo_zone['name']; ?></option>
                <?php } ?>
                <?php } ?>
              </select></td>
          </tr>

    </table>
  </div>
</form>

<script type="text/javascript"><!--
$.tabs('.tabs a'); 
//--></script>
<?php echo $footer; ?>

That’s it for admin section to manage gateway settings. Than follow the next tutorial to configure out your front end. Next Catalog Codes

commenter

About Varadharaj V

The founder of Kvcodes, Varadharaj V is an ERP Analyst and a Web developer specializing in WordPress(WP), WP Theme development, WP Plugin development, Frontaccounting(FA), Sales, Purchases, Inventory, Ledgers, Payroll & HRM, CRM, FA Core Customization, PHP and Data Analyst. Database Management Advance Level

4 comments

  1. commenter

    Hi ,

    I got a permission denied on enabling the module and saving it.Please suggest.

    Thanks
    Vishal

  2. commenter

    good job .but i need some more help
    i need code for front end or can you tell me how to show it on front end

Comment Below

Your email address will not be published. Required fields are marked *

*

Current ye@r *

Menu

Sidebar