Skip to content

Commit

Permalink
Merge pull request #889 from mollie/release-6.1.0
Browse files Browse the repository at this point in the history
Release 6.1.0
  • Loading branch information
JevgenijVisockij authored Mar 5, 2024
2 parents 89f0450 + 23a8872 commit cff9740
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 7 deletions.
5 changes: 4 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
"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",
"prestashop/module-lib-service-container": "v2.0",
"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",
Expand All @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
54 changes: 54 additions & 0 deletions controllers/admin/AdminMollieSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions module_dependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dependencies": [
{
"name" : "ps_accounts"
},
{
"name" : "ps_eventbus"
}
]
}
2 changes: 1 addition & 1 deletion mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,15 @@ class Config
PaymentMethod::KLARNA_PAY_LATER,
PaymentMethod::KLARNA_SLICE_IT,
PaymentMethod::KLARNA_PAY_NOW,
PaymentMethod::KLARNA_ONE,
PaymentMethod::BILLIE,
];

const ORDER_API_ONLY_METHODS = [
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,
Expand Down Expand Up @@ -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';
Expand Down
10 changes: 9 additions & 1 deletion src/Service/ApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions views/js/admin/cloudsync.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
35 changes: 35 additions & 0 deletions views/templates/admin/cloudsync.tpl
Original file line number Diff line number Diff line change
@@ -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 [email protected] 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 <[email protected]>
* @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
*}

<prestashop-accounts></prestashop-accounts>
<br>
<div id="prestashop-cloudsync"></div>

<div id="ps-modal"></div>

<br>

<script src="{$urlAccountsCdn|escape:'htmlall':'UTF-8'}" rel=preload></script>
<script src="{$urlCloudsync|escape:'htmlall':'UTF-8'}"></script>
17 changes: 17 additions & 0 deletions views/templates/admin/dependency_builder.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Load cdc library -->
<script src="https://assets.prestashop3.com/dst/mbo/v1/mbo-cdc-dependencies-resolver.umd.js"></script>

<!-- cdc container -->
<div id="cdc-container"></div>

<script defer>
const renderMboCdcDependencyResolver = window.mboCdcDependencyResolver.render
const context = {
...{$dependencies|json_encode},
onDependenciesResolved: () => location.reload(),
onDependencyResolved: (dependencyData) => console.log('Dependency installed', dependencyData), // name, displayName, version
onDependencyFailed: (dependencyData) => console.log('Failed to install dependency', dependencyData),
onDependenciesFailed: () => console.log('There are some errors'),
}
renderMboCdcDependencyResolver(context, '#cdc-container')
</script>

0 comments on commit cff9740

Please sign in to comment.