Skip to content

Commit

Permalink
Merge pull request #922 from mollie/release-6.2.0
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 4e3054b + 39945bd commit bd9da0b
Show file tree
Hide file tree
Showing 193 changed files with 6,544 additions and 1,409 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');
}
}
4 changes: 2 additions & 2 deletions mails/en/mollie_subscription_cancel.html
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@
>
<![endif]--></td>
</tr>
<tr><th bgcolor="#FDFDFD" style="font-family: Open sans, Arial, sans-serif; font-size: 12px; background-color: #fdfdfd; color: #353943; font-weight: 600; padding: 10px 5px; border: 1px solid #DFDFDF;">Reference</th><th bgcolor="#FDFDFD" style="font-family: Open sans, Arial, sans-serif; font-size: 12px; background-color: #fdfdfd; color: #353943; font-weight: 600; padding: 10px 5px; border: 1px solid #DFDFDF;">Product</th><th bgcolor="#FDFDFD" style="font-family: Open sans, Arial, sans-serif; font-size: 12px; background-color: #fdfdfd; color: #353943; font-weight: 600; padding: 10px 5px; border: 1px solid #DFDFDF;">Unit price</th><th bgcolor="#FDFDFD" style="font-family: Open sans, Arial, sans-serif; font-size: 12px; background-color: #fdfdfd; color: #353943; font-weight: 600; padding: 10px 5px; border: 1px solid #DFDFDF;">Quantity</th><th bgcolor="#FDFDFD" style="font-family: Open sans, Arial, sans-serif; font-size: 12px; background-color: #fdfdfd; color: #353943; font-weight: 600; padding: 10px 5px; border: 1px solid #DFDFDF;">Total price</th></tr>
<tr><th bgcolor="#FDFDFD" style="font-family: Open sans, Arial, sans-serif; font-size: 12px; background-color: #fdfdfd; color: #353943; font-weight: 600; padding: 10px 5px; border: 1px solid #DFDFDF;">Reference</th><th bgcolor="#FDFDFD" style="font-family: Open sans, Arial, sans-serif; font-size: 12px; background-color: #fdfdfd; color: #353943; font-weight: 600; padding: 10px 5px; border: 1px solid #DFDFDF;">Product</th><th bgcolor="#FDFDFD" style="font-family: Open sans, Arial, sans-serif; font-size: 12px; background-color: #fdfdfd; color: #353943; font-weight: 600; padding: 10px 5px; border: 1px solid #DFDFDF;">Unit price(tax excl.)</th><th bgcolor="#FDFDFD" style="font-family: Open sans, Arial, sans-serif; font-size: 12px; background-color: #fdfdfd; color: #353943; font-weight: 600; padding: 10px 5px; border: 1px solid #DFDFDF;">Quantity</th><th bgcolor="#FDFDFD" style="font-family: Open sans, Arial, sans-serif; font-size: 12px; background-color: #fdfdfd; color: #353943; font-weight: 600; padding: 10px 5px; border: 1px solid #DFDFDF;">Total price</th></tr>
<tr><th bgcolor="#FDFDFD" style="font-family: Open sans, Arial, sans-serif; font-size: 12px; background-color: #fdfdfd; color: #353943; font-weight: 600; padding: 10px 5px; border: 1px solid #DFDFDF;">subscription_reference</th><th bgcolor="#FDFDFD" style="font-family: Open sans, Arial, sans-serif; font-size: 12px; background-color: #fdfdfd; color: #353943; font-weight: 600; padding: 10px 5px; border: 1px solid #DFDFDF;">product_name</th><th bgcolor="#FDFDFD" style="font-family: Open sans, Arial, sans-serif; font-size: 12px; background-color: #fdfdfd; color: #353943; font-weight: 600; padding: 10px 5px; border: 1px solid #DFDFDF;">unit_price</th><th bgcolor="#FDFDFD" style="font-family: Open sans, Arial, sans-serif; font-size: 12px; background-color: #fdfdfd; color: #353943; font-weight: 600; padding: 10px 5px; border: 1px solid #DFDFDF;">quantity</th><th bgcolor="#FDFDFD" style="font-family: Open sans, Arial, sans-serif; font-size: 12px; background-color: #fdfdfd; color: #353943; font-weight: 600; padding: 10px 5px; border: 1px solid #DFDFDF;">total_price</th></tr>
</tbody>
</table>
Expand Down Expand Up @@ -677,4 +677,4 @@
<p></p>
</body>

</html>
</html>
18 changes: 9 additions & 9 deletions mails/en/mollie_subscription_cancel.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Hi firstName lastName,
We are emailing you because the following item was set to renew and that the payment method on file failed. Please log in into your account and update the payment method.
We’ll keep trying to process your payment however if it continues to fail your subscription will get cancelled.
t
Reference Product Unit price Quantity Total price
subscription_reference product_name unit_price quantity total_price
Hi firstName lastName,


We are emailing you because the following item was set to renew and that the payment method on file failed. Please log in into your account and update the payment method.

We’ll keep trying to process your payment however if it continues to fail your subscription will get cancelled.

Reference Product Unit price(tax excl.) Quantity Total price
subscription_reference product_name unit_price quantity total_price
Loading

0 comments on commit bd9da0b

Please sign in to comment.