Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes unused stuff for vaulting release #1228

Merged
merged 4 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions config/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,8 @@ services:
PrestaShop\Module\PrestashopCheckout\Environment\Env:
class: 'PrestaShop\Module\PrestashopCheckout\Environment\Env'
public: true

PrestaShop\Module\PrestashopCheckout\Environment\PaymentEnv:
class: 'PrestaShop\Module\PrestashopCheckout\Environment\PaymentEnv'
public: true

PrestaShop\Module\PrestashopCheckout\Environment\PaypalEnv:
class: 'PrestaShop\Module\PrestashopCheckout\Environment\PaypalEnv'
public: true
arguments:
- '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration'

ps_checkout.tactician.bus:
class: 'League\Tactician\CommandBus'
Expand Down Expand Up @@ -114,7 +108,7 @@ services:
public: true
arguments:
- '@PrestaShop\Module\PrestashopCheckout\Repository\PsCheckoutCartRepository'
- '@ps_checkout.bus.command'
- '@ps_checkout.module'

PrestaShop\Module\PrestashopCheckout\PayPal\Order\EventSubscriber\PayPalOrderEventSubscriber:
class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\EventSubscriber\PayPalOrderEventSubscriber'
Expand Down Expand Up @@ -187,7 +181,7 @@ services:
class: 'PrestaShop\Module\PrestashopCheckout\ShopContext'
public: true
arguments:
- '@PrestaShop\Module\PrestashopCheckout\Environment\PaymentEnv'
- '@PrestaShop\Module\PrestashopCheckout\Environment\Env'

PrestaShop\Module\PrestashopCheckout\Shop\ShopProvider:
class: 'PrestaShop\Module\PrestashopCheckout\Shop\ShopProvider'
Expand Down Expand Up @@ -235,6 +229,7 @@ services:
public: true
arguments:
- '@ps_checkout.module'
- '@PrestaShop\Module\PrestashopCheckout\Environment\Env'
- '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration'
- '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalPayLaterConfiguration'
- '@PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceConfigurationRepository'
Expand Down
4 changes: 2 additions & 2 deletions config/http-clients.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
class: 'PrestaShop\Module\PrestashopCheckout\Builder\Configuration\MaaslandHttpClientConfigurationBuilder'
public: true
arguments:
- '@PrestaShop\Module\PrestashopCheckout\Environment\PaymentEnv'
- '@PrestaShop\Module\PrestashopCheckout\Environment\Env'
- '@PrestaShop\Module\PrestashopCheckout\Routing\Router'
- '@PrestaShop\Module\PrestashopCheckout\ShopContext'
- '@PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository'
Expand All @@ -38,7 +38,7 @@ services:
class: 'PrestaShop\Module\PrestashopCheckout\Builder\Configuration\CheckoutClientConfigurationBuilder'
public: true
arguments:
- '@PrestaShop\Module\PrestashopCheckout\Environment\PaymentEnv'
- '@PrestaShop\Module\PrestashopCheckout\Environment\Env'
- '@PrestaShop\Module\PrestashopCheckout\Routing\Router'
- '@PrestaShop\Module\PrestashopCheckout\ShopContext'
- '@PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository'
Expand Down
33 changes: 30 additions & 3 deletions controllers/admin/AdminAjaxPrestashopCheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
use Monolog\Logger;
use PrestaShop\Module\PrestashopCheckout\CommandBus\CommandBusInterface;
use PrestaShop\Module\PrestashopCheckout\Configuration\BatchConfigurationProcessor;
use PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration;
use PrestaShop\Module\PrestashopCheckout\Exception\PayPalException;
use PrestaShop\Module\PrestashopCheckout\ExpressCheckout\ExpressCheckoutConfiguration;
use PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceConfigurationRepository;
use PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceTranslationProvider;
use PrestaShop\Module\PrestashopCheckout\Http\MaaslandHttpClient;
use PrestaShop\Module\PrestashopCheckout\Logger\LoggerDirectory;
use PrestaShop\Module\PrestashopCheckout\Logger\LoggerFactory;
use PrestaShop\Module\PrestashopCheckout\Logger\LoggerFileFinder;
Expand Down Expand Up @@ -215,7 +218,7 @@ public function ajaxProcessToggleECOrderPage()
$ecConfiguration = $this->module->getService(ExpressCheckoutConfiguration::class);
$ecConfiguration->setOrderPage((bool) Tools::getValue('status'));

(new PrestaShop\Module\PrestashopCheckout\Api\Payment\Shop(Context::getContext()->link))->updateSettings();
$this->updateExpressCheckoutSettings();

$this->ajaxDie(json_encode(true));
}
Expand All @@ -229,7 +232,7 @@ public function ajaxProcessToggleECCheckoutPage()
$ecConfiguration = $this->module->getService(ExpressCheckoutConfiguration::class);
$ecConfiguration->setCheckoutPage(Tools::getValue('status') ? true : false);

(new PrestaShop\Module\PrestashopCheckout\Api\Payment\Shop(Context::getContext()->link))->updateSettings();
$this->updateExpressCheckoutSettings();

$this->ajaxDie(json_encode(true));
}
Expand All @@ -243,11 +246,35 @@ public function ajaxProcessToggleECProductPage()
$ecConfiguration = $this->module->getService(ExpressCheckoutConfiguration::class);
$ecConfiguration->setProductPage(Tools::getValue('status') ? true : false);

(new PrestaShop\Module\PrestashopCheckout\Api\Payment\Shop(Context::getContext()->link))->updateSettings();
$this->updateExpressCheckoutSettings();

$this->ajaxDie(json_encode(true));
}

/**
* @return void
*
* @throws PayPalException
*/
private function updateExpressCheckoutSettings()
{
/** @var PrestaShopConfiguration $configuration */
$configuration = $this->module->getService(PrestaShopConfiguration::class);
/** @var ExpressCheckoutConfiguration $ecConfiguration */
$ecConfiguration = $this->module->getService(ExpressCheckoutConfiguration::class);
/** @var MaaslandHttpClient $maaslandHttpClient */
$maaslandHttpClient = $this->module->getService(MaaslandHttpClient::class);

$maaslandHttpClient->updateSettings([
'settings' => [
'cb' => (bool) $configuration->get('PS_CHECKOUT_CARD_PAYMENT_ENABLED'),
'express_in_product' => (bool) $ecConfiguration->isProductPageEnabled(),
'express_in_cart' => (bool) $ecConfiguration->isOrderPageEnabled(),
'express_in_checkout' => (bool) $ecConfiguration->isCheckoutPageEnabled(),
],
]);
}

/**
* AJAX: Toggle pay later message on order page
*/
Expand Down
6 changes: 4 additions & 2 deletions controllers/front/DispatchWebHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use PrestaShop\Module\PrestashopCheckout\Controller\AbstractFrontController;
use PrestaShop\Module\PrestashopCheckout\Dispatcher\OrderDispatcher;
use PrestaShop\Module\PrestashopCheckout\Exception\PsCheckoutException;
use PrestaShop\Module\PrestashopCheckout\Http\MaaslandHttpClient;
use PrestaShop\Module\PrestashopCheckout\Order\Exception\OrderNotFoundException;
use PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository;
use PrestaShop\Module\PrestashopCheckout\WebHookValidation;
Expand Down Expand Up @@ -128,8 +129,9 @@ public function display()
*/
private function checkPSLSignature(array $bodyValues)
{
$context = Context::getContext();
$response = (new Webhook($context->link))->getShopSignature($bodyValues);
/** @var MaaslandHttpClient $maaslandHttpClient */
$maaslandHttpClient = $this->module->getService(MaaslandHttpClient::class);
$response = $maaslandHttpClient->getShopSignature($bodyValues);

// data return false if no error
if (200 === $response['httpCode'] && 'VERIFIED' === $response['body']['message']) {
Expand Down
3 changes: 2 additions & 1 deletion ps_checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ public function getContent()
'contextPsAccounts' => $contextPsAccounts,
]);

$env = new \PrestaShop\Module\PrestashopCheckout\Environment\Env();
/** @var \PrestaShop\Module\PrestashopCheckout\Environment\Env $env */
$env = $this->getService(\PrestaShop\Module\PrestashopCheckout\Environment\Env::class);
$boSdkUrl = $env->getEnv('CHECKOUT_BO_SDK_URL');
if (substr($boSdkUrl, -3) !== '.js') {
$boSdkVersion = $env->getEnv('CHECKOUT_BO_SDK_VERSION');
Expand Down
7 changes: 5 additions & 2 deletions src/Adapter/LinkAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

namespace PrestaShop\Module\PrestashopCheckout\Adapter;

use PrestaShop\Module\PrestashopCheckout\Environment\PaymentEnv;
use PrestaShop\Module\PrestashopCheckout\ShopContext;

/**
Expand Down Expand Up @@ -59,8 +58,12 @@ public function __construct(\Link $link = null)
public function getAdminLink($controller, $withToken = true, $sfRouteParams = [], $params = [])
{
$shop = \Context::getContext()->shop;
/** @var \Ps_checkout $module */
$module = \Module::getInstanceByName('ps_checkout');
/** @var ShopContext $shopContext */
$shopContext = $module->getService(ShopContext::class);

if ((new ShopContext(new PaymentEnv()))->isShop17()) {
if ($shopContext->isShop17()) {
$adminLink = $this->link->getAdminLink($controller, $withToken, $sfRouteParams, $params);

if ($shop->virtual_uri !== '') {
Expand Down
Loading
Loading