Skip to content

Commit

Permalink
Merge pull request #1004 from mollie/PIPRES-468/title-multilang
Browse files Browse the repository at this point in the history
PIPRES-468 Title multilang functionality
  • Loading branch information
GytisZum authored Dec 10, 2024
2 parents c00a2ec + 821c15e commit 3f9a4db
Show file tree
Hide file tree
Showing 26 changed files with 435 additions and 103 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

# Changelog #

## Changes in release 6.2.5 ##
+ Fixed issue with order status on multishop
+ Phone number validation improvements
+ Add to cart validation improvements on recurring orders
+ Code bawe improvements following prestashop standards

## Changes in release 6.2.4 ##
+ Workflow improvements
+ Satispay payment method added
Expand Down
3 changes: 0 additions & 3 deletions controllers/admin/AdminMollieSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,6 @@ public function postProcess()
/** @var \Mollie\Builder\FormBuilder $settingsFormBuilder */
$settingsFormBuilder = $this->module->getService(\Mollie\Builder\FormBuilder::class);

/** @var Logger $logger * */
$logger = $this->module->getService(LoggerInterface::class);

try {
$html .= $settingsFormBuilder->buildSettingsForm();
} catch (PrestaShopDatabaseException $e) {
Expand Down
2 changes: 1 addition & 1 deletion mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function __construct()
{
$this->name = 'mollie';
$this->tab = 'payments_gateways';
$this->version = '6.2.4';
$this->version = '6.2.5';
$this->author = 'Mollie B.V.';
$this->need_instance = 1;
$this->bootstrap = true;
Expand Down
11 changes: 11 additions & 0 deletions shared/Core/Shared/Repository/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
4 changes: 4 additions & 0 deletions shared/Infrastructure/Exception/MollieDatabaseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
use Mollie\Exception\Code\ExceptionCode;
use Mollie\Exception\MollieException;

if (!defined('_PS_VERSION_')) {
exit;
}

class MollieDatabaseException extends MollieException
{
public static function failedToFindRecord(string $className, array $keyValues): self
Expand Down
10 changes: 4 additions & 6 deletions src/Entity/MolPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ class MolPaymentMethod extends ObjectModel
*/
public $method_name;

/**
* @var string
*/
public $title;

/**
* @var string
*/
Expand Down Expand Up @@ -112,6 +107,10 @@ class MolPaymentMethod extends ObjectModel
* @var int
*/
public $id_shop;
/**
* @var array
*/
public $titles;

/**
* @var array
Expand All @@ -123,7 +122,6 @@ class MolPaymentMethod extends ObjectModel
'id_method' => ['type' => self::TYPE_STRING, 'validate' => 'isString'],
'method_name' => ['type' => self::TYPE_STRING, 'validate' => 'isString'],
'enabled' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
'title' => ['type' => self::TYPE_STRING, 'validate' => 'isString'],
'method' => ['type' => self::TYPE_STRING, 'validate' => 'isString'],
'description' => ['type' => self::TYPE_STRING, 'validate' => 'isString'],
'is_countries_applicable' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
Expand Down
65 changes: 65 additions & 0 deletions src/Entity/MolPaymentMethodLang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
/**
* Mollie https://www.mollie.nl
*
* @author Mollie B.V. <[email protected]>
* @copyright Mollie B.V.
* @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md
*
* @see https://github.com/mollie/PrestaShop
* @codingStandardsIgnoreStart
*/
if (!defined('_PS_VERSION_')) {
exit;
}

class MolPaymentMethodLang extends ObjectModel
{
/** @var int */
public $id;

/** @var string name of the payment method */
public $id_method;

/** @var int */
public $id_lang;

/** @var int */
public $id_shop;

/** @var string payment title */
public $text;

/**
* Definition of the ObjectModel
*/
public static $definition = [
'table' => 'mol_payment_method_lang',
'primary' => 'id',
'fields' => [
'id_method' => [
'type' => self::TYPE_STRING,
'validate' => 'isString',
'required' => true,
'size' => 64,
],
'id_lang' => [
'type' => self::TYPE_INT,
'validate' => 'isUnsignedInt',
'required' => true,
'size' => 11,
],
'id_shop' => [
'type' => self::TYPE_INT,
'validate' => 'isUnsignedInt',
'required' => true,
'size' => 11,
],
'text' => [
'type' => self::TYPE_STRING,
'validate' => 'isString',
'size' => 255,
],
],
];
}
11 changes: 10 additions & 1 deletion src/Install/DatabaseTableInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ private function getCommands()
`id_method` VARCHAR(64) NOT NULL,
`method_name` VARCHAR(64) NOT NULL,
`enabled` TINYINT(1),
`title` VARCHAR(64),
`method` VARCHAR(64),
`description` VARCHAR(255),
`is_countries_applicable` TINYINT(1),
Expand Down Expand Up @@ -151,6 +150,16 @@ private function getCommands()
INDEX (`id_shop`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;';

$sql[] = '
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'mol_payment_method_lang` (
`id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`id_method` VARCHAR(64) NOT NULL,
`id_lang` INT(11),
`id_shop` INT(11),
`text` TINYTEXT,
INDEX (`id_method`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;';

return $sql;
}

Expand Down
1 change: 1 addition & 0 deletions src/Install/DatabaseTableUninstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ private function getCommands(): array
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'mol_excluded_country`;';
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'mol_pending_order_cart_rule`;';
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'mol_payment_method_order_total_restriction`;';
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'mol_payment_method_lang`;';

return $sql;
}
Expand Down
4 changes: 4 additions & 0 deletions src/Logger/LogFormatterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

namespace Mollie\Logger;

if (!defined('_PS_VERSION_')) {
exit;
}

interface LogFormatterInterface
{
/**
Expand Down
4 changes: 4 additions & 0 deletions src/Logger/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
use Mollie\Service\EntityManager\ObjectModelUnitOfWork;
use Mollie\Utility\NumberIdempotencyProvider;

if (!defined('_PS_VERSION_')) {
exit;
}

class Logger implements LoggerInterface
{
public const FILE_NAME = 'Logger';
Expand Down
4 changes: 4 additions & 0 deletions src/Logger/LoggerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

namespace Mollie\Logger;

if (!defined('_PS_VERSION_')) {
exit;
}

interface LoggerInterface extends \Psr\Log\LoggerInterface
{
}
21 changes: 19 additions & 2 deletions src/Provider/PaymentOption/BancontactPaymentOptionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@
namespace Mollie\Provider\PaymentOption;

use Mollie;
use Mollie\Adapter\Context;
use Mollie\Adapter\LegacyContext;
use Mollie\Api\Types\PaymentMethod;
use Mollie\Provider\CreditCardLogoProvider;
use Mollie\Provider\OrderTotal\OrderTotalProviderInterface;
use Mollie\Provider\PaymentFeeProviderInterface;
use Mollie\Repository\PaymentMethodLangRepositoryInterface;
use Mollie\Service\LanguageService;
use MolPaymentMethod;
use MolPaymentMethodLang;
use PrestaShop\PrestaShop\Core\Payment\PaymentOption;
use Tools;

Expand Down Expand Up @@ -79,6 +82,7 @@ class BancontactPaymentOptionProvider implements PaymentOptionProviderInterface
* @var LanguageService
*/
private $languageService;

/** @var OrderTotalProviderInterface */
private $orderTotalProvider;

Expand All @@ -105,10 +109,23 @@ public function getPaymentOption(MolPaymentMethod $paymentMethod): PaymentOption
{
$paymentOption = new PaymentOption();

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

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

/** @var MolPaymentMethodLang $molPaymentMethodLang */
$molPaymentMethodLang = $paymentMethodLangRepository->findOneBy([
'id_method' => $paymentMethod->id_method,
'id_lang' => $context->getLanguageId(),
'id_shop' => $context->getShopId(),
]);

$paymentOption->setCallToActionText(
$paymentMethod->title ?:
$this->languageService->lang($paymentMethod->method_name)
$molPaymentMethodLang->text ?: $paymentMethod->method_name
);

$paymentOption->setModuleName($this->module->name);
$paymentOption->setAction($this->context->getLink()->getModuleLink(
'mollie',
Expand Down
21 changes: 19 additions & 2 deletions src/Provider/PaymentOption/BasePaymentOptionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@
namespace Mollie\Provider\PaymentOption;

use Mollie;
use Mollie\Adapter\Context;
use Mollie\Adapter\LegacyContext;
use Mollie\Provider\CreditCardLogoProvider;
use Mollie\Provider\OrderTotal\OrderTotalProviderInterface;
use Mollie\Provider\PaymentFeeProviderInterface;
use Mollie\Repository\PaymentMethodLangRepositoryInterface;
use Mollie\Service\LanguageService;
use MolPaymentMethod;
use MolPaymentMethodLang;
use PrestaShop\PrestaShop\Core\Payment\PaymentOption;
use Tools;

Expand Down Expand Up @@ -78,6 +81,7 @@ class BasePaymentOptionProvider implements PaymentOptionProviderInterface
* @var LanguageService
*/
private $languageService;

/** @var OrderTotalProviderInterface */
private $orderTotalProvider;

Expand All @@ -104,10 +108,23 @@ public function getPaymentOption(MolPaymentMethod $paymentMethod): PaymentOption
{
$paymentOption = new PaymentOption();

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

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

/** @var MolPaymentMethodLang $molPaymentMethodLang */
$molPaymentMethodLang = $paymentMethodLangRepository->findOneBy([
'id_method' => $paymentMethod->id_method,
'id_lang' => $context->getLanguageId(),
'id_shop' => $context->getShopId(),
]);

$paymentOption->setCallToActionText(
$paymentMethod->title ?:
$this->languageService->lang($paymentMethod->method_name)
$molPaymentMethodLang->text ?: $paymentMethod->method_name
);

$paymentOption->setModuleName($this->module->name);
$paymentOption->setAction($this->context->getLink()->getModuleLink(
'mollie',
Expand Down
21 changes: 19 additions & 2 deletions src/Provider/PaymentOption/CreditCardPaymentOptionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@
use MolCustomer;
use Mollie;
use Mollie\Adapter\ConfigurationAdapter;
use Mollie\Adapter\Context;
use Mollie\Adapter\Customer;
use Mollie\Adapter\LegacyContext;
use Mollie\Config\Config;
use Mollie\Provider\CreditCardLogoProvider;
use Mollie\Provider\OrderTotal\OrderTotalProviderInterface;
use Mollie\Provider\PaymentFeeProviderInterface;
use Mollie\Repository\MolCustomerRepository;
use Mollie\Repository\PaymentMethodLangRepositoryInterface;
use Mollie\Service\LanguageService;
use Mollie\Utility\CustomerUtility;
use MolPaymentMethod;
use MolPaymentMethodLang;
use PrestaShop\PrestaShop\Core\Payment\PaymentOption;
use Tools;

Expand Down Expand Up @@ -128,10 +131,24 @@ public function __construct(
public function getPaymentOption(MolPaymentMethod $paymentMethod): PaymentOption
{
$paymentOption = new PaymentOption();

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

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

/** @var MolPaymentMethodLang $molPaymentMethodLang */
$molPaymentMethodLang = $paymentMethodLangRepository->findOneBy([
'id_method' => $paymentMethod->id_method,
'id_lang' => $context->getLanguageId(),
'id_shop' => $context->getShopId(),
]);

$paymentOption->setCallToActionText(
$paymentMethod->title ?:
$this->languageService->lang($paymentMethod->method_name)
$molPaymentMethodLang->text ?: $paymentMethod->method_name
);

$paymentOption->setModuleName($this->module->name);
$paymentOption->setAction($this->context->getLink()->getModuleLink(
'mollie',
Expand Down
Loading

0 comments on commit 3f9a4db

Please sign in to comment.