Skip to content

Commit

Permalink
Merge pull request #893 from mollie/develop
Browse files Browse the repository at this point in the history
Develop-6.1.0
  • Loading branch information
JevgenijVisockij authored Mar 19, 2024
2 parents e52bede + 780e572 commit 1d60186
Show file tree
Hide file tree
Showing 35 changed files with 3,072 additions and 563 deletions.
79 changes: 0 additions & 79 deletions .docker/.htaccess1785

This file was deleted.

53 changes: 29 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
module = mollie

# target: fix-lint - Launch php cs fixer
fix-lint:
Expand All @@ -14,26 +15,15 @@ endif

# Local machine docker build with PS autoinstall
e2eh$(VERSION)_local:
composer install
# detaching containers
docker-compose -f docker-compose.$(VERSION).yml up -d --force-recreate
# sees what containers are running
docker-compose -f docker-compose.$(VERSION).yml ps
# waiting for app containers to build up
/bin/bash .docker/wait-loader.sh 8002
# seeding the customized settings for PS
mysql -h 127.0.0.1 -P 9002 --protocol=tcp -u root -pprestashop prestashop < ${PWD}/tests/seed/database/prestashop_$(VERSION).sql
# installing module
docker exec -i prestashop-mollie-$(VERSION) sh -c "cd /var/www/html && php bin/console prestashop:module install mollie"
# installing module (in case for Addons Marketplace)
docker exec -i prestashop-mollie-$(VERSION) sh -c "cd /var/www/html && php bin/console prestashop:module install mollie"
# uninstalling module
docker exec -i prestashop-mollie-$(VERSION) sh -c "cd /var/www/html && php bin/console prestashop:module uninstall mollie"
# installing the module again
docker exec -i prestashop-mollie-$(VERSION) sh -c "cd /var/www/html && php bin/console prestashop:module install mollie"
# enabling the module
docker exec -i prestashop-mollie-$(VERSION) sh -c "cd /var/www/html && php bin/console prestashop:module enable mollie"
# chmod all folders
docker exec -i prestashop-mollie-$(VERSION) sh -c "chmod -R 777 /var/www/html"
make waiting-for-containers-local
make seeding-customized-sql
make installing-uninstalling-enabling-module
make chmod-app
make open-e2e-tests-locally

# For CI build with PS autoinstall
Expand All @@ -42,20 +32,35 @@ e2eh$(VERSION):
docker-compose -f docker-compose.$(VERSION).yml up -d --force-recreate
# sees what containers are running
docker-compose -f docker-compose.$(VERSION).yml ps
make waiting-for-containers-CI
make seeding-customized-sql
make installing-uninstalling-enabling-module
make chmod-app

waiting-for-containers-CI:
# waiting for app containers to build up
sleep 90s
# configuring base database

waiting-for-containers-local:
# waiting for app containers to build up
/bin/bash .docker/wait-loader.sh 8002

seeding-customized-sql:
mysql -h 127.0.0.1 -P 9002 --protocol=tcp -u root -pprestashop prestashop < ${PWD}/tests/seed/database/prestashop_$(VERSION).sql

installing-uninstalling-enabling-module:
# installing module
docker exec -i prestashop-mollie-$(VERSION) sh -c "cd /var/www/html && php bin/console prestashop:module install mollie"
docker exec -i prestashop-$(module)-$(VERSION) sh -c "cd /var/www/html && php bin/console prestashop:module install $(module)"
# uninstalling module
docker exec -i prestashop-mollie-$(VERSION) sh -c "cd /var/www/html && php bin/console prestashop:module uninstall mollie"
docker exec -i prestashop-$(module)-$(VERSION) sh -c "cd /var/www/html && php bin/console prestashop:module uninstall $(module)"
# installing the module again
docker exec -i prestashop-mollie-$(VERSION) sh -c "cd /var/www/html && php bin/console prestashop:module install mollie"
docker exec -i prestashop-$(module)-$(VERSION) sh -c "cd /var/www/html && php bin/console prestashop:module install $(module)"
# enabling the module
docker exec -i prestashop-mollie-$(VERSION) sh -c "cd /var/www/html && php bin/console prestashop:module enable mollie"
docker exec -i prestashop-$(module)-$(VERSION) sh -c "cd /var/www/html && php bin/console prestashop:module enable $(module)"

chmod-app:
# chmod all folders
docker exec -i prestashop-mollie-$(VERSION) sh -c "chmod -R 777 /var/www/html"
docker exec -i prestashop-$(module)-$(VERSION) sh -c "chmod -R 777 /var/www/html"

open-e2e-tests-locally:
npm install -D cypress
Expand All @@ -73,11 +78,11 @@ upgrading-module-test-$(VERSION):
git checkout v5.2.0 .
composer install
# installing 5.2.0 module
docker exec -i prestashop-mollie-$(VERSION) sh -c "cd /var/www/html && php bin/console prestashop:module install mollie"
docker exec -i prestashop-$(module)-$(VERSION) sh -c "cd /var/www/html && php bin/console prestashop:module install $(module)"
# installing develop branch module
git checkout -- .
git checkout develop --force
docker exec -i prestashop-mollie-$(VERSION) sh -c "cd /var/www/html && php bin/console prestashop:module install mollie"
docker exec -i prestashop-$(module)-$(VERSION) sh -c "cd /var/www/html && php bin/console prestashop:module install $(module)"

npm-package-install:
cd views/assets && npm i && npm run build
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
80 changes: 70 additions & 10 deletions controllers/admin/AdminMollieSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,77 @@ public function __construct()
$this->bootstrap = true;
}

private function initCloudSyncAndPsAccounts(): bool
{
$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');

return false;
}

$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');

return true;
}

public function postProcess()
{
/** @var \Mollie\Service\Content\TemplateParserInterface $templateParser */
$templateParser = $this->module->getService(\Mollie\Service\Content\TemplateParserInterface::class);

$this->content = $templateParser->parseTemplate(
$this->context->smarty,
$this->module->getService(\Mollie\Builder\Content\LogoInfoBlock::class),
$this->module->getLocalPath() . 'views/templates/admin/logo.tpl'
);
$cloudSyncComplete = $this->initCloudSyncAndPsAccounts();
if (!$cloudSyncComplete) {
return;
}
/** @var \Mollie\Repository\ModuleRepository $moduleRepository */
$moduleRepository = $this->module->getService(\Mollie\Repository\ModuleRepository::class);
$moduleDatabaseVersion = $moduleRepository->getModuleDatabaseVersion($this->module->name);
Expand All @@ -47,9 +116,6 @@ public function postProcess()
return;
}

/** @var \Mollie\Service\Content\TemplateParserInterface $templateParser */
$templateParser = $this->module->getService(\Mollie\Service\Content\TemplateParserInterface::class);

$isSubmitted = (bool) Tools::isSubmit("submit{$this->module->name}");

/* @phpstan-ignore-next-line */
Expand Down Expand Up @@ -95,17 +161,11 @@ public function postProcess()
$this->context->controller->addCSS($this->module->getPathUri() . 'views/css/mollie.css');
$this->context->controller->addCSS($this->module->getPathUri() . 'views/css/admin/logo_input.css');

$html = $templateParser->parseTemplate(
$this->context->smarty,
$this->module->getService(\Mollie\Builder\Content\LogoInfoBlock::class),
$this->module->getLocalPath() . 'views/templates/admin/logo.tpl'
);

/** @var \Mollie\Builder\Content\UpdateMessageInfoBlock $updateMessageInfoBlock */
$updateMessageInfoBlock = $this->module->getService(\Mollie\Builder\Content\UpdateMessageInfoBlock::class);
$updateMessageInfoBlockData = $updateMessageInfoBlock->setAddons(false);

$html .= $templateParser->parseTemplate(
$html = $templateParser->parseTemplate(
$this->context->smarty,
$updateMessageInfoBlockData,
$this->module->getLocalPath() . 'views/templates/admin/updateMessage.tpl'
Expand Down
18 changes: 2 additions & 16 deletions cypress/e2e/ps1785/01_mollie.ps1785.ModuleConfiguration.specs.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
/// <reference types="Cypress" />
//Caching the BO and FO session
const login = (MollieBOFOLoggingIn) => {
cy.session(MollieBOFOLoggingIn,() => {
cy.visit('/admin1/')
cy.url().should('contain', 'https').as('Check if HTTPS exists')
cy.get('#email').type('[email protected]',{delay: 0, log: false})
cy.get('#passwd').type('demodemo',{delay: 0, log: false})
cy.get('#submit_login').click().wait(1000).as('Connection successsful')
cy.visit('/en/my-account')
cy.get('#login-form [name="email"]').eq(0).type('[email protected]')
cy.get('#login-form [name="password"]').eq(0).type('demodemo')
cy.get('#login-form [type="submit"]').eq(0).click({force:true})
cy.get('#history-link > .link-item').click()
})
}

//Checking the console for errors
let windowConsoleError;
Cypress.on('window:before:load', (win) => {
Expand All @@ -30,7 +16,7 @@ afterEach(function() {
describe('PS1785 Module initial configuration setup', () => {
beforeEach(() => {
cy.viewport(1920,1080)
login('MollieBOFOLoggingIn')
cy.CachingBOFOPS1785()
})
it('C339305: 01 Connecting test API successsfully', () => {
cy.visit('/admin1/')
Expand Down
Loading

0 comments on commit 1d60186

Please sign in to comment.