Skip to content

Commit

Permalink
Merge pull request #46 from omise/feature/1-offsite
Browse files Browse the repository at this point in the history
  • Loading branch information
nimid authored Apr 4, 2017
2 parents 948df4f + d8a372f commit b241fcd
Show file tree
Hide file tree
Showing 103 changed files with 2,653 additions and 4,763 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Change Log
==========

[1.4] 2017-04-04
---
- *`Added`* Support for [Internet Banking](https://www.omise.co/offsite-payment)
- *`Added`* Support SSL when create the URL link
- *`Updated`* Upgrade `omise-php` library to 2.7.1

[1.3] 2017-03-22
---
- *`Added`* Support new currencies, IDR, JPY and SGD.
Expand Down Expand Up @@ -39,4 +45,4 @@ Implemented the Omise services into OpenCart 1.5.x, The features are as follows:
- *`Added`* Implemented **Omise Charge API** (supported for `Authorize & Capture` method only).
- *`Added`* Added **Omise Checkout Form** into OpenCart's checkout page.
- *`Added`* Added [omise-php](https://github.com/omise/omise-php) library *(v2.1.2)* into this extension.
- *`Added`* Added **README.md** file.
- *`Added`* Added **README.md** file.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The steps below are the method to install the extension manually. This method re
<p align="center"><img alt="Payments menu" src="https://omise-cdn.s3.amazonaws.com/assets/omise-opencart/omise-opencart-install-02.png"></p>

4. Look for **Omise Payment Gateway** and click **Install**.
<p align="center"><img alt="Install Omise Payment Gateway extension menu" src="https://omise-cdn.s3.amazonaws.com/assets/omise-opencart/omise-opencart-install-03.png"></p>
<p align="center"><img alt="Install Omise Payment Gateway extension menu" src="https://cloud.githubusercontent.com/assets/245383/24483141/43460fda-1520-11e7-80ec-326343a4e12e.png"></p>

### First Time Setup

Expand Down Expand Up @@ -58,6 +58,21 @@ The table below is the settings for the extension and the description for each s

If the setting for `Enable test mode` has been checked, the `Test Keys` will be used. If the setting for `Enable test mode` has not been checked, the `Live Keys` will be used.

**Internet Banking**

1. Login to your administration side. From the top menu, go to **Extensions** > **Payments**.
<p align="center"><img alt="Payments menu" src="https://omise-cdn.s3.amazonaws.com/assets/omise-opencart/omise-opencart-install-02.png"></p>

2. Look for **Omise Payment Gateway - Internet Banking**, click **Edit** link.
<p align="center"><img alt="Edit Omise Payment Gateway - Internet Banking" src="https://cloud.githubusercontent.com/assets/245383/24483149/4ac72b7c-1520-11e7-8f57-2a9ba6cda6d6.png"></p>

3. In **Omise Payment Gateway - Internet Banking** setting page, enable the module by changing **Module Status** to **Enabled**

4. Click **Save**.
<p align="center"><img alt="Enable Omise Payment Gateway Internet Banking" src="https://cloud.githubusercontent.com/assets/245383/24483153/4d05dfa0-1520-11e7-8f4d-cad88778a4b0.png"></p>

> In order to enable **Omise Payment Gateway - Internet Banking**, **Omise Payment Gateway** must be installed and enabled.
## Contributing

Thanks for your interest in contributing to Omise OpenCart. We're looking forward to hearing your thoughts and willing to review your changes.
Expand Down
161 changes: 161 additions & 0 deletions src/admin/controller/payment/omise_offsite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<?php

class ControllerPaymentOmiseOffsite extends Controller {
/**
* Render Omise Payment Gateway - Internet Banking extension setting page
*
* @return void
*/
public function index() {
/**
* Prepare and loading necessary scripts.
*
*/
// Load model.
$this->load->model('setting/setting');

// Load language.
$this->language->load('payment/omise');
$this->language->load('payment/omise_offsite');

/**
* POST Request handle.
*
*/
if (($this->request->server['REQUEST_METHOD'] == 'POST')) {
if ($this->request->post['omise_offsite_status'] == 1 && $this->config->get('omise_status') != 1) {
$this->session->data['error'] = $this->language->get('error_need_omise_extension');
$this->data['input_error']['omise_offsite_status'] = $this->language->get('error_need_omise_extension');
} else {
$this->model_setting_setting->editSetting('omise_offsite', $this->request->post);
$this->data['input_error'] = array();
$this->data = array_merge($this->data, $this->request->post);

$this->session->data['success'] = $this->language->get('text_session_save');
$this->redirect($this->url->link('payment/omise_offsite', 'token=' . $this->session->data['token'], 'SSL'));
}
}

/**
* Language setup.
*
*/
$this->document->setTitle('Omise Payment Gateway Internet Banking Configuration');

// Set form label with language.
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['button_save'] = $this->language->get('text_button_save');
$this->data['button_cancel'] = $this->language->get('text_button_cancel');
$this->data['entry_order_status'] = $this->language->get('entry_order_status');
$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');

// Set action button.
$this->data['action'] = $this->url->link('payment/omise_offsite', 'token=' . $this->session->data['token'], 'SSL');
$this->data['cancel'] = $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL');

/**
* Page data setup.
*
*/
$this->data['omise_offsite_status'] = $this->config->get('omise_offsite_status');

/**
* Page setup.
*
*/
$this->_setBreadcrumb()
->_getSessionFlash();

/**
* Template setup.
*
*/
// Set template.
$this->template = 'payment/omise_offsite_setting.tpl';

// Include sub-template.
$this->children = array('common/header',
'common/footer');

// Render output.
$this->response->setOutput($this->render());
}

/**
* Set page breadcrumb
*
* @return self
*/
private function _setBreadcrumb($current = null) {
// Set Breadcrumbs.
$this->data['breadcrumbs'] = array();

$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => false,
);

$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_payment'),
'href' => $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => ' :: ',
);

$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('payment/omise_offsite', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => ' :: ',
);

if (!is_null($current)) {
$this->data['breadcrumbs'][] = $current;
}

return $this;
}

/**
* Get session flash from session variable and unset it
*
* @return self
*/
private function _getSessionFlash() {
$this->data['success'] = '';
if (isset($this->session->data['success'])) {
$this->data['success'] = $this->session->data['success'];

unset($this->session->data['success']);
}

$this->data['error'] = '';
if (isset($this->session->data['error'])) {
$this->data['error'] = $this->session->data['error'];

unset($this->session->data['error']);
}

return $this;
}

/**
* This method will fire when user click `install` button from `extension/payment` page
*
* @return void
*/
public function install() {
// Set `success` session if it completely done.
$this->session->data['success'] = 'Installed';
}

/**
* This method will fire when user click `Uninstall` button from `extension/payment` page
* Uninstall anything about Omise Payment Gateway module that installed.
*
* @return void
*/
public function uninstall() {
}
}
1 change: 1 addition & 0 deletions src/admin/language/english/payment/omise.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
$_['heading_title'] = 'Omise Payment Gateway';
$_['text_omise'] = '<a href="https://www.omise.co" target="_blank" style="border: 1px solid #EEEEEE; padding: 2px; width: 94px; max-height:25px; display: inline-block;" alt="Omise Payment Gateway"" title="Omise Payment Gateway"><img src="view/image/payment/omise-payment.png" alt="Omise Payment Gateway"" title="Omise Payment Gateway" style="max-height:18px;" /></a>';

