Skip to content

Commit

Permalink
Merge pull request #20 from payrexx/bugfix/PP-10834
Browse files Browse the repository at this point in the history
bugfix/PP-10834: Testing Our Actual Plugin Version With Our Prestashop Plugin
  • Loading branch information
michaelraess authored Jan 9, 2024
2 parents 76d3ab1 + f02cdea commit 271205b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 35 deletions.
14 changes: 14 additions & 0 deletions payrexx/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Apache 2.2
<IfModule !mod_authz_core.c>
<Files *.php>
order allow,deny
deny from all
</Files>
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
<Files *.php>
Require all denied
</Files>
</IfModule>
13 changes: 6 additions & 7 deletions payrexx/src/Service/PayrexxApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author Payrexx <integration@payrexx.com>
* @copyright 2023 Payrexx
* @copyright 2024 Payrexx
* @license MIT License
*/

Expand All @@ -15,7 +15,6 @@
exit;
}

use Configuration;
use Payrexx\Models\Request\SignatureCheck;
use Payrexx\Models\Response\Gateway;
use Payrexx\Models\Response\Transaction;
Expand All @@ -29,9 +28,9 @@ class PayrexxApiService

public function __construct()
{
$this->instanceName = Configuration::get('PAYREXX_INSTANCE_NAME');
$this->apiKey = Configuration::get('PAYREXX_API_SECRET');
$this->platform = Configuration::get('PAYREXX_PLATFORM');
$this->instanceName = \Configuration::get('PAYREXX_INSTANCE_NAME');
$this->apiKey = \Configuration::get('PAYREXX_API_SECRET');
$this->platform = \Configuration::get('PAYREXX_PLATFORM');
}

/**
Expand Down Expand Up @@ -160,8 +159,8 @@ public function createPayrexxGateway(
$gateway->setReferenceId($cart->id);
$gateway->setSkipResultPage(true);

if (Configuration::get('PAYREXX_LOOK_AND_FEEL_ID')) {
$gateway->setLookAndFeelProfile(Configuration::get('PAYREXX_LOOK_AND_FEEL_ID'));
if (\Configuration::get('PAYREXX_LOOK_AND_FEEL_ID')) {
$gateway->setLookAndFeelProfile(\Configuration::get('PAYREXX_LOOK_AND_FEEL_ID'));
}

$gateway->addField('title', '');
Expand Down
12 changes: 5 additions & 7 deletions payrexx/src/Service/PayrexxDbService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
* Payrexx Payment Gateway.
*
* @author Payrexx <integration@payrexx.com>
* @copyright 2023 Payrexx
* @copyright 2024 Payrexx
* @license MIT License
*/

namespace Payrexx\PayrexxPaymentGateway\Service;

use Db;

if (!defined('_PS_VERSION_')) {
exit;
}
Expand All @@ -28,7 +26,7 @@ public function insertGatewayInfo($idCart, $idGateway, $paymentMethod)
if (empty($idCart) || empty($idGateway)) {
return false;
}
return Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('
return \Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('
INSERT INTO `' . _DB_PREFIX_ . 'payrexx_gateway` (`id_cart`, `id_gateway`, `pm`)
VALUES (' . (int) $idCart . ',' . (int) $idGateway . ',\'' . $paymentMethod . '\')'
. ' ON DUPLICATE KEY UPDATE id_gateway = ' . (int) $idGateway
Expand All @@ -46,7 +44,7 @@ public function getCartGatewayId($idCart)
return null;
}

return (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
return (int) \Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT id_gateway FROM `' . _DB_PREFIX_ . 'payrexx_gateway`
WHERE id_cart = ' . (int) $idCart
);
Expand All @@ -61,7 +59,7 @@ public function getGatewayCartId($idGateway)
return null;
}

return (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
return (int) \Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT id_cart FROM `' . _DB_PREFIX_ . 'payrexx_gateway`
WHERE id_gateway = ' . (int) $idGateway
);
Expand All @@ -77,7 +75,7 @@ public function getPaymentMethodByCartId($idCart): string
return '';
}

return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
return \Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT pm FROM `' . _DB_PREFIX_ . 'payrexx_gateway`
WHERE id_cart = ' . (int) $idCart
);
Expand Down
34 changes: 13 additions & 21 deletions payrexx/src/Service/PayrexxOrderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,12 @@
* Payrexx Payment Gateway.
*
* @author Payrexx <integration@payrexx.com>
* @copyright 2023 Payrexx
* @copyright 2024 Payrexx
* @license MIT License
*/

namespace Payrexx\PayrexxPaymentGateway\Service;

use Cart;
use Configuration;
use Context;
use Customer;
use Db;
use Module;
use OrderHistory;

if (!defined('_PS_VERSION_')) {
exit;
}
Expand Down Expand Up @@ -50,10 +42,10 @@ public function createOrder(
$paymentMethod,
array $extraVars = []
) {
$payrexxModule = Module::getInstanceByName('payrexx');
$cart = new Cart($cartId);
$customer = new Customer($cart->id_customer);
$statusId = (int) Configuration::get($prestaStatus);
$payrexxModule = \Module::getInstanceByName('payrexx');
$cart = new \Cart($cartId);
$customer = new \Customer($cart->id_customer);
$statusId = (int) \Configuration::get($prestaStatus);

$payrexxModule->validateOrder(
(int) $cart->id,
Expand All @@ -66,7 +58,7 @@ public function createOrder(
false,
$customer->secure_key
);
$context = Context::getContext();
$context = \Context::getContext();
$context->cart = $cart;
}

Expand Down Expand Up @@ -108,13 +100,13 @@ public function transitionAllowed($newStatus, $oldStatusId)
{
switch ($newStatus) {
case self::PS_STATUS_ERROR:
return !in_array($oldStatusId, [(int) Configuration::get(self::PS_STATUS_PAYMENT), (int) Configuration::get(self::PS_STATUS_REFUND)]);
return !in_array($oldStatusId, [(int) \Configuration::get(self::PS_STATUS_PAYMENT), (int) \Configuration::get(self::PS_STATUS_REFUND)]);
case self::PS_STATUS_REFUND:
return in_array($oldStatusId, [(int) Configuration::get(self::PS_STATUS_PAYMENT), (int) Configuration::get(self::PS_STATUS_REFUND)]);
return in_array($oldStatusId, [(int) \Configuration::get(self::PS_STATUS_PAYMENT), (int) \Configuration::get(self::PS_STATUS_REFUND)]);
case self::PS_STATUS_PAYMENT:
return $oldStatusId !== (int) Configuration::get(self::PS_STATUS_PAYMENT);
return $oldStatusId !== (int) \Configuration::get(self::PS_STATUS_PAYMENT);
case self::PS_STATUS_BANKWIRE:
return $oldStatusId !== (int) Configuration::get(self::PS_STATUS_BANKWIRE);
return $oldStatusId !== (int) \Configuration::get(self::PS_STATUS_BANKWIRE);
}
}

Expand All @@ -125,8 +117,8 @@ public function transitionAllowed($newStatus, $oldStatusId)
*/
public function updateOrderStatus($prestaStatus, $order)
{
$orderHistory = new OrderHistory();
$prestaStatusId = Configuration::get($prestaStatus);
$orderHistory = new \OrderHistory();
$prestaStatusId = \Configuration::get($prestaStatus);

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

return (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
return (int) \Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT id_gateway FROM `' . _DB_PREFIX_ . 'payrexx_gateway`
WHERE id_cart = ' . (int) $id_cart);
}
Expand Down

0 comments on commit 271205b

Please sign in to comment.