Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions OpenCart 3.x — API 2.0/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Платежный модуль TRANZZO для CMS OpenCart 3.x

Тестировался модуль на CMS OpenCart 3.0.2.0

### Установка
1. Создать архив **tranzzo.ocmod.zip**, добавить в архив папку **upload**
2. Установить модуль через установщик дополнений, в панели управления зайти в раздел меню _**Дополнения → Установка дополнений**_.
3. Открыть панель управления Вашего сайта и выбрать в меню _**Дополнения → Дополнения**_ , выберать тип дополнения "Платежи".
4. Найдите строчку со способом оплаты TRANZZO и нажмите "Установить".

### Настройка
1. Получите ключи авторизации и идентификации сервиса TRANZZO (*POS_ID, API_KEY, API_SECRET, ENDPOINTS_KEY*).
2. После установки модуля, на странице списка способов оплаты, нажмите "Редактировать".
3. Настройте способ оплаты, заполнив все необходимые поля.
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
<?php

class ControllerExtensionPaymentTranzzo extends Controller
{
private $error = array();

public function index()
{
$this->load->language('extension/payment/tranzzo');
$this->document->setTitle($this->language->get('heading_title'));
$data = $this->language->all();

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

$this->model_setting_setting->editSetting('payment_tranzzo', $this->request->post);

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

$this->response->redirect($this->url->link('extension/payment/tranzzo', 'user_token=' . $this->session->data['user_token']. '&type=payment', true));
}

if (isset($this->session->data['success'])) {
$data['success'] = $this->session->data['success'];
unset($this->session->data['success']);
} else {
$data['success'] = '';
}

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

if (isset($this->error['pos_id'])) {
$data['error_pos_id'] = $this->error['pos_id'];
} else {
$data['error_pos_id'] = '';
}

if (isset($this->error['api_key'])) {
$data['error_api_key'] = $this->error['api_key'];
} else {
$data['error_api_key'] = '';
}
if (isset($this->error['api_secret'])) {
$data['error_api_secret'] = $this->error['api_secret'];
} else {
$data['error_api_secret'] = '';
}
if (isset($this->error['endpoints_key'])) {
$data['error_endpoints_key'] = $this->error['endpoints_key'];
} else {
$data['error_endpoints_key'] = '';
}

if (isset($this->error['order_status'])) {
$data['error_order_status'] = $this->error['order_status'];
} else {
$data['error_order_status'] = '';
}

if (isset($this->error['order_status_complete_id'])) {
$data['error_order_status_complete_id'] = $this->error['order_status_complete_id'];
} else {
$data['error_order_status_complete_id'] = '';
}
if (isset($this->error['order_status_failure_id'])) {
$data['error_order_status_failure_id'] = $this->error['order_status_failure_id'];
} else {
$data['error_order_status_failure_id'] = '';
}
if (isset($this->error['order_status_listen'])) {
$data['error_order_status_listen'] = $this->error['order_status_listen'];
} else {
$data['error_order_status_listen'] = '';
}

//new
if (isset($this->error['order_status_auth_id'])) {
$data['error_order_status_auth_id'] = $this->error['order_status_auth_id'];
} else {
$data['error_order_status_auth_id'] = '';
}
//new

$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_extension'),
'href' => $this->url->link('extension/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('extension/payment/tranzzo', 'user_token=' . $this->session->data['user_token'], true)
);

$data['action'] = $this->url->link('extension/payment/tranzzo', 'user_token=' . $this->session->data['user_token'], true);

$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true);

$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');

$data = $this->prepareSettings($data);

$data['user_token'] = $this->session->data['user_token'];

$this->response->setOutput($this->load->view('extension/payment/tranzzo', $data));

}

