Skip to content

Commit

Permalink
Merge pull request mollie#937 from mollie/develop
Browse files Browse the repository at this point in the history
Release 6.2.0
  • Loading branch information
GytisZum authored Jun 10, 2024
2 parents 668c8c1 + bd9da0b commit f465a4b
Show file tree
Hide file tree
Showing 202 changed files with 6,843 additions and 1,701 deletions.
File renamed without changes.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,13 @@ upgrading-module-test-$(VERSION):

npm-package-install:
cd views/assets && npm i && npm run build

prepare-zip:
composer install --no-dev --optimize-autoloader --classmap-authoritative
composer dump-autoload --no-dev --optimize --classmap-authoritative
cp .github/.htaccess vendor/.htaccess
rm -rf .git .docker .editorconfig .github tests .php-cs-fixer.php Makefile cypress .docker cypress.config.js cypress.env.json docker-compose*.yml .gitignore bin codeception.yml package-lock.json package.json .php_cs.dist .php-cs-fixer.dist




10 changes: 10 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

# Changelog #

## Changes in release 6.2.0 ##
+ New payment methods: Bancomat and Alma
+ Apple certificate update
+ Conflicting services fix
+ Bootstrap 5 compatibility improved
+ Maximum fee field
+ Multi carrier for subscription orders added
+ Design improvements in BO
+ Improved subscription creation logic

## Changes in release 6.1.1 ##
+ Updated translations for Dutch, German, English and French languages
+ Added credit card translations for Italian and Spanish languages
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"require-dev": {
"roave/security-advisories": "dev-latest",
"invertus/prestashop-models": "^1.0",
"prestashop/php-dev-tools": "*",
"phpunit/phpunit": "~5.7"
},
Expand All @@ -32,7 +33,8 @@
"autoload": {
"psr-4": {
"Mollie\\": "src/",
"Mollie\\Subscription\\": "subscription/"
"Mollie\\Subscription\\": "subscription/",
"Mollie\\Shared\\": "shared/"
},
"classmap": [
"mollie.php",
Expand Down
47 changes: 27 additions & 20 deletions controllers/front/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
use Mollie\Adapter\ConfigurationAdapter;
use Mollie\Adapter\ToolsAdapter;
use Mollie\Controller\AbstractMollieController;
use Mollie\Errors\Http\HttpStatusCode;
use Mollie\Exception\FailedToProvidePaymentFeeException;
use Mollie\Infrastructure\Response\JsonResponse;
use Mollie\Provider\PaymentFeeProviderInterface;
use Mollie\Repository\CurrencyRepositoryInterface;
use Mollie\Subscription\Exception\SubscriptionProductValidationException;
use Mollie\Shared\Core\Shared\Repository\CurrencyRepositoryInterface;
use Mollie\Subscription\Exception\ExceptionCode;
use Mollie\Subscription\Validator\CanProductBeAddedToCartValidator;
use Mollie\Utility\NumberUtility;

Expand Down Expand Up @@ -185,30 +187,35 @@ private function displayCheckoutError(): void

private function validateProduct(): void
{
/** @var CanProductBeAddedToCartValidator $cartValidation */
$cartValidation = $this->module->getService(CanProductBeAddedToCartValidator::class);
/** @var CanProductBeAddedToCartValidator $canProductBeAddedToCartValidator */
$canProductBeAddedToCartValidator = $this->module->getService(CanProductBeAddedToCartValidator::class);

$product = Tools::getValue('product');

$productCanBeAdded = true;
$message = '';

try {
$cartValidation->validate((int) $product['id_product_attribute']);
} catch (SubscriptionProductValidationException $e) {
$productCanBeAdded = false;
$message = $this->module->l('Please note: Only one subscription product can be added to the cart at a time.', self::FILE_NAME);
$canProductBeAddedToCartValidator->validate((int) ($product['id_product_attribute'] ?? 0));
} catch (\Throwable $exception) {
if ($exception->getCode() === ExceptionCode::CART_ALREADY_HAS_SUBSCRIPTION_PRODUCT) {
$this->ajaxResponse(JsonResponse::error(
$this->module->l('Please note: Only one subscription product can be added to the cart at a time.', self::FILE_NAME),
HttpStatusCode::HTTP_BAD_REQUEST
));
}

if ($exception->getCode() === ExceptionCode::CART_INVALID_SUBSCRIPTION_SETTINGS) {
$this->ajaxResponse(JsonResponse::error(
$this->module->l('Subscription service is disabled. Please change the attribute to Subscription: none.', self::FILE_NAME),
HttpStatusCode::HTTP_BAD_REQUEST
));
}

$this->ajaxResponse(JsonResponse::error(
$this->module->l('Unknown error. Try again or change the attribute to Subscription: none.', self::FILE_NAME),
HttpStatusCode::HTTP_BAD_REQUEST
));
}

$this->ajaxRender(
json_encode(
[
'success' => true,
'isValid' => $productCanBeAdded,
'message' => $message,
]
)
);
$this->ajaxResponse(JsonResponse::success([]));
}

private function returnDefaultOrderSummaryBlock(Cart $cart, array $errorData = [], array $presentedCart = null): void
Expand Down
26 changes: 22 additions & 4 deletions controllers/front/recurringOrderDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,28 @@ public function initContent()
$recurringOrderId = (int) Tools::getValue('id_mol_recurring_order');
$recurringOrderId = Validate::isUnsignedId($recurringOrderId) ? $recurringOrderId : false;

$failureRedirectUrl = Context::getContext()->link->getModuleLink($this->module->name, 'subscriptions', [], true);

/** @var RecurringOrderRepositoryInterface $recurringOrderRepository */
$recurringOrderRepository = $this->module->getService(RecurringOrderRepositoryInterface::class);

$recurringOrder = $recurringOrderRepository->findOneBy(['id_mol_recurring_order' => $recurringOrderId]);
try {
/** @var \MolRecurringOrder $recurringOrder */
$recurringOrder = $recurringOrderRepository->findOrFail([
'id_mol_recurring_order' => $recurringOrderId,
]);
} catch (\Throwable $exception) {
// TODO add notification about data retrieve failure

Tools::redirect($failureRedirectUrl);

return;
}

if ((int) $recurringOrder->id_customer !== (int) $this->context->customer->id) {
Tools::redirect($failureRedirectUrl);

if (!Validate::isLoadedObject($recurringOrder) || (int) $recurringOrder->id_customer !== (int) $this->context->customer->id) {
Tools::redirect(Context::getContext()->link->getModuleLink($this->module->name, 'subscriptions', [], true));
return;
}

/** @var PrestaLoggerInterface $logger */
Expand All @@ -82,10 +97,13 @@ public function initContent()
'Exception code' => $exception->getCode(),
]);

Tools::redirect(Context::getContext()->link->getModuleLink($this->module->name, 'subscriptions', [], true));
Tools::redirect($failureRedirectUrl);

return;
}

