Skip to content

Commit f02cdea

Browse files
committed
bugfix/PP-10834: changed the code as for module validator
1 parent 5cb016f commit f02cdea

File tree

4 files changed

+38
-35
lines changed

4 files changed

+38
-35
lines changed

payrexx/.htaccess

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Apache 2.2
2+
<IfModule !mod_authz_core.c>
3+
<Files *.php>
4+
order allow,deny
5+
deny from all
6+
</Files>
7+
</IfModule>
8+
9+
# Apache 2.4
10+
<IfModule mod_authz_core.c>
11+
<Files *.php>
12+
Require all denied
13+
</Files>
14+
</IfModule>

payrexx/src/Service/PayrexxApiService.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* needs please refer to http://www.prestashop.com for more information.
66
*
77
* @author Payrexx <[email protected]>
8-
* @copyright 2023 Payrexx
8+
* @copyright 2024 Payrexx
99
* @license MIT License
1010
*/
1111

@@ -15,7 +15,6 @@
1515
exit;
1616
}
1717

18-
use Configuration;
1918
use Payrexx\Models\Request\SignatureCheck;
2019
use Payrexx\Models\Response\Gateway;
2120
use Payrexx\Models\Response\Transaction;
@@ -29,9 +28,9 @@ class PayrexxApiService
2928

3029
public function __construct()
3130
{
32-
$this->instanceName = Configuration::get('PAYREXX_INSTANCE_NAME');
33-
$this->apiKey = Configuration::get('PAYREXX_API_SECRET');
34-
$this->platform = Configuration::get('PAYREXX_PLATFORM');
31+
$this->instanceName = \Configuration::get('PAYREXX_INSTANCE_NAME');
32+
$this->apiKey = \Configuration::get('PAYREXX_API_SECRET');
33+
$this->platform = \Configuration::get('PAYREXX_PLATFORM');
3534
}
3635

3736
/**
@@ -160,8 +159,8 @@ public function createPayrexxGateway(
160159
$gateway->setReferenceId($cart->id);
161160
$gateway->setSkipResultPage(true);
162161

163-
if (Configuration::get('PAYREXX_LOOK_AND_FEEL_ID')) {
164-
$gateway->setLookAndFeelProfile(Configuration::get('PAYREXX_LOOK_AND_FEEL_ID'));
162+
if (\Configuration::get('PAYREXX_LOOK_AND_FEEL_ID')) {
163+
$gateway->setLookAndFeelProfile(\Configuration::get('PAYREXX_LOOK_AND_FEEL_ID'));
165164
}
166165

167166
$gateway->addField('title', '');

payrexx/src/Service/PayrexxDbService.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
* Payrexx Payment Gateway.
44
*
55
* @author Payrexx <[email protected]>
6-
* @copyright 2023 Payrexx
6+
* @copyright 2024 Payrexx
77
* @license MIT License
88
*/
99

1010
namespace Payrexx\PayrexxPaymentGateway\Service;
1111

12-
use Db;
13-
1412
if (!defined('_PS_VERSION_')) {
1513
exit;
1614
}
@@ -28,7 +26,7 @@ public function insertGatewayInfo($idCart, $idGateway, $paymentMethod)
2826
if (empty($idCart) || empty($idGateway)) {
2927
return false;
3028
}
31-
return Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('
29+
return \Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('
3230
INSERT INTO `' . _DB_PREFIX_ . 'payrexx_gateway` (`id_cart`, `id_gateway`, `pm`)
3331
VALUES (' . (int) $idCart . ',' . (int) $idGateway . ',\'' . $paymentMethod . '\')'
3432
. ' ON DUPLICATE KEY UPDATE id_gateway = ' . (int) $idGateway
@@ -46,7 +44,7 @@ public function getCartGatewayId($idCart)
4644
return null;
4745
}
4846

49-
return (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
47+
return (int) \Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
5048
SELECT id_gateway FROM `' . _DB_PREFIX_ . 'payrexx_gateway`
5149
WHERE id_cart = ' . (int) $idCart
5250
);
@@ -61,7 +59,7 @@ public function getGatewayCartId($idGateway)
6159
return null;
6260
}
6361

64-
return (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
62+
return (int) \Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
6563
SELECT id_cart FROM `' . _DB_PREFIX_ . 'payrexx_gateway`
6664
WHERE id_gateway = ' . (int) $idGateway
6765
);
@@ -77,7 +75,7 @@ public function getPaymentMethodByCartId($idCart): string
7775
return '';
7876
}
7977

