Skip to content

Commit

Permalink
enable on other version
Browse files Browse the repository at this point in the history
  • Loading branch information
hakiemaul committed Dec 17, 2020
1 parent 7dd3783 commit e49c9b6
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 32 deletions.
27 changes: 23 additions & 4 deletions opencart1.5.x/upload/admin/controller/payment/xendit.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class ControllerPaymentXendit extends Controller
{
private $error = array();
private static $placeholder_sensitive_information = '********';

public function index()
{
Expand All @@ -14,6 +15,16 @@ public function index()
$this->load->model('localisation/order_status');

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
foreach ($this->request->post as $key => &$value) {
if ($value === self::$placeholder_sensitive_information) {
/**
* if value is placeholder, replace with current config value
*
* To prevent placeholder value stored as config value
*/
$value = $this->config->get($key);
}
}
$this->model_setting_setting->editSetting('xendit', $this->request->post);
$this->session->data['success'] = $this->language->get('text_success');

Expand Down Expand Up @@ -76,31 +87,39 @@ public function index()
if (isset($this->request->post['payment_xendit_test_public_key'])) {
$this->data['xendit_test_public_key'] = $this->request->post['payment_xendit_test_public_key'];
} elseif ($this->config->has('payment_xendit_test_public_key')) {
$this->data['xendit_test_public_key'] = $this->config->get('payment_xendit_test_public_key');
$this->data['xendit_test_public_key'] = $this->config->get('payment_xendit_test_public_key') === '' ?
$this->config->get('payment_xendit_test_public_key') :
self::$placeholder_sensitive_information;
} else {
$this->data['xendit_test_public_key'] = '';
}

if (isset($this->request->post['payment_xendit_live_public_key'])) {
$this->data['xendit_live_public_key'] = $this->request->post['payment_xendit_live_public_key'];
} elseif ($this->config->has('payment_xendit_live_public_key')) {
$this->data['xendit_live_public_key'] = $this->config->get('payment_xendit_live_public_key');
$this->data['xendit_live_public_key'] = $this->config->get('payment_xendit_live_public_key') === '' ?
$this->config->get('payment_xendit_live_public_key') :
self::$placeholder_sensitive_information;
} else {
$this->data['xendit_live_public_key'] = '';
}

if (isset($this->request->post['payment_xendit_test_secret_key'])) {
$this->data['xendit_test_secret_key'] = $this->request->post['payment_xendit_test_secret_key'];
} elseif ($this->config->has('payment_xendit_test_secret_key')) {
$this->data['xendit_test_secret_key'] = $this->config->get('payment_xendit_test_secret_key');
$this->data['xendit_test_secret_key'] = $this->config->get('payment_xendit_test_secret_key') === '' ?
$this->config->get('payment_xendit_test_secret_key') :
self::$placeholder_sensitive_information;
} else {
$this->data['xendit_test_secret_key'] = '';
}

if (isset($this->request->post['payment_xendit_live_secret_key'])) {
$this->data['xendit_live_secret_key'] = $this->request->post['payment_xendit_live_secret_key'];
} elseif ($this->config->has('payment_xendit_live_secret_key')) {
$this->data['xendit_live_secret_key'] = $this->config->get('payment_xendit_live_secret_key');
$this->data['xendit_live_secret_key'] = $this->config->get('payment_xendit_live_secret_key') === '' ?
$this->config->get('payment_xendit_live_secret_key') :
self::$placeholder_sensitive_information;
} else {
$this->data['xendit_live_secret_key'] = '';
}
Expand Down
27 changes: 23 additions & 4 deletions opencart2.0.x-2.2.x/upload/admin/controller/payment/xendit.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class Controllerpaymentxendit extends Controller
{
private $error = array();
private static $placeholder_sensitive_information = '********';

public function index()
{
Expand All @@ -14,6 +15,16 @@ public function index()
$this->load->model('localisation/order_status');

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
foreach ($this->request->post as $key => &$value) {
if ($value === self::$placeholder_sensitive_information) {
/**
* if value is placeholder, replace with current config value
*
* To prevent placeholder value stored as config value
*/
$value = $this->config->get($key);
}
}
$this->model_setting_setting->editSetting('xendit', $this->request->post);
$this->session->data['success'] = $this->language->get('text_success');

Expand Down Expand Up @@ -76,31 +87,39 @@ public function index()
if (isset($this->request->post['xendit_test_public_key'])) {
$data['xendit_test_public_key'] = $this->request->post['xendit_test_public_key'];
} elseif ($this->config->has('xendit_test_public_key')) {
$data['xendit_test_public_key'] = $this->config->get('xendit_test_public_key');
$data['xendit_test_public_key'] = $this->config->get('xendit_test_public_key') === '' ?
$this->config->get('xendit_test_public_key') :
self::$placeholder_sensitive_information;
} else {
$data['xendit_test_public_key'] = '';
}

if (isset($this->request->post['xendit_live_public_key'])) {
$data['xendit_live_public_key'] = $this->request->post['xendit_live_public_key'];
} elseif ($this->config->has('xendit_live_public_key')) {
$data['xendit_live_public_key'] = $this->config->get('xendit_live_public_key');
$data['xendit_live_public_key'] = $this->config->get('xendit_live_public_key') === '' ?
$this->config->get('xendit_live_public_key') :
self::$placeholder_sensitive_information;
} else {
$data['xendit_live_public_key'] = '';
}

if (isset($this->request->post['xendit_test_secret_key'])) {
$data['xendit_test_secret_key'] = $this->request->post['xendit_test_secret_key'];
} elseif ($this->config->has('xendit_test_secret_key')) {
$data['xendit_test_secret_key'] = $this->config->get('xendit_test_secret_key');
$data['xendit_test_secret_key'] = $this->config->get('xendit_test_secret_key') === '' ?
$this->config->get('xendit_test_secret_key') :
self::$placeholder_sensitive_information;
} else {
$data['xendit_test_secret_key'] = '';
}

if (isset($this->request->post['xendit_live_secret_key'])) {
$data['xendit_live_secret_key'] = $this->request->post['xendit_live_secret_key'];
} elseif ($this->config->has('xendit_live_secret_key')) {
$data['xendit_live_secret_key'] = $this->config->get('xendit_live_secret_key');
$data['xendit_live_secret_key'] = $this->config->get('xendit_live_secret_key') === '' ?
$this->config->get('xendit_live_secret_key') :
self::$placeholder_sensitive_information;
} else {
$data['xendit_live_secret_key'] = '';
}
Expand Down
27 changes: 23 additions & 4 deletions opencart2.3.x/upload/admin/controller/extension/payment/xendit.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class ControllerExtensionPaymentXendit extends Controller
{
private $error = array();
private static $placeholder_sensitive_information = '********';

public function index()
{
Expand All @@ -14,6 +15,16 @@ public function index()
$this->load->model('localisation/order_status');

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
foreach ($this->request->post as $key => &$value) {
if ($value === self::$placeholder_sensitive_information) {
/**
* if value is placeholder, replace with current config value
*
* To prevent placeholder value stored as config value
*/
$value = $this->config->get($key);
}
}
$this->model_setting_setting->editSetting('xendit', $this->request->post);
$this->session->data['success'] = $this->language->get('text_success');

Expand Down Expand Up @@ -75,31 +86,39 @@ public function index()
if (isset($this->request->post['xendit_test_public_key'])) {
$data['xendit_test_public_key'] = $this->request->post['xendit_test_public_key'];
} elseif ($this->config->has('xendit_test_public_key')) {
$data['xendit_test_public_key'] = $this->config->get('xendit_test_public_key');
$data['xendit_test_public_key'] = $this->config->get('xendit_test_public_key') === '' ?
$this->config->get('xendit_test_public_key') :
self::$placeholder_sensitive_information;
} else {
$data['xendit_test_public_key'] = '';
}

if (isset($this->request->post['xendit_live_public_key'])) {
$data['xendit_live_public_key'] = $this->request->post['xendit_live_public_key'];
} elseif ($this->config->has('xendit_live_public_key')) {
$data['xendit_live_public_key'] = $this->config->get('xendit_live_public_key');
$data['xendit_live_public_key'] = $this->config->get('xendit_live_public_key') === '' ?
$this->config->get('xendit_live_public_key') :
self::$placeholder_sensitive_information;
} else {
$data['xendit_live_public_key'] = '';
}

if (isset($this->request->post['xendit_test_secret_key'])) {
$data['xendit_test_secret_key'] = $this->request->post['xendit_test_secret_key'];
} elseif ($this->config->has('xendit_test_secret_key')) {
$data['xendit_test_secret_key'] = $this->config->get('xendit_test_secret_key');
$data['xendit_test_secret_key'] = $this->config->get('xendit_test_secret_key') === '' ?
$this->config->get('xendit_test_secret_key') :
self::$placeholder_sensitive_information;
} else {
$data['xendit_test_secret_key'] = '';
}

if (isset($this->request->post['xendit_live_secret_key'])) {
$data['xendit_live_secret_key'] = $this->request->post['xendit_live_secret_key'];
} elseif ($this->config->has('xendit_live_secret_key')) {
$data['xendit_live_secret_key'] = $this->config->get('xendit_live_secret_key');
$data['xendit_live_secret_key'] = $this->config->get('xendit_live_secret_key') === '' ?
$this->config->get('xendit_live_secret_key') :
self::$placeholder_sensitive_information;
} else {
$data['xendit_live_secret_key'] = '';
}
Expand Down
32 changes: 12 additions & 20 deletions opencart3.0.x/upload/admin/controller/extension/payment/xendit.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,47 +83,39 @@ public function index()
if (isset($this->request->post['payment_xendit_test_public_key'])) {
$data['xendit_test_public_key'] = $this->request->post['payment_xendit_test_public_key'];
} elseif ($this->config->has('payment_xendit_test_public_key')) {
if ($this->config->get('payment_xendit_test_public_key') === '') {
$data['xendit_test_public_key'] = $this->config->get('payment_xendit_test_public_key');
} else {
$data['xendit_test_public_key'] = self::$placeholder_sensitive_information;
}
$data['xendit_test_public_key'] = $this->config->get('payment_xendit_test_public_key') === '' ?
$this->config->get('payment_xendit_test_public_key') :
self::$placeholder_sensitive_information;
} else {
$data['xendit_test_public_key'] = '';
}

if (isset($this->request->post['payment_xendit_live_public_key'])) {
$data['xendit_live_public_key'] = $this->request->post['payment_xendit_live_public_key'];
} elseif ($this->config->has('payment_xendit_live_public_key')) {
if ($this->config->get('payment_xendit_live_public_key') === '') {
$data['xendit_live_public_key'] = $this->config->get('payment_xendit_live_public_key');
} else {
$data['xendit_live_public_key'] = self::$placeholder_sensitive_information;
}
$data['xendit_live_public_key'] = $this->config->get('payment_xendit_live_public_key') === '' ?
$this->config->get('payment_xendit_live_public_key') :
self::$placeholder_sensitive_information;
} else {
$data['xendit_live_public_key'] = '';
}

if (isset($this->request->post['payment_xendit_test_secret_key'])) {
$data['xendit_test_secret_key'] = $this->request->post['payment_xendit_test_secret_key'];
} elseif ($this->config->has('payment_xendit_test_secret_key')) {
if ($this->config->get('payment_xendit_test_secret_key') === '') {
$data['xendit_test_secret_key'] = $this->config->get('payment_xendit_test_secret_key');
} else {
$data['xendit_test_secret_key'] = self::$placeholder_sensitive_information;
}
$data['xendit_test_secret_key'] = $this->config->get('payment_xendit_test_secret_key') === '' ?
$this->config->get('payment_xendit_test_secret_key') :
self::$placeholder_sensitive_information;
} else {
$data['xendit_test_secret_key'] = '';
}

if (isset($this->request->post['payment_xendit_live_secret_key'])) {
$data['xendit_live_secret_key'] = $this->request->post['payment_xendit_live_secret_key'];
} elseif ($this->config->has('payment_xendit_live_secret_key')) {
if ($this->config->get('payment_xendit_live_secret_key') === '') {
$data['xendit_live_secret_key'] = $this->config->get('payment_xendit_live_secret_key');
} else {
$data['xendit_live_secret_key'] = self::$placeholder_sensitive_information;
}
$data['xendit_live_secret_key'] = $this->config->get('payment_xendit_live_secret_key') === '' ?
$this->config->get('payment_xendit_live_secret_key') :
self::$placeholder_sensitive_information;
} else {
$data['xendit_live_secret_key'] = '';
}
Expand Down

0 comments on commit e49c9b6

Please sign in to comment.