parent::initContent();

$this->context->controller->addCSS($this->module->getPathUri() . 'views/css/front/subscription/customer_order_detail.css');
$this->setTemplate('module:mollie/views/templates/front/subscription/customerRecurringOrderDetail.tpl');
}
Expand Down
46 changes: 24 additions & 22 deletions controllers/front/subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @codingStandardsIgnoreStart
*/

use Mollie\Repository\MolCustomerRepository;
use Mollie\Repository\MolCustomerRepositoryInterface;
use Mollie\Subscription\Presenter\RecurringOrdersPresenter;

/*
Expand Down Expand Up @@ -52,40 +52,29 @@ class mollieSubscriptionsModuleFrontController extends ModuleFrontController
*/
public $display_column_left;

/**
* @throws PrestaShopException
*/
public function initContent()
{
$this->display_column_right = false;
$this->display_column_left = false;
$context = Context::getContext();
if (empty($context->customer->id)) {

if (empty($this->context->customer->id)) {
Tools::redirect('index.php');
}

/** @var MolCustomerRepository $molCustomerRepository */
$molCustomerRepository = $this->module->getService(MolCustomerRepository::class);
/** @var MolCustomerRepositoryInterface $molCustomerRepository */
$molCustomerRepository = $this->module->getService(MolCustomerRepositoryInterface::class);

/** @var RecurringOrdersPresenter $recurringOrdersPresenter */
$recurringOrdersPresenter = $this->module->getService(RecurringOrdersPresenter::class);

$molCustomer = $molCustomerRepository->findOneBy(['email' => $context->customer->email]);

$recurringOrdersPresentData = [];
if ($molCustomer) {
$recurringOrdersPresentData = $recurringOrdersPresenter->present($molCustomer->customer_id);
}

parent::initContent();

$this->context->smarty->assign([
'recurringOrdersData' => $recurringOrdersPresentData,
/** @var ?\MolCustomer $molCustomer */
$molCustomer = $molCustomerRepository->findOneBy([
'email' => $this->context->customer->email,
]);

$this->context->smarty->tpl_vars['page']->value['body_classes']['page-customer-account'] = true;

$this->setTemplate('module:mollie/views/templates/front/subscription/customerSubscriptionsData.tpl');
$this->prepareTemplate(
$molCustomer ? $recurringOrdersPresenter->present($molCustomer->customer_id) : []
);
}

public function setMedia()
Expand All @@ -97,4 +86,17 @@ public function setMedia()
$this->context->controller->addJS($js_path . 'front.js');
$this->context->controller->addCSS($css_path . 'customerPersonalData.css');
}

private function prepareTemplate(array $recurringOrdersPresentData = []): void
{
parent::initContent();

$this->context->smarty->assign([
'recurringOrdersData' => $recurringOrdersPresentData,
]);

$this->context->smarty->tpl_vars['page']->value['body_classes']['page-customer-account'] = true;

$this->setTemplate('module:mollie/views/templates/front/subscription/customerSubscriptionsData.tpl');
}
}
33 changes: 2 additions & 31 deletions cypress/e2e/ps1785/01_mollie.ps1785.ModuleConfiguration.specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,9 @@ it('C339339: 03 Checking the Advanced Settings tab, verifying the Front-end comp
cy.visit('/admin1/')
cy.OpeningModuleDashboardURL()
cy.get('[href="#advanced_settings"]').click({force:true})
cy.get('[id="MOLLIE_PAYMENTSCREEN_LOCALE"]').should('be.visible')
cy.get('[id="MOLLIE_SEND_ORDER_CONFIRMATION"]').should('be.visible')
cy.get('[id="MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS"]').should('be.visible')
cy.get('[class="help-block"]').should('be.visible')
cy.get('[id="MOLLIE_STATUS_AWAITING"]').should('be.visible')
cy.get('[id="MOLLIE_STATUS_PAID"]').should('be.visible')
cy.get('[name="MOLLIE_MAIL_WHEN_PAID"]').should('exist')
cy.get('[name="MOLLIE_MAIL_WHEN_COMPLETED"]').should('exist')
cy.get('[name="MOLLIE_STATUS_COMPLETED"]').should('exist')
cy.get('[name="MOLLIE_MAIL_WHEN_CANCELED"]').should('exist')
cy.get('[name="MOLLIE_STATUS_CANCELED"]').should('exist')
cy.get('[name="MOLLIE_MAIL_WHEN_EXPIRED"]').should('exist')
cy.get('[name="MOLLIE_STATUS_EXPIRED"]').should('exist')
cy.get('[name="MOLLIE_MAIL_WHEN_REFUNDED"]').should('exist')
cy.get('[name="MOLLIE_STATUS_REFUNDED"]').should('exist')
cy.get('[name="MOLLIE_STATUS_OPEN"]').should('exist')
cy.get('[name="MOLLIE_MAIL_WHEN_SHIPPING"]').should('exist')
cy.get('[name="MOLLIE_STATUS_SHIPPING"]').should('exist')
cy.get('[name="MOLLIE_STATUS_PARTIAL_REFUND"]').should('exist')
cy.get('[name="MOLLIE_IMAGES"]').should('exist')
cy.get('[name="MOLLIE_CSS"]').should('exist')
cy.get('[id="MOLLIE_TRACKING_URLS__container"]').should('exist')
cy.get('[id="MOLLIE_AS_MAIN_info"]').should('exist')
cy.get('[id="MOLLIE_AS_STATUSES_info"]').should('exist')
cy.get('[name="MOLLIE_DISPLAY_ERRORS"]').should('exist')
cy.get('[name="MOLLIE_DEBUG_LOG"]').should('exist')
cy.advancedSettingsValidation()
cy.reload()
cy.matchImage(); // let's make a snapshot for visual regression testing later, if UI matches
//cy.window() will check if there are no Errors in console
});
it('C688472: Checking the Subscriptions tab, and console errors', () => {
cy.visit('/admin1/')
Expand All @@ -84,10 +58,7 @@ it('C688473: Checking the Subscriptions FAQ, and console errors', () => {
cy.visit('/admin1/')
cy.OpeningModuleDashboardURL()
cy.get('#subtab-AdminMollieSubscriptionFAQ').click()
cy.get(':nth-child(2) > .col-lg-12 > .card').should('be.visible')
cy.get(':nth-child(3) > .col-lg-12 > .card').should('be.visible')
cy.get(':nth-child(4) > .col-lg-12 > .card').should('be.visible')
cy.get(':nth-child(5) > .col-lg-12 > .card').should('be.visible')
cy.subscriptionsUiCheck()
cy.matchImage(); // let's make a snapshot for visual regression testing later, if UI matches
});
})
64 changes: 32 additions & 32 deletions cypress/e2e/ps1785/03_mollie.ps1785.PaymentTestsOrdersAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,43 +338,43 @@ it('C1860461: Pay with Klarna UK Order Shipping, Refunding [Orders API]', () =>
})
// TODO - some reported possible bugs in the workflow, but still continuing on completing the tests...
it.only('Blik Checkouting [Orders API]', () => {
cy.visit('/en/order-history')
// switching the currency
cy.pause()
cy.contains('Reorder').click()
cy.contains('UK').click({force:true})
//Billing country LT, DE etc.
cy.get('.clearfix > .btn').click()
cy.get('#js-delivery > .continue').click()
//Payment method choosing
cy.contains('Blik').click({force:true})
cy.get('.condition-label > .js-terms').click({force:true})
cy.contains('Place order').click()
cy.get('[value="authorized"]').click()
cy.get('[class="button form__button"]').click()
cy.get('#content-hook_order_confirmation > .card-block').should('be.visible')
cy.visit('/en/order-history')
// switching the currency
cy.pause()
cy.contains('Reorder').click()
cy.contains('UK').click({force:true})
//Billing country LT, DE etc.
cy.get('.clearfix > .btn').click()
cy.get('#js-delivery > .continue').click()
//Payment method choosing
cy.contains('Blik').click({force:true})
cy.get('.condition-label > .js-terms').click({force:true})
cy.contains('Place order').click()
cy.get('[value="authorized"]').click()
cy.get('[class="button form__button"]').click()
cy.get('#content-hook_order_confirmation > .card-block').should('be.visible')
});
it.only('Blik Order Shipping, Refunding [Orders API]', () => {
cy.OrderShippingRefundingOrdersAPI()
cy.OrderShippingRefundingOrdersAPI()
})
it('TWINT Checkouting [Orders API]', () => {
cy.visit('/en/order-history')
// switching the currency
cy.pause()
cy.contains('Reorder').click()
cy.contains('UK').click({force:true})
//Billing country LT, DE etc.
cy.get('.clearfix > .btn').click()
cy.get('#js-delivery > .continue').click()
//Payment method choosing
cy.contains('TWINT').click({force:true})
cy.get('.condition-label > .js-terms').click({force:true})
cy.contains('Place order').click()
cy.get('[value="authorized"]').click()
cy.get('[class="button form__button"]').click()
cy.get('#content-hook_order_confirmation > .card-block').should('be.visible')
cy.visit('/en/order-history')
// switching the currency
cy.pause()
cy.contains('Reorder').click()
cy.contains('UK').click({force:true})
//Billing country LT, DE etc.
cy.get('.clearfix > .btn').click()
cy.get('#js-delivery > .continue').click()
//Payment method choosing
cy.contains('TWINT').click({force:true})
cy.get('.condition-label > .js-terms').click({force:true})
cy.contains('Place order').click()
cy.get('[value="authorized"]').click()
cy.get('[class="button form__button"]').click()
cy.get('#content-hook_order_confirmation > .card-block').should('be.visible')
});
it('TWINT Order Shipping, Refunding [Orders API]', () => {
cy.OrderShippingRefundingOrdersAPI()
cy.OrderShippingRefundingOrdersAPI()
})
})
Loading

0 comments on commit f465a4b

Please sign in to comment.