/**
* General Message.
Expand Down
8 changes: 8 additions & 0 deletions src/admin/language/english/payment/omise_offsite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
// Module title
$_['heading_title'] = 'Omise Payment Gateway - Internet Banking';
$_['text_omise_offsite'] = '<a href="https://www.omise.co" target="_blank" style="border: 1px solid #EEEEEE; padding: 2px; width: 94px; max-height:25px; display: inline-block;" alt="Omise Payment Gateway"" title="Omise Payment Gateway"><img src="view/image/payment/omise-payment.png" alt="Omise Payment Gateway"" title="Omise Payment Gateway" style="max-height:18px;" /></a>';

// Errors
$_['error_need_omise_extension'] = 'Please install and enable <strong>Omise Payment Gateway</strong> extension before enabling <strong>Omise Payment Gateway - Internet Banking</strong> (check \'Setting\' tab).';
?>
12 changes: 11 additions & 1 deletion src/admin/model/payment/omise.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
// Define 'OMISE_USER_AGENT_SUFFIX'
if(!defined('OMISE_USER_AGENT_SUFFIX') && defined('VERSION'))
define('OMISE_USER_AGENT_SUFFIX', 'OmiseOpenCart/1.3 OpenCart/'.VERSION);
define('OMISE_USER_AGENT_SUFFIX', 'OmiseOpenCart/1.4 OpenCart/'.VERSION);

// Define 'OMISE_API_VERSION'
if(!defined('OMISE_API_VERSION'))
Expand Down Expand Up @@ -31,6 +31,16 @@ public function install()
`test_mode` tinyint NOT NULL DEFAULT 0,
PRIMARY KEY `id` (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");

/* Install omise_charge table */
$this->db->query(
"CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "omise_charge` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`order_id` INT(11) NOT NULL,
`omise_charge_id` CHAR(45) NOT NULL,
`date_added` DATETIME NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");

// Insert seed data into table.
$this->db->query("INSERT INTO `" .DB_PREFIX. "omise_gateway`
(`id`, `public_key`, `secret_key`, `public_key_test`, `secret_key_test`, `test_mode`)
Expand Down
Binary file added src/admin/view/image/payment/omise-payment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions src/admin/view/template/payment/omise_offsite_setting.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
/**
* Include header.
*
*/
echo $header; ?>

<!-- Include Omise's stylesheet -->
<link rel="stylesheet" type="text/css" href="view/stylesheet/omise/omise-admin.css">

<div id="content">
<!-- Breadcrumb -->
<div class="breadcrumb">
<?php
foreach ($breadcrumbs as $breadcrumb):
echo $breadcrumb['separator'];
echo '<a href="'.$breadcrumb['href'].'">'.$breadcrumb['text'].'</a>';
endforeach;
?>
</div> <!-- /END .breadcrumb -->

<!-- Session flash box -->
<?php if ($success) echo '<div class="success">'.$success.'</div>'; ?>
<?php if ($error) echo '<div class="warning">'.$error.'</div>'; ?>

<!-- Content -->
<div class="box">
<div class="heading">
<h1><img src="view/image/payment.png" alt="" /> <?php echo $heading_title; ?></h1>
<div class="buttons">
<a onclick="$('#form').submit();" class="button"><?php echo $button_save; ?></a>
<a href="<?php echo $cancel; ?>" class="button"><?php echo $button_cancel; ?></a>
</div>
</div> <!-- /END .heading -->

<div class="content">
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
<!-- Module config -->
<h3>Module config</h3>
<table class="form">
<tr>
<td><?php echo $entry_status; ?></td>
<td>
<select name="omise_offsite_status">
<option value="1" <?php echo $omise_offsite_status ? 'selected="selected"' : ''; ?>><?php echo $text_enabled; ?></option>
<option value="0" <?php echo !$omise_offsite_status ? 'selected="selected"' : ''; ?>><?php echo $text_disabled; ?></option>
</select>
</td>
</tr>
</table>
</form>

<div class="text-right" style="margin-top: 40px;">
<a href="<?php echo $cancel; ?>" class="button">Back</a>
</div>
</div> <!-- /END .content -->
</div> <!-- /END .box -->
</div>

<?php
/**
* Include footer.
*
*/
echo $footer; ?>
2 changes: 1 addition & 1 deletion src/admin/view/template/payment/omise_setting.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ echo $header; ?>
</table>

<!-- Module config -->
<h3>Mudule config</h3>
<h3>Module config</h3>
<table class="form">
<tr>
<td><?php echo $entry_status; ?></td>
Expand Down
Loading

0 comments on commit b241fcd

Please sign in to comment.