public function prepareSettings($data)
{
$this->load->model('localisation/order_status');
$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();

$this->load->model('localisation/geo_zone');
$data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();

if (isset($this->request->post['payment_tranzzo_geo_zone_id'])) {
$data['payment_tranzzo_geo_zone_id'] = $this->request->post['payment_tranzzo_geo_zone_id'];
} else {
$data['payment_tranzzo_geo_zone_id'] = $this->config->get('payment_tranzzo_geo_zone_id');
}

if (isset($this->request->post['payment_tranzzo_sort_order'])) {
$data['payment_tranzzo_sort_order'] = $this->request->post['payment_tranzzo_sort_order'];
} else {
$data['payment_tranzzo_sort_order'] = $this->config->get('payment_tranzzo_sort_order');
}

if (isset($this->request->post['payment_tranzzo_pos_id'])) {
$data['payment_tranzzo_pos_id'] = $this->request->post['payment_tranzzo_pos_id'];
} else {
$data['payment_tranzzo_pos_id'] = $this->config->get('payment_tranzzo_pos_id');
}
if (isset($this->request->post['payment_tranzzo_api_secret'])) {
$data['payment_tranzzo_api_secret'] = $this->request->post['payment_tranzzo_api_secret'];
} else {
$data['payment_tranzzo_api_secret'] = $this->config->get('payment_tranzzo_api_secret');
}
if (isset($this->request->post['payment_tranzzo_api_key'])) {
$data['payment_tranzzo_api_key'] = $this->request->post['payment_tranzzo_api_key'];
} else {
$data['payment_tranzzo_api_key'] = $this->config->get('payment_tranzzo_api_key');
}
if (isset($this->request->post['payment_tranzzo_endpoints_key'])) {
$data['payment_tranzzo_endpoints_key'] = $this->request->post['payment_tranzzo_endpoints_key'];
} else {
$data['payment_tranzzo_endpoints_key'] = $this->config->get('payment_tranzzo_endpoints_key');
}

if (isset($this->request->post['payment_tranzzo_status'])) {
$data['payment_tranzzo_status'] = $this->request->post['payment_tranzzo_status'];
} else {
$data['payment_tranzzo_status'] = $this->config->get('payment_tranzzo_status');
}
if (isset($this->request->post['payment_tranzzo_total'])) {
$data['payment_tranzzo_total'] = $this->request->post['payment_tranzzo_total'];
} else {
$data['payment_tranzzo_total'] = $this->config->get('payment_tranzzo_total');
}
if (isset($this->request->post['payment_tranzzo_order_status_complete_id'])) {
$data['payment_tranzzo_order_status_complete_id'] = $this->request->post['payment_tranzzo_order_status_complete_id'];
} else {
$data['payment_tranzzo_order_status_complete_id'] = $this->config->get('payment_tranzzo_order_status_complete_id');
}
if (isset($this->request->post['payment_tranzzo_order_status_failure_id'])) {
$data['payment_tranzzo_order_status_failure_id'] = $this->request->post['payment_tranzzo_order_status_failure_id'];
} else {
$data['payment_tranzzo_order_status_failure_id'] = $this->config->get('payment_tranzzo_order_status_failure_id');
}
if (isset($this->request->post['payment_tranzzo_order_status_listen'])) {
$data['payment_tranzzo_order_status_listen'] = $this->request->post['payment_tranzzo_order_status_listen'];
} else {
$data['payment_tranzzo_order_status_listen'] = $this->config->get('payment_tranzzo_order_status_listen');
}
//new
if (isset($this->request->post['payment_tranzzo_type_payment'])) {
$data['payment_tranzzo_type_payment'] = $this->request->post['payment_tranzzo_type_payment'];
} else {
$data['payment_tranzzo_type_payment'] = $this->config->get('payment_tranzzo_type_payment');
}
if (isset($this->request->post['payment_tranzzo_order_status_auth_id'])) {
$data['payment_tranzzo_order_status_auth_id'] = $this->request->post['payment_tranzzo_order_status_auth_id'];
} else {
$data['payment_tranzzo_order_status_auth_id'] = $this->config->get('payment_tranzzo_order_status_auth_id');
}

return $data;
}


protected function validate()
{
if (!$this->user->hasPermission('modify', 'extension/payment/tranzzo')) {
$this->error['warning'] = $this->language->get('error_permission');
}
if (!$this->request->post['payment_tranzzo_pos_id']) {
$this->error['pos_id'] = $this->language->get('error_pos_id');
}
if (!$this->request->post['payment_tranzzo_api_key']) {
$this->error['api_key'] = $this->language->get('error_api_key');
}
if (!$this->request->post['payment_tranzzo_api_secret']) {
$this->error['api_secret'] = $this->language->get('error_api_secret');
}
if (!$this->request->post['payment_tranzzo_endpoints_key']) {
$this->error['endpoints_key'] = $this->language->get('error_endpoints_key');
}
if (!$this->request->post['payment_tranzzo_order_status_complete_id']) {
$this->error['order_status_complete_id'] = $this->language->get('error_order_status_complete_id');
}
if (!$this->request->post['payment_tranzzo_order_status_failure_id']) {
$this->error['order_status_failure_id'] = $this->language->get('error_order_status_failure_id');
}

//new
if ($this->request->post['payment_tranzzo_type_payment'] && !$this->request->post['payment_tranzzo_order_status_auth_id']) {
$this->error['order_status_auth_id'] = $this->language->get('error_order_status_auth_id');
}
//new

$complete = (int)$this->request->post['payment_tranzzo_order_status_complete_id'];
//new
$auth = (int)$this->request->post['payment_tranzzo_order_status_auth_id'];
//new
$fail = (int)$this->request->post['payment_tranzzo_order_status_failure_id'];
if ($complete == $fail || $complete == $auth || $auth == $fail) {
$this->error['order_status'] = $this->language->get('error_order_status');
}

return !$this->error;
}

public function install()
{
$this->load->model('setting/event');

$this->model_setting_event->addEvent('tranzzo',
'catalog/model/checkout/order/addOrderHistory/before',
'extension/payment/tranzzo/tranzzoRefund'
);

//new
$this->load->model('extension/payment/tranzzo');
$this->model_extension_payment_tranzzo->install();
//new
}

public function uninstall()
{
$this->load->model('setting/event');
$this->model_setting_event->deleteEvent('tranzzo');

//new
$this->load->model('extension/payment/tranzzo');
$this->model_extension_payment_tranzzo->uninstall();
//new
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
// Heading
$_['heading_title'] = 'TRANZZO';

// Text
$_['text_success'] = 'Settings successfully changed!';
$_['text_edit'] = 'Edit';
$_['text_extension'] = 'Additions';
$_['text_tranzzo'] = '<a target="_BLANK" href="https://tranzzo.com/"><img src="view/image/payment/tranzzo.png" alt="TRANZZO" title="TRANZZO" /></a>';

// Entry
$_['entry_pos_id'] = 'POS_ID';
$_['entry_api_key'] = 'API_KEY';
$_['entry_api_secret'] = 'API_SECRET';
$_['entry_endpoints_key'] = 'ENDPOINTS_KEY';
$_['entry_status'] = 'Status';
$_['entry_total'] = 'Lower bound';
$_['entry_order_status_complete'] = 'Order status after payment';
$_['entry_order_status_failure'] = 'Order status in case of failure';
$_['entry_order_status_listen'] = 'Order status for refund';
$_['entry_geo_zone'] = 'Geographical area';
$_['entry_sort_order'] = 'Sorting order';
//new
$_['error_type_payment'] = 'type_payment';
$_['entry_order_status_auth'] = 'Order status after auth payment';
//new

// Error
$_['error_permission'] = 'You are not authorized to manage this module!';
$_['error_pos_id'] = 'It is necessary to fill POS_ID!';
$_['error_api_key'] = 'You must fill API_KEY!';
$_['error_api_secret'] = 'API_SECRET must be filled!';
$_['error_endpoints_key'] = 'You need to fill ENDPOINTS_KEY!';
$_['error_order_status'] = 'Selected statuses can not be the same';
$_['error_order_status_complete_id'] = 'You must select a status';
$_['error_order_status_failure_id'] = 'You must select a status';
$_['error_order_status_listen'] = 'You must select a status';
//new
$_['error_order_status_auth_id'] = 'You must select a status';
//new

// Help
$_['help_total'] = 'The minimum order amount. Below this amount, the payment method will not be available.';
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
// Heading
$_['heading_title'] = 'TRANZZO';

// Text
$_['text_success'] = 'Настройки успешно изменены!';
$_['text_edit'] = 'Редактирование';
$_['text_refresh'] = 'Обновить';
$_['text_extension'] = 'Дополнения';
$_['text_tranzzo'] = '<a target="_BLANK" href="https://tranzzo.com/"><img src="view/image/payment/tranzzo.png" alt="TRANZZO" title="TRANZZO" /></a>';

// Entry
$_['entry_pos_id'] = 'POS_ID';
$_['entry_api_key'] = 'API_KEY';
$_['entry_api_secret'] = 'API_SECRET';
$_['entry_endpoints_key'] = 'ENDPOINTS_KEY';
$_['entry_status'] = 'Статус';
$_['entry_total'] = 'Нижняя граница';
$_['entry_order_status_complete'] = 'Статус заказа после оплаты';
$_['entry_order_status_failure'] = 'Статус заказа в случае неудачи';
$_['entry_order_status_listen'] = 'Статус заказа для возврата средств';
$_['entry_geo_zone'] = 'Географическая зона';
$_['entry_sort_order'] = 'Порядок сортировки';
//new
$_['entry_type_payment'] = 'Блокировка платежа';
$_['entry_order_status_auth'] = 'Статус заказа с заблокированной оплатой';
//new

// Error
$_['error_permission'] = 'У Вас нет прав для управления данным модулем!';
$_['error_pos_id'] = 'Необходимо заполнить POS_ID!';
$_['error_api_key'] = 'Необходимо заполнить API_KEY!';
$_['error_api_secret'] = 'Необходимо заполнить API_SECRET!';
$_['error_endpoints_key'] = 'Необходимо заполнить ENDPOINTS_KEY!';
$_['error_order_status'] = 'Выбраные статусы немогу совпадать';
$_['error_order_status_complete_id'] = 'Необходимо выбрать статус';
$_['error_order_status_failure_id'] = 'Необходимо выбрать статус';
$_['error_order_status_listen'] = 'Необходимо выбрать статус';

// Help
$_['help_total'] = 'Минимальная сумма заказа. Ниже данной суммы, способ оплаты будет недоступен.';
Loading