80-
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
78+
return \Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
8179
SELECT pm FROM `' . _DB_PREFIX_ . 'payrexx_gateway`
8280
WHERE id_cart = ' . (int) $idCart
8381
);

payrexx/src/Service/PayrexxOrderService.php

+13-21
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,12 @@
33
* Payrexx Payment Gateway.
44
*
55
* @author Payrexx <[email protected]>
6-
* @copyright 2023 Payrexx
6+
* @copyright 2024 Payrexx
77
* @license MIT License
88
*/
99

1010
namespace Payrexx\PayrexxPaymentGateway\Service;
1111

12-
use Cart;
13-
use Configuration;
14-
use Context;
15-
use Customer;
16-
use Db;
17-
use Module;
18-
use OrderHistory;
19-
2012
if (!defined('_PS_VERSION_')) {
2113
exit;
2214
}
@@ -50,10 +42,10 @@ public function createOrder(
5042
$paymentMethod,
5143
array $extraVars = []
5244
) {
53-
$payrexxModule = Module::getInstanceByName('payrexx');
54-
$cart = new Cart($cartId);
55-
$customer = new Customer($cart->id_customer);
56-
$statusId = (int) Configuration::get($prestaStatus);
45+
$payrexxModule = \Module::getInstanceByName('payrexx');
46+
$cart = new \Cart($cartId);
47+
$customer = new \Customer($cart->id_customer);
48+
$statusId = (int) \Configuration::get($prestaStatus);
5749

5850
$payrexxModule->validateOrder(
5951
(int) $cart->id,
@@ -66,7 +58,7 @@ public function createOrder(
6658
false,
6759
$customer->secure_key
6860
);
69-
$context = Context::getContext();
61+
$context = \Context::getContext();
7062
$context->cart = $cart;
7163
}
7264

@@ -108,13 +100,13 @@ public function transitionAllowed($newStatus, $oldStatusId)
108100
{
109101
switch ($newStatus) {
110102
case self::PS_STATUS_ERROR:
111-
return !in_array($oldStatusId, [(int) Configuration::get(self::PS_STATUS_PAYMENT), (int) Configuration::get(self::PS_STATUS_REFUND)]);
103+
return !in_array($oldStatusId, [(int) \Configuration::get(self::PS_STATUS_PAYMENT), (int) \Configuration::get(self::PS_STATUS_REFUND)]);
112104
case self::PS_STATUS_REFUND:
113-
return in_array($oldStatusId, [(int) Configuration::get(self::PS_STATUS_PAYMENT), (int) Configuration::get(self::PS_STATUS_REFUND)]);
105+
return in_array($oldStatusId, [(int) \Configuration::get(self::PS_STATUS_PAYMENT), (int) \Configuration::get(self::PS_STATUS_REFUND)]);
114106
case self::PS_STATUS_PAYMENT:
115-
return $oldStatusId !== (int) Configuration::get(self::PS_STATUS_PAYMENT);
107+
return $oldStatusId !== (int) \Configuration::get(self::PS_STATUS_PAYMENT);
116108
case self::PS_STATUS_BANKWIRE:
117-
return $oldStatusId !== (int) Configuration::get(self::PS_STATUS_BANKWIRE);
109+
return $oldStatusId !== (int) \Configuration::get(self::PS_STATUS_BANKWIRE);
118110
}
119111
}
120112

@@ -125,8 +117,8 @@ public function transitionAllowed($newStatus, $oldStatusId)
125117
*/
126118
public function updateOrderStatus($prestaStatus, $order)
127119
{
128-
$orderHistory = new OrderHistory();
129-
$prestaStatusId = Configuration::get($prestaStatus);
120+
$orderHistory = new \OrderHistory();
121+
$prestaStatusId = \Configuration::get($prestaStatus);
130122

131123
$orderHistory->id_order = (int) $order->id;
132124
$orderHistory->changeIdOrderState($prestaStatusId, $order, true);
@@ -145,7 +137,7 @@ public function getCartGatewayId($id_cart)
145137
return 0;
146138
}
147139

148-
return (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
140+
return (int) \Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
149141
SELECT id_gateway FROM `' . _DB_PREFIX_ . 'payrexx_gateway`
150142
WHERE id_cart = ' . (int) $id_cart);
151143
}

0 commit comments

Comments
 (0)