diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 32f780890..9e3f100f1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -97,4 +97,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: ${{ env.MODULE_NAME }} - path: ./ \ No newline at end of file + path: ./ diff --git a/config/services.yml b/config/services.yml index b815319b3..4025f13b7 100644 --- a/config/services.yml +++ b/config/services.yml @@ -100,3 +100,15 @@ services: - '@subscription_options_data_provider' - 'subscription_options': 'Mollie\Subscription\Form\Options\SubscriptionOptionsType' - 'SubscriptionOptions' + + Mollie\Subscription\Controller\Symfony\SubscriptionFAQController: + class: Mollie\Subscription\Controller\Symfony\SubscriptionFAQController + public: true + autoconfigure: true + autowire: true # Optional, but useful for dependency injection + + Mollie\Subscription\Controller\Symfony\SubscriptionController: + class: Mollie\Subscription\Controller\Symfony\SubscriptionController + public: true + autowire: true + autoconfigure: true diff --git a/controllers/admin/AdminMollieAjaxController.php b/controllers/admin/AdminMollieAjaxController.php index b6f75b3da..f6ef11d4e 100644 --- a/controllers/admin/AdminMollieAjaxController.php +++ b/controllers/admin/AdminMollieAjaxController.php @@ -32,6 +32,9 @@ class AdminMollieAjaxController extends ModuleAdminController public function postProcess() { $action = Tools::getValue('action'); + + $this->context->smarty->assign('bootstrap', true); + switch ($action) { case 'togglePaymentMethod': $this->togglePaymentMethod(); @@ -80,7 +83,7 @@ private function togglePaymentMethod() } $method->update(); - $this->ajaxDie(json_encode( + $this->ajaxRender(json_encode( [ 'success' => true, 'paymentStatus' => (int) $method->enabled, @@ -100,7 +103,7 @@ private function resendPaymentMail() $response = $molliePaymentMailService->sendSecondChanceMail($orderId); - $this->ajaxDie(json_encode($response)); + $this->ajaxRender(json_encode($response)); } /** @@ -119,7 +122,7 @@ private function testApiKeys() $apiKeysTestInfo = $apiTestFeedbackBuilder->buildParams(); $this->context->smarty->assign($apiKeysTestInfo); - $this->ajaxDie(json_encode( + $this->ajaxRender(json_encode( [ 'template' => $this->context->smarty->fetch($this->module->getLocalPath() . 'views/templates/admin/api_test_results.tpl'), ] @@ -141,7 +144,7 @@ private function validateLogo() $returnText = ''; // Check image format if ('jpg' !== $imageFileType && 'png' !== $imageFileType) { - $returnText = $this->l('Upload a .jpg or .png file.'); + $returnText = $this->module->l('Upload a .jpg or .png file.'); $isUploaded = 0; } @@ -151,7 +154,7 @@ private function validateLogo() $returnText = basename($_FILES['fileToUpload']['name']); } else { $isUploaded = 0; - $returnText = $this->l('Something went wrong when uploading your logo.'); + $returnText = $this->module->l('Something went wrong when uploading your logo.'); } } diff --git a/controllers/admin/AdminMollieLogsController.php b/controllers/admin/AdminMollieLogsController.php index d44b2f114..1dd0f9d71 100644 --- a/controllers/admin/AdminMollieLogsController.php +++ b/controllers/admin/AdminMollieLogsController.php @@ -327,7 +327,7 @@ protected function ajaxResponse($value = null, $controller = null, $method = nul $logger = $this->module->getService(LoggerInterface::class); try { - $this->ajaxDie($value, $controller, $method); + $this->ajaxRender($value, $controller, $method); } catch (\Exception $exception) { $logger->error('Could not return ajax response', [ 'context' => [ diff --git a/controllers/admin/AdminMollieSettingsController.php b/controllers/admin/AdminMollieSettingsController.php index 4d7178a1b..aca70b8d7 100644 --- a/controllers/admin/AdminMollieSettingsController.php +++ b/controllers/admin/AdminMollieSettingsController.php @@ -165,8 +165,8 @@ public function postProcess() Media::addJsDef([ 'description_message' => addslashes($this->module->l('Enter a description')), - 'min_amount_message' => addslashes($this->l('You have entered incorrect min amount')), - 'max_amount_message' => addslashes($this->l('You have entered incorrect max amount')), + 'min_amount_message' => addslashes($this->module->l('You have entered incorrect min amount')), + 'max_amount_message' => addslashes($this->module->l('You have entered incorrect max amount')), 'payment_api' => addslashes(Mollie\Config\Config::MOLLIE_PAYMENTS_API), 'ajaxUrl' => addslashes($this->context->link->getAdminLink('AdminMollieAjax')), diff --git a/controllers/front/applePayDirectAjax.php b/controllers/front/applePayDirectAjax.php index 3890099ca..aec598bda 100644 --- a/controllers/front/applePayDirectAjax.php +++ b/controllers/front/applePayDirectAjax.php @@ -79,7 +79,7 @@ private function getApplePaySession() ); $response = $handler->handle($command); - $this->ajaxDie(json_encode($response)); + $this->ajaxRender(json_encode($response)); } private function updateShippingMethod() @@ -94,7 +94,7 @@ private function updateShippingMethod() ); $response = $handler->handle($command); - $this->ajaxDie(json_encode($response)); + $this->ajaxRender(json_encode($response)); } private function updateAppleShippingContact() @@ -142,7 +142,7 @@ private function updateAppleShippingContact() ]; } - $this->ajaxDie(json_encode($result)); + $this->ajaxRender(json_encode($result)); } private function createApplePayOrder() @@ -167,13 +167,13 @@ private function createApplePayOrder() ); $response = $handler->handle($command); if (!$response['success']) { - $this->ajaxDie(json_encode($response)); + $this->ajaxRender(json_encode($response)); } //we need to recover created order with customer settings so that we can show order confirmation page OrderRecoverUtility::recoverCreatedOrder($this->context, $cart->id_customer); - $this->ajaxDie(json_encode($response)); + $this->ajaxRender(json_encode($response)); } private function getTotalApplePayCartPrice() @@ -181,7 +181,7 @@ private function getTotalApplePayCartPrice() $cartId = Tools::getValue('cartId'); $cart = new Cart($cartId); - $this->ajaxDie(json_encode( + $this->ajaxRender(json_encode( [ 'total' => $cart->getOrderTotal(), ] diff --git a/controllers/front/bancontactAjax.php b/controllers/front/bancontactAjax.php index 1fa1f1e6e..3acb93d3a 100644 --- a/controllers/front/bancontactAjax.php +++ b/controllers/front/bancontactAjax.php @@ -82,7 +82,7 @@ private function createTransaction() ); $newPayment = $this->module->getApiClient()->payments->create($paymentData->jsonSerialize(), ['include' => 'details.qrCode']); - $this->ajaxDie(json_encode( + $this->ajaxRender(json_encode( [ 'qr_code' => $newPayment->details->qrCode->src, ] @@ -96,7 +96,7 @@ private function checkForPaidTransaction() $cart = Context::getContext()->cart; $proc = function () use ($cart) { - $orderId = Order::getOrderByCartId($cart->id); + $orderId = Order::getIdByCartId($cart->id); /* @phpstan-ignore-next-line */ if (!$orderId) { throw new OrderCreationException('Order was not created in webhook', OrderCreationException::ORDER_IS_NOT_CREATED); @@ -115,7 +115,7 @@ private function checkForPaidTransaction() ] ); } catch (RetryOverException $e) { - $this->ajaxDie(json_encode( + $this->ajaxRender(json_encode( [ 'success' => false, ] @@ -123,7 +123,7 @@ private function checkForPaidTransaction() } if (!$orderId) { - $this->ajaxDie(json_encode( + $this->ajaxRender(json_encode( [ 'success' => false, ] @@ -143,7 +143,7 @@ private function checkForPaidTransaction() ); OrderRecoverUtility::recoverCreatedOrder($this->context, $cart->id_customer); - $this->ajaxDie(json_encode( + $this->ajaxRender(json_encode( [ 'success' => true, 'redirectUrl' => $successUrl, diff --git a/controllers/front/fail.php b/controllers/front/fail.php index 89c1eb533..7a4a6d086 100644 --- a/controllers/front/fail.php +++ b/controllers/front/fail.php @@ -68,7 +68,7 @@ public function init() $redirectLink = 'index.php?controller=history'; - $orderId = (int) Order::getOrderByCartId((int) $this->id_cart); /* @phpstan-ignore-line */ + $orderId = (int) Order::getIdByCartId((int) $this->id_cart); /* @phpstan-ignore-line */ $this->id_order = $orderId; $this->secure_key = Tools::getValue('secureKey'); diff --git a/controllers/front/payment.php b/controllers/front/payment.php index ad45cc624..1dcb1aa05 100644 --- a/controllers/front/payment.php +++ b/controllers/front/payment.php @@ -168,7 +168,7 @@ public function initContent() try { if ($method === PaymentMethod::BANKTRANSFER) { - $orderId = Order::getOrderByCartId($cart->id); + $orderId = Order::getIdByCartId($cart->id); $order = new Order($orderId); $paymentMethodRepository->addOpenStatusPayment( $cart->id, diff --git a/controllers/front/return.php b/controllers/front/return.php index 18783dc22..5112f561e 100644 --- a/controllers/front/return.php +++ b/controllers/front/return.php @@ -103,7 +103,7 @@ public function initContent() // any paid payments for this cart? if (false === $data['mollie_info']) { - $data['mollie_info'] = $paymentMethodRepo->getPaymentBy('order_id', (int) Order::getOrderByCartId($idCart)); + $data['mollie_info'] = $paymentMethodRepo->getPaymentBy('order_id', (int) Order::getIdByCartId($idCart)); } if (false === $data['mollie_info']) { $data['mollie_info'] = []; @@ -220,7 +220,7 @@ protected function processGetStatus() } /* @phpstan-ignore-next-line */ - $orderId = (int) Order::getOrderByCartId((int) $cart->id); + $orderId = (int) Order::getIdByCartId((int) $cart->id); /** @phpstan-ignore-line */ $order = new Order((int) $orderId); diff --git a/mollie.php b/mollie.php index 97d800c3b..386cb96a7 100755 --- a/mollie.php +++ b/mollie.php @@ -521,7 +521,7 @@ public function hookDisplayAdminOrder($params) 'errorDisplay' => Configuration::get(Mollie\Config\Config::MOLLIE_DISPLAY_ERRORS), ]); - return $this->display(__FILE__, 'order_info.tpl'); + return $this->display($this->getLocalPath(), 'views/templates/hook/order_info.tpl'); } /** @@ -701,7 +701,7 @@ public function hookActionEmailSendBefore($params) } $cart = new Cart($params['cart']->id); - $orderId = Order::getOrderByCartId($cart->id); + $orderId = Order::getIdByCartId($cart->id); $order = new Order($orderId); if (!Validate::isLoadedObject($order)) { diff --git a/src/Application/CommandHandler/CreateApplePayOrderHandler.php b/src/Application/CommandHandler/CreateApplePayOrderHandler.php index 93a271b61..269459ff9 100644 --- a/src/Application/CommandHandler/CreateApplePayOrderHandler.php +++ b/src/Application/CommandHandler/CreateApplePayOrderHandler.php @@ -105,7 +105,7 @@ public function handle(CreateApplePayOrder $command): array // we need to wait for webhook to create the order. That's why we wait here for few seconds and check if order is created $proc = function () use ($command) { - $orderId = Order::getOrderByCartId($command->getCartId()); + $orderId = Order::getIdByCartId($command->getCartId()); /* @phpstan-ignore-next-line */ if (!$orderId) { throw new OrderCreationException('Order was not created in webhook', OrderCreationException::ORDER_IS_NOT_CREATED); @@ -146,7 +146,7 @@ public function handle(CreateApplePayOrder $command): array [ 'id_cart' => (int) $cart->id, 'id_module' => (int) $this->module->id, - 'id_order' => Order::getOrderByCartId($cart->id), + 'id_order' => Order::getIdByCartId($cart->id), 'key' => $cart->secure_key, ] ); diff --git a/src/Handler/Order/OrderCreationHandler.php b/src/Handler/Order/OrderCreationHandler.php index 39ba1fb53..c522c9766 100644 --- a/src/Handler/Order/OrderCreationHandler.php +++ b/src/Handler/Order/OrderCreationHandler.php @@ -141,7 +141,7 @@ public function createOrder($apiPayment, int $cartId, bool $isAuthorizablePaymen $paymentFeeData = $this->paymentFeeProvider->getPaymentFee($paymentMethod, (float) $originalAmount); - if (Order::getOrderByCartId((int) $cartId)) { + if (Order::getIdByCartId((int) $cartId)) { return 0; } @@ -159,7 +159,7 @@ public function createOrder($apiPayment, int $cartId, bool $isAuthorizablePaymen ); /* @phpstan-ignore-next-line */ - $orderId = (int) Order::getOrderByCartId((int) $cartId); + $orderId = (int) Order::getIdByCartId((int) $cartId); $this->createRecurringOrderEntity(new Order($orderId), $paymentMethod->id_method); @@ -199,7 +199,7 @@ public function createOrder($apiPayment, int $cartId, bool $isAuthorizablePaymen ); /* @phpstan-ignore-next-line */ - $orderId = (int) Order::getOrderByCartId((int) $cartId); + $orderId = (int) Order::getIdByCartId((int) $cartId); $this->orderPaymentFeeHandler->addOrderPaymentFee($orderId, $apiPayment); @@ -231,7 +231,7 @@ public function createBankTransferOrder($paymentData, Cart $cart) $cart->secure_key ); - $orderId = Order::getOrderByCartId($cart->id); + $orderId = Order::getIdByCartId($cart->id); $order = new Order($orderId); $environment = (int) Configuration::get(Mollie\Config\Config::MOLLIE_ENVIRONMENT); diff --git a/src/Logger/Logger.php b/src/Logger/Logger.php index 9189faf77..116c169d4 100644 --- a/src/Logger/Logger.php +++ b/src/Logger/Logger.php @@ -1,14 +1,5 @@ - * @copyright Mollie B.V. - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * - * @see https://github.com/mollie/PrestaShop - * @codingStandardsIgnoreStart - */ +declare(strict_types=1); namespace Mollie\Logger; @@ -18,6 +9,7 @@ use Mollie\Service\EntityManager\EntityManagerInterface; use Mollie\Service\EntityManager\ObjectModelUnitOfWork; use Mollie\Utility\NumberIdempotencyProvider; +use Psr\Log\LoggerInterface; if (!defined('_PS_VERSION_')) { exit; @@ -56,64 +48,79 @@ public function __construct( $this->prestashopLoggerRepository = $prestashopLoggerRepository; } - public function emergency($message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function emergency($message, array $context = []): void { - $this->log( - $this->configuration->getAsInteger( - 'PS_LOGS_BY_EMAIL', - $this->context->getShopId() - ), - $message, - $context - ); + $this->log(self::SEVERITY_ERROR, $message, $context); } - public function alert($message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function alert($message, array $context = []): void { $this->log(self::SEVERITY_WARNING, $message, $context); } - public function critical($message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function critical($message, array $context = []): void { - $this->log( - $this->configuration->getAsInteger( - 'PS_LOGS_BY_EMAIL', - $this->context->getShopId() - ), - $message, - $context - ); + $this->log(self::SEVERITY_ERROR, $message, $context); } - public function error($message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function error($message, array $context = []): void { $this->log(self::SEVERITY_ERROR, $message, $context); } - public function warning($message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function warning($message, array $context = []): void { $this->log(self::SEVERITY_WARNING, $message, $context); } - public function notice($message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function notice($message, array $context = []): void { $this->log(self::SEVERITY_INFO, $message, $context); } - public function info($message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function info($message, array $context = []): void { $this->log(self::SEVERITY_INFO, $message, $context); } - public function debug($message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function debug($message, array $context = []): void { if ((int) $this->configuration->get(Config::MOLLIE_DEBUG_LOG) === Config::DEBUG_LOG_ALL) { $this->log(self::SEVERITY_INFO, $message, $context); } } - public function log($level, $message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function log($level, $message, array $context = []): void { + $this->validateMessage($message); + $idempotencyKey = $this->idempotencyProvider->getIdempotencyKey(); \PrestaShopLogger::addLog( @@ -136,7 +143,7 @@ public function log($level, $message, array $context = []) $this->logContext($logId, $context); } - private function logContext($logId, array $context) + private function logContext($logId, array $context): void { $request = ''; $response = ''; @@ -162,7 +169,7 @@ private function logContext($logId, array $context) $this->entityManager->flush(); } - private function getFilledContextWithShopData(array $context = []) + private function getFilledContextWithShopData(array $context): array { $context['context_id_customer'] = $this->context->getCustomerId(); $context['id_shop'] = $this->context->getShopId(); @@ -171,4 +178,17 @@ private function getFilledContextWithShopData(array $context = []) return $context; } + + /** + * Validate that the message is a string or Stringable. + * + * @param mixed $message + * @throws \InvalidArgumentException + */ + private function validateMessage($message): void + { + if (!is_string($message) && !$message instanceof \Stringable) { + throw new \InvalidArgumentException('Message must be a string or Stringable.'); + } + } } diff --git a/src/Logger/PrestaLogger.php b/src/Logger/PrestaLogger.php index e476f1c2a..f86aef6e1 100644 --- a/src/Logger/PrestaLogger.php +++ b/src/Logger/PrestaLogger.php @@ -1,14 +1,5 @@ - * @copyright Mollie B.V. - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * - * @see https://github.com/mollie/PrestaShop - * @codingStandardsIgnoreStart - */ +declare(strict_types=1); namespace Mollie\Logger; @@ -22,9 +13,6 @@ class PrestaLogger implements PrestaLoggerInterface { - // TODO move this as a shared service for subscriptions and main source - // TODO refactor whole logger logic and implement leftover methods - /** @var ConfigurationAdapter */ private $configuration; @@ -33,23 +21,40 @@ public function __construct(ConfigurationAdapter $configuration) $this->configuration = $configuration; } - public function emergency($message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function emergency($message, array $context = []): void { - throw new NotImplementedException('not implemented method'); + $this->validateMessage($message); + $this->logWithPrestaShop('emergency', $message, $context); } - public function alert($message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function alert($message, array $context = []): void { - throw new NotImplementedException('not implemented method'); + $this->validateMessage($message); + $this->logWithPrestaShop('alert', $message, $context); } - public function critical($message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function critical($message, array $context = []): void { - throw new NotImplementedException('not implemented method'); + $this->validateMessage($message); + $this->logWithPrestaShop('critical', $message, $context); } - public function error($message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function error($message, array $context = []): void { + $this->validateMessage($message); + if ((int) $this->configuration->get(Config::MOLLIE_DEBUG_LOG) === Config::DEBUG_LOG_NONE) { return; } @@ -62,18 +67,31 @@ public function error($message, array $context = []) ); } - public function warning($message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function warning($message, array $context = []): void { - throw new NotImplementedException('not implemented method'); + $this->validateMessage($message); + $this->logWithPrestaShop('warning', $message, $context); } - public function notice($message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function notice($message, array $context = []): void { - throw new NotImplementedException('not implemented method'); + $this->validateMessage($message); + $this->logWithPrestaShop('notice', $message, $context); } - public function info($message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function info($message, array $context = []): void { + $this->validateMessage($message); + if ((int) $this->configuration->get(Config::MOLLIE_DEBUG_LOG) !== Config::DEBUG_LOG_ALL) { return; } @@ -85,22 +103,51 @@ public function info($message, array $context = []) ); } - public function debug($message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function debug($message, array $context = []): void { - // TODO implement single method, which handles logging - + $this->validateMessage($message); $this->info($message, $context); } - public function log($level, $message, array $context = []) + /** + * @param string|\Stringable $message + */ + public function log($level, $message, array $context = []): void { + $this->validateMessage($message); throw new NotImplementedException('not implemented method'); } - private function getMessageWithContext($message, array $context = []) + private function getMessageWithContext(string $message, array $context = []): string { $content = json_encode($context); return "{$message} . context: {$content}"; } + + /** + * Handle logging logic with PrestaShopLogger. + * + * @param string|\Stringable $message + */ + private function logWithPrestaShop(string $level, $message, array $context): void + { + throw new NotImplementedException("Method {$level} not implemented."); + } + + /** + * Validate that the message is a string or Stringable. + * + * @param mixed $message + * @throws \InvalidArgumentException + */ + private function validateMessage($message): void + { + if (!is_string($message) && !$message instanceof \Stringable) { + throw new \InvalidArgumentException('Message must be a string or Stringable.'); + } + } } diff --git a/src/Service/PaymentMethod/PaymentMethodRestrictionValidation.php b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation.php index f93a10cd3..08101d1f7 100644 --- a/src/Service/PaymentMethod/PaymentMethodRestrictionValidation.php +++ b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation.php @@ -41,6 +41,7 @@ use Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\PaymentMethodRestrictionValidatorInterface; use MolPaymentMethod; use PrestaShopLogger; +use Throwable; if (!defined('_PS_VERSION_')) { exit; @@ -77,7 +78,7 @@ public function isPaymentMethodValid(MolPaymentMethod $paymentMethod): bool return false; } } - } catch (Exception $exception) { + } catch (Throwable $exception) { PrestaShopLogger::addLog( sprintf('%s has caught error: %s', __METHOD__, $exception->getMessage()), Config::ERROR, diff --git a/src/Service/PaymentReturnService.php b/src/Service/PaymentReturnService.php index dca30f8fa..7a58e9a06 100644 --- a/src/Service/PaymentReturnService.php +++ b/src/Service/PaymentReturnService.php @@ -148,7 +148,7 @@ public function handleTestPendingStatus() private function getStatusResponse($transaction, $status, $cartId, $cartSecureKey) { /* @phpstan-ignore-next-line */ - $orderId = (int) Order::getOrderByCartId((int) $cartId); + $orderId = (int) Order::getIdByCartId((int) $cartId); $successUrl = $this->context->link->getPageLink( 'order-confirmation', diff --git a/src/Service/TransactionService.php b/src/Service/TransactionService.php index d34a154e0..09953438d 100644 --- a/src/Service/TransactionService.php +++ b/src/Service/TransactionService.php @@ -145,7 +145,7 @@ public function processTransaction($apiPayment) } /** @var int $orderId */ - $orderId = Order::getOrderByCartId((int) $apiPayment->metadata->cart_id); + $orderId = Order::getIdByCartId((int) $apiPayment->metadata->cart_id); $cart = new Cart($apiPayment->metadata->cart_id); @@ -213,7 +213,7 @@ public function processTransaction($apiPayment) $this->orderStatusService->setOrderStatus($orderId, $apiPayment->status); } - $orderId = Order::getOrderByCartId((int) $apiPayment->metadata->cart_id); + $orderId = Order::getIdByCartId((int) $apiPayment->metadata->cart_id); } break; case Config::MOLLIE_API_STATUS_ORDER: @@ -295,7 +295,7 @@ public function processTransaction($apiPayment) } } - $orderId = Order::getOrderByCartId((int) $apiPayment->metadata->cart_id); + $orderId = Order::getIdByCartId((int) $apiPayment->metadata->cart_id); } if (!$orderId) { @@ -507,7 +507,7 @@ private function handlePaymentDescription(Payment $apiPayment) { $paymentMethod = $this->paymentMethodRepository->getPaymentBy('order_reference', $apiPayment->description); if ($paymentMethod) { - $orderId = Order::getOrderByCartId($paymentMethod['cart_id']); + $orderId = Order::getIdByCartId($paymentMethod['cart_id']); if (!$orderId) { return; } @@ -523,7 +523,7 @@ private function handleOrderDescription(MollieOrderAlias $apiPayment) { $paymentMethod = $this->paymentMethodRepository->getPaymentBy('order_reference', $apiPayment->orderNumber); if ($paymentMethod) { - $orderId = Order::getOrderByCartId($paymentMethod['cart_id']); + $orderId = Order::getIdByCartId($paymentMethod['cart_id']); if (!$orderId) { return; } diff --git a/src/ServiceProvider/BaseServiceProvider.php b/src/ServiceProvider/BaseServiceProvider.php index 8dcdc7e4f..4d2e6d869 100644 --- a/src/ServiceProvider/BaseServiceProvider.php +++ b/src/ServiceProvider/BaseServiceProvider.php @@ -14,7 +14,6 @@ namespace Mollie\ServiceProvider; -use League\Container\Container; use Mollie; use Mollie\Adapter\ConfigurationAdapter; use Mollie\Adapter\Context; @@ -144,6 +143,7 @@ use Mollie\Utility\Decoder\DecoderInterface; use Mollie\Utility\Decoder\JsonDecoder; use Mollie\Utility\NumberIdempotencyProvider; +use League\Container\Container; use Mollie\Verification\PaymentType\CanBeRegularPaymentType; use Mollie\Verification\PaymentType\PaymentTypeVerificationInterface; use Mollie\Verification\Shipment\CanSendShipment; diff --git a/src/ServiceProvider/PrestashopContainer.php b/src/ServiceProvider/PrestashopContainer.php index 8f13e4f13..b782485c3 100644 --- a/src/ServiceProvider/PrestashopContainer.php +++ b/src/ServiceProvider/PrestashopContainer.php @@ -14,8 +14,8 @@ namespace Mollie\ServiceProvider; -use PrestaShop\PrestaShop\Adapter\SymfonyContainer; use Psr\Container\ContainerInterface as PsrContainerInterface; +use PrestaShop\PrestaShop\Adapter\SymfonyContainer; use Symfony\Component\DependencyInjection\ContainerInterface; if (!defined('_PS_VERSION_')) { diff --git a/subscription/Controller/Symfony/AbstractSymfonyController.php b/subscription/Controller/Symfony/AbstractSymfonyController.php index ceb1c6d7d..5ebd73c71 100644 --- a/subscription/Controller/Symfony/AbstractSymfonyController.php +++ b/subscription/Controller/Symfony/AbstractSymfonyController.php @@ -30,8 +30,6 @@ abstract class AbstractSymfonyController extends FrameworkBundleAdminController public function __construct() { - parent::__construct(); - /* @phpstan-ignore-next-line */ $this->module = Module::getInstanceByName('mollie'); } diff --git a/subscription/Form/Options/SubscriptionOptionsType.php b/subscription/Form/Options/SubscriptionOptionsType.php index 3b35adaa5..420c00332 100644 --- a/subscription/Form/Options/SubscriptionOptionsType.php +++ b/subscription/Form/Options/SubscriptionOptionsType.php @@ -18,7 +18,8 @@ use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Contracts\Translation\TranslatorInterface as NewTranslatorInterface; // Newer Symfony translator +use Symfony\Component\Translation\TranslatorInterface as OldTranslatorInterface; // Older Symfony translator if (!defined('_PS_VERSION_')) { exit; @@ -30,9 +31,11 @@ class SubscriptionOptionsType extends TranslatorAwareType private $carrierOptionProvider; /** @var Module */ private $module; + /** @var NewTranslatorInterface | OldTranslatorInterface */ + private $translator; public function __construct( - TranslatorInterface $translator, + $translator, array $locales, FormChoiceProviderInterface $carrierOptionProvider, Module $module diff --git a/subscription/Install/AttributeInstaller.php b/subscription/Install/AttributeInstaller.php index 4fdd6c64b..7ea92291a 100644 --- a/subscription/Install/AttributeInstaller.php +++ b/subscription/Install/AttributeInstaller.php @@ -21,9 +21,9 @@ use Mollie\Logger\PrestaLoggerInterface; use Mollie\Subscription\Config\Config; use Mollie\Subscription\Repository\LanguageRepository; +use Psr\Log\LogLevel; use PrestaShopDatabaseException; use PrestaShopException; -use Psr\Log\LogLevel; use Validate; if (!defined('_PS_VERSION_')) {