Skip to content

Commit

Permalink
+new plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
feyzullahdemir committed Apr 18, 2023
1 parent cdb95bb commit fb26c83
Show file tree
Hide file tree
Showing 81 changed files with 1,640 additions and 2,100 deletions.
Binary file added .DS_Store
Binary file not shown.
26 changes: 0 additions & 26 deletions README.md

This file was deleted.

Binary file not shown.
138 changes: 0 additions & 138 deletions opencart-test-suite/tests/admin/SampleAdminTest.php

This file was deleted.

28 changes: 0 additions & 28 deletions opencart-test-suite/tests/catalog/Sample2Test.php

This file was deleted.

25 changes: 0 additions & 25 deletions opencart-test-suite/tests/catalog/SampleTest.php

This file was deleted.

Binary file added paywithiyzico/admin/.DS_Store
Binary file not shown.
Binary file added paywithiyzico/admin/controller/.DS_Store
Binary file not shown.
Binary file not shown.
146 changes: 146 additions & 0 deletions paywithiyzico/admin/controller/payment/paywithiyzico.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?php
namespace Opencart\Admin\Controller\Extension\paywithiyzico\Payment;
use stdClass;
class paywithiyzico extends \Opencart\System\Engine\Controller
{

private $module_version = '1.0';
private $module_product_name = 'starter-1.0';

private $error = array();

private $fields = array(
array(
'validateField' => 'blank',
'name' => 'payment_paywithiyzico_status',
),
array(
'validateField' => 'error_order_status',
'name' => 'payment_paywithiyzico_order_status',
),
array(
'validateField' => 'error_cancel_order_status',
'name' => 'payment_paywithiyzico_order_cancel_status',
)

);


public function install() {

$this->load->model('extension/paywithiyzico/payment/paywithiyzico');
$this->model_extension_paywithiyzico_payment_paywithiyzico->install();
$this->model_setting_event->addEvent('pwi_logo_css_for_order_history', 'catalog/controller/common/footer/after', 'extension/payment/paywithiyzico/injectPwiLogoCss');
}

public function uninstall() {

$this->load->model('extension/paywithiyzico/payment/paywithiyzico');
$this->model_extension_paywithiyzico_payment_paywithiyzico->uninstall();
$this->model_setting_event->deleteEventByCode('pwi_logo_css_for_order_history');
}

public function index(): void {

$this->load->language('extension/paywithiyzico/payment/paywithiyzico');
$this->load->model('setting/setting');
$this->load->model('user/user');
$this->load->model('extension/paywithiyzico/payment/paywithiyzico');

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {

$request = $this->requestIyzico($this->request->post,'add','');

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



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

/* Get Order Status */
$this->load->model('localisation/order_status');
$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment');


$data['action'] = $this->url->link('extension/paywithiyzico/payment/paywithiyzico', 'user_token=' . $this->session->data['user_token'], true);
$data['heading_title'] = $this->language->get('heading_title');
$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
$data['locale'] = $this->language->get('code');
$data['version'] = $this->module_version;
$data['pwi_module_logo']=$this->language->get('pwi_module_setting_logo');


foreach ($this->fields as $key => $field) {

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

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


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

protected function validate() {

if (!$this->user->hasPermission('modify', 'extension/paywithiyzico/payment/paywithiyzico')) {
$this->error['warning'] = $this->language->get('error_permission');
}

foreach ($this->fields as $key => $field) {

if($field['validateField'] != 'blank') {

if (!$this->request->post[$field['name']]){
$this->error[$field['validateField']] = $this->language->get($field['validateField']);
}
}

}

return !$this->error;
}

public function requestIyzico($request,$method_type,$extra_request = false) {

$request_modify = array();

if ($method_type == 'add') {


foreach ($this->fields as $key => $field) {

if(isset($request[$field['name']])) {

if($field['name'] == 'payment_paywithiyzico_api_key' || $field['name'] == 'payment_paywithiyzico_secret_key')
$request[$field['name']] = str_replace(' ','',$request[$field['name']]);

$request_modify[$field['name']] = $request[$field['name']];

}

}


}



return $request_modify;
}



}
Binary file added paywithiyzico/admin/language/.DS_Store
Binary file not shown.
Binary file added paywithiyzico/admin/language/en-gb/.DS_Store
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit fb26c83

Please sign in to comment.