Skip to content

Commit 2aeebb6

Browse files
Merge pull request #4 from MichaelRotaru/master
CE-Phoenix distribution: Added logic to validate the public and private keys upon saving.
2 parents 60bfbda + 63fe6db commit 2aeebb6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+4335
-32
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
4141
```
4242
require_once('includes/modules/payment/paylike/errors.php');
4343
```
44-
Before 'require('includes/application_top.php');' line;
44+
Before require('includes/application_top.php'); line;
4545
4646
7.2.Add:
4747
```
4848
require_once('includes/modules/payment/paylike/validate.php');
4949
```
50-
After 'reset($HTTP_POST_VARS['configuration']);' line;
50+
After reset($HTTP_POST_VARS['configuration']); line;
5151
52-
7.3.Replace 'tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'");' line with:
52+
7.3.Replace tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'"); line with:
5353
```
5454
if(sizeof($errors) === 0 || array_search($key, $validation_keys) === FALSE){
5555
tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'");
@@ -62,13 +62,13 @@ Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
6262
tep_redirect(tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $HTTP_GET_VARS['module'] . '&action=edit'));
6363
}
6464
```
65-
Before 'tep_redirect(tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $HTTP_GET_VARS['module']));' line;
65+
Before tep_redirect(tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $HTTP_GET_VARS['module'])); line;
6666
6767
7.5.Add:
6868
```
6969
if(isset($errorHandler))$errorHandler->display();
7070
```
71-
After 'case 'edit':' line.
71+
After case 'edit': line.
7272
8. Install the Paylike module from modules -> payment in the admin
7373
9. Insert the app key and your public key in the settings and enable the plugin
7474

README_CE-Phoenix-2341-Frozen.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
4242
```
4343
require_once('includes/modules/payment/paylike/errors.php');
4444
```
45-
Before 'require('includes/application_top.php');' line;
45+
Before require('includes/application_top.php'); line;
4646
4747
7.2.Add:
4848
```
4949
require_once('includes/modules/payment/paylike/validate.php');
5050
```
51-
After 'case 'save':' line;
51+
After case 'save': line;
5252
5353
7.3.Replace 'tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'");' line with:
5454
```
@@ -63,13 +63,13 @@ Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
6363
tep_redirect(tep_href_link('modules.php', 'set=' . $set . '&module=' . $HTTP_GET_VARS['module'] . '&action=edit'));
6464
}
6565
```
66-
Before 'tep_redirect(tep_href_link('modules.php', 'set=' . $set . '&module=' . $_GET['module']));' line;
66+
Before tep_redirect(tep_href_link('modules.php', 'set=' . $set . '&module=' . $_GET['module'])); line;
6767
6868
7.5.Add:
6969
```
7070
if(isset($errorHandler))$errorHandler->display();
7171
```
72-
After 'case 'edit':' line.
72+
After case 'edit': line.
7373
8. Install the Paylike module from modules -> payment in the admin
7474
9. Insert the app key and your public key in the settings and enable the plugin
7575

README_Phoenix.md

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ available by a user.
55

66
Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
77

8-
98
## Supported osCommerce versions
109

1110
*The plugin has been tested with osCommerce v.2.3.4.1 and osCommerce CE Phoenix
@@ -25,8 +24,8 @@ Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
2524
<script src="https://sdk.paylike.io/3.js"></script>
2625
<script src= "includes/javascript/paylike.js"></script>
2726
<?php
28-
}
29-
?>
27+
}
28+
?>
3029
```
3130
Anywhere betwen the `head` tags.
3231
6. In: `includes/.htaccess` add:
@@ -37,9 +36,41 @@ Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
3736
3837
```
3938
After the last line.
40-
7. Install the Paylike module from modules -> payment in the admin
41-
8. Insert the app key and your public key in the settings and enable the plugin
39+
7. In: `admin/modules.php`
40+
7.1.Add:
41+
```
42+
require_once('includes/modules/payment/paylike/errors.php');
43+
```
44+
Before require 'includes/application_top.php'; line;
45+
46+
7.2.Add:
47+
```
48+
require_once('includes/modules/payment/paylike/validate.php');
49+
```
50+
After case 'save': line;
51+
52+
7.3.Replace tep_db_query("UPDATE configuration SET configuration_value = '" . tep_db_input($value) . "' WHERE configuration_key = '" . tep_db_input($key) . "'"); line with:
53+
```
54+
if(sizeof($errors) === 0 || array_search($key, $validation_keys) === FALSE){
55+
tep_db_query("UPDATE configuration SET configuration_value = '" . tep_db_input($value) . "' WHERE configuration_key = '" . tep_db_input($key) . "'");
56+
}
57+
```
4258
59+
7.4.Add:
60+
```
61+
if(sizeof($errors)){
62+
tep_redirect(tep_href_link('modules.php', 'set=' . $set . '&module=' . $_GET['module'] . '&action=edit'));
63+
}
64+
```
65+
Before tep_redirect(tep_href_link('modules.php', 'set=' . $set . '&module=' . $_GET['module'])); line;
66+
67+
7.5.Add:
68+
```
69+
<?php if(isset($errorHandler))$errorHandler->display(); ?>
70+
```
71+
Before <div class="row no-gutters"> line.
72+
8. Install the Paylike module from modules -> payment in the admin
73+
9. Insert the app key and your public key in the settings and enable the plugin
4374
4475
## Updating settings
4576

upload/admin/includes/modules/payment/paylike/composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"name": "esparks/module-paylike",
3-
"description": "Paylike integration with payment gateway prestashop",
4-
"type": "prestashop-module",
2+
"name": "paylike/module-paylike",
3+
"description": "Paylike integration with payment gateway oscommerce",
4+
"type": "oscommerce-module",
55
"version": "1.0.6",
66
"license": [
77
"GPL-3.0-or-later"
88
],
99
"authors": [
1010
{
11-
"name": "Ionut Calara",
12-
"email": "ionut.calara@gmail.com"
11+
"name": "Genuineq",
12+
"email": "office@genuineq.com"
1313
}
1414
],
1515
"require": {

upload/admin/includes/modules/payment/paylike/helpers/Paylike_Keys_Validator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function validateAppKeyField($value, $mode)
2727
/** Load the identity from API**/
2828
$identity = $paylikeClient->apps()->fetch();
2929
} catch (\Paylike\Exception\ApiException $exception) {
30-
$this->logMessage(sprintf(ERROR_APP_KEY_INVALID, $mode));
30+
self::logMessage(sprintf(ERROR_APP_KEY_INVALID, $mode));
3131
return sprintf(ERROR_APP_KEY_INVALID, $mode);
3232
}
3333

@@ -43,13 +43,13 @@ public function validateAppKeyField($value, $mode)
4343
}
4444
}
4545
} catch (\Paylike\Exception\ApiException $exception) {
46-
$this->logMessage(sprintf(ERROR_APP_KEY_INVALID, $mode));
46+
self::logMessage(sprintf(ERROR_APP_KEY_INVALID, $mode));
4747
}
4848
/** Check if public keys array for the current mode is populated **/
4949
if (empty($this->validationPublicKeys[$mode])) {
5050
/** Generate the error based on the current mode **/
5151
$error = sprintf(ERROR_APP_KEY_INVALID_MODE, $mode, array_values(array_diff(array_keys($this->validationPublicKeys), array($mode)))[0]);
52-
$this->logMessage($error);
52+
self::logMessage($error);
5353
return $error;
5454
}
5555
}
@@ -71,7 +71,7 @@ public function validatePublicKeyField($value, $mode)
7171
/** Check if the local stored public keys array is empty OR the key is not in public keys list **/
7272
if (empty($this->validationPublicKeys[$mode]) || ! in_array($value, $this->validationPublicKeys[$mode])) {
7373
$error = sprintf(ERROR_PUBLIC_KEY_INVALID, $mode);
74-
$this->logMessage($error);
74+
self::logMessage($error);
7575
return $error;
7676
}
7777
}

upload_CE-Phoenix-2341-Frozen/admin/includes/modules/payment/paylike/composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"name": "esparks/module-paylike",
3-
"description": "Paylike integration with payment gateway prestashop",
4-
"type": "prestashop-module",
2+
"name": "paylike/module-paylike",
3+
"description": "Paylike integration with payment gateway oscommerce",
4+
"type": "oscommerce-module",
55
"version": "1.0.6",
66
"license": [
77
"GPL-3.0-or-later"
88
],
99
"authors": [
1010
{
11-
"name": "Ionut Calara",
12-
"email": "ionut.calara@gmail.com"
11+
"name": "Genuineq",
12+
"email": "office@genuineq.com"
1313
}
1414
],
1515
"require": {

upload_CE-Phoenix-2341-Frozen/admin/includes/modules/payment/paylike/helpers/Paylike_Keys_Validator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function validateAppKeyField($value, $mode)
2727
/** Load the identity from API**/
2828
$identity = $paylikeClient->apps()->fetch();
2929
} catch (\Paylike\Exception\ApiException $exception) {
30-
$this->logMessage(sprintf(ERROR_APP_KEY_INVALID, $mode));
30+
self::logMessage(sprintf(ERROR_APP_KEY_INVALID, $mode));
3131
return sprintf(ERROR_APP_KEY_INVALID, $mode);
3232
}
3333

@@ -43,13 +43,13 @@ public function validateAppKeyField($value, $mode)
4343
}
4444
}
4545
} catch (\Paylike\Exception\ApiException $exception) {
46-
$this->logMessage(sprintf(ERROR_APP_KEY_INVALID, $mode));
46+
self::logMessage(sprintf(ERROR_APP_KEY_INVALID, $mode));
4747
}
4848
/** Check if public keys array for the current mode is populated **/
4949
if (empty($this->validationPublicKeys[$mode])) {
5050
/** Generate the error based on the current mode **/
5151
$error = sprintf(ERROR_APP_KEY_INVALID_MODE, $mode, array_values(array_diff(array_keys($this->validationPublicKeys), array($mode)))[0]);
52-
$this->logMessage($error);
52+
self::logMessage($error);
5353
return $error;
5454
}
5555
}
@@ -71,7 +71,7 @@ public function validatePublicKeyField($value, $mode)
7171
/** Check if the local stored public keys array is empty OR the key is not in public keys list **/
7272
if (empty($this->validationPublicKeys[$mode]) || ! in_array($value, $this->validationPublicKeys[$mode])) {
7373
$error = sprintf(ERROR_PUBLIC_KEY_INVALID, $mode);
74-
$this->logMessage($error);
74+
self::logMessage($error);
7575
return $error;
7676
}
7777
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "paylike/module-paylike",
3+
"description": "Paylike integration with payment gateway oscommerce",
4+
"type": "oscommerce-module",
5+
"version": "1.0.6",
6+
"license": [
7+
"GPL-3.0-or-later"
8+
],
9+
"authors": [
10+
{
11+
"name": "Genuineq",
12+
"email": "office@genuineq.com"
13+
}
14+
],
15+
"require": {
16+
"paylike/php-api": "^1.0.3"
17+
}
18+
}

upload_ce_phoenix/admin/includes/modules/payment/paylike/composer.lock

Lines changed: 59 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
/* Initialize errors object */
3+
require_once('helpers/Paylike_Errors.php');
4+
$errorHandler = new PaylikeErrors();

0 commit comments

Comments
 (0)