diff --git a/changelog.md b/changelog.md index b56553f5a..f5ba38210 100644 --- a/changelog.md +++ b/changelog.md @@ -2,11 +2,14 @@ # Changelog # +## Changes in release 6.1.0 ## ++ New payment methods: Twint, Blik and Klarna ++ Added PrestaShop CloudSync support + ## Changes in release 6.0.5 ## + Recurring order options are now in "Subscriptions" tab + Implemented atomic action protection for Mollie API callbacks + Overall improvements and bug fixes -+ Added PrestaShop CloudSync support ## Changes in release 6.0.4 ## + New payment method: Billie. diff --git a/composer.json b/composer.json index cb2569150..d86cafc06 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "ext-json": "*", "ext-simplexml": "*", "prestashop/decimal": "^1.3", - "mollie/mollie-api-php": "v2.61.0", + "mollie/mollie-api-php": "v2.65.0", "segmentio/analytics-php": "^1.5", "sentry/sentry": "3.17.0", "league/container": "2.5.0", @@ -15,7 +15,9 @@ "webmozart/assert": "^1.11", "symfony/http-client": "^4.4", "http-interop/http-factory-guzzle": "^1.1", - "php-http/message-factory": "^1.1" + "php-http/message-factory": "^1.1", + "prestashop/prestashop-accounts-installer": "^1.0.4", + "prestashop/module-lib-mbo-installer": "^2.0" }, "require-dev": { "roave/security-advisories": "dev-latest", @@ -41,11 +43,11 @@ }, "config": { "platform": { - "php": "7.2" + "php": "7.2.5" }, "prepend-autoloader": false, "allow-plugins": { - "php-http/discovery": true + "php-http/discovery": false } }, "type": "prestashop-module", diff --git a/config/services.yml b/config/services.yml index 76634b961..b815319b3 100644 --- a/config/services.yml +++ b/config/services.yml @@ -8,6 +8,20 @@ services: arguments: - 'mollie' + ##################### + # PS Account + Mollie.PsAccountsInstaller: + class: 'PrestaShop\PsAccountsInstaller\Installer\Installer' + public: true + arguments: + - "5.0" + + Mollie.PsAccountsFacade: + class: 'PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts' + public: true + arguments: + - "@Mollie.PsAccountsInstaller" + Mollie\Subscription\Grid\SubscriptionGridQueryBuilder: class: Mollie\Subscription\Grid\SubscriptionGridQueryBuilder parent: 'prestashop.core.grid.abstract_query_builder' diff --git a/controllers/admin/AdminMollieSettingsController.php b/controllers/admin/AdminMollieSettingsController.php index b9cf243af..420f9f43d 100644 --- a/controllers/admin/AdminMollieSettingsController.php +++ b/controllers/admin/AdminMollieSettingsController.php @@ -27,8 +27,62 @@ public function __construct() $this->bootstrap = true; } + private function initCloudSyncAndPsAccounts(): void + { + $mboInstaller = new Prestashop\ModuleLibMboInstaller\DependencyBuilder($this->module); + + if (!$mboInstaller->areDependenciesMet()) { + $dependencies = $mboInstaller->handleDependencies(); + $this->context->smarty->assign('dependencies', $dependencies); + + $this->content .= $this->context->smarty->fetch($this->module->getLocalPath() . 'views/templates/admin/dependency_builder.tpl'); + } + + $this->context->smarty->assign('module_dir', $this->module->getPathUri()); + $moduleManager = PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder::getInstance()->build(); + + try { + $accountsFacade = $this->module->getService('Mollie.PsAccountsFacade'); + $accountsService = $accountsFacade->getPsAccountsService(); + } catch (PrestaShop\PsAccountsInstaller\Installer\Exception\InstallerException $e) { + $accountsInstaller = $this->module->getService('Mollie.PsAccountsInstaller'); + $accountsInstaller->install(); + $accountsFacade = $this->module->getService('Mollie.PsAccountsFacade'); + $accountsService = $accountsFacade->getPsAccountsService(); + } + + try { + Media::addJsDef([ + 'contextPsAccounts' => $accountsFacade->getPsAccountsPresenter() + ->present($this->module->name), + ]); + + // Retrieve Account CDN + $this->context->smarty->assign('urlAccountsCdn', $accountsService->getAccountsCdn()); + } catch (Exception $e) { + $this->context->controller->errors[] = $e->getMessage(); + } + + if ($moduleManager->isInstalled('ps_eventbus')) { + $eventbusModule = \Module::getInstanceByName('ps_eventbus'); + if ($eventbusModule && version_compare($eventbusModule->version, '1.9.0', '>=')) { + /** @phpstan-ignore-next-line PHPStan does not recognize the event bus module, so it doesn't know it has getService function */ + $eventbusPresenterService = $eventbusModule->getService('PrestaShop\Module\PsEventbus\Service\PresenterService'); + + $this->context->smarty->assign('urlCloudsync', 'https://assets.prestashop3.com/ext/cloudsync-merchant-sync-consent/latest/cloudsync-cdc.js'); + $this->addJs($this->module->getPathUri() . '/views/js/admin/cloudsync.js'); + Media::addJsDef([ + 'contextPsEventbus' => $eventbusPresenterService->expose($this->module, ['info', 'modules', 'themes']), + ]); + } + } + + $this->content .= $this->context->smarty->fetch($this->module->getLocalPath() . 'views/templates/admin/cloudsync.tpl'); + } + public function postProcess() { + $this->initCloudSyncAndPsAccounts(); /** @var \Mollie\Repository\ModuleRepository $moduleRepository */ $moduleRepository = $this->module->getService(\Mollie\Repository\ModuleRepository::class); $moduleDatabaseVersion = $moduleRepository->getModuleDatabaseVersion($this->module->name); diff --git a/module_dependencies.json b/module_dependencies.json new file mode 100644 index 000000000..d8b1e5b1f --- /dev/null +++ b/module_dependencies.json @@ -0,0 +1,10 @@ +{ + "dependencies": [ + { + "name" : "ps_accounts" + }, + { + "name" : "ps_eventbus" + } + ] +} \ No newline at end of file diff --git a/mollie.php b/mollie.php index b6d1d4900..ba3a8f1ff 100755 --- a/mollie.php +++ b/mollie.php @@ -85,7 +85,7 @@ public function __construct() { $this->name = 'mollie'; $this->tab = 'payments_gateways'; - $this->version = '6.0.5'; + $this->version = '6.1.0'; $this->author = 'Mollie B.V.'; $this->need_instance = 1; $this->bootstrap = true; diff --git a/src/Config/Config.php b/src/Config/Config.php index 2ce23d4e1..fb0963599 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -266,6 +266,7 @@ class Config PaymentMethod::KLARNA_PAY_LATER, PaymentMethod::KLARNA_SLICE_IT, PaymentMethod::KLARNA_PAY_NOW, + PaymentMethod::KLARNA_ONE, PaymentMethod::BILLIE, ]; @@ -273,6 +274,7 @@ class Config PaymentMethod::KLARNA_PAY_LATER, PaymentMethod::KLARNA_SLICE_IT, PaymentMethod::KLARNA_PAY_NOW, + PaymentMethod::KLARNA_ONE, PaymentMethod::BILLIE, self::MOLLIE_VOUCHER_METHOD_ID, self::MOLLIE_in3_METHOD_ID, @@ -314,6 +316,9 @@ class Config 'klarnapaynow' => 'Klarna Pay now.', 'in3' => 'in3', 'billie' => 'Billie', + 'twint' => 'TWINT', + 'blik' => 'BLIK', + 'klarna' => 'Pay with Klarna.', ]; const MOLLIE_BUTTON_ORDER_TOTAL_REFRESH = 'MOLLIE_BUTTON_ORDER_TOTAL_REFRESH'; diff --git a/src/Service/ApiService.php b/src/Service/ApiService.php index ce72e8e42..09ecdb344 100644 --- a/src/Service/ApiService.php +++ b/src/Service/ApiService.php @@ -19,6 +19,7 @@ use Mollie\Api\Exceptions\ApiException; use Mollie\Api\MollieApiClient; use Mollie\Api\Resources\BaseCollection; +use Mollie\Api\Resources\Method; use Mollie\Api\Resources\MethodCollection; use Mollie\Api\Resources\Order as MollieOrderAlias; use Mollie\Api\Resources\Payment; @@ -116,9 +117,16 @@ public function getMethodsForConfig(MollieApiClient $api) { $notAvailable = []; try { + /** Requires local param or fails */ /** @var BaseCollection|MethodCollection $apiMethods */ - $apiMethods = $api->methods->allActive(['resource' => 'orders', 'include' => 'issuers', 'includeWallets' => 'applepay']); + $apiMethods = $api->methods->allAvailable(['locale' => '']); $apiMethods = $apiMethods->getArrayCopy(); + /** @var Method $method */ + foreach ($apiMethods as $key => $method) { + if ($method->status !== 'activated') { + unset($apiMethods[$key]); + } + } } catch (Exception $e) { $errorHandler = \Mollie\Handler\ErrorHandler\ErrorHandler::getInstance(); $errorHandler->handle($e, $e->getCode(), false); diff --git a/views/js/admin/cloudsync.js b/views/js/admin/cloudsync.js new file mode 100644 index 000000000..38aee98c0 --- /dev/null +++ b/views/js/admin/cloudsync.js @@ -0,0 +1,15 @@ +$(document).ready(function () { + window?.psaccountsVue?.init(); + + // Cloud Sync + const cdc = window.cloudSyncSharingConsent; + + cdc.init('#prestashop-cloudsync'); + cdc.on('OnboardingCompleted', (isCompleted) => { + console.log('OnboardingCompleted', isCompleted); + + }); + cdc.isOnboardingCompleted((isCompleted) => { + console.log('Onboarding is already Completed', isCompleted); + }); +}); diff --git a/views/templates/admin/cloudsync.tpl b/views/templates/admin/cloudsync.tpl new file mode 100644 index 000000000..adb8e6b83 --- /dev/null +++ b/views/templates/admin/cloudsync.tpl @@ -0,0 +1,35 @@ +{* +* 2007-2023 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2023 PrestaShop SA +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + + +
+
+ +
+ +
+ + + diff --git a/views/templates/admin/dependency_builder.tpl b/views/templates/admin/dependency_builder.tpl new file mode 100644 index 000000000..10ff76f74 --- /dev/null +++ b/views/templates/admin/dependency_builder.tpl @@ -0,0 +1,17 @@ + + + + +
+ + \ No newline at end of file