diff --git a/.htaccess b/.htaccess new file mode 100644 index 000000000..db12ecd28 --- /dev/null +++ b/.htaccess @@ -0,0 +1,15 @@ +# Apache 2.2 + + Order deny,allow + Deny from all + + Allow from all + + +# Apache 2.4 + + Require all denied + + Require all granted + + diff --git a/changelog.md b/changelog.md index e5c003d72..58ac6174a 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,12 @@ # Changelog # +## Changes in release 5.4.3 ## ++ New payment method: Billie. ++ Enabled PrestaShop CloudSync. ++ Migrated dependency injection service from Symfony to League container. ++ Overall improvements and bug fixes. + ## Changes in release 5.4.2 ## + Decoupled Apple Pay direct feature flag into product and cart separate settings. + Overall improvements and bug fixes. diff --git a/composer.json b/composer.json index 951607fdb..f33ab538e 100644 --- a/composer.json +++ b/composer.json @@ -11,11 +11,15 @@ "segmentio/analytics-php": "^1.5", "sentry/sentry": "^1.11.0", "vlucas/phpdotenv": "3.4", - "prestashop/autoindex": "^1.0" + "prestashop/autoindex": "^1.0", + "league/container": "2.5.0", + "prestashop/prestashop-accounts-installer": "^1.0.4", + "prestashop/module-lib-service-container": "v2.0" }, "require-dev": { "roave/security-advisories": "dev-latest", - "prestashop/php-dev-tools": "*" + "prestashop/php-dev-tools": "*", + "phpunit/phpunit": "6.5.14" }, "autoload-dev": { "psr-4": { @@ -40,4 +44,4 @@ }, "type": "prestashop-module", "author": "PrestaShop" -} +} \ No newline at end of file diff --git a/config/adapter.yml b/config/adapter.yml deleted file mode 100644 index 9b758b37f..000000000 --- a/config/adapter.yml +++ /dev/null @@ -1,9 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Adapter\ConfigurationAdapter: - class: Mollie\Adapter\ConfigurationAdapter - - Mollie\Adapter\ToolsAdapter: - class: Mollie\Adapter\ToolsAdapter diff --git a/config/builder.yml b/config/builder.yml deleted file mode 100644 index 4562f86e9..000000000 --- a/config/builder.yml +++ /dev/null @@ -1,64 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Builder\FormBuilder: - class: Mollie\Builder\FormBuilder - arguments: - - '@mollie' - - '@Mollie\Service\ApiService' - - '@Mollie\Service\CountryService' - - '@Mollie\Service\ConfigFieldService' - - '@Mollie\Service\MolCarrierInformationService' - - '@mollie.language' - - '@mollie.smarty' - - '@mollie.link' - - '@Mollie\Provider\CreditCardLogoProvider' - - '@Mollie\Adapter\ConfigurationAdapter' - - '@Mollie\Repository\TaxRulesGroupRepositoryInterface' - - '@mollie.adapter.context' - - Mollie\Builder\ApiTestFeedbackBuilder: - class: Mollie\Builder\ApiTestFeedbackBuilder - arguments: - - '@=service("mollie.factory.module_factory").getModuleVersion()' - - '@Mollie\Service\ApiKeyService' - - Mollie\Builder\InvoicePdfTemplateBuilder: - class: Mollie\Builder\InvoicePdfTemplateBuilder - arguments: - - '@Mollie\Repository\MolOrderPaymentFeeRepositoryInterface' - - '@Mollie\Repository\CurrencyRepositoryInterface' - - '@Mollie\Adapter\ToolsAdapter' - - Mollie\Builder\Content\BaseInfoBlock: - class: Mollie\Builder\Content\BaseInfoBlock - arguments: - - '@mollie' - - Mollie\Builder\Content\LogoInfoBlock: - class: Mollie\Builder\Content\LogoInfoBlock - arguments: - - '@mollie' - - Mollie\Builder\Content\UpdateMessageInfoBlock: - class: Mollie\Builder\Content\UpdateMessageInfoBlock - arguments: - - '@Mollie\Service\UpgradeNoticeService' - - '@Mollie\Adapter\ConfigurationAdapter' - - '@Mollie\Provider\UpdateMessageProvider' - - Mollie\Builder\Content\PaymentOption\IdealDropdownInfoBlock: - class: Mollie\Builder\Content\PaymentOption\IdealDropdownInfoBlock - arguments: - - '@mollie' - - '@Mollie\Service\IssuerService' - - Mollie\Builder\ApplePayDirect\ApplePayOrderBuilder: - class: Mollie\Builder\ApplePayDirect\ApplePayOrderBuilder - - Mollie\Builder\ApplePayDirect\ApplePayCarriersBuilder: - class: Mollie\Builder\ApplePayDirect\ApplePayCarriersBuilder - - Mollie\Builder\ApplePayDirect\ApplePayProductBuilder: - class: Mollie\Builder\ApplePayDirect\ApplePayProductBuilder diff --git a/config/certificate.yml b/config/certificate.yml deleted file mode 100644 index dd2d09dc9..000000000 --- a/config/certificate.yml +++ /dev/null @@ -1,10 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Handler\Certificate\CertificateHandlerInterface: '@Mollie\Handler\Certificate\ApplePayDirectCertificateHandler' - - Mollie\Handler\Certificate\ApplePayDirectCertificateHandler: - class: Mollie\Handler\Certificate\ApplePayDirectCertificateHandler - arguments: - - '@mollie' diff --git a/config/collector.yml b/config/collector.yml deleted file mode 100644 index a20a3d17e..000000000 --- a/config/collector.yml +++ /dev/null @@ -1,8 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Collector\ApplePayDirect\OrderTotalCollector: - class: Mollie\Collector\ApplePayDirect\OrderTotalCollector - arguments: - - '@Mollie\Service\OrderPaymentFeeService' diff --git a/config/command.yml b/config/command.yml deleted file mode 100644 index 870363fd7..000000000 --- a/config/command.yml +++ /dev/null @@ -1,24 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Command\TranslationCsvFileGeneratorConsoleCommand: - class: Mollie\Command\TranslationCsvFileGeneratorConsoleCommand - arguments: - - '@mollie' - tags: - - { name: 'console.command' } - - Mollie\Command\UploadTranslationsFromCsvFileConsoleCommand: - class: Mollie\Command\UploadTranslationsFromCsvFileConsoleCommand - arguments: - - '@mollie' - tags: - - { name: 'console.command' } - - Mollie\Command\UpdateTranslationsConsoleCommand: - class: Mollie\Command\UpdateTranslationsConsoleCommand - arguments: - - '@mollie' - tags: - - { name: 'console.command' } diff --git a/config/command_handler.yml b/config/command_handler.yml deleted file mode 100644 index ff8b3cf6c..000000000 --- a/config/command_handler.yml +++ /dev/null @@ -1,39 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Application\CommandHandler\RequestApplePayPaymentSessionHandler: - class: 'Mollie\Application\CommandHandler\RequestApplePayPaymentSessionHandler' - arguments: - - '@mollie' - - '@Mollie\Service\ApiService' - tags: - - { name: tactician.handler, command: Mollie\Application\Command\RequestApplePayPaymentSession } - - Mollie\Application\CommandHandler\UpdateApplePayShippingContactHandler: - class: 'Mollie\Application\CommandHandler\UpdateApplePayShippingContactHandler' - arguments: - - '@Mollie\Builder\ApplePayDirect\ApplePayCarriersBuilder' - - '@Mollie\Service\OrderPaymentFeeService' - - '@Mollie\Collector\ApplePayDirect\OrderTotalCollector' - tags: - - { name: tactician.handler, command: Mollie\Application\Command\UpdateApplePayShippingContact } - - Mollie\Application\CommandHandler\UpdateApplePayShippingMethodHandler: - class: 'Mollie\Application\CommandHandler\UpdateApplePayShippingMethodHandler' - arguments: - - '@Mollie\Service\OrderPaymentFeeService' - tags: - - { name: tactician.handler, command: Mollie\Application\Command\RequestApplePayPaymentSession } - - Mollie\Application\CommandHandler\CreateApplePayOrderHandler: - class: 'Mollie\Application\CommandHandler\CreateApplePayOrderHandler' - arguments: - - '@Mollie\Repository\PaymentMethodRepository' - - '@Mollie\Service\PaymentMethodService' - - '@Mollie\Service\MollieOrderCreationService' - - '@mollie.link' - - '@mollie' - - '@Mollie\Handler\RetryHandlerInterface' - tags: - - { name: tactician.handler, command: Mollie\Application\Command\RequestApplePayPaymentSession } diff --git a/config/config.yml b/config/config.yml deleted file mode 100644 index ba2b1e067..000000000 --- a/config/config.yml +++ /dev/null @@ -1,66 +0,0 @@ -imports: - - { resource: logger.yml } - - { resource: adapter.yml } - - { resource: builder.yml } - - { resource: service.yml } - - { resource: repository.yml } - - { resource: context.yml } - - { resource: factory.yml } - - { resource: presenter.yml } - - { resource: validator.yml } - - { resource: command.yml } - - { resource: provider.yml } - - { resource: handler.yml } - - { resource: grid.yml } - - { resource: segment.yml } - - { resource: verification.yml } - - { resource: payment_option_provider.yml } - - { resource: decoder.yml } - - { resource: certificate.yml } - - { resource: command_handler.yml } - - { resource: collector.yml } - -services: - _defaults: - public: true - - mollie: - class: 'Mollie' - factory: ['Module', 'getInstanceByName'] - arguments: - - 'mollie' - - Mollie\Install\Installer: - class: Mollie\Install\Installer - arguments: - - '@mollie' - - '@Mollie\Install\DatabaseTableInstaller' - - '@Mollie\Tracker\Segment' - - '@Mollie\Adapter\ConfigurationAdapter' - - '@Mollie\Install\OrderStateInstaller' - - Mollie\Install\Uninstall: - class: Mollie\Install\Uninstall - arguments: - - '@Mollie\Install\DatabaseTableUninstaller' - - '@Mollie\Tracker\Segment' - - '@Mollie\Adapter\ConfigurationAdapter' - - Mollie\Install\DatabaseTableInstaller: - class: Mollie\Install\DatabaseTableInstaller - - Mollie\Install\DatabaseTableUninstaller: - class: Mollie\Install\DatabaseTableUninstaller - - mollie.adapter.context: - class: Mollie\Adapter\LegacyContext - - Mollie\Config\Env: - class: Mollie\Config\Env - - Mollie\Install\OrderStateInstaller: - class: Mollie\Install\OrderStateInstaller - arguments: - - '@mollie.factory.module_factory' - - '@Mollie\Adapter\ConfigurationAdapter' - - '@Mollie\Service\OrderStateImageService' diff --git a/config/context.yml b/config/context.yml deleted file mode 100644 index 340677360..000000000 --- a/config/context.yml +++ /dev/null @@ -1,43 +0,0 @@ -services: - _defaults: - public: true - - mollie.context: - class: 'Context' - factory: ['Mollie\Factory\ContextFactory', 'getContext'] - - mollie.controller: - class: 'Controller' - factory: ['Mollie\Factory\ContextFactory', 'getController'] - - mollie.cookie: - class: 'Cookie' - factory: ['Mollie\Factory\ContextFactory', 'getCookie'] - - mollie.language: - class: 'Language' - factory: ['Mollie\Factory\ContextFactory', 'getLanguage'] - - mollie.currency: - class: 'Currency' - factory: ['Mollie\Factory\ContextFactory', 'getCurrency'] - - mollie.smarty: - class: 'Smarty' - factory: ['Mollie\Factory\ContextFactory', 'getSmarty'] - - mollie.shop: - class: 'Shop' - factory: ['Mollie\Factory\ContextFactory', 'getShop'] - - mollie.link: - class: 'Shop' - factory: ['Mollie\Factory\ContextFactory', 'getLink'] - - mollie.country: - class: 'Shop' - factory: ['Mollie\Factory\ContextFactory', 'getCountry'] - - mollie.customer: - class: 'Customer' - factory: ['Mollie\Factory\ContextFactory', 'getCustomer'] diff --git a/config/decoder.yml b/config/decoder.yml deleted file mode 100644 index e6d5f512d..000000000 --- a/config/decoder.yml +++ /dev/null @@ -1,8 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Utility\Decoder\JsonDecoder: - class: Mollie\Utility\Decoder\JsonDecoder - - diff --git a/config/factory.yml b/config/factory.yml deleted file mode 100644 index 92f1d6b83..000000000 --- a/config/factory.yml +++ /dev/null @@ -1,9 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Factory\CustomerFactory: - class: Mollie\Factory\CustomerFactory - - mollie.factory.module_factory: - class: 'Mollie\Factory\ModuleFactory' diff --git a/config/grid.yml b/config/grid.yml deleted file mode 100644 index feebf4057..000000000 --- a/config/grid.yml +++ /dev/null @@ -1,16 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Grid\Row\AccessibilityChecker\SecondChanceAccessibilityChecker: - class: Mollie\Grid\Row\AccessibilityChecker\SecondChanceAccessibilityChecker - arguments: - - '@Mollie\Repository\PaymentMethodRepository' - - Mollie\Grid\Definition\Modifier\OrderGridDefinitionModifier: - class: Mollie\Grid\Definition\Modifier\OrderGridDefinitionModifier - arguments: - - '@mollie' - - Mollie\Grid\Query\Modifier\OrderGridQueryModifier: - class: Mollie\Grid\Query\Modifier\OrderGridQueryModifier diff --git a/config/handler.yml b/config/handler.yml deleted file mode 100644 index ed7c7321e..000000000 --- a/config/handler.yml +++ /dev/null @@ -1,65 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Handler\Settings\PaymentMethodPositionHandler: - class: Mollie\Handler\Settings\PaymentMethodPositionHandler - arguments: - - '@Mollie\Repository\PaymentMethodRepositoryInterface' - - Mollie\Handler\Settings\PaymentMethodPositionHandlerInterface: '@Mollie\Handler\Settings\PaymentMethodPositionHandler' - - Mollie\Handler\Exception\OrderExceptionHandler: - class: Mollie\Handler\Exception\OrderExceptionHandler - - Mollie\Handler\Api\OrderEndpointPaymentTypeHandler: - class: Mollie\Handler\Api\OrderEndpointPaymentTypeHandler - arguments: - - '@Mollie\Verification\PaymentType\CanBeRegularPaymentType' - - Mollie\Handler\Shipment\ShipmentSenderHandler: - class: Mollie\Handler\Shipment\ShipmentSenderHandler - arguments: - - '@Mollie\Verification\Shipment\CanSendShipment' - - '@Mollie\Service\Shipment\ShipmentInformationSender' - - Mollie\Handler\Shipment\ShipmentSenderHandlerInterface: '@Mollie\Handler\Shipment\ShipmentSenderHandler' - - Mollie\Handler\PaymentOption\PaymentOptionHandler: - class: Mollie\Handler\PaymentOption\PaymentOptionHandler - arguments: - - '@Mollie\Provider\PaymentOption\BasePaymentOptionProvider' - - '@Mollie\Provider\PaymentOption\CreditCardPaymentOptionProvider' - - '@Mollie\Provider\PaymentOption\CreditCardSingleClickPaymentOptionProvider' - - '@Mollie\Provider\PaymentOption\IdealPaymentOptionProvider' - - '@Mollie\Provider\PaymentOption\BancontactPaymentOptionProvider' - - '@Mollie\Adapter\ConfigurationAdapter' - - Mollie\Handler\PaymentOption\PaymentOptionHandlerInterface: '@Mollie\Handler\PaymentOption\PaymentOptionHandler' - - Mollie\Handler\ErrorHandler\ErrorHandler: - class: Mollie\Handler\ErrorHandler\ErrorHandler - arguments: - - '@mollie' - - Mollie\Handler\Order\OrderCreationHandler: - class: Mollie\Handler\Order\OrderCreationHandler - arguments: - - '@mollie' - - '@Mollie\Repository\PaymentMethodRepositoryInterface' - - '@Mollie\Service\PaymentMethodService' - - '@Mollie\Handler\Order\OrderPaymentFeeHandler' - - '@Mollie\Service\OrderStatusService' - - '@Mollie\Provider\PaymentFeeProviderInterface' - - Mollie\Handler\Order\OrderPaymentFeeHandler: - class: Mollie\Handler\Order\OrderPaymentFeeHandler - arguments: - - '@Mollie\Service\OrderPaymentFeeService' - - '@Mollie\Service\PaymentMethodService' - - '@Mollie\Provider\PaymentFeeProviderInterface' - - Mollie\Handler\RetryHandlerInterface: '@Mollie\Handler\RetryHandler' - - Mollie\Handler\RetryHandler: - class: Mollie\Handler\RetryHandler diff --git a/config/logger.yml b/config/logger.yml deleted file mode 100644 index 554bbfea5..000000000 --- a/config/logger.yml +++ /dev/null @@ -1,8 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Logger\PrestaLogger: - class: Mollie\Logger\PrestaLogger - - Mollie\Logger\PrestaLoggerInterface: '@Mollie\Logger\PrestaLogger' diff --git a/config/payment_option_provider.yml b/config/payment_option_provider.yml deleted file mode 100644 index e6ca2f0ee..000000000 --- a/config/payment_option_provider.yml +++ /dev/null @@ -1,74 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Provider\TaxCalculatorProvider: - class: Mollie\Provider\TaxCalculatorProvider - arguments: - - '@Mollie\Repository\TaxRuleRepositoryInterface' - - '@Mollie\Repository\TaxRepositoryInterface' - - Mollie\Provider\PaymentFeeProvider: - class: Mollie\Provider\PaymentFeeProvider - arguments: - - '@mollie.adapter.context' - - '@Mollie\Repository\AddressRepositoryInterface' - - '@Mollie\Provider\TaxCalculatorProvider' - - Mollie\Provider\PaymentOption\BasePaymentOptionProvider: - class: Mollie\Provider\PaymentOption\BasePaymentOptionProvider - arguments: - - '@mollie' - - '@=service("mollie.adapter.context")' - - '@Mollie\Provider\CreditCardLogoProvider' - - '@Mollie\Provider\PaymentFeeProviderInterface' - - '@Mollie\Service\LanguageService' - - '@Mollie\Provider\OrderTotal\OrderTotalProviderInterface' - - Mollie\Provider\PaymentOption\IdealPaymentOptionProvider: - class: Mollie\Provider\PaymentOption\IdealPaymentOptionProvider - arguments: - - '@mollie' - - '@=service("mollie.adapter.context")' - - '@Mollie\Provider\CreditCardLogoProvider' - - '@Mollie\Provider\PaymentFeeProviderInterface' - - '@Mollie\Service\Content\TemplateParserInterface' - - '@Mollie\Builder\Content\PaymentOption\IdealDropdownInfoBlock' - - '@Mollie\Service\LanguageService' - - '@Mollie\Provider\OrderTotal\OrderTotalProviderInterface' - - Mollie\Provider\PaymentOption\CreditCardPaymentOptionProvider: - class: Mollie\Provider\PaymentOption\CreditCardPaymentOptionProvider - arguments: - - '@mollie' - - '@=service("mollie.adapter.context")' - - '@Mollie\Provider\CreditCardLogoProvider' - - '@Mollie\Provider\OrderTotal\OrderTotalProviderInterface' - - '@Mollie\Provider\PaymentFeeProviderInterface' - - '@Mollie\Service\LanguageService' - - '@mollie.customer' - - '@Mollie\Repository\MolCustomerRepository' - - '@Mollie\Adapter\ConfigurationAdapter' - - Mollie\Provider\PaymentOption\CreditCardSingleClickPaymentOptionProvider: - class: Mollie\Provider\PaymentOption\CreditCardSingleClickPaymentOptionProvider - arguments: - - '@mollie' - - '@=service("mollie.adapter.context")' - - '@Mollie\Provider\CreditCardLogoProvider' - - '@Mollie\Provider\OrderTotal\OrderTotalProviderInterface' - - '@Mollie\Provider\PaymentFeeProviderInterface' - - '@Mollie\Service\LanguageService' - - '@mollie.customer' - - '@Mollie\Repository\MolCustomerRepository' - - '@Mollie\Adapter\ConfigurationAdapter' - - Mollie\Provider\PaymentOption\BancontactPaymentOptionProvider: - class: Mollie\Provider\PaymentOption\BancontactPaymentOptionProvider - arguments: - - '@mollie' - - '@mollie.adapter.context' - - '@Mollie\Provider\CreditCardLogoProvider' - - '@Mollie\Provider\PaymentFeeProviderInterface' - - '@Mollie\Service\LanguageService' - - '@Mollie\Provider\OrderTotal\OrderTotalProviderInterface' diff --git a/config/presenter.yml b/config/presenter.yml deleted file mode 100644 index c7191c7c3..000000000 --- a/config/presenter.yml +++ /dev/null @@ -1,8 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Presenter\OrderListActionBuilder: - class: Mollie\Presenter\OrderListActionBuilder - arguments: - - '@mollie' diff --git a/config/provider.yml b/config/provider.yml deleted file mode 100644 index 386194fb3..000000000 --- a/config/provider.yml +++ /dev/null @@ -1,46 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Provider\CreditCardLogoProvider: - class: Mollie\Provider\CreditCardLogoProvider - arguments: - - '@=service("mollie.factory.module_factory").getLocalPath()' - - '@=service("mollie.factory.module_factory").getPathUri()' - - Mollie\Service\PaymentMethod\PaymentMethodSortProvider: - class: Mollie\Service\PaymentMethod\PaymentMethodSortProvider - - Mollie\Service\PaymentMethod\PaymentMethodSortProviderInterface: '@Mollie\Service\PaymentMethod\PaymentMethodSortProvider' - - Mollie\Provider\PhoneNumberProvider: - class: Mollie\Provider\PhoneNumberProvider - - Mollie\Provider\PhoneNumberProviderInterface: '@Mollie\Provider\PhoneNumberProvider' - - Mollie\Provider\Shipment\AutomaticShipmentSenderStatusesProvider: - class: Mollie\Provider\Shipment\AutomaticShipmentSenderStatusesProvider - arguments: - - '@Mollie\Adapter\ConfigurationAdapter' - - '@Mollie\Utility\Decoder\JsonDecoder' - - Mollie\Provider\PaymentType\RegularPaymentTypeIdentification: - class: Mollie\Provider\PaymentType\RegularPaymentTypeIdentification - - Mollie\Provider\UpdateMessageProvider: - class: Mollie\Provider\UpdateMessageProvider - arguments: - - '@mollie' - - Mollie\Provider\EnvironmentVersionProvider: - class: Mollie\Provider\EnvironmentVersionProvider - - Mollie\Provider\ProfileIdProviderInterface: '@Mollie\Provider\ProfileIdProvider' - - Mollie\Provider\ProfileIdProvider: - class: Mollie\Provider\ProfileIdProvider - - Mollie\Provider\PaymentFeeProvider: - class: Mollie\Provider\PaymentFeeProvider - - Mollie\Provider\PaymentFeeProviderInterface: '@Mollie\Provider\PaymentFeeProvider' diff --git a/config/repository.yml b/config/repository.yml deleted file mode 100644 index 780ed794e..000000000 --- a/config/repository.yml +++ /dev/null @@ -1,81 +0,0 @@ -services: - _defaults: - public: true - -# @deprecated - dont call repositories directly, use interface instead - Mollie\Repository\PaymentMethodRepository: - class: Mollie\Repository\PaymentMethodRepository - - Mollie\Repository\PaymentMethodRepositoryInterface: '@Mollie\Repository\PaymentMethodRepository' - - Mollie\Repository\MolOrderPaymentFeeRepository: - class: Mollie\Repository\MolOrderPaymentFeeRepository - - Mollie\Repository\CountryRepository: - class: Mollie\Repository\CountryRepository - - Mollie\Repository\OrderShipmentRepository: - class: Mollie\Repository\OrderShipmentRepository - - Mollie\Repository\MethodCountryRepository: - class: Mollie\Repository\MethodCountryRepository - - Mollie\Repository\MolCarrierInformationRepository: - class: Mollie\Repository\MolCarrierInformationRepository - - Mollie\Repository\ModuleRepository: - class: Mollie\Repository\ModuleRepository - - Mollie\Repository\PendingOrderCartRepository: - class: Mollie\Repository\PendingOrderCartRepository - arguments: - - 'MolPendingOrderCart' - - Mollie\Repository\MolCustomerRepository: - class: Mollie\Repository\MolCustomerRepository - arguments: - - 'MolCustomer' - - Mollie\Repository\AttributeRepository: - class: Mollie\Repository\AttributeRepository - - Mollie\Repository\OrderStateRepository: - class: Mollie\Repository\OrderStateRepository - - Mollie\Repository\OrderRepository: - class: Mollie\Repository\OrderRepository - - Mollie\Repository\OrderCartRuleRepository: - class: Mollie\Repository\OrderCartRuleRepository - - Mollie\Repository\CartRuleRepository: - class: Mollie\Repository\CartRuleRepository - - Mollie\Repository\PendingOrderCartRuleRepository: - class: Mollie\Repository\PendingOrderCartRuleRepository - - Mollie\Repository\CurrencyRepository: - class: Mollie\Repository\CurrencyRepository - - Mollie\Repository\GenderRepository: - class: Mollie\Repository\GenderRepository - - Mollie\Repository\AddressRepository: - class: Mollie\Repository\AddressRepository - - Mollie\Repository\TaxRepository: - class: Mollie\Repository\TaxRepository - - Mollie\Repository\TaxRuleRepository: - class: Mollie\Repository\TaxRuleRepository - - Mollie\Repository\TaxRulesGroupRepository: - class: Mollie\Repository\TaxRulesGroupRepository - - Mollie\Repository\CurrencyRepositoryInterface: '@Mollie\Repository\CurrencyRepository' - Mollie\Repository\GenderRepositoryInterface: '@Mollie\Repository\GenderRepository' - Mollie\Repository\AddressRepositoryInterface: '@Mollie\Repository\AddressRepository' - Mollie\Repository\MolOrderPaymentFeeRepositoryInterface: '@Mollie\Repository\MolOrderPaymentFeeRepository' - Mollie\Repository\TaxRepositoryInterface: '@Mollie\Repository\TaxRepository' - Mollie\Repository\TaxRuleRepositoryInterface: '@Mollie\Repository\TaxRuleRepository' - Mollie\Repository\TaxRulesGroupRepositoryInterface: '@Mollie\Repository\TaxRulesGroupRepository' diff --git a/config/segment.yml b/config/segment.yml deleted file mode 100644 index 8ceba9539..000000000 --- a/config/segment.yml +++ /dev/null @@ -1,9 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Tracker\Segment: - class: 'Mollie\Tracker\Segment' - arguments: - - '@mollie.context' - - '@Mollie\Config\Env' diff --git a/config/service.yml b/config/service.yml deleted file mode 100644 index 1bae5e7c2..000000000 --- a/config/service.yml +++ /dev/null @@ -1,249 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Service\OrderPaymentFeeService: - class: Mollie\Service\OrderPaymentFeeService - arguments: - - '@Mollie\Repository\PaymentMethodRepositoryInterface' - - '@mollie.shop' - - '@Mollie\Provider\PaymentFeeProviderInterface' - - Mollie\Service\PaymentMethodService: - class: Mollie\Service\PaymentMethodService - arguments: - - '@mollie' - - '@Mollie\Repository\PaymentMethodRepositoryInterface' - - '@Mollie\Service\CartLinesService' - - '@Mollie\Service\PaymentsTranslationService' - - '@Mollie\Service\CustomerService' - - '@Mollie\Provider\CreditCardLogoProvider' - - '@Mollie\Service\PaymentMethod\PaymentMethodSortProviderInterface' - - '@Mollie\Provider\PhoneNumberProviderInterface' - - '@Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidationInterface' - - '@mollie.shop' - - '@Mollie\Repository\GenderRepositoryInterface' - - '@Mollie\Adapter\ConfigurationAdapter' - - '@Mollie\Provider\PaymentFeeProviderInterface' - - '@mollie.adapter.context' - - '@Mollie\Provider\OrderTotal\OrderTotalProviderInterface' - - Mollie\Service\ApiService: - class: Mollie\Service\ApiService - arguments: - - '@Mollie\Repository\PaymentMethodRepositoryInterface' - - '@Mollie\Repository\CountryRepository' - - '@Mollie\Service\PaymentMethod\PaymentMethodSortProvider' - - '@Mollie\Adapter\ConfigurationAdapter' - - '@Mollie\Service\TransactionService' - - '@mollie.shop' - - '@Mollie\Provider\TaxCalculatorProvider' - - '@mollie.adapter.context' - - Mollie\Service\ConfigFieldService: - class: Mollie\Service\ConfigFieldService - arguments: - - '@mollie' - - '@Mollie\Service\ApiService' - - '@Mollie\Repository\CountryRepository' - - '@Mollie\Adapter\ConfigurationAdapter' - - Mollie\Service\IssuerService: - class: Mollie\Service\IssuerService - arguments: - - '@mollie' - - '@Mollie\Repository\PaymentMethodRepository' - - Mollie\Service\RefundService: - class: Mollie\Service\RefundService - arguments: - - '@mollie' - - '@Mollie\Service\TransactionService' - - Mollie\Service\ShipService: - class: Mollie\Service\ShipService - arguments: - - '@mollie' - - Mollie\Service\CancelService: - class: Mollie\Service\CancelService - arguments: - - '@mollie' - - '@Mollie\Service\TransactionService' - - Mollie\Service\CarrierService: - class: Mollie\Service\CarrierService - - Mollie\Service\OrderStatusService: - class: Mollie\Service\OrderStatusService - arguments: - - '@Mollie\Service\MailService' - - Mollie\Service\ErrorDisplayService: - class: Mollie\Service\ErrorDisplayService - - Mollie\Service\OrderStateImageService: - class: Mollie\Service\OrderStateImageService - - Mollie\Service\CountryService: - class: Mollie\Service\CountryService - arguments: - - '@mollie' - - Mollie\Service\SettingsSaveService: - class: Mollie\Service\SettingsSaveService - arguments: - - '@mollie' - - '@Mollie\Repository\CountryRepository' - - '@Mollie\Repository\PaymentMethodRepository' - - '@Mollie\Service\PaymentMethodService' - - '@Mollie\Service\ApiService' - - '@Mollie\Service\MolCarrierInformationService' - - '@Mollie\Handler\Settings\PaymentMethodPositionHandlerInterface' - - '@Mollie\Service\ApiKeyService' - - '@Mollie\Handler\Certificate\CertificateHandlerInterface' - - '@mollie.shop' - - '@Mollie\Adapter\ConfigurationAdapter' - - Mollie\Service\ShipmentService: - class: Mollie\Service\ShipmentService - arguments: - - '@Mollie\Repository\OrderShipmentRepository' - - '@Mollie\Repository\MolCarrierInformationRepository' - - Mollie\Service\CartLinesService: - class: Mollie\Service\CartLinesService - arguments: - - '@Mollie\Service\LanguageService' - - '@Mollie\Service\VoucherService' - - '@Mollie\Adapter\ToolsAdapter' - - '@mollie.adapter.context' - - Mollie\Service\CustomerService: - class: Mollie\Service\CustomerService - arguments: - - '@mollie' - - '@Mollie\Repository\MolCustomerRepository' - - Mollie\Service\MollieOrderInfoService: - class: Mollie\Service\MollieOrderInfoService - arguments: - - '@mollie' - - '@Mollie\Repository\PaymentMethodRepositoryInterface' - - '@Mollie\Service\RefundService' - - '@Mollie\Service\ShipService' - - '@Mollie\Service\CancelService' - - '@Mollie\Service\ShipmentService' - - '@Mollie\Service\ApiService' - - Mollie\Service\MolCarrierInformationService: - class: Mollie\Service\MolCarrierInformationService - arguments: - - '@Mollie\Repository\MolCarrierInformationRepository' - - Mollie\Service\LanguageService: - class: Mollie\Service\LanguageService - arguments: - - '@mollie' - - Mollie\Service\RepeatOrderLinkFactory: - class: Mollie\Service\RepeatOrderLinkFactory - - Mollie\Logger\PrestaLogger: - class: Mollie\Logger\PrestaLogger - - Mollie\Service\TransactionService: - class: Mollie\Service\TransactionService - arguments: - - '@mollie' - - '@Mollie\Service\OrderStatusService' - - '@Mollie\Repository\PaymentMethodRepositoryInterface' - - '@Mollie\Handler\Order\OrderCreationHandler' - - '@Mollie\Service\PaymentMethodService' - - '@Mollie\Service\MollieOrderCreationService' - - '@Mollie\Handler\Order\OrderPaymentFeeHandler' - - '@Mollie\Handler\Shipment\ShipmentSenderHandlerInterface' - - '@Mollie\Logger\PrestaLoggerInterface' - - '@Mollie\Service\ExceptionService' - - Mollie\Service\MolliePaymentMailService: - class: Mollie\Service\MolliePaymentMailService - arguments: - - '@mollie' - - '@Mollie\Repository\PaymentMethodRepository' - - '@Mollie\Service\MailService' - - Mollie\Service\MailService: - class: Mollie\Service\MailService - arguments: - - '@mollie' - - Mollie\Service\PaymentsTranslationService: - class: Mollie\Service\PaymentsTranslationService - arguments: - - '@mollie' - - '@Mollie\Service\LanguageService' - - Mollie\Service\PaymentReturnService: - class: Mollie\Service\PaymentReturnService - arguments: - - '@mollie' - - '@Mollie\Repository\PaymentMethodRepository' - - '@Mollie\Service\RepeatOrderLinkFactory' - - '@Mollie\Service\TransactionService' - - '@Mollie\Handler\CartRule\CartRuleQuantityChangeHandler' - - Mollie\Service\UpgradeNoticeService: - class: Mollie\Service\UpgradeNoticeService - - Mollie\Service\VoucherService: - class: Mollie\Service\VoucherService - arguments: - - '@Mollie\Repository\AttributeRepository' - - '@Mollie\Adapter\ConfigurationAdapter' - - Mollie\Service\ExceptionService: - class: Mollie\Service\ExceptionService - arguments: - - '@mollie' - - Mollie\Service\ApiKeyService: - class: Mollie\Service\ApiKeyService - - Mollie\Handler\CartRule\CartRuleQuantityChangeHandler: - class: Mollie\Handler\CartRule\CartRuleQuantityChangeHandler - arguments: - - '@Mollie\Repository\PendingOrderCartRuleRepository' - - '@Mollie\Repository\OrderCartRuleRepository' - - '@Mollie\Repository\CartRuleRepository' - - '@Mollie\Repository\OrderRepository' - - Mollie\Handler\CartRule\CartRuleQuantityResetHandler: - class: Mollie\Handler\CartRule\CartRuleQuantityResetHandler - arguments: - - '@Mollie\Repository\PendingOrderCartRuleRepository' - - '@Mollie\Repository\OrderCartRuleRepository' - - '@Mollie\Repository\CartRuleRepository' - - '@Mollie\Repository\OrderRepository' - - Mollie\Service\Shipment\ShipmentInformationSender: - class: Mollie\Service\Shipment\ShipmentInformationSender - arguments: - - '@Mollie\Repository\PaymentMethodRepositoryInterface' - - '@Mollie\Service\ShipmentService' - - Mollie\Service\Shipment\ShipmentInformationSenderInterface: '@Mollie\Service\Shipment\ShipmentInformationSender' - - Mollie\Service\Content\SmartyTemplateParser: - class: Mollie\Service\Content\SmartyTemplateParser - - Mollie\Service\Content\TemplateParserInterface: '@Mollie\Service\Content\SmartyTemplateParser' - - Mollie\Service\EntityManager\ObjectModelManager: - class: Mollie\Service\EntityManager\ObjectModelManager - - Mollie\Service\MollieOrderCreationService: - class: Mollie\Service\MollieOrderCreationService - arguments: - - '@Mollie\Handler\Exception\OrderExceptionHandler' - - '@mollie' diff --git a/config/validator.yml b/config/validator.yml deleted file mode 100644 index 08fd95079..000000000 --- a/config/validator.yml +++ /dev/null @@ -1,76 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Validator\OrderConfMailValidator: - class: Mollie\Validator\OrderConfMailValidator - arguments: - - '@Mollie\Adapter\ConfigurationAdapter' - - Mollie\Validator\VoucherValidator: - class: Mollie\Validator\VoucherValidator - arguments: - - '@Mollie\Adapter\ConfigurationAdapter' - - '@Mollie\Service\VoucherService' - - Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\ApplePayPaymentMethodRestrictionValidator: - class: Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\ApplePayPaymentMethodRestrictionValidator - arguments: - - '@=service("mollie.adapter.context")' - - '@Mollie\Adapter\ConfigurationAdapter' - tags: - - { name: mollie.paymentmethodrestriction } - - Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\VoucherPaymentMethodRestrictionValidator: - class: Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\VoucherPaymentMethodRestrictionValidator - arguments: - - '@=service("mollie.adapter.context")' - - '@Mollie\Validator\VoucherValidator' - tags: - - { name: mollie.paymentmethodrestriction } - - Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\EnvironmentVersionSpecificPaymentMethodRestrictionValidator: - class: Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\EnvironmentVersionSpecificPaymentMethodRestrictionValidator - arguments: - - '@=service("mollie.adapter.context")' - - '@Mollie\Provider\EnvironmentVersionProvider' - - '@Mollie\Repository\MethodCountryRepository' - tags: - - { name: mollie.paymentmethodrestriction, priority: 9} - - Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\BasePaymentMethodRestrictionValidator: - class: Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\BasePaymentMethodRestrictionValidator - tags: - - { name: mollie.paymentmethodrestriction, priority: 10} - - Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\AmountPaymentMethodRestrictionValidator: - class: Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\AmountPaymentMethodRestrictionValidator - arguments: - - '@=service("mollie.adapter.context")' - tags: - - { name: mollie.paymentmethodrestriction, priority: 11} - - Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation: - class: Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation - arguments: - 0: - - '@Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\BasePaymentMethodRestrictionValidator' - - '@Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\VoucherPaymentMethodRestrictionValidator' - - '@Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\EnvironmentVersionSpecificPaymentMethodRestrictionValidator' - - '@Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\ApplePayPaymentMethodRestrictionValidator' - - '@Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\AmountPaymentMethodRestrictionValidator' - - Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidationInterface: '@Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation' - - Mollie\Provider\OrderTotal\OrderTotalProvider: - class: Mollie\Provider\OrderTotal\OrderTotalProvider - arguments: - - '@=service("mollie.adapter.context")' - - - Mollie\Provider\OrderTotal\OrderTotalProviderInterface: '@Mollie\Provider\OrderTotal\OrderTotalProvider' - - Mollie\Validator\OrderCallBackValidator: - class: Mollie\Validator\OrderCallBackValidator - arguments: - - '@mollie.context' - - '@mollie' diff --git a/config/verification.yml b/config/verification.yml deleted file mode 100644 index d4e799798..000000000 --- a/config/verification.yml +++ /dev/null @@ -1,28 +0,0 @@ -services: - _defaults: - public: true - - Mollie\Verification\IsPaymentInformationAvailable: - class: Mollie\Verification\IsPaymentInformationAvailable - arguments: - - '@Mollie\Repository\PaymentMethodRepositoryInterface' - - Mollie\Verification\Shipment\CanSendShipment: - class: Mollie\Verification\Shipment\CanSendShipment - arguments: - - '@Mollie\Adapter\ConfigurationAdapter' - - '@Mollie\Provider\Shipment\AutomaticShipmentSenderStatusesProvider' - - '@Mollie\Handler\Api\OrderEndpointPaymentTypeHandler' - - '@Mollie\Repository\PaymentMethodRepositoryInterface' - - '@Mollie\Service\ShipmentService' - - '@Mollie\Verification\IsPaymentInformationAvailable' - tags: - - { name: 'shipment.information.verification' } - - Mollie\Verification\PaymentType\CanBeRegularPaymentType: - class: Mollie\Verification\PaymentType\CanBeRegularPaymentType - arguments: - - '@Mollie\Adapter\ToolsAdapter' - - '@Mollie\Provider\PaymentType\RegularPaymentTypeIdentification' - tags: - - { name: 'payment.type.verification' } diff --git a/controllers/admin/AdminMollieAjaxController.php b/controllers/admin/AdminMollieAjaxController.php index 39d395885..aecec4444 100644 --- a/controllers/admin/AdminMollieAjaxController.php +++ b/controllers/admin/AdminMollieAjaxController.php @@ -10,16 +10,20 @@ * @codingStandardsIgnoreStart */ -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; use Mollie\Builder\ApiTestFeedbackBuilder; use Mollie\Config\Config; use Mollie\Provider\CreditCardLogoProvider; use Mollie\Provider\TaxCalculatorProvider; -use Mollie\Repository\PaymentMethodRepository; +use Mollie\Repository\PaymentMethodRepositoryInterface; use Mollie\Service\MolliePaymentMailService; use Mollie\Utility\NumberUtility; use Mollie\Utility\TimeUtility; +if (!defined('_PS_VERSION_')) { + exit; +} + class AdminMollieAjaxController extends ModuleAdminController { /** @var Mollie */ @@ -61,8 +65,8 @@ private function togglePaymentMethod() $paymentMethod = Tools::getValue('paymentMethod'); $paymentStatus = Tools::getValue('status'); - /** @var PaymentMethodRepository $paymentMethodRepo */ - $paymentMethodRepo = $this->module->getMollieContainer(PaymentMethodRepository::class); + /** @var PaymentMethodRepositoryInterface $paymentMethodRepo */ + $paymentMethodRepo = $this->module->getService(PaymentMethodRepositoryInterface::class); $environment = (int) Configuration::get(Mollie\Config\Config::MOLLIE_ENVIRONMENT); $methodId = $paymentMethodRepo->getPaymentMethodIdByMethodId($paymentMethod, $environment); $method = new MolPaymentMethod($methodId); @@ -92,7 +96,7 @@ private function resendPaymentMail() $orderId = Tools::getValue('id_order'); /** @var MolliePaymentMailService $molliePaymentMailService */ - $molliePaymentMailService = $this->module->getMollieContainer(MolliePaymentMailService::class); + $molliePaymentMailService = $this->module->getService(MolliePaymentMailService::class); $response = $molliePaymentMailService->sendSecondChanceMail($orderId); @@ -109,7 +113,7 @@ private function testApiKeys() $liveKey = Tools::getValue('liveKey'); /** @var ApiTestFeedbackBuilder $apiTestFeedbackBuilder */ - $apiTestFeedbackBuilder = $this->module->getMollieContainer(ApiTestFeedbackBuilder::class); + $apiTestFeedbackBuilder = $this->module->getService(ApiTestFeedbackBuilder::class); $apiTestFeedbackBuilder->setTestKey($testKey); $apiTestFeedbackBuilder->setLiveKey($liveKey); $apiKeysTestInfo = $apiTestFeedbackBuilder->buildParams(); @@ -130,7 +134,7 @@ private function closeUpgradeNotice() private function validateLogo() { /** @var CreditCardLogoProvider $creditCardLogoProvider */ - $creditCardLogoProvider = $this->module->getMollieContainer(CreditCardLogoProvider::class); + $creditCardLogoProvider = $this->module->getService(CreditCardLogoProvider::class); $target_file = $creditCardLogoProvider->getLocalLogoPath(); $isUploaded = 1; $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION); @@ -195,10 +199,10 @@ private function updateFixedPaymentFeePrice() } /** @var TaxCalculatorProvider $taxCalculatorProvider */ - $taxCalculatorProvider = $this->module->getMollieContainer(TaxCalculatorProvider::class); + $taxCalculatorProvider = $this->module->getService(TaxCalculatorProvider::class); - /** @var LegacyContext $context */ - $context = $this->module->getMollieContainer('mollie.adapter.context'); + /** @var Context $context */ + $context = $this->module->getService(Context::class); $taxCalculator = $taxCalculatorProvider->getTaxCalculator( $taxRulesGroupId, diff --git a/controllers/admin/AdminMollieModuleController.php b/controllers/admin/AdminMollieModuleController.php index 2b2d538cd..d12283644 100644 --- a/controllers/admin/AdminMollieModuleController.php +++ b/controllers/admin/AdminMollieModuleController.php @@ -9,20 +9,17 @@ * @see https://github.com/mollie/PrestaShop * @codingStandardsIgnoreStart */ + +use Mollie\Bootstrap\ModuleTabs; + +if (!defined('_PS_VERSION_')) { + exit; +} + class AdminMollieModuleController extends ModuleAdminController { - public function postProcess() + public function init() { - Tools::redirectAdmin( - /* @phpstan-ignore-next-line */ - $this->context->link->getAdminLink( - 'AdminModules', - true, - [], - [ - 'configure' => 'mollie', - ] - ) - ); + Tools::redirectAdmin($this->context->link->getAdminLink(ModuleTabs::ADMIN_MOLLIE_SETTINGS_CONTROLLER)); } } diff --git a/controllers/admin/AdminMollieSettingsController.php b/controllers/admin/AdminMollieSettingsController.php new file mode 100644 index 000000000..7ab0c103c --- /dev/null +++ b/controllers/admin/AdminMollieSettingsController.php @@ -0,0 +1,264 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +use Mollie\Adapter\ConfigurationAdapter; +use Mollie\Adapter\ToolsAdapter; +use Mollie\Builder\Content\BaseInfoBlock; +use Mollie\Builder\Content\LogoInfoBlock; +use Mollie\Builder\Content\UpdateMessageInfoBlock; +use Mollie\Builder\FormBuilder; +use Mollie\Config\Config; +use Mollie\Logger\PrestaLoggerInterface; +use Mollie\Repository\ModuleRepository; +use Mollie\Service\Content\TemplateParserInterface; +use Mollie\Service\SettingsSaveService; +use PrestaShop\Module\PsEventbus\Service\PresenterService; +use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder; +use PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException; +use PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts; +use PrestaShop\PsAccountsInstaller\Installer\Installer as PsAccountsInstaller; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class AdminMollieSettingsController extends ModuleAdminController +{ + const FILE_NAME = 'AdminMollieSettingsController'; + + /** @var Mollie */ + public $module; + + public function __construct() + { + parent::__construct(); + $this->bootstrap = true; + } + + public function initContent() + { + $this->setEnvironmentForAccounts(); + $this->setEnvironmentForCloudSync(); + + $this->content .= $this->context->smarty->fetch($this->module->getLocalPath() . '/views/templates/admin/_configure/configuration.tpl'); + + $this->content .= $this->displayModuleSettings(); + + $this->addJs($this->module->getPathUri() . '/views/js/admin/_configure/configuration.js'); + + parent::initContent(); + } + + public function postProcess() + { + /** @var ConfigurationAdapter $configuration */ + $configuration = $this->module->getService(ConfigurationAdapter::class); + + /** @var ToolsAdapter $tools */ + $tools = $this->module->getService(ToolsAdapter::class); + + $isSubmitted = $tools->isSubmit("submit{$this->module->name}"); + + /* @phpstan-ignore-next-line */ + if (!$isSubmitted && !$configuration->get(Config::MOLLIE_STATUS_AWAITING)) { + $this->context->controller->errors[] = $this->module->l('Select an order status for \"Status for Awaiting payments\" in the \"Advanced settings\" tab'); + } + + $errors = []; + + if ($isSubmitted) { + /** @var SettingsSaveService $saveSettingsService */ + $saveSettingsService = $this->module->getService(SettingsSaveService::class); + + $resultMessages = $saveSettingsService->saveSettings($errors); + + if (!empty($errors)) { + $this->context->controller->errors = array_merge( + $this->context->controller->errors, + $resultMessages + ); + } else { + $this->context->controller->confirmations = array_merge( + $this->context->controller->confirmations, + $resultMessages + ); + } + } + } + + private function displayModuleSettings(): string + { + /** @var ModuleRepository $moduleRepository */ + $moduleRepository = $this->module->getService(ModuleRepository::class); + + $moduleDatabaseVersion = $moduleRepository->getModuleDatabaseVersion($this->module->name); + + $needsUpgrade = Tools::version_compare($this->module->version, $moduleDatabaseVersion, '>'); + + if ($needsUpgrade) { + $this->context->controller->errors[] = $this->module->l('Please upgrade Mollie module'); + + return ''; + } + + if (\Shop::getContext() !== \Shop::CONTEXT_SHOP) { + $this->context->controller->errors[] = $this->module->l('Select the shop that you want to configure'); + + return ''; + } + + Media::addJsDef([ + 'description_message' => addslashes($this->module->l('Enter a description')), + 'min_amount_message' => addslashes($this->module->l('You have entered incorrect min amount')), + 'max_amount_message' => addslashes($this->module->l('You have entered incorrect max amount')), + + 'payment_api' => addslashes(Mollie\Config\Config::MOLLIE_PAYMENTS_API), + 'ajaxUrl' => addslashes($this->context->link->getAdminLink('AdminMollieAjax')), + ]); + + /* Custom logo JS vars*/ + Media::addJsDef([ + 'image_size_message' => addslashes($this->module->l('Upload an image %s%x%s1%')), + 'not_valid_file_message' => addslashes($this->module->l('Invalid file: %s%')), + ]); + + $this->context->controller->addJS($this->module->getPathUri() . 'views/js/method_countries.js'); + $this->context->controller->addJS($this->module->getPathUri() . 'views/js/validation.js'); + $this->context->controller->addJS($this->module->getPathUri() . 'views/js/admin/settings.js'); + $this->context->controller->addJS($this->module->getPathUri() . 'views/js/admin/custom_logo.js'); + $this->context->controller->addJS($this->module->getPathUri() . 'views/js/admin/upgrade_notice.js'); + $this->context->controller->addJS($this->module->getPathUri() . 'views/js/admin/api_key_test.js'); + $this->context->controller->addJS($this->module->getPathUri() . 'views/js/admin/init_mollie_account.js'); + $this->context->controller->addCSS($this->module->getPathUri() . 'views/css/mollie.css'); + $this->context->controller->addCSS($this->module->getPathUri() . 'views/css/admin/logo_input.css'); + + /** @var TemplateParserInterface $templateParser */ + $templateParser = $this->module->getService(TemplateParserInterface::class); + + $html = $templateParser->parseTemplate( + $this->context->smarty, + $this->module->getService(LogoInfoBlock::class), + $this->module->getLocalPath() . 'views/templates/admin/logo.tpl' + ); + + /** @var UpdateMessageInfoBlock $updateMessageInfoBlock */ + $updateMessageInfoBlock = $this->module->getService(UpdateMessageInfoBlock::class); + + $updateMessageInfoBlockData = $updateMessageInfoBlock->setAddons($this->module::ADDONS); + + $html .= $templateParser->parseTemplate( + $this->context->smarty, + $updateMessageInfoBlockData, + $this->module->getLocalPath() . 'views/templates/admin/updateMessage.tpl' + ); + + /** @var BaseInfoBlock $baseInfoBlock */ + $baseInfoBlock = $this->module->getService(BaseInfoBlock::class); + + $this->context->smarty->assign($baseInfoBlock->buildParams()); + + /** @var FormBuilder $settingsFormBuilder */ + $settingsFormBuilder = $this->module->getService(FormBuilder::class); + + try { + $html .= $settingsFormBuilder->buildSettingsForm(); + } catch (PrestaShopDatabaseException $e) { + $errorHandler = \Mollie\Handler\ErrorHandler\ErrorHandler::getInstance(); + $errorHandler->handle($e, $e->getCode(), false); + $this->context->controller->errors[] = $this->module->l('The database tables are missing. Reset the module.'); + } + + return $html; + } + + private function setEnvironmentForAccounts() + { + /** @var PrestaLoggerInterface $logger */ + $logger = $this->module->getService(PrestaLoggerInterface::class); + + try { + /** @var PsAccounts $accountsFacade */ + $accountsFacade = $this->module->getService(PsAccounts::class); + + $psAccountsPresenter = $accountsFacade->getPsAccountsPresenter(); + $psAccountsService = $accountsFacade->getPsAccountsService(); + } catch (ModuleNotInstalledException $exception) { + try { + /** @var PsAccountsInstaller $prestashopAccountsInstaller */ + $prestashopAccountsInstaller = $this->module->getService(PsAccountsInstaller::class); + + if (!$prestashopAccountsInstaller->install()) { + $this->context->controller->errors[] = + $this->module->l('Failed to install Prestashop Accounts module. Please contact support.'); + + return; + } + } catch (\Throwable $exception) { + $logger->error('"PrestaShop Accounts" install failed.', [ + 'Exception message' => $exception->getMessage(), + 'Exception code' => $exception->getCode(), + ]); + + $this->context->controller->errors[] = + $this->module->l('Failed to install Prestashop Accounts module. Please contact support.'); + + return; + } + + $psAccountsPresenter = $accountsFacade->getPsAccountsPresenter(); + $psAccountsService = $accountsFacade->getPsAccountsService(); + } catch (\Throwable $exception) { + $logger->error('"PrestaShop Accounts" unknown error.', [ + 'Exception message' => $exception->getMessage(), + 'Exception code' => $exception->getCode(), + ]); + + $this->context->controller->errors[] = + $this->module->l('"PrestaShop Accounts" initialization failed.', self::FILE_NAME); + + return; + } + + Media::addJsDef([ + 'contextPsAccounts' => $psAccountsPresenter->present(), + ]); + + $this->context->smarty->assign([ + 'urlAccountsCdn' => $psAccountsService->getAccountsCdn(), + ]); + } + + private function setEnvironmentForCloudSync() + { + $moduleManager = ModuleManagerBuilder::getInstance()->build(); + + if (!$moduleManager->isInstalled('ps_eventbus')) { + return; + } + + /** @var \Ps_eventbus $eventbusModule */ + $eventbusModule = \Module::getInstanceByName('ps_eventbus'); + + if (version_compare($eventbusModule->version, '1.9.0', '>=')) { + /** @var PresenterService $eventbusPresenterService */ + $eventbusPresenterService = $eventbusModule->getService(PresenterService::class); + + Media::addJsDef([ + 'contextPsEventbus' => $eventbusPresenterService->expose($this->module, ['orders']), + ]); + } + + $this->context->smarty->assign([ + 'cloudSyncPathCDC' => Config::PRESTASHOP_CLOUDSYNC_CDN, + ]); + } +} diff --git a/controllers/front/ajax.php b/controllers/front/ajax.php index 993cc6f99..ed37e3148 100644 --- a/controllers/front/ajax.php +++ b/controllers/front/ajax.php @@ -18,6 +18,10 @@ use Mollie\Repository\CurrencyRepositoryInterface; use Mollie\Utility\NumberUtility; +if (!defined('_PS_VERSION_')) { + exit; +} + class MollieAjaxModuleFrontController extends AbstractMollieController { const FILE_NAME = 'ajax'; @@ -43,7 +47,7 @@ private function getTotalCartPrice() $cart = Context::getContext()->cart; /** @var ToolsAdapter $tools */ - $tools = $this->module->getMollieContainer(ToolsAdapter::class); + $tools = $this->module->getService(ToolsAdapter::class); $paymentMethodId = (int) $tools->getValue('paymentMethodId'); @@ -68,7 +72,7 @@ private function getTotalCartPrice() } /** @var CurrencyRepositoryInterface $currencyRepository */ - $currencyRepository = $this->module->getMollieContainer(CurrencyRepositoryInterface::class); + $currencyRepository = $this->module->getService(CurrencyRepositoryInterface::class); /** @var Currency $cartCurrency */ $cartCurrency = $currencyRepository->findOneBy([ @@ -76,10 +80,10 @@ private function getTotalCartPrice() ]); /** @var PaymentFeeProviderInterface $paymentFeeProvider */ - $paymentFeeProvider = $this->module->getMollieContainer(PaymentFeeProviderInterface::class); + $paymentFeeProvider = $this->module->getService(PaymentFeeProviderInterface::class); /** @var ConfigurationAdapter $configuration */ - $configuration = $this->module->getMollieContainer(ConfigurationAdapter::class); + $configuration = $this->module->getService(ConfigurationAdapter::class); try { $paymentFeeData = $paymentFeeProvider->getPaymentFee($molPaymentMethod, (float) $cart->getOrderTotal()); diff --git a/controllers/front/applePayDirectAjax.php b/controllers/front/applePayDirectAjax.php index e511ba37b..d561f469a 100644 --- a/controllers/front/applePayDirectAjax.php +++ b/controllers/front/applePayDirectAjax.php @@ -22,6 +22,10 @@ use Mollie\Builder\ApplePayDirect\ApplePayProductBuilder; use Mollie\Utility\OrderRecoverUtility; +if (!defined('_PS_VERSION_')) { + exit; +} + class MollieApplePayDirectAjaxModuleFrontController extends ModuleFrontController { /** @var Mollie */ @@ -53,7 +57,7 @@ private function getApplePaySession() $cartId = (int) Tools::getValue('cartId'); $validationUrl = Tools::getValue('validationUrl'); /** @var RequestApplePayPaymentSessionHandler $handler */ - $handler = $this->module->getMollieContainer(RequestApplePayPaymentSessionHandler::class); + $handler = $this->module->getService(RequestApplePayPaymentSessionHandler::class); $command = new RequestApplePayPaymentSession( $validationUrl, @@ -69,7 +73,7 @@ private function getApplePaySession() private function updateShippingMethod() { /** @var UpdateApplePayShippingMethodHandler $handler */ - $handler = $this->module->getMollieContainer(UpdateApplePayShippingMethodHandler::class); + $handler = $this->module->getService(UpdateApplePayShippingMethodHandler::class); $shippingMethodDetails = Tools::getValue('shippingMethod'); $command = new UpdateApplePayShippingMethod( @@ -84,9 +88,9 @@ private function updateShippingMethod() private function updateAppleShippingContact() { /** @var UpdateApplePayShippingContactHandler $handler */ - $handler = $this->module->getMollieContainer(UpdateApplePayShippingContactHandler::class); + $handler = $this->module->getService(UpdateApplePayShippingContactHandler::class); /** @var ApplePayProductBuilder $productBuilder */ - $productBuilder = $this->module->getMollieContainer(ApplePayProductBuilder::class); + $productBuilder = $this->module->getService(ApplePayProductBuilder::class); $simplifiedContent = Tools::getValue('simplifiedContact'); $cartId = (int) Tools::getValue('cartId'); @@ -118,9 +122,9 @@ private function createApplePayOrder() $products = $this->getWantedCartProducts($cartId); /** @var CreateApplePayOrderHandler $handler */ - $handler = $this->module->getMollieContainer(CreateApplePayOrderHandler::class); + $handler = $this->module->getService(CreateApplePayOrderHandler::class); /** @var ApplePayOrderBuilder $applePayProductBuilder */ - $applePayProductBuilder = $this->module->getMollieContainer(ApplePayOrderBuilder::class); + $applePayProductBuilder = $this->module->getService(ApplePayOrderBuilder::class); $shippingContent = Tools::getValue('shippingContact'); $billingContent = Tools::getValue('billingContact'); diff --git a/controllers/front/bancontactAjax.php b/controllers/front/bancontactAjax.php index 777aaed4c..352c761a8 100644 --- a/controllers/front/bancontactAjax.php +++ b/controllers/front/bancontactAjax.php @@ -20,6 +20,10 @@ use Mollie\Utility\OrderNumberUtility; use Mollie\Utility\OrderRecoverUtility; +if (!defined('_PS_VERSION_')) { + exit; +} + class MollieBancontactAjaxModuleFrontController extends ModuleFrontController { /** @var Mollie */ @@ -40,9 +44,9 @@ public function postProcess() private function createTransaction() { /** @var PaymentMethodService $paymentMethodService */ - $paymentMethodService = $this->module->getMollieContainer(PaymentMethodService::class); + $paymentMethodService = $this->module->getService(PaymentMethodService::class); /** @var PaymentMethodRepositoryInterface $paymentMethodRepository */ - $paymentMethodRepository = $this->module->getMollieContainer(PaymentMethodRepositoryInterface::class); + $paymentMethodRepository = $this->module->getService(PaymentMethodRepositoryInterface::class); /** @var MolPaymentMethod|null $paymentMethod */ $paymentMethod = $paymentMethodRepository->findOneBy( @@ -78,7 +82,7 @@ private function createTransaction() private function checkForPaidTransaction() { /** @var RetryHandlerInterface $retryHandler */ - $retryHandler = $this->module->getMollieContainer(RetryHandlerInterface::class); + $retryHandler = $this->module->getService(RetryHandlerInterface::class); $cart = Context::getContext()->cart; $proc = function () use ($cart) { diff --git a/controllers/front/fail.php b/controllers/front/fail.php index 2798300bf..291bfd6d5 100644 --- a/controllers/front/fail.php +++ b/controllers/front/fail.php @@ -12,6 +12,10 @@ use PrestaShop\PrestaShop\Adapter\Order\OrderPresenter; +if (!defined('_PS_VERSION_')) { + exit; +} + class MollieFailModuleFrontController extends ModuleFrontController { /** diff --git a/controllers/front/payScreen.php b/controllers/front/payScreen.php index a627d00cb..ec651118c 100644 --- a/controllers/front/payScreen.php +++ b/controllers/front/payScreen.php @@ -13,6 +13,10 @@ use Mollie\Api\Types\PaymentMethod; use Mollie\Provider\ProfileIdProviderInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + class MolliePayScreenModuleFrontController extends ModuleFrontController { /** @var Mollie */ @@ -55,7 +59,7 @@ public function initContent() public function setMedia() { /** @var ProfileIdProviderInterface $profileIdProvider */ - $profileIdProvider = $this->module->getMollieContainer(ProfileIdProviderInterface::class); + $profileIdProvider = $this->module->getService(ProfileIdProviderInterface::class); Media::addJsDef([ 'profileId' => $profileIdProvider->getProfileId($this->module->getApiClient()), diff --git a/controllers/front/payment.php b/controllers/front/payment.php index caeb1fa13..d922e2ce2 100644 --- a/controllers/front/payment.php +++ b/controllers/front/payment.php @@ -15,22 +15,17 @@ use Mollie\Handler\Order\OrderCreationHandler; use Mollie\Repository\PaymentMethodRepositoryInterface; use Mollie\Service\ExceptionService; +use Mollie\Service\LanguageService; use Mollie\Service\MollieOrderCreationService; use Mollie\Service\PaymentMethodService; use Mollie\Utility\OrderNumberUtility; if (!defined('_PS_VERSION_')) { - return; + exit; } require_once dirname(__FILE__) . '/../../mollie.php'; -/** - * Class MolliePaymentModuleFrontController. - * - * @property Context $context - * @property Mollie $module - */ class MolliePaymentModuleFrontController extends ModuleFrontController { const FILE_NAME = 'payment'; @@ -44,6 +39,9 @@ class MolliePaymentModuleFrontController extends ModuleFrontController /** @var bool */ public $display_column_right = false; + /** @var \Mollie */ + public $module; + /** * @throws PrestaShopDatabaseException * @throws PrestaShopException @@ -60,8 +58,8 @@ public function initContent() $cart, $customer )) { - /** @var Mollie\Service\LanguageService $langService */ - $langService = $this->module->getMollieContainer(Mollie\Service\LanguageService::class); + /** @var LanguageService $langService */ + $langService = $this->module->getService(LanguageService::class); $this->errors[] = $langService->lang('This payment method is not available.'); $this->setTemplate('error.tpl'); @@ -81,13 +79,13 @@ public function initContent() } /** @var PaymentMethodRepositoryInterface $paymentMethodRepo */ - $paymentMethodRepo = $this->module->getMollieContainer(PaymentMethodRepositoryInterface::class); + $paymentMethodRepo = $this->module->getService(PaymentMethodRepositoryInterface::class); /** @var PaymentMethodService $transactionService */ - $transactionService = $this->module->getMollieContainer(PaymentMethodService::class); + $transactionService = $this->module->getService(PaymentMethodService::class); /** @var MollieOrderCreationService $mollieOrderCreationService */ - $mollieOrderCreationService = $this->module->getMollieContainer(MollieOrderCreationService::class); + $mollieOrderCreationService = $this->module->getService(MollieOrderCreationService::class); /** @var PaymentMethodRepositoryInterface $paymentMethodRepository */ - $paymentMethodRepository = $this->module->getMollieContainer(PaymentMethodRepositoryInterface::class); + $paymentMethodRepository = $this->module->getService(PaymentMethodRepositoryInterface::class); $environment = (int) Configuration::get(Mollie\Config\Config::MOLLIE_ENVIRONMENT); $paymentMethodId = $paymentMethodRepo->getPaymentMethodIdByMethodId($method, $environment); @@ -111,7 +109,7 @@ public function initContent() if ($method === PaymentMethod::BANKTRANSFER) { /** @var OrderCreationHandler $orderCreationHandler */ - $orderCreationHandler = $this->module->getMollieContainer(OrderCreationHandler::class); + $orderCreationHandler = $this->module->getService(OrderCreationHandler::class); $paymentData = $orderCreationHandler->createBankTransferOrder($paymentData, $cart); } @@ -124,7 +122,7 @@ public function initContent() $message = 'Cart Dump: ' . $e->getMessage() . ' json: ' . json_encode($paymentData, JSON_PRETTY_PRINT); } else { /** @var ExceptionService $exceptionService */ - $exceptionService = $this->module->getMollieContainer(ExceptionService::class); + $exceptionService = $this->module->getService(ExceptionService::class); $message = $exceptionService->getErrorMessageForException($e); } $this->errors[] = $message; diff --git a/controllers/front/return.php b/controllers/front/return.php index 3c56cb176..729b06087 100644 --- a/controllers/front/return.php +++ b/controllers/front/return.php @@ -15,7 +15,7 @@ use Mollie\Config\Config; use Mollie\Controller\AbstractMollieController; use Mollie\Factory\CustomerFactory; -use Mollie\Repository\PaymentMethodRepository; +use Mollie\Repository\PaymentMethodRepositoryInterface; use Mollie\Service\PaymentReturnService; use Mollie\Utility\ArrayUtility; use Mollie\Utility\TransactionUtility; @@ -52,14 +52,14 @@ public function initContent() $customer = $context->customer; /** @var OrderCallBackValidator $orderCallBackValidator */ - $orderCallBackValidator = $this->module->getMollieContainer(OrderCallBackValidator::class); + $orderCallBackValidator = $this->module->getService(OrderCallBackValidator::class); if (!$orderCallBackValidator->validate($key, $idCart)) { Tools::redirectLink('index.php'); } /** @var CustomerFactory $customerFactory */ - $customerFactory = $this->module->getMollieContainer(CustomerFactory::class); + $customerFactory = $this->module->getService(CustomerFactory::class); $this->context = $customerFactory->recreateFromRequest($customer->id, $key, $this->context); if (Tools::getValue('ajax')) { $this->processAjax(); @@ -71,8 +71,8 @@ public function initContent() $data = []; $cart = null; - /** @var PaymentMethodRepository $paymentMethodRepo */ - $paymentMethodRepo = $this->module->getMollieContainer(PaymentMethodRepository::class); + /** @var PaymentMethodRepositoryInterface $paymentMethodRepo */ + $paymentMethodRepo = $this->module->getService(PaymentMethodRepositoryInterface::class); if (Tools::getIsset('cart_id')) { $idCart = (int) Tools::getValue('cart_id'); @@ -184,8 +184,8 @@ protected function processAjax() protected function processGetStatus() { header('Content-Type: application/json;charset=UTF-8'); - /** @var PaymentMethodRepository $paymentMethodRepo */ - $paymentMethodRepo = $this->module->getMollieContainer(PaymentMethodRepository::class); + /** @var PaymentMethodRepositoryInterface $paymentMethodRepo */ + $paymentMethodRepo = $this->module->getService(PaymentMethodRepositoryInterface::class); $transactionId = Tools::getValue('transaction_id'); $dbPayment = $paymentMethodRepo->getPaymentBy('transaction_id', $transactionId); @@ -233,7 +233,7 @@ protected function processGetStatus() $wrongAmountMessage = $this->module->l('The payment failed because the order and payment amounts are different. Try again.', self::FILE_NAME); /** @var PaymentReturnService $paymentReturnService */ - $paymentReturnService = $this->module->getMollieContainer(PaymentReturnService::class); + $paymentReturnService = $this->module->getService(PaymentReturnService::class); switch ($orderStatus) { case PaymentStatus::STATUS_OPEN: case PaymentStatus::STATUS_PENDING: diff --git a/controllers/front/webhook.php b/controllers/front/webhook.php index 97e7caa74..3d1868345 100644 --- a/controllers/front/webhook.php +++ b/controllers/front/webhook.php @@ -69,7 +69,7 @@ public function initContent() protected function executeWebhook() { /** @var TransactionService $transactionService */ - $transactionService = $this->module->getMollieContainer(TransactionService::class); + $transactionService = $this->module->getService(TransactionService::class); $transactionId = Tools::getValue('id'); if (!$transactionId) { @@ -94,7 +94,7 @@ protected function executeWebhook() $payment = $transactionService->processTransaction($transaction); } catch (TransactionException $e) { /** @var ErrorHandler $errorHandler */ - $errorHandler = $this->module->getMollieContainer(ErrorHandler::class); + $errorHandler = $this->module->getService(ErrorHandler::class); $errorHandler->handle($e, $e->getCode(), false); $this->respond('failed', $e->getCode(), $e->getMessage()); } diff --git a/mollie.php b/mollie.php index d72b37322..cb525859c 100644 --- a/mollie.php +++ b/mollie.php @@ -13,28 +13,47 @@ use Mollie\Adapter\ConfigurationAdapter; use Mollie\Adapter\ToolsAdapter; use Mollie\Api\Exceptions\ApiException; +use Mollie\Bootstrap\ModuleTabs; use Mollie\Builder\InvoicePdfTemplateBuilder; use Mollie\Config\Config; use Mollie\Exception\ShipmentCannotBeSentException; +use Mollie\Grid\Definition\Modifier\OrderGridDefinitionModifier; +use Mollie\Grid\Query\Modifier\OrderGridQueryModifier; +use Mollie\Handler\PaymentOption\PaymentOptionHandlerInterface; use Mollie\Handler\Shipment\ShipmentSenderHandlerInterface; +use Mollie\Install\Installer; +use Mollie\Install\Uninstall; use Mollie\Logger\PrestaLoggerInterface; +use Mollie\Presenter\OrderListActionBuilder; use Mollie\Provider\ProfileIdProviderInterface; +use Mollie\Repository\ModuleRepository; use Mollie\Repository\MolOrderPaymentFeeRepositoryInterface; use Mollie\Repository\PaymentMethodRepositoryInterface; +use Mollie\Service\ApiKeyService; +use Mollie\Service\ErrorDisplayService; use Mollie\Service\ExceptionService; +use Mollie\Service\LanguageService; +use Mollie\Service\MollieOrderInfoService; +use Mollie\Service\MolliePaymentMailService; +use Mollie\Service\PaymentMethodService; +use Mollie\Service\ShipmentServiceInterface; +use Mollie\ServiceProvider\LeagueServiceContainerProvider; +use Mollie\Tracker\Segment; use Mollie\Utility\PsVersionUtility; +use Mollie\Validator\OrderConfMailValidator; use Mollie\Verification\IsPaymentInformationAvailable; +use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder; use PrestaShop\PrestaShop\Core\Localization\Locale\Repository; +use PrestaShop\PsAccountsInstaller\Installer\Installer as PsAccountsInstaller; + +if (!defined('_PS_VERSION_')) { + exit; +} require_once __DIR__ . '/vendor/autoload.php'; class Mollie extends PaymentModule { - /** - * Symfony DI Container. - **/ - private $moduleContainer; - const DISABLE_CACHE = true; /** @var \Mollie\Api\MollieApiClient|null */ @@ -51,8 +70,8 @@ class Mollie extends PaymentModule const SUPPORTED_PHP_VERSION = '70080'; - const ADMIN_MOLLIE_CONTROLLER = 'AdminMollieModuleController'; - const ADMIN_MOLLIE_AJAX_CONTROLLER = 'AdminMollieAjaxController'; + /** @var LeagueServiceContainerProvider */ + private $containerProvider; /** * Mollie constructor. @@ -61,7 +80,7 @@ public function __construct() { $this->name = 'mollie'; $this->tab = 'payments_gateways'; - $this->version = '5.4.2'; + $this->version = '5.4.3'; $this->author = 'Mollie B.V.'; $this->need_instance = 1; $this->bootstrap = true; @@ -73,12 +92,19 @@ public function __construct() $this->displayName = $this->l('Mollie'); $this->description = $this->l('Mollie Payments'); - $this->compile(); $this->loadEnv(); - $this->setApiKey(); new \Mollie\Handler\ErrorHandler\ErrorHandler($this); } + public function getService(string $serviceName) + { + if ($this->containerProvider === null) { + $this->containerProvider = new LeagueServiceContainerProvider(); + } + + return $this->containerProvider->getService($serviceName); + } + private function loadEnv() { if (!class_exists('\Dotenv\Dotenv')) { @@ -118,8 +144,44 @@ public function install() return false; } - /** @var \Mollie\Install\Installer $installer */ - $installer = $this->getMollieContainer(\Mollie\Install\Installer::class); + try { + /** @var PsAccountsInstaller $prestashopAccountsInstaller */ + $prestashopAccountsInstaller = $this->getService(PsAccountsInstaller::class); + + if (!$prestashopAccountsInstaller->install()) { + $this->_errors[] = $this->l('Failed to install Prestashop Accounts module. Please contact support.'); + + return false; + } + } catch (\Throwable $exception) { + $this->_errors[] = $this->l('Failed to install Prestashop Accounts module. Please contact support.'); + + return false; + } + + $moduleManager = ModuleManagerBuilder::getInstance()->build(); + + try { + /* + * NOTE: install method upgrades the module if there is a newer version + */ + if ( + $moduleManager->isInstalled('ps_eventbus') && + !$moduleManager->isEnabled('ps_eventbus') + ) { + $moduleManager->enable('ps_eventbus'); + } + + $moduleManager->install('ps_eventbus'); + } catch (Exception $exception) { + $this->_errors[] = $this->l('Failed to install/upgrade Prestashop event bus module. Please contact support.'); + + return false; + } + + /** @var Installer $installer */ + $installer = $this->getService(Installer::class); + if (!$installer->install()) { $this->_errors = array_merge($this->_errors, $installer->getErrors()); @@ -134,8 +196,8 @@ public function install() */ public function uninstall() { - /** @var \Mollie\Install\Uninstall $uninstall */ - $uninstall = $this->getMollieContainer(\Mollie\Install\Uninstall::class); + /** @var Uninstall $uninstall */ + $uninstall = $this->getService(Uninstall::class); if (!$uninstall->uninstall()) { $this->_errors[] = $uninstall->getErrors(); @@ -165,49 +227,6 @@ public function enable($force_all = false) return parent::enable($force_all); } - private function compile() - { - if (!class_exists('Symfony\Component\DependencyInjection\ContainerBuilder') || - !class_exists('Segment') || - !class_exists('Dotenv\Dotenv') || - !class_exists('\Mollie\Repository\ModuleRepository')) { - // If you wonder why this happens then this problem occurs in rare case when upgrading mollie from old versions - // where dependency injection container was without "MolliePrefix". - // On Upgrade PrestaShop cached previous vendor thus causing missing class issues - the only way is to convince - // merchant to try installing again where. - $isAdmin = $this->context->controller instanceof AdminController; - - if ($isAdmin) { - http_response_code(500); - exit( - $this->l('The module upload requires an extra refresh. Upload the Mollie module ZIP file again. If you continue to see this message after reuploading the module, contact Mollie support at info@mollie.com and attach a screenshot of the error. ') - ); - } - } - - $containerBuilder = new \Symfony\Component\DependencyInjection\ContainerBuilder(); - $locator = new \Symfony\Component\Config\FileLocator($this->getLocalPath() . 'config'); - $loader = new \Symfony\Component\DependencyInjection\Loader\YamlFileLoader($containerBuilder, $locator); - $loader->load('config.yml'); - $containerBuilder->compile(); - - $this->moduleContainer = $containerBuilder; - } - - /** - * @param string|bool $id - * - * @return mixed - */ - public function getMollieContainer($id = false) - { - if ($id) { - return $this->moduleContainer->get($id); - } - - return $this->moduleContainer; - } - /** * @return mixed */ @@ -241,6 +260,8 @@ public function getIdentifier() */ public function getContent() { + // TODO create admin controller for this tab + if (Tools::getValue('ajax')) { header('Content-Type: application/json;charset=UTF-8'); @@ -251,104 +272,8 @@ public function getContent() } exit(json_encode($this->{'displayAjax' . Tools::ucfirst(Tools::getValue('action'))}())); } - /** @var \Mollie\Repository\ModuleRepository $moduleRepository */ - $moduleRepository = $this->getMollieContainer(\Mollie\Repository\ModuleRepository::class); - $moduleDatabaseVersion = $moduleRepository->getModuleDatabaseVersion($this->name); - $needsUpgrade = Tools::version_compare($this->version, $moduleDatabaseVersion, '>'); - if ($needsUpgrade) { - $this->context->controller->errors[] = $this->l('Please upgrade Mollie module'); - - return; - } - - $isShopContext = Shop::getContext() === Shop::CONTEXT_SHOP; - - if (!$isShopContext) { - $this->context->controller->errors[] = $this->l('Select the shop that you want to configure'); - - return; - } - - /** @var \Mollie\Service\Content\TemplateParserInterface $templateParser */ - $templateParser = $this->getMollieContainer(\Mollie\Service\Content\TemplateParserInterface::class); - - $isSubmitted = (bool) Tools::isSubmit("submit{$this->name}"); - - /* @phpstan-ignore-next-line */ - if (false === Configuration::get(Mollie\Config\Config::MOLLIE_STATUS_AWAITING) && !$isSubmitted) { - $this->context->controller->errors[] = $this->l('Select an order status for \"Status for Awaiting payments\" in the \"Advanced settings\" tab'); - } - - $errors = []; - - if (Tools::isSubmit("submit{$this->name}")) { - /** @var \Mollie\Service\SettingsSaveService $saveSettingsService */ - $saveSettingsService = $this->getMollieContainer(\Mollie\Service\SettingsSaveService::class); - $resultMessages = $saveSettingsService->saveSettings($errors); - if (!empty($errors)) { - $this->context->controller->errors = $resultMessages; - } else { - $this->context->controller->confirmations = $resultMessages; - } - } - Media::addJsDef([ - 'description_message' => addslashes($this->l('Enter a description')), - 'min_amount_message' => addslashes($this->l('You have entered incorrect min amount')), - 'max_amount_message' => addslashes($this->l('You have entered incorrect max amount')), - - 'payment_api' => addslashes(Mollie\Config\Config::MOLLIE_PAYMENTS_API), - 'ajaxUrl' => addslashes($this->context->link->getAdminLink('AdminMollieAjax')), - ]); - - /* Custom logo JS vars*/ - Media::addJsDef([ - 'image_size_message' => addslashes($this->l('Upload an image %s%x%s1%')), - 'not_valid_file_message' => addslashes($this->l('Invalid file: %s%')), - ]); - - $this->context->controller->addJS($this->getPathUri() . 'views/js/method_countries.js'); - $this->context->controller->addJS($this->getPathUri() . 'views/js/validation.js'); - $this->context->controller->addJS($this->getPathUri() . 'views/js/admin/settings.js'); - $this->context->controller->addJS($this->getPathUri() . 'views/js/admin/custom_logo.js'); - $this->context->controller->addJS($this->getPathUri() . 'views/js/admin/upgrade_notice.js'); - $this->context->controller->addJS($this->getPathUri() . 'views/js/admin/api_key_test.js'); - $this->context->controller->addJS($this->getPathUri() . 'views/js/admin/init_mollie_account.js'); - $this->context->controller->addCSS($this->getPathUri() . 'views/css/mollie.css'); - $this->context->controller->addCSS($this->getPathUri() . 'views/css/admin/logo_input.css'); - - $html = $templateParser->parseTemplate( - $this->context->smarty, - $this->getMollieContainer(\Mollie\Builder\Content\LogoInfoBlock::class), - $this->getLocalPath() . 'views/templates/admin/logo.tpl' - ); - - /** @var \Mollie\Builder\Content\UpdateMessageInfoBlock $updateMessageInfoBlock */ - $updateMessageInfoBlock = $this->getMollieContainer(\Mollie\Builder\Content\UpdateMessageInfoBlock::class); - $updateMessageInfoBlockData = $updateMessageInfoBlock->setAddons(self::ADDONS); - - $html .= $templateParser->parseTemplate( - $this->context->smarty, - $updateMessageInfoBlockData, - $this->getLocalPath() . 'views/templates/admin/updateMessage.tpl' - ); - - /** @var \Mollie\Builder\Content\BaseInfoBlock $baseInfoBlock */ - $baseInfoBlock = $this->getMollieContainer(\Mollie\Builder\Content\BaseInfoBlock::class); - $this->context->smarty->assign($baseInfoBlock->buildParams()); - - /** @var \Mollie\Builder\FormBuilder $settingsFormBuilder */ - $settingsFormBuilder = $this->getMollieContainer(\Mollie\Builder\FormBuilder::class); - - try { - $html .= $settingsFormBuilder->buildSettingsForm(); - } catch (PrestaShopDatabaseException $e) { - $errorHandler = \Mollie\Handler\ErrorHandler\ErrorHandler::getInstance(); - $errorHandler->handle($e, $e->getCode(), false); - $this->context->controller->errors[] = $this->l('The database tables are missing. Reset the module.'); - } - - return $html; + Tools::redirectAdmin($this->context->link->getAdminLink('AdminMollieSettings')); } /** @@ -360,8 +285,8 @@ public function getContent() */ public function lang($str) { - /** @var Mollie\Service\LanguageService $langService */ - $langService = $this->getMollieContainer(Mollie\Service\LanguageService::class); + /** @var LanguageService $langService */ + $langService = $this->getService(LanguageService::class); $lang = $langService->getLang(); if (array_key_exists($str, $lang)) { return $lang[$str]; @@ -383,7 +308,7 @@ public function hookDisplayHeader(array $params) } /** @var ProfileIdProviderInterface $profileIdProvider */ - $profileIdProvider = $this->getMollieContainer(ProfileIdProviderInterface::class); + $profileIdProvider = $this->getService(ProfileIdProviderInterface::class); Media::addJsDef([ 'profileId' => $profileIdProvider->getProfileId($apiClient), @@ -423,14 +348,14 @@ public function hookDisplayHeader(array $params) */ public function hookActionFrontControllerSetMedia($params) { - /** @var \Mollie\Service\ErrorDisplayService $errorDisplayService */ - $errorDisplayService = $this->getMollieContainer()->get(\Mollie\Service\ErrorDisplayService::class); + /** @var ErrorDisplayService $errorDisplayService */ + $errorDisplayService = $this->getService(ErrorDisplayService::class); /** @var PaymentMethodRepositoryInterface $methodRepository */ - $methodRepository = $this->getMollieContainer()->get(PaymentMethodRepositoryInterface::class); + $methodRepository = $this->getService(PaymentMethodRepositoryInterface::class); /** @var ConfigurationAdapter $configuration */ - $configuration = $this->getMollieContainer()->get(ConfigurationAdapter::class); + $configuration = $this->getService(ConfigurationAdapter::class); $controller = $this->context->controller; @@ -506,8 +431,7 @@ public function hookActionAdminControllerSetMedia() $moduleName = Tools::getValue('configure'); - // We are on module configuration page - if ($this->name === $moduleName && 'AdminModules' === $currentController) { + if ('AdminMollieSettings' === $currentController) { Media::addJsDef([ 'paymentMethodTaxRulesGroupIdConfig' => Config::MOLLIE_METHOD_TAX_RULES_GROUP_ID, 'paymentMethodSurchargeFixedAmountTaxInclConfig' => Config::MOLLIE_METHOD_SURCHARGE_FIXED_AMOUNT_TAX_INCL, @@ -553,11 +477,11 @@ public function hookDisplayBackOfficeHeader() */ public function hookDisplayAdminOrder($params) { - /** @var \Mollie\Repository\PaymentMethodRepository $paymentMethodRepo */ - $paymentMethodRepo = $this->getMollieContainer(PaymentMethodRepositoryInterface::class); + /** @var PaymentMethodRepositoryInterface $paymentMethodRepo */ + $paymentMethodRepo = $this->getService(PaymentMethodRepositoryInterface::class); - /** @var \Mollie\Service\ShipmentServiceInterface $shipmentService */ - $shipmentService = $this->getMollieContainer(\Mollie\Service\ShipmentService::class); + /** @var ShipmentServiceInterface $shipmentService */ + $shipmentService = $this->getService(ShipmentServiceInterface::class); $cartId = Cart::getCartIdByOrderId((int) $params['id_order']); $transaction = $paymentMethodRepo->getPaymentBy('cart_id', (string) $cartId); @@ -607,16 +531,16 @@ public function hookPaymentOptions($params) $paymentOptions = []; /** @var PaymentMethodRepositoryInterface $paymentMethodRepository */ - $paymentMethodRepository = $this->getMollieContainer(PaymentMethodRepositoryInterface::class); + $paymentMethodRepository = $this->getService(PaymentMethodRepositoryInterface::class); - /** @var \Mollie\Handler\PaymentOption\PaymentOptionHandlerInterface $paymentOptionsHandler */ - $paymentOptionsHandler = $this->getMollieContainer(\Mollie\Handler\PaymentOption\PaymentOptionHandlerInterface::class); + /** @var PaymentOptionHandlerInterface $paymentOptionsHandler */ + $paymentOptionsHandler = $this->getService(PaymentOptionHandlerInterface::class); - /** @var \Mollie\Service\PaymentMethodService $paymentMethodService */ - $paymentMethodService = $this->getMollieContainer(\Mollie\Service\PaymentMethodService::class); + /** @var PaymentMethodService $paymentMethodService */ + $paymentMethodService = $this->getService(PaymentMethodService::class); /** @var PrestaLoggerInterface $logger */ - $logger = $this->getMollieContainer(PrestaLoggerInterface::class); + $logger = $this->getService(PrestaLoggerInterface::class); $methods = $paymentMethodService->getMethodsForCheckout(); @@ -649,8 +573,8 @@ public function hookPaymentOptions($params) */ public function hookDisplayOrderConfirmation() { - /** @var \Mollie\Repository\PaymentMethodRepository $paymentMethodRepo */ - $paymentMethodRepo = $this->getMollieContainer(\Mollie\Repository\PaymentMethodRepository::class); + /** @var PaymentMethodRepositoryInterface $paymentMethodRepo */ + $paymentMethodRepo = $this->getService(PaymentMethodRepositoryInterface::class); $payment = $paymentMethodRepo->getPaymentBy('cart_id', (string) Tools::getValue('id_cart')); if (!$payment) { return ''; @@ -675,8 +599,8 @@ public function displayAjaxMollieOrderInfo() { header('Content-Type: application/json;charset=UTF-8'); - /** @var \Mollie\Service\MollieOrderInfoService $orderInfoService */ - $orderInfoService = $this->getMollieContainer(\Mollie\Service\MollieOrderInfoService::class); + /** @var MollieOrderInfoService $orderInfoService */ + $orderInfoService = $this->getService(MollieOrderInfoService::class); $input = @json_decode(Tools::file_get_contents('php://input'), true); @@ -722,20 +646,20 @@ public function hookActionOrderStatusUpdate(array $params = []) } /** @var IsPaymentInformationAvailable $isPaymentInformationAvailable */ - $isPaymentInformationAvailable = $this->getMollieContainer(IsPaymentInformationAvailable::class); + $isPaymentInformationAvailable = $this->getService(IsPaymentInformationAvailable::class); if (!$isPaymentInformationAvailable->verify((int) $order->id)) { return; } /** @var ShipmentSenderHandlerInterface $shipmentSenderHandler */ - $shipmentSenderHandler = $this->getMollieContainer(ShipmentSenderHandlerInterface::class); + $shipmentSenderHandler = $this->getService(ShipmentSenderHandlerInterface::class); /** @var ExceptionService $exceptionService */ - $exceptionService = $this->getMollieContainer(ExceptionService::class); + $exceptionService = $this->getService(ExceptionService::class); /** @var PrestaLoggerInterface $logger */ - $logger = $this->getMollieContainer(PrestaLoggerInterface::class); + $logger = $this->getService(PrestaLoggerInterface::class); try { $shipmentSenderHandler->handleShipmentSender($apiClient, $order, $orderStatus); @@ -777,8 +701,8 @@ public function hookActionEmailSendBefore($params) return true; } - /** @var \Mollie\Validator\OrderConfMailValidator $orderConfMailValidator */ - $orderConfMailValidator = $this->getMollieContainer(\Mollie\Validator\OrderConfMailValidator::class); + /** @var OrderConfMailValidator $orderConfMailValidator */ + $orderConfMailValidator = $this->getService(OrderConfMailValidator::class); /** @var string $template */ $template = $params['template']; @@ -802,10 +726,10 @@ public function hookActionEmailSendBefore($params) 'bankwire' === $template || 'refund' === $template) { /** @var MolOrderPaymentFeeRepositoryInterface $molOrderPaymentFeeRepository */ - $molOrderPaymentFeeRepository = $this->getMollieContainer(MolOrderPaymentFeeRepositoryInterface::class); + $molOrderPaymentFeeRepository = $this->getService(MolOrderPaymentFeeRepositoryInterface::class); /** @var ToolsAdapter $tools */ - $tools = $this->getMollieContainer(ToolsAdapter::class); + $tools = $this->getService(ToolsAdapter::class); $orderCurrency = new Currency($order->id_currency); @@ -860,7 +784,7 @@ public function hookDisplayPDFInvoice($params): string } /** @var InvoicePdfTemplateBuilder $invoiceTemplateBuilder */ - $invoiceTemplateBuilder = $this->getMollieContainer(InvoicePdfTemplateBuilder::class); + $invoiceTemplateBuilder = $this->getService(InvoicePdfTemplateBuilder::class); $locale = null; @@ -868,10 +792,10 @@ public function hookDisplayPDFInvoice($params): string /** @var Repository $localeRepo */ $localeRepo = $this->get('prestashop.core.localization.locale.repository'); - /** + /** * NOTE: context language is set based on customer/employee context */ - $locale = $localeRepo->getLocale($this->context->language->getLocale()); + $locale = $localeRepo->getLocale($this->context->language->getLocale()); } $templateParams = $invoiceTemplateBuilder @@ -890,27 +814,12 @@ public function hookDisplayPDFInvoice($params): string ); } - /** - * @return array - */ - public function getTabs() + public function getTabs(): array { - return [ - [ - 'name' => $this->name, - 'class_name' => self::ADMIN_MOLLIE_CONTROLLER, - 'ParentClassName' => 'AdminParentShipping', - 'parent' => 'AdminParentShipping', - ], - [ - 'name' => $this->l('AJAX', __CLASS__), - 'class_name' => self::ADMIN_MOLLIE_AJAX_CONTROLLER, - 'ParentClassName' => self::ADMIN_MOLLIE_CONTROLLER, - 'parent' => self::ADMIN_MOLLIE_CONTROLLER, - 'module_tab' => true, - 'visible' => false, - ], - ]; + /** @var ModuleTabs $moduleTabs */ + $moduleTabs = $this->getService(ModuleTabs::class); + + return $moduleTabs->getTabs(); } public function hookActionAdminOrdersListingFieldsModifier($params) @@ -939,8 +848,8 @@ public function hookActionOrderGridDefinitionModifier(array $params) return; } - /** @var \Mollie\Grid\Definition\Modifier\OrderGridDefinitionModifier $orderGridDefinitionModifier */ - $orderGridDefinitionModifier = $this->getMollieContainer(\Mollie\Grid\Definition\Modifier\OrderGridDefinitionModifier::class); + /** @var OrderGridDefinitionModifier $orderGridDefinitionModifier */ + $orderGridDefinitionModifier = $this->getService(OrderGridDefinitionModifier::class); $gridDefinition = $params['definition']; $orderGridDefinitionModifier->modify($gridDefinition); @@ -948,8 +857,8 @@ public function hookActionOrderGridDefinitionModifier(array $params) public function hookActionOrderGridQueryBuilderModifier(array $params) { - /** @var \Mollie\Grid\Query\Modifier\OrderGridQueryModifier $orderGridQueryModifier */ - $orderGridQueryModifier = $this->getMollieContainer(\Mollie\Grid\Query\Modifier\OrderGridQueryModifier::class); + /** @var OrderGridQueryModifier $orderGridQueryModifier */ + $orderGridQueryModifier = $this->getService(OrderGridQueryModifier::class); $searchQueryBuilder = $params['search_query_builder']; $orderGridQueryModifier->modify($searchQueryBuilder); @@ -979,8 +888,8 @@ public function hookActionValidateOrder($params) $orderPayment = $params['order']->payment; $orderId = $params['order']->id; - /** @var \Mollie\Service\PaymentMethodService $paymentMethodService */ - $paymentMethodService = $this->getMollieContainer(\Mollie\Service\PaymentMethodService::class); + /** @var PaymentMethodService $paymentMethodService */ + $paymentMethodService = $this->getService(PaymentMethodService::class); $paymentMethodObj = new MolPaymentMethod(); $paymentData = $paymentMethodService->getPaymentData( $totalPaid, @@ -995,8 +904,8 @@ public function hookActionValidateOrder($params) $newPayment = $apiClient->payments->create($paymentData->jsonSerialize()); - /** @var \Mollie\Repository\PaymentMethodRepository $paymentMethodRepository */ - $paymentMethodRepository = $this->getMollieContainer(\Mollie\Repository\PaymentMethodRepository::class); + /** @var PaymentMethodRepositoryInterface $paymentMethodRepository */ + $paymentMethodRepository = $this->getService(PaymentMethodRepositoryInterface::class); $paymentMethodRepository->addOpenStatusPayment( $cartId, $orderPayment, @@ -1007,8 +916,8 @@ public function hookActionValidateOrder($params) $sendMolliePaymentMail = Tools::getValue('mollie-email-send'); if ('on' === $sendMolliePaymentMail) { - /** @var \Mollie\Service\MolliePaymentMailService $molliePaymentMailService */ - $molliePaymentMailService = $this->getMollieContainer(\Mollie\Service\MolliePaymentMailService::class); + /** @var MolliePaymentMailService $molliePaymentMailService */ + $molliePaymentMailService = $this->getService(MolliePaymentMailService::class); $molliePaymentMailService->sendSecondChanceMail($orderId); } } @@ -1020,7 +929,7 @@ public function hookActionObjectOrderPaymentAddAfter($params) $orderPayment = $params['object']; /** @var PaymentMethodRepositoryInterface $paymentMethodRepo */ - $paymentMethodRepo = $this->getMollieContainer(PaymentMethodRepositoryInterface::class); + $paymentMethodRepo = $this->getService(PaymentMethodRepositoryInterface::class); $orders = Order::getByReference($orderPayment->order_reference); /** @var Order $order */ @@ -1066,15 +975,15 @@ public static function resendOrderPaymentLink($orderId) { /** @var Mollie $module */ $module = Module::getInstanceByName('mollie'); - /** @var \Mollie\Repository\PaymentMethodRepository $molliePaymentRepo */ - $molliePaymentRepo = $module->getMollieContainer(PaymentMethodRepositoryInterface::class); + /** @var PaymentMethodRepositoryInterface $molliePaymentRepo */ + $molliePaymentRepo = $module->getService(PaymentMethodRepositoryInterface::class); $molPayment = $molliePaymentRepo->getPaymentBy('cart_id', (string) Cart::getCartIdByOrderId($orderId)); if (\Mollie\Utility\MollieStatusUtility::isPaymentFinished($molPayment['bank_status'])) { return false; } - /** @var \Mollie\Presenter\OrderListActionBuilder $orderListActionBuilder */ - $orderListActionBuilder = $module->getMollieContainer(\Mollie\Presenter\OrderListActionBuilder::class); + /** @var OrderListActionBuilder $orderListActionBuilder */ + $orderListActionBuilder = $module->getService(OrderListActionBuilder::class); return $orderListActionBuilder->buildOrderPaymentResendButton($module->smarty, $orderId); } @@ -1089,16 +998,16 @@ private function setApiKey($shopId = null) if ($this->api && $shopId === null) { return; } - /** @var \Mollie\Repository\ModuleRepository $moduleRepository */ - $moduleRepository = $this->getMollieContainer(\Mollie\Repository\ModuleRepository::class); + /** @var ModuleRepository $moduleRepository */ + $moduleRepository = $this->getService(ModuleRepository::class); $moduleDatabaseVersion = $moduleRepository->getModuleDatabaseVersion($this->name); $needsUpgrade = Tools::version_compare($this->version, $moduleDatabaseVersion, '>'); if ($needsUpgrade) { return; } - /** @var \Mollie\Service\ApiKeyService $apiKeyService */ - $apiKeyService = $this->getMollieContainer(\Mollie\Service\ApiKeyService::class); + /** @var ApiKeyService $apiKeyService */ + $apiKeyService = $this->getService(ApiKeyService::class); $environment = (int) Configuration::get(Mollie\Config\Config::MOLLIE_ENVIRONMENT); $apiKeyConfig = \Mollie\Config\Config::ENVIRONMENT_LIVE === (int) $environment ? @@ -1129,8 +1038,8 @@ private function setApiKey($shopId = null) public function runUpgradeModule() { - /** @var Mollie\Tracker\Segment $segment */ - $segment = $this->getMollieContainer(Mollie\Tracker\Segment::class); + /** @var Segment $segment */ + $segment = $this->getService(Segment::class); $segment->setMessage('Mollie module upgrade'); $segment->track(); diff --git a/src/Adapter/API/CurlPSMollieHttpAdapter.php b/src/Adapter/API/CurlPSMollieHttpAdapter.php index 53aae65c3..22dd90118 100644 --- a/src/Adapter/API/CurlPSMollieHttpAdapter.php +++ b/src/Adapter/API/CurlPSMollieHttpAdapter.php @@ -18,6 +18,10 @@ use Mollie\Api\HttpAdapter\MollieHttpAdapterInterface; use Mollie\Api\MollieApiClient; +if (!defined('_PS_VERSION_')) { + exit; +} + final class CurlPSMollieHttpAdapter implements MollieHttpAdapterInterface { /** diff --git a/src/Adapter/ConfigurationAdapter.php b/src/Adapter/ConfigurationAdapter.php index 38ddb4d5a..9b8d7bf65 100644 --- a/src/Adapter/ConfigurationAdapter.php +++ b/src/Adapter/ConfigurationAdapter.php @@ -16,6 +16,10 @@ use Mollie\Config\Config; use Shop; +if (!defined('_PS_VERSION_')) { + exit; +} + class ConfigurationAdapter { public function get($key, $idShop = null, $idLang = null, $idShopGroup = null) diff --git a/src/Adapter/LegacyContext.php b/src/Adapter/Context.php similarity index 72% rename from src/Adapter/LegacyContext.php rename to src/Adapter/Context.php index 1c36da9cd..974e6340f 100644 --- a/src/Adapter/LegacyContext.php +++ b/src/Adapter/Context.php @@ -37,13 +37,17 @@ namespace Mollie\Adapter; use Configuration as PrestashopConfiguration; -use Context; +use Context as PrestaShopContext; -class LegacyContext +if (!defined('_PS_VERSION_')) { + exit; +} + +class Context { public function getContext() { - return Context::getContext(); + return PrestaShopContext::getContext(); } public function getCookieValue($key) @@ -160,7 +164,7 @@ public function getModuleLink( ); } - public function getAddressInvoiceId(): int + public function getInvoiceAddressId(): int { return (int) $this->getContext()->cart->id_address_invoice; } @@ -174,4 +178,59 @@ public function getCurrencyIso(): string { return (string) $this->getContext()->currency->iso_code; } + + public function getAdminLink(string $controller): string + { + return (string) $this->getContext()->link->getAdminLink($controller); + } + + public function getLanguageId(): int + { + return (int) $this->getContext()->language->id; + } + + public function getPageLink(string $controller, bool $ssl = null, int $idLang = null, $request = null): string + { + return (int) $this->getContext()->link->getPageLink($controller, $ssl, $idLang, $request); + } + + public function getLanguageIso(): string + { + return (string) $this->getContext()->language->iso_code; + } + + public function getShopContext(): int + { + return (int) $this->getContext()->shop->getContextType(); + } + + public function getShops(bool $active = true, int $id_shop_group = null, bool $get_as_list_id = false): array + { + return $this->getContext()->shop::getShops($active, $id_shop_group, $get_as_list_id); + } + + public function getContextShopGroupID(): int + { + return (int) $this->getContext()->shop->getContextualShopId(); + } + + public function getShopDomain(): string + { + return (string) $this->getContext()->shop->domain; + } + + public function getCustomerId(): int + { + return (int) ($this->getContext()->customer->id ?? 0); + } + + public function getCustomerEmail(): string + { + return (string) ($this->getContext()->customer->email ?? ''); + } + + public function isCustomerGuest(): bool + { + return (string) ($this->getContext()->customer->isGuest() ?? ''); + } } diff --git a/src/Adapter/Language.php b/src/Adapter/Language.php new file mode 100644 index 000000000..85012c351 --- /dev/null +++ b/src/Adapter/Language.php @@ -0,0 +1,27 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Adapter; + +use Language as PrestashopLanguage; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class Language +{ + public function getAllLanguages(): array + { + return PrestashopLanguage::getLanguages(false); + } +} diff --git a/src/Adapter/Tab.php b/src/Adapter/Tab.php new file mode 100644 index 000000000..e869a3aad --- /dev/null +++ b/src/Adapter/Tab.php @@ -0,0 +1,43 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Adapter; + +use Tab as PrestashopTab; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class Tab +{ + public function initTab(int $idTab = null): PrestashopTab + { + return new PrestashopTab($idTab); + } + + /** + * @param string|null $parent + * + * @return int|null + */ + public function getIdFromClassName($parent) + { + $tabId = (int) PrestashopTab::getIdFromClassName($parent); + + if (!$tabId) { + return null; + } + + return $tabId; + } +} diff --git a/src/Adapter/ToolsAdapter.php b/src/Adapter/ToolsAdapter.php index bedc983f5..7c33c81fd 100644 --- a/src/Adapter/ToolsAdapter.php +++ b/src/Adapter/ToolsAdapter.php @@ -15,6 +15,10 @@ use Currency; use Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + class ToolsAdapter { public function strtoupper($str) @@ -41,4 +45,9 @@ public function displayPrice(float $price, Currency $currency): string { return Tools::displayPrice($price, $currency); } + + public function isSubmit(string $string): bool + { + return (bool) Tools::isSubmit($string); + } } diff --git a/src/Application/Command/CreateApplePayOrder.php b/src/Application/Command/CreateApplePayOrder.php index 61aff332e..39e5d1539 100644 --- a/src/Application/Command/CreateApplePayOrder.php +++ b/src/Application/Command/CreateApplePayOrder.php @@ -14,6 +14,10 @@ use Mollie\DTO\ApplePay\Order; +if (!defined('_PS_VERSION_')) { + exit; +} + final class CreateApplePayOrder { /** diff --git a/src/Application/Command/RequestApplePayPaymentSession.php b/src/Application/Command/RequestApplePayPaymentSession.php index dbb19c45d..cfb606737 100644 --- a/src/Application/Command/RequestApplePayPaymentSession.php +++ b/src/Application/Command/RequestApplePayPaymentSession.php @@ -12,6 +12,10 @@ namespace Mollie\Application\Command; +if (!defined('_PS_VERSION_')) { + exit; +} + final class RequestApplePayPaymentSession { /** diff --git a/src/Application/Command/UpdateApplePayShippingContact.php b/src/Application/Command/UpdateApplePayShippingContact.php index ac523da7b..9ccf48e49 100644 --- a/src/Application/Command/UpdateApplePayShippingContact.php +++ b/src/Application/Command/UpdateApplePayShippingContact.php @@ -14,6 +14,10 @@ use Mollie\DTO\ApplePay\Product; +if (!defined('_PS_VERSION_')) { + exit; +} + final class UpdateApplePayShippingContact { /** diff --git a/src/Application/Command/UpdateApplePayShippingMethod.php b/src/Application/Command/UpdateApplePayShippingMethod.php index 576d125a4..4412e5c3c 100644 --- a/src/Application/Command/UpdateApplePayShippingMethod.php +++ b/src/Application/Command/UpdateApplePayShippingMethod.php @@ -12,6 +12,10 @@ namespace Mollie\Application\Command; +if (!defined('_PS_VERSION_')) { + exit; +} + final class UpdateApplePayShippingMethod { /** diff --git a/src/Application/CommandHandler/CreateApplePayOrderHandler.php b/src/Application/CommandHandler/CreateApplePayOrderHandler.php index e685cb08f..41d99f7ce 100644 --- a/src/Application/CommandHandler/CreateApplePayOrderHandler.php +++ b/src/Application/CommandHandler/CreateApplePayOrderHandler.php @@ -17,13 +17,14 @@ use Configuration; use Country; use Currency; -use Link; use Mollie; +use Mollie\Adapter\Context; use Mollie\Application\Command\CreateApplePayOrder; use Mollie\Config\Config; use Mollie\DTO\ApplePay\ShippingContent; use Mollie\Exception\OrderCreationException; use Mollie\Exception\RetryOverException; +use Mollie\Factory\ModuleFactory; use Mollie\Handler\RetryHandlerInterface; use Mollie\Repository\PaymentMethodRepositoryInterface; use Mollie\Service\MollieOrderCreationService; @@ -33,6 +34,10 @@ use Order; use Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + final class CreateApplePayOrderHandler { const FILE_NAME = 'CreateApplePayOrderHandler'; @@ -49,31 +54,29 @@ final class CreateApplePayOrderHandler * @var MollieOrderCreationService */ private $mollieOrderCreationService; - /** - * @var Link - */ - private $link; /** * @var Mollie */ private $module; /** @var RetryHandlerInterface */ private $retryHandler; + /** @var Context */ + private $context; public function __construct( PaymentMethodRepositoryInterface $paymentMethodRepository, PaymentMethodService $paymentMethodService, MollieOrderCreationService $mollieOrderCreationService, - Link $link, - Mollie $module, - RetryHandlerInterface $retryHandler + ModuleFactory $moduleFactory, + RetryHandlerInterface $retryHandler, + Context $context ) { $this->paymentMethodRepository = $paymentMethodRepository; $this->paymentMethodService = $paymentMethodService; $this->mollieOrderCreationService = $mollieOrderCreationService; - $this->link = $link; - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->retryHandler = $retryHandler; + $this->context = $context; } public function handle(CreateApplePayOrder $command): array @@ -135,7 +138,7 @@ public function handle(CreateApplePayOrder $command): array $this->deleteAddress($order->id_address_delivery); $this->deleteAddress($order->id_address_invoice); - $successUrl = $this->link->getPageLink( + $successUrl = $this->context->getPageLink( 'order-confirmation', true, null, diff --git a/src/Application/CommandHandler/RequestApplePayPaymentSessionHandler.php b/src/Application/CommandHandler/RequestApplePayPaymentSessionHandler.php index 919bfd0e6..7ae10d52b 100644 --- a/src/Application/CommandHandler/RequestApplePayPaymentSessionHandler.php +++ b/src/Application/CommandHandler/RequestApplePayPaymentSessionHandler.php @@ -17,8 +17,13 @@ use Mollie\Api\Exceptions\ApiException; use Mollie\Application\Command\RequestApplePayPaymentSession; use Mollie\Exception\MollieApiException; +use Mollie\Factory\ModuleFactory; use Mollie\Service\ApiServiceInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + final class RequestApplePayPaymentSessionHandler { /** @@ -30,9 +35,9 @@ final class RequestApplePayPaymentSessionHandler */ private $apiService; - public function __construct(Mollie $module, ApiServiceInterface $apiService) + public function __construct(ModuleFactory $moduleFactory, ApiServiceInterface $apiService) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->apiService = $apiService; } diff --git a/src/Application/CommandHandler/UpdateApplePayShippingContactHandler.php b/src/Application/CommandHandler/UpdateApplePayShippingContactHandler.php index ff475d2c1..6236c91bb 100644 --- a/src/Application/CommandHandler/UpdateApplePayShippingContactHandler.php +++ b/src/Application/CommandHandler/UpdateApplePayShippingContactHandler.php @@ -25,6 +25,10 @@ use Mollie\Utility\ApplePayDirect\ShippingMethodUtility; use Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + final class UpdateApplePayShippingContactHandler { /** diff --git a/src/Application/CommandHandler/UpdateApplePayShippingMethodHandler.php b/src/Application/CommandHandler/UpdateApplePayShippingMethodHandler.php index 75b2f3340..16636ea58 100644 --- a/src/Application/CommandHandler/UpdateApplePayShippingMethodHandler.php +++ b/src/Application/CommandHandler/UpdateApplePayShippingMethodHandler.php @@ -17,6 +17,10 @@ use Mollie\Config\Config; use Mollie\Service\OrderPaymentFeeService; +if (!defined('_PS_VERSION_')) { + exit; +} + final class UpdateApplePayShippingMethodHandler { /** diff --git a/src/Bootstrap/ModuleTabs.php b/src/Bootstrap/ModuleTabs.php new file mode 100644 index 000000000..b20ab333f --- /dev/null +++ b/src/Bootstrap/ModuleTabs.php @@ -0,0 +1,79 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Bootstrap; + +use Mollie\Factory\ModuleFactory; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class ModuleTabs +{ + const SELF_NAME = 'ModuleTabs'; + + const ADMIN_MOLLIE_CONTROLLER = 'AdminMollieModule'; + const ADMIN_MOLLIE_AJAX_CONTROLLER = 'AdminMollieAjax'; + const ADMIN_MOLLIE_SETTINGS_CONTROLLER = 'AdminMollieSettings'; + + /** @var \Mollie */ + private $module; + + public function __construct(ModuleFactory $moduleFactory) + { + $this->module = $moduleFactory->getModule(); + } + + public function getTabs(): array + { + // TODO legacy tab translator + + return [ + [ + 'name' => [ + 'en' => $this->module->displayName, + 'en-US' => $this->module->displayName, + ], + 'class_name' => self::ADMIN_MOLLIE_CONTROLLER, + 'parent_class_name' => 'IMPROVE', + 'ParentClassName' => 'IMPROVE', + 'visible' => true, + 'icon' => 'mollie', + ], + [ + 'name' => [ + 'en' => $this->module->l('AJAX', self::SELF_NAME), + 'en-US' => $this->module->l('AJAX', self::SELF_NAME), + ], + 'class_name' => self::ADMIN_MOLLIE_AJAX_CONTROLLER, + 'parent_class_name' => '', + 'ParentClassName' => '', + 'module_tab' => true, + 'visible' => false, + 'icon' => '', + ], + [ + 'name' => [ + 'en' => $this->module->l('Settings', self::SELF_NAME), + 'en-US' => $this->module->l('Settings', self::SELF_NAME), + ], + 'class_name' => self::ADMIN_MOLLIE_SETTINGS_CONTROLLER, + 'parent_class_name' => '', + 'ParentClassName' => '', + 'module_tab' => true, + 'visible' => false, + 'icon' => '', + ], + ]; + } +} diff --git a/src/Bootstrap/index.php b/src/Bootstrap/index.php new file mode 100644 index 000000000..d3343995f --- /dev/null +++ b/src/Bootstrap/index.php @@ -0,0 +1,20 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ +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; diff --git a/src/Builder/ApiTestFeedbackBuilder.php b/src/Builder/ApiTestFeedbackBuilder.php index 89ba3f55b..165bc5020 100644 --- a/src/Builder/ApiTestFeedbackBuilder.php +++ b/src/Builder/ApiTestFeedbackBuilder.php @@ -16,6 +16,10 @@ use Mollie\Api\Resources\MethodCollection; use Mollie\Service\ApiKeyService; +if (!defined('_PS_VERSION_')) { + exit; +} + class ApiTestFeedbackBuilder implements TemplateBuilderInterface { /** diff --git a/src/Builder/ApplePayDirect/ApplePayCarriersBuilder.php b/src/Builder/ApplePayDirect/ApplePayCarriersBuilder.php index 270720557..8baeb971b 100644 --- a/src/Builder/ApplePayDirect/ApplePayCarriersBuilder.php +++ b/src/Builder/ApplePayDirect/ApplePayCarriersBuilder.php @@ -15,6 +15,10 @@ use Carrier; use Mollie\DTO\ApplePay\Carrier\Carrier as AppleCarrier; +if (!defined('_PS_VERSION_')) { + exit; +} + class ApplePayCarriersBuilder { /** diff --git a/src/Builder/ApplePayDirect/ApplePayOrderBuilder.php b/src/Builder/ApplePayDirect/ApplePayOrderBuilder.php index ab65257a6..b75360a6a 100644 --- a/src/Builder/ApplePayDirect/ApplePayOrderBuilder.php +++ b/src/Builder/ApplePayDirect/ApplePayOrderBuilder.php @@ -16,6 +16,10 @@ use Mollie\DTO\ApplePay\Product; use Mollie\DTO\ApplePay\ShippingContent; +if (!defined('_PS_VERSION_')) { + exit; +} + class ApplePayOrderBuilder { public function build(array $products, array $shippingContent, array $billingContent): Order diff --git a/src/Builder/ApplePayDirect/ApplePayProductBuilder.php b/src/Builder/ApplePayDirect/ApplePayProductBuilder.php index 012226d1f..6cf04380e 100644 --- a/src/Builder/ApplePayDirect/ApplePayProductBuilder.php +++ b/src/Builder/ApplePayDirect/ApplePayProductBuilder.php @@ -14,6 +14,10 @@ use Mollie\DTO\ApplePay\Product; +if (!defined('_PS_VERSION_')) { + exit; +} + class ApplePayProductBuilder { public function build(array $productParams): array diff --git a/src/Builder/Content/BaseInfoBlock.php b/src/Builder/Content/BaseInfoBlock.php index 4c5f878d6..47e3654b0 100644 --- a/src/Builder/Content/BaseInfoBlock.php +++ b/src/Builder/Content/BaseInfoBlock.php @@ -16,6 +16,11 @@ use Context; use Mollie; use Mollie\Builder\TemplateBuilderInterface; +use Mollie\Factory\ModuleFactory; + +if (!defined('_PS_VERSION_')) { + exit; +} class BaseInfoBlock implements TemplateBuilderInterface { @@ -24,9 +29,9 @@ class BaseInfoBlock implements TemplateBuilderInterface */ private $module; - public function __construct(Mollie $module) + public function __construct(ModuleFactory $moduleFactory) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); } /** diff --git a/src/Builder/Content/LogoInfoBlock.php b/src/Builder/Content/LogoInfoBlock.php index b26caaa57..495ee215f 100644 --- a/src/Builder/Content/LogoInfoBlock.php +++ b/src/Builder/Content/LogoInfoBlock.php @@ -14,6 +14,11 @@ use Mollie; use Mollie\Builder\TemplateBuilderInterface; +use Mollie\Factory\ModuleFactory; + +if (!defined('_PS_VERSION_')) { + exit; +} class LogoInfoBlock implements TemplateBuilderInterface { @@ -22,9 +27,9 @@ class LogoInfoBlock implements TemplateBuilderInterface */ private $module; - public function __construct(Mollie $module) + public function __construct(ModuleFactory $moduleFactory) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); } /** diff --git a/src/Builder/Content/PaymentOption/IdealDropdownInfoBlock.php b/src/Builder/Content/PaymentOption/IdealDropdownInfoBlock.php index 2e688712f..a95667972 100644 --- a/src/Builder/Content/PaymentOption/IdealDropdownInfoBlock.php +++ b/src/Builder/Content/PaymentOption/IdealDropdownInfoBlock.php @@ -12,26 +12,23 @@ namespace Mollie\Builder\Content\PaymentOption; -use Mollie; use Mollie\Api\Types\PaymentMethod; use Mollie\Builder\TemplateBuilderInterface; use Mollie\Service\IssuerService; +if (!defined('_PS_VERSION_')) { + exit; +} + class IdealDropdownInfoBlock implements TemplateBuilderInterface { - /** - * @var Mollie - */ - private $module; - /** * @var IssuerService */ private $issuerService; - public function __construct(Mollie $module, IssuerService $issuerService) + public function __construct(IssuerService $issuerService) { - $this->module = $module; $this->issuerService = $issuerService; } diff --git a/src/Builder/Content/UpdateMessageInfoBlock.php b/src/Builder/Content/UpdateMessageInfoBlock.php index b31a53448..a4f1cee4f 100644 --- a/src/Builder/Content/UpdateMessageInfoBlock.php +++ b/src/Builder/Content/UpdateMessageInfoBlock.php @@ -18,6 +18,10 @@ use Mollie\Provider\UpdateMessageProviderInterface; use Mollie\Service\UpgradeNoticeService; +if (!defined('_PS_VERSION_')) { + exit; +} + class UpdateMessageInfoBlock implements TemplateBuilderInterface { /** diff --git a/src/Builder/FormBuilder.php b/src/Builder/FormBuilder.php index 7774f690d..a2c54a678 100644 --- a/src/Builder/FormBuilder.php +++ b/src/Builder/FormBuilder.php @@ -12,15 +12,15 @@ namespace Mollie\Builder; -use Configuration; use HelperFormCore as HelperForm; use Mollie; use Mollie\Adapter\ConfigurationAdapter; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; use Mollie\Api\Types\OrderStatus; use Mollie\Api\Types\PaymentStatus; use Mollie\Api\Types\RefundStatus; use Mollie\Config\Config; +use Mollie\Factory\ModuleFactory; use Mollie\Provider\CreditCardLogoProvider; use Mollie\Repository\TaxRulesGroupRepositoryInterface; use Mollie\Service\ApiService; @@ -31,9 +31,12 @@ use Mollie\Utility\EnvironmentUtility; use Mollie\Utility\TagsUtility; use OrderStateCore as OrderState; -use Smarty; use ToolsCore as Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + class FormBuilder { const FILE_NAME = 'FormBuilder'; @@ -53,15 +56,6 @@ class FormBuilder */ private $countryService; - private $lang; - - /** - * @var Smarty - */ - private $smarty; - - private $link; - /** * @var ConfigFieldService */ @@ -81,29 +75,23 @@ class FormBuilder private $configurationAdapter; /** @var TaxRulesGroupRepositoryInterface */ private $taxRulesGroupRepository; - /** @var LegacyContext */ + /** @var Context */ private $context; public function __construct( - Mollie $module, + ModuleFactory $moduleFactory, ApiService $apiService, CountryService $countryService, ConfigFieldService $configFieldService, MolCarrierInformationService $carrierInformationService, - $lang, - Smarty $smarty, - $link, CreditCardLogoProvider $creditCardLogoProvider, ConfigurationAdapter $configurationAdapter, TaxRulesGroupRepositoryInterface $taxRulesGroupRepository, - LegacyContext $context + Context $context ) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->apiService = $apiService; $this->countryService = $countryService; - $this->lang = $lang; - $this->smarty = $smarty; - $this->link = $link; $this->configFieldService = $configFieldService; $this->carrierInformationService = $carrierInformationService; $this->creditCardLogoProvider = $creditCardLogoProvider; @@ -144,8 +132,6 @@ public function buildSettingsForm() $helper->identifier = $this->module->getIdentifier(); $helper->submit_action = 'submitmollie'; - $helper->currentIndex = $this->module->getContext()->link->getAdminLink('AdminModules', false) - . "&configure={$this->module->name}&tab_module={$this->module->tab}&module_name={$this->module->name}"; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = [ @@ -424,8 +410,6 @@ protected function getAccountSettingsSection($isApiKeyProvided) 'customLogoUrl' => $this->creditCardLogoProvider->getLogoPathUri() . "?{$dateStamp}", 'customLogoExist' => $this->creditCardLogoProvider->logoExists(), 'voucherCategory' => $this->configurationAdapter->get(Config::MOLLIE_VOUCHER_CATEGORY), - 'klarnaPayments' => Config::KLARNA_PAYMENTS, - 'klarnaStatuses' => [Config::MOLLIE_STATUS_KLARNA_AUTHORIZED, Config::MOLLIE_STATUS_KLARNA_SHIPPED], 'applePayDirectProduct' => (int) $this->configurationAdapter->get(Config::MOLLIE_APPLE_PAY_DIRECT_PRODUCT), 'applePayDirectCart' => (int) $this->configurationAdapter->get(Config::MOLLIE_APPLE_PAY_DIRECT_CART), 'applePayDirectStyle' => (int) $this->configurationAdapter->get(Config::MOLLIE_APPLE_PAY_DIRECT_STYLE), @@ -450,7 +434,7 @@ protected function getAdvancedSettingsSection() $advancedSettings = 'advanced_settings'; $input = []; $orderStatuses = []; - $orderStatuses = array_merge($orderStatuses, OrderState::getOrderStates($this->lang->id)); + $orderStatuses = array_merge($orderStatuses, OrderState::getOrderStates($this->context->getLanguageId())); $input[] = [ 'type' => 'select', 'label' => $this->module->l('Use selected locale in webshop', self::FILE_NAME), @@ -499,22 +483,22 @@ protected function getAdvancedSettingsSection() $input[] = [ 'type' => 'select', - 'label' => $this->module->l('Select when to create the Klarna invoice', self::FILE_NAME), + 'label' => $this->module->l('Select when to create the Order invoice', self::FILE_NAME), 'desc' => $this->module->display($this->module->getPathUri(), 'views/templates/admin/invoice_description.tpl'), 'tab' => $advancedSettings, - 'name' => Config::MOLLIE_KLARNA_INVOICE_ON, + 'name' => Config::MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS, 'options' => [ 'query' => [ [ - 'id' => Config::MOLLIE_STATUS_DEFAULT, + 'id' => Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_DEFAULT, 'name' => $this->module->l('Default', self::FILE_NAME), ], [ - 'id' => Config::MOLLIE_STATUS_KLARNA_AUTHORIZED, + 'id' => Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED, 'name' => $this->module->l('Authorised', self::FILE_NAME), ], [ - 'id' => Config::MOLLIE_STATUS_KLARNA_SHIPPED, + 'id' => Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED, 'name' => $this->module->l('Shipped', self::FILE_NAME), ], ], @@ -527,7 +511,7 @@ protected function getAdvancedSettingsSection() $descriptionStatus = $this->module->l('`%s` payments get `%s` status', self::FILE_NAME); $messageMail = $this->module->l('Send email when %s', self::FILE_NAME); $descriptionMail = $this->module->l('Send email when transaction status becomes %s?, self::FILE_NAME', self::FILE_NAME); - $allStatuses = OrderState::getOrderStates($this->lang->id); + $allStatuses = OrderState::getOrderStates($this->context->getLanguageId()); $allStatusesWithSkipOption = array_merge([['id_order_state' => 0, 'name' => $this->module->l('Skip this status', self::FILE_NAME), 'color' => '#565656']], $allStatuses); $statusOptions = [ @@ -556,7 +540,7 @@ protected function getAdvancedSettingsSection() $val = (int) $val; if ($val) { $orderStatus = new OrderState($val); - $statusName = $orderStatus->getFieldByLang('name', $this->lang->id); + $statusName = $orderStatus->getFieldByLang('name', $this->context->getLanguageId()); $desc = Tools::strtolower( sprintf( $descriptionStatus, @@ -678,7 +662,7 @@ protected function getAdvancedSettingsSection() 'name' => Config::MOLLIE_TRACKING_URLS, 'depends' => Config::MOLLIE_API, 'depends_value' => Config::MOLLIE_ORDERS_API, - 'carriers' => $this->carrierInformationService->getAllCarriersInformation($this->lang->id), + 'carriers' => $this->carrierInformationService->getAllCarriersInformation($this->context->getLanguageId()), ]; $input[] = [ 'type' => 'mollie-carrier-switch', @@ -729,7 +713,7 @@ protected function getAdvancedSettingsSection() 'id_order_state' => '0', ], ]; - $orderStatuses = array_merge($orderStatuses, OrderState::getOrderStates($this->lang->id)); + $orderStatuses = array_merge($orderStatuses, OrderState::getOrderStates($this->context->getLanguageId())); $orderStatusesCount = count($orderStatuses); for ($i = 0; $i < $orderStatusesCount; ++$i) { $orderStatuses[$i]['name'] = $orderStatuses[$i]['id_order_state'] . ' - ' . $orderStatuses[$i]['name']; @@ -737,8 +721,8 @@ protected function getAdvancedSettingsSection() AssortUtility::aasort($orderStatuses, 'id_order_state'); - $this->smarty->assign([ - 'logs' => $this->link->getAdminLink('AdminLogs'), + $this->context->getSmarty()->assign([ + 'logs' => $this->context->getAdminLink('AdminLogs'), ]); $input = array_merge( $input, diff --git a/src/Builder/InvoicePdfTemplateBuilder.php b/src/Builder/InvoicePdfTemplateBuilder.php index 964c9a9b7..8ce1a21ed 100644 --- a/src/Builder/InvoicePdfTemplateBuilder.php +++ b/src/Builder/InvoicePdfTemplateBuilder.php @@ -21,6 +21,10 @@ use Order; use PrestaShop\PrestaShop\Core\Localization\Locale; +if (!defined('_PS_VERSION_')) { + exit; +} + final class InvoicePdfTemplateBuilder implements TemplateBuilderInterface { /** @var Order */ diff --git a/src/Builder/TemplateBuilderInterface.php b/src/Builder/TemplateBuilderInterface.php index 486e564b3..089be0e6e 100644 --- a/src/Builder/TemplateBuilderInterface.php +++ b/src/Builder/TemplateBuilderInterface.php @@ -12,6 +12,10 @@ namespace Mollie\Builder; +if (!defined('_PS_VERSION_')) { + exit; +} + interface TemplateBuilderInterface { /** diff --git a/src/Calculator/PaymentFeeCalculator.php b/src/Calculator/PaymentFeeCalculator.php index 98f76c50d..4a1b375d1 100644 --- a/src/Calculator/PaymentFeeCalculator.php +++ b/src/Calculator/PaymentFeeCalculator.php @@ -1,22 +1,36 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Calculator; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; use Mollie\DTO\PaymentFeeData; use Mollie\Utility\NumberUtility; use TaxCalculator; +if (!defined('_PS_VERSION_')) { + exit; +} + class PaymentFeeCalculator { const MAX_PERCENTAGE = 100; /** @var TaxCalculator */ private $taxCalculator; - /** @var LegacyContext */ + /** @var Context */ private $context; - public function __construct(TaxCalculator $taxCalculator, LegacyContext $context) + public function __construct(TaxCalculator $taxCalculator, Context $context) { $this->taxCalculator = $taxCalculator; $this->context = $context; diff --git a/src/Calculator/index.php b/src/Calculator/index.php new file mode 100644 index 000000000..d3343995f --- /dev/null +++ b/src/Calculator/index.php @@ -0,0 +1,20 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ +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; diff --git a/src/Collector/ApplePayDirect/OrderTotalCollector.php b/src/Collector/ApplePayDirect/OrderTotalCollector.php index 3b371f375..f7f9f68cb 100644 --- a/src/Collector/ApplePayDirect/OrderTotalCollector.php +++ b/src/Collector/ApplePayDirect/OrderTotalCollector.php @@ -17,6 +17,10 @@ use Mollie\DTO\ApplePay\Carrier\Carrier as AppleCarrier; use Mollie\Service\OrderPaymentFeeService; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderTotalCollector { /** @var OrderPaymentFeeService */ diff --git a/src/Command/TranslationCsvFileGeneratorConsoleCommand.php b/src/Command/TranslationCsvFileGeneratorConsoleCommand.php index beadfa578..1aa08a9cd 100644 --- a/src/Command/TranslationCsvFileGeneratorConsoleCommand.php +++ b/src/Command/TranslationCsvFileGeneratorConsoleCommand.php @@ -13,10 +13,15 @@ namespace Mollie\Command; use Mollie; +use Mollie\Factory\ModuleFactory; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + class TranslationCsvFileGeneratorConsoleCommand extends Command { /** @@ -24,10 +29,11 @@ class TranslationCsvFileGeneratorConsoleCommand extends Command */ private $module; - public function __construct(Mollie $module) + public function __construct(ModuleFactory $moduleFactory) { parent::__construct(); - $this->module = $module; + + $this->module = $moduleFactory->getModule(); } protected function configure() diff --git a/src/Command/UpdateTranslationsConsoleCommand.php b/src/Command/UpdateTranslationsConsoleCommand.php index 8cb325840..5681bd573 100644 --- a/src/Command/UpdateTranslationsConsoleCommand.php +++ b/src/Command/UpdateTranslationsConsoleCommand.php @@ -12,22 +12,19 @@ namespace Mollie\Command; -use Mollie; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + class UpdateTranslationsConsoleCommand extends Command { - /** - * @var Mollie - */ - private $module; - - public function __construct(Mollie $module) + public function __construct() { parent::__construct(); - $this->module = $module; } protected function configure() diff --git a/src/Command/UploadTranslationsFromCsvFileConsoleCommand.php b/src/Command/UploadTranslationsFromCsvFileConsoleCommand.php index ea07047b1..6dcb567c0 100644 --- a/src/Command/UploadTranslationsFromCsvFileConsoleCommand.php +++ b/src/Command/UploadTranslationsFromCsvFileConsoleCommand.php @@ -13,10 +13,15 @@ namespace Mollie\Command; use Mollie; +use Mollie\Factory\ModuleFactory; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + class UploadTranslationsFromCsvFileConsoleCommand extends Command { const CSV_POSITION_ID = 0; @@ -30,10 +35,10 @@ class UploadTranslationsFromCsvFileConsoleCommand extends Command */ private $module; - public function __construct(Mollie $module) + public function __construct(ModuleFactory $moduleFactory) { parent::__construct(); - $this->module = $module; + $this->module = $moduleFactory->getModule(); } protected function configure() diff --git a/src/Config/Config.php b/src/Config/Config.php index 7097dee73..5905d3a37 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -19,6 +19,10 @@ use Mollie\Api\Types\RefundStatus; use Mollie\Utility\EnvironmentUtility; +if (!defined('_PS_VERSION_')) { + exit; +} + class Config { const SEGMENT_KEY = 'x8qDW8mWIlcY9SXbMhKLoH7xYQ1cSxF2'; @@ -144,11 +148,11 @@ class Config const MOLLIE_STATUS_INITIATED = 'MOLLIE_STATUS_INITIATED'; const MOLLIE_STATUS_PARTIALLY_SHIPPED = 'MOLLIE_PARTIALLY_SHIPPED'; const MOLLIE_STATUS_ORDER_COMPLETED = 'MOLLIE_STATUS_ORDER_COMPLETED'; - const MOLLIE_STATUS_DEFAULT = 'MOLLIE_STATUS_DEFAULT'; - const MOLLIE_STATUS_KLARNA_AUTHORIZED = 'MOLLIE_STATUS_KLARNA_AUTHORIZED'; - const MOLLIE_STATUS_KLARNA_SHIPPED = 'MOLLIE_STATUS_KLARNA_SHIPPED'; + const MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_DEFAULT = 'MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_DEFAULT'; + const MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED = 'MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED'; + const MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED = 'MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED'; const MOLLIE_STATUS_CHARGEBACK = 'MOLLIE_STATUS_CHARGEBACK'; - const MOLLIE_KLARNA_INVOICE_ON = 'MOLLIE_KLARNA_INVOICE_ON'; + const MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS = 'MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS'; const MOLLIE_APPLE_PAY_DIRECT_PRODUCT = 'MOLLIE_APPLE_PAY_DIRECT_PRODUCT'; const MOLLIE_APPLE_PAY_DIRECT_CART = 'MOLLIE_APPLE_PAY_DIRECT_CART'; @@ -239,6 +243,11 @@ class Config const MOLLIE_VOUCHER_METHOD_ID = 'voucher'; const MOLLIE_in3_METHOD_ID = 'in3'; + /** + * @see https://www.mollie.com/en/payments/billie + */ + const MOLLIE_PAYMENT_METHOD_BILLIE = 'billie'; + const MOLLIE_VOUCHER_CATEGORY_NULL = 'null'; const MOLLIE_VOUCHER_CATEGORY_MEAL = 'meal'; const MOLLIE_VOUCHER_CATEGORY_GIFT = 'gift'; @@ -257,16 +266,18 @@ class Config const RESTORE_CART_BACKTRACE_MEMORIZATION_SERVICE = 'memo'; const RESTORE_CART_BACKTRACE_RETURN_CONTROLLER = 'return'; - const KLARNA_PAYMENTS = [ + const AUTHORIZABLE_PAYMENTS = [ PaymentMethod::KLARNA_PAY_LATER, PaymentMethod::KLARNA_SLICE_IT, PaymentMethod::KLARNA_PAY_NOW, + self::MOLLIE_PAYMENT_METHOD_BILLIE, ]; const ORDER_API_ONLY_METHODS = [ PaymentMethod::KLARNA_PAY_LATER, PaymentMethod::KLARNA_SLICE_IT, PaymentMethod::KLARNA_PAY_NOW, + self::MOLLIE_PAYMENT_METHOD_BILLIE, self::MOLLIE_VOUCHER_METHOD_ID, self::MOLLIE_in3_METHOD_ID, ]; @@ -304,20 +315,25 @@ class Config 'voucher' => 'Voucher', 'klarnapaynow' => 'Klarna Pay now.', 'in3' => 'in3', + 'billie' => 'Billie', ]; const MOLLIE_BUTTON_ORDER_TOTAL_REFRESH = 'MOLLIE_BUTTON_ORDER_TOTAL_REFRESH'; + const PRESTASHOP_ACCOUNTS_INSTALLER_VERSION = '5.0.0'; + const PRESTASHOP_CLOUDSYNC_CDN = 'https://assets.prestashop3.com/ext/cloudsync-merchant-sync-consent/latest/cloudsync-cdc.js'; + public static function getStatuses() { - $isKlarnaDefault = Configuration::get(Config::MOLLIE_KLARNA_INVOICE_ON) === Config::MOLLIE_STATUS_DEFAULT; + $isAuthorizablePaymentInvoiceOnStatusDefault = + Configuration::get(Config::MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS) === Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_DEFAULT; return [ self::MOLLIE_AWAITING_PAYMENT => Configuration::get(self::MOLLIE_STATUS_AWAITING), PaymentStatus::STATUS_PAID => Configuration::get(self::MOLLIE_STATUS_PAID), OrderStatus::STATUS_COMPLETED => Configuration::get(self::MOLLIE_STATUS_COMPLETED), - PaymentStatus::STATUS_AUTHORIZED => $isKlarnaDefault ? - Configuration::get(self::MOLLIE_STATUS_PAID) : Configuration::get(self::MOLLIE_STATUS_KLARNA_AUTHORIZED), + PaymentStatus::STATUS_AUTHORIZED => $isAuthorizablePaymentInvoiceOnStatusDefault ? + Configuration::get(self::MOLLIE_STATUS_PAID) : Configuration::get(self::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED), PaymentStatus::STATUS_CANCELED => Configuration::get(self::MOLLIE_STATUS_CANCELED), PaymentStatus::STATUS_EXPIRED => Configuration::get(self::MOLLIE_STATUS_EXPIRED), RefundStatus::STATUS_REFUNDED => Configuration::get(self::MOLLIE_STATUS_REFUNDED), @@ -330,7 +346,7 @@ public static function getStatuses() self::STATUS_PAID_ON_BACKORDER => Configuration::get('PS_OS_OUTOFSTOCK_PAID'), self::STATUS_PENDING_ON_BACKORDER => Configuration::get('PS_OS_OUTOFSTOCK_UNPAID'), self::STATUS_ON_BACKORDER => Configuration::get('PS_OS_OUTOFSTOCK'), - self::MOLLIE_STATUS_KLARNA_SHIPPED => Configuration::get(self::MOLLIE_STATUS_KLARNA_SHIPPED), + self::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED => Configuration::get(self::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED), self::MOLLIE_CHARGEBACK => Configuration::get(self::MOLLIE_STATUS_CHARGEBACK), ]; } @@ -352,8 +368,8 @@ public static function getMollieOrderStatuses() self::MOLLIE_STATUS_PARTIAL_REFUND, self::MOLLIE_STATUS_AWAITING, self::MOLLIE_STATUS_ORDER_COMPLETED, - self::MOLLIE_STATUS_KLARNA_AUTHORIZED, - self::MOLLIE_STATUS_KLARNA_SHIPPED, + self::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED, + self::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED, self::MOLLIE_STATUS_CHARGEBACK, ]; } diff --git a/src/Config/Env.php b/src/Config/Env.php index 779116764..74024c29e 100644 --- a/src/Config/Env.php +++ b/src/Config/Env.php @@ -12,6 +12,10 @@ namespace Mollie\Config; +if (!defined('_PS_VERSION_')) { + exit; +} + /** * This class allows to retrieve config data that can be overwritten by a .env file. * Otherwise it returns by default from the Config class. diff --git a/src/Controller/AbstractMollieController.php b/src/Controller/AbstractMollieController.php index fc31ec634..f131a5fcf 100644 --- a/src/Controller/AbstractMollieController.php +++ b/src/Controller/AbstractMollieController.php @@ -15,6 +15,10 @@ use Mollie\Errors\Http\HttpStatusCode; use Mollie\Utility\PsVersionUtility; +if (!defined('_PS_VERSION_')) { + exit; +} + class AbstractMollieController extends \ModuleFrontControllerCore { protected function respond($status, $statusCode = HttpStatusCode::HTTP_OK, $message = '') diff --git a/src/Controller/AdminMollieEmailController.php b/src/Controller/AdminMollieEmailController.php index 5cd4611ce..3d87eab0d 100644 --- a/src/Controller/AdminMollieEmailController.php +++ b/src/Controller/AdminMollieEmailController.php @@ -17,6 +17,10 @@ use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; use Symfony\Component\HttpFoundation\Request; +if (!defined('_PS_VERSION_')) { + exit; +} + class AdminMollieEmailController extends FrameworkBundleAdminController { public function sendSecondChanceMessage($orderId, Request $request) @@ -25,7 +29,7 @@ public function sendSecondChanceMessage($orderId, Request $request) $mollie = Module::getInstanceByName('mollie'); //Unable to get services without mollieContainer. /** @var MolliePaymentMailService $molliePaymentMailService */ - $molliePaymentMailService = $mollie->getMollieContainer(MolliePaymentMailService::class); + $molliePaymentMailService = $mollie->getService(MolliePaymentMailService::class); $response = $molliePaymentMailService->sendSecondChanceMail($orderId); if (empty($response)) { diff --git a/src/DTO/ApplePay/Carrier/Carrier.php b/src/DTO/ApplePay/Carrier/Carrier.php index 20d32fac9..dfb6dad3f 100644 --- a/src/DTO/ApplePay/Carrier/Carrier.php +++ b/src/DTO/ApplePay/Carrier/Carrier.php @@ -13,6 +13,10 @@ use JsonSerializable; +if (!defined('_PS_VERSION_')) { + exit; +} + class Carrier implements JsonSerializable { /** diff --git a/src/DTO/ApplePay/Order.php b/src/DTO/ApplePay/Order.php index d9375cd66..d6d807311 100644 --- a/src/DTO/ApplePay/Order.php +++ b/src/DTO/ApplePay/Order.php @@ -11,6 +11,10 @@ namespace Mollie\DTO\ApplePay; +if (!defined('_PS_VERSION_')) { + exit; +} + class Order { /** diff --git a/src/DTO/ApplePay/Product.php b/src/DTO/ApplePay/Product.php index 0c3f2c8d9..cf1d998f1 100644 --- a/src/DTO/ApplePay/Product.php +++ b/src/DTO/ApplePay/Product.php @@ -11,6 +11,10 @@ namespace Mollie\DTO\ApplePay; +if (!defined('_PS_VERSION_')) { + exit; +} + class Product { /** diff --git a/src/DTO/ApplePay/ShippingContent.php b/src/DTO/ApplePay/ShippingContent.php index 287de5a3d..670b1a643 100644 --- a/src/DTO/ApplePay/ShippingContent.php +++ b/src/DTO/ApplePay/ShippingContent.php @@ -11,6 +11,10 @@ namespace Mollie\DTO\ApplePay; +if (!defined('_PS_VERSION_')) { + exit; +} + class ShippingContent { /** diff --git a/src/DTO/Line.php b/src/DTO/Line.php index 2bea43493..da595d695 100644 --- a/src/DTO/Line.php +++ b/src/DTO/Line.php @@ -14,6 +14,10 @@ use JsonSerializable; use Mollie\DTO\Object\Amount; +if (!defined('_PS_VERSION_')) { + exit; +} + class Line implements JsonSerializable { /** diff --git a/src/DTO/Object/Amount.php b/src/DTO/Object/Amount.php index 69a6621c1..7421b5076 100644 --- a/src/DTO/Object/Amount.php +++ b/src/DTO/Object/Amount.php @@ -12,6 +12,10 @@ namespace Mollie\DTO\Object; +if (!defined('_PS_VERSION_')) { + exit; +} + class Amount { /** diff --git a/src/DTO/Object/Company.php b/src/DTO/Object/Company.php new file mode 100644 index 000000000..730d6c87c --- /dev/null +++ b/src/DTO/Object/Company.php @@ -0,0 +1,72 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\DTO\Object; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class Company implements \JsonSerializable +{ + /** @var string */ + private $vatNumber; + /** @var string */ + private $registrationNumber; + + /** + * @return string + */ + public function getVatNumber(): string + { + return $this->vatNumber; + } + + /** + * @param string $vatNumber + * + * @maps vatNumber + */ + public function setVatNumber(string $vatNumber) + { + $this->vatNumber = $vatNumber; + } + + /** + * @return string + */ + public function getRegistrationNumber(): string + { + return $this->registrationNumber; + } + + /** + * @param string $registrationNumber + * + * @maps registrationNumber + */ + public function setRegistrationNumber(string $registrationNumber) + { + $this->registrationNumber = $registrationNumber; + } + + public function jsonSerialize() + { + $json = []; + $json['vatNumber'] = $this->getVatNumber(); + $json['registrationNumber'] = $this->getRegistrationNumber(); + + return array_filter($json, static function ($val) { + return $val !== null && $val !== ''; + }); + } +} diff --git a/src/DTO/Object/Payment.php b/src/DTO/Object/Payment.php new file mode 100644 index 000000000..705e120c7 --- /dev/null +++ b/src/DTO/Object/Payment.php @@ -0,0 +1,156 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\DTO\Object; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class Payment implements \JsonSerializable +{ + /** @var ?string */ + private $cardToken; + /** @var string */ + private $webhookUrl; + /** @var ?string */ + private $issuer; + /** @var ?string */ + private $customerId; + /** @var ?string */ + private $applePayPaymentToken; + /** @var ?Company */ + private $company; + + /** + * @return ?string + */ + public function getCardToken() + { + return $this->cardToken; + } + + /** + * @param string $cardToken + * + * @maps cardToken + */ + public function setCardToken(string $cardToken) + { + $this->cardToken = $cardToken; + } + + /** + * @return string + */ + public function getWebhookUrl(): string + { + return $this->webhookUrl; + } + + /** + * @param string $webhookUrl + * + * @maps webhookUrl + */ + public function setWebhookUrl(string $webhookUrl) + { + $this->webhookUrl = $webhookUrl; + } + + /** + * @return ?string + */ + public function getIssuer() + { + return $this->issuer; + } + + /** + * @param string $issuer + * + * @maps issuer + */ + public function setIssuer(string $issuer) + { + $this->issuer = $issuer; + } + + /** + * @return ?string + */ + public function getCustomerId() + { + return $this->customerId; + } + + /** + * @param string $customerId + * + * @maps customerId + */ + public function setCustomerId(string $customerId) + { + $this->customerId = $customerId; + } + + /** + * @return ?string + */ + public function getApplePayPaymentToken() + { + return $this->applePayPaymentToken; + } + + /** + * @param string $applePayPaymentToken + * + * @maps applePayPaymentToken + */ + public function setApplePayPaymentToken(string $applePayPaymentToken) + { + $this->applePayPaymentToken = $applePayPaymentToken; + } + + /** + * @return ?Company + */ + public function getCompany() + { + return $this->company; + } + + /** + * @param \Mollie\DTO\Object\Company $company + * + * @maps company + */ + public function setCompany(Company $company) + { + $this->company = $company; + } + + public function jsonSerialize() + { + $result = []; + $result['cardToken'] = $this->getCardToken(); + $result['webhookUrl'] = $this->getWebhookUrl(); + $result['issuer'] = $this->getIssuer(); + $result['customerId'] = $this->getCustomerId(); + $result['applePayPaymentToken'] = $this->getApplePayPaymentToken(); + $result['company'] = $this->getCompany() ? $this->getCompany()->jsonSerialize() : null; + + return array_filter($result, static function ($val) { + return $val !== null && $val !== ''; + }); + } +} diff --git a/src/DTO/OrderData.php b/src/DTO/OrderData.php index 28671b792..ef31a20f9 100644 --- a/src/DTO/OrderData.php +++ b/src/DTO/OrderData.php @@ -16,6 +16,11 @@ use Country; use JsonSerializable; use Mollie\DTO\Object\Amount; +use Mollie\DTO\Object\Payment; + +if (!defined('_PS_VERSION_')) { + exit; +} class OrderData implements JsonSerializable { @@ -85,7 +90,7 @@ class OrderData implements JsonSerializable private $lines; /** - * @var array + * @var Payment */ private $payment; @@ -358,17 +363,19 @@ public function setLines($lines) } /** - * @return array + * @return Payment */ - public function getPayment() + public function getPayment(): Payment { return $this->payment; } /** - * @param array $payment + * @param \Mollie\DTO\Object\Payment $payment + * + * @maps payment */ - public function setPayment($payment) + public function setPayment(Payment $payment) { $this->payment = $payment; } @@ -448,7 +455,7 @@ public function jsonSerialize() 'locale' => $this->getLocale(), 'orderNumber' => $this->getOrderNumber(), 'lines' => $lines, - 'payment' => $this->getPayment(), + 'payment' => $this->getPayment()->jsonSerialize(), 'consumerDateOfBirth' => $this->getConsumerDateOfBirth(), ]; @@ -460,7 +467,9 @@ public function jsonSerialize() $result['shippingAddress']['phone'] = $this->deliveryPhoneNumber; } - return $result; + return array_filter($result, static function ($val) { + return $val !== null && $val !== ''; + }); } private function cleanUpInput($input, $defaultValue = 'N/A') diff --git a/src/DTO/OrderStateData.php b/src/DTO/OrderStateData.php index 10fbebe7c..ffe2129bf 100644 --- a/src/DTO/OrderStateData.php +++ b/src/DTO/OrderStateData.php @@ -1,7 +1,21 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\DTO; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderStateData { /** @var string */ diff --git a/src/DTO/PaymentData.php b/src/DTO/PaymentData.php index 6655ab276..4dfd59a4f 100644 --- a/src/DTO/PaymentData.php +++ b/src/DTO/PaymentData.php @@ -17,6 +17,10 @@ use JsonSerializable; use Mollie\DTO\Object\Amount; +if (!defined('_PS_VERSION_')) { + exit; +} + class PaymentData implements JsonSerializable { /** diff --git a/src/DTO/PaymentFeeData.php b/src/DTO/PaymentFeeData.php index cd8cbe2b9..d50578adb 100644 --- a/src/DTO/PaymentFeeData.php +++ b/src/DTO/PaymentFeeData.php @@ -1,7 +1,21 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\DTO; +if (!defined('_PS_VERSION_')) { + exit; +} + class PaymentFeeData { /** @var float */ diff --git a/src/Entity/MolCarrierInformation.php b/src/Entity/MolCarrierInformation.php index 6d3483a6d..5b0462d26 100644 --- a/src/Entity/MolCarrierInformation.php +++ b/src/Entity/MolCarrierInformation.php @@ -9,6 +9,10 @@ * @see https://github.com/mollie/PrestaShop * @codingStandardsIgnoreStart */ +if (!defined('_PS_VERSION_')) { + exit; +} + class MolCarrierInformation extends ObjectModel { /** diff --git a/src/Entity/MolCustomer.php b/src/Entity/MolCustomer.php index 12f76109b..3fd50a539 100644 --- a/src/Entity/MolCustomer.php +++ b/src/Entity/MolCustomer.php @@ -9,6 +9,10 @@ * @see https://github.com/mollie/PrestaShop * @codingStandardsIgnoreStart */ +if (!defined('_PS_VERSION_')) { + exit; +} + class MolCustomer extends ObjectModel { /** diff --git a/src/Entity/MolOrderPaymentFee.php b/src/Entity/MolOrderPaymentFee.php index 703b316ba..8a99a5b6f 100644 --- a/src/Entity/MolOrderPaymentFee.php +++ b/src/Entity/MolOrderPaymentFee.php @@ -9,6 +9,10 @@ * @see https://github.com/mollie/PrestaShop * @codingStandardsIgnoreStart */ +if (!defined('_PS_VERSION_')) { + exit; +} + class MolOrderPaymentFee extends ObjectModel { /** diff --git a/src/Entity/MolPaymentMethod.php b/src/Entity/MolPaymentMethod.php index f960ca063..d383af058 100644 --- a/src/Entity/MolPaymentMethod.php +++ b/src/Entity/MolPaymentMethod.php @@ -9,6 +9,10 @@ * @see https://github.com/mollie/PrestaShop * @codingStandardsIgnoreStart */ +if (!defined('_PS_VERSION_')) { + exit; +} + class MolPaymentMethod extends ObjectModel { /** @@ -139,8 +143,8 @@ class MolPaymentMethod extends ObjectModel ], ]; - public function getPaymentMethodName() + public function getPaymentMethodName(): string { - return $this->id_method; + return (string) $this->id_method; } } diff --git a/src/Entity/MolPaymentMethodIssuer.php b/src/Entity/MolPaymentMethodIssuer.php index 61e66e419..932acc12b 100644 --- a/src/Entity/MolPaymentMethodIssuer.php +++ b/src/Entity/MolPaymentMethodIssuer.php @@ -9,6 +9,10 @@ * @see https://github.com/mollie/PrestaShop * @codingStandardsIgnoreStart */ +if (!defined('_PS_VERSION_')) { + exit; +} + class MolPaymentMethodIssuer extends ObjectModel { /** diff --git a/src/Entity/MolPendingOrderCart.php b/src/Entity/MolPendingOrderCart.php index f8e60f494..17b6ad04d 100644 --- a/src/Entity/MolPendingOrderCart.php +++ b/src/Entity/MolPendingOrderCart.php @@ -9,6 +9,9 @@ * @see https://github.com/mollie/PrestaShop * @codingStandardsIgnoreStart */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * Holds data for duplicated cart -> order id from which cart was duplicated. diff --git a/src/Entity/MolPendingOrderCartRule.php b/src/Entity/MolPendingOrderCartRule.php index 987245fd3..a7310029d 100644 --- a/src/Entity/MolPendingOrderCartRule.php +++ b/src/Entity/MolPendingOrderCartRule.php @@ -9,6 +9,10 @@ * @see https://github.com/mollie/PrestaShop * @codingStandardsIgnoreStart */ +if (!defined('_PS_VERSION_')) { + exit; +} + class MolPendingOrderCartRule extends ObjectModel { /** diff --git a/src/Enum/EmailTemplate.php b/src/Enum/EmailTemplate.php index 46292d8b6..43239340f 100644 --- a/src/Enum/EmailTemplate.php +++ b/src/Enum/EmailTemplate.php @@ -1,7 +1,21 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Enum; +if (!defined('_PS_VERSION_')) { + exit; +} + class EmailTemplate { const PAYMENT = 'payment'; diff --git a/src/Enum/PaymentTypeEnum.php b/src/Enum/PaymentTypeEnum.php index ffddb1600..d9b46b6ed 100644 --- a/src/Enum/PaymentTypeEnum.php +++ b/src/Enum/PaymentTypeEnum.php @@ -12,6 +12,10 @@ namespace Mollie\Enum; +if (!defined('_PS_VERSION_')) { + exit; +} + class PaymentTypeEnum { const PAYMENT_TYPE_PAYMENT = 0; diff --git a/src/Errors/Error.php b/src/Errors/Error.php index 164084247..6d2cc76cf 100644 --- a/src/Errors/Error.php +++ b/src/Errors/Error.php @@ -12,6 +12,10 @@ namespace Mollie\Errors; +if (!defined('_PS_VERSION_')) { + exit; +} + class Error implements \JsonSerializable { /** @var int|null */ diff --git a/src/Errors/Http/HttpStatusCode.php b/src/Errors/Http/HttpStatusCode.php index c23c867e9..33a06f320 100644 --- a/src/Errors/Http/HttpStatusCode.php +++ b/src/Errors/Http/HttpStatusCode.php @@ -12,6 +12,10 @@ namespace Mollie\Errors\Http; +if (!defined('_PS_VERSION_')) { + exit; +} + class HttpStatusCode { const HTTP_CONTINUE = 100; diff --git a/src/Exception/CancelPendingOrderException.php b/src/Exception/CancelPendingOrderException.php index 0b26e3359..9aa00f42c 100644 --- a/src/Exception/CancelPendingOrderException.php +++ b/src/Exception/CancelPendingOrderException.php @@ -12,6 +12,10 @@ namespace Mollie\Exception; +if (!defined('_PS_VERSION_')) { + exit; +} + class CancelPendingOrderException extends MollieException { } diff --git a/src/Exception/CouldNotInstallModule.php b/src/Exception/CouldNotInstallModule.php index 514ffab2c..96ae2cd0c 100644 --- a/src/Exception/CouldNotInstallModule.php +++ b/src/Exception/CouldNotInstallModule.php @@ -1,10 +1,24 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Exception; +if (!defined('_PS_VERSION_')) { + exit; +} + class CouldNotInstallModule extends MollieException { - public static function failedToInstallOrderState(string $orderStateName, \Exception $exception): CouldNotInstallModule + public static function failedToInstallOrderState(string $orderStateName, \Exception $exception): self { return new self( sprintf('Failed to install order state (%s).', $orderStateName), @@ -12,4 +26,13 @@ public static function failedToInstallOrderState(string $orderStateName, \Except $exception ); } + + public static function failedToInstallModuleTab(\Exception $exception, string $moduleTab): self + { + return new self( + sprintf('Failed to install module tab (%s)', $moduleTab), + ExceptionCode::INFRASTRUCTURE_FAILED_TO_INSTALL_MODULE_TAB, + $exception + ); + } } diff --git a/src/Exception/ExceptionCode.php b/src/Exception/ExceptionCode.php index 0357e3cec..06fd17043 100644 --- a/src/Exception/ExceptionCode.php +++ b/src/Exception/ExceptionCode.php @@ -1,12 +1,27 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Exception; +if (!defined('_PS_VERSION_')) { + exit; +} + class ExceptionCode { // Infrastructure error codes starts from 1000 const INFRASTRUCTURE_FAILED_TO_INSTALL_ORDER_STATE = 1001; + const INFRASTRUCTURE_FAILED_TO_INSTALL_MODULE_TAB = 1002; const FAILED_TO_FIND_CUSTOMER_ADDRESS = 2001; } diff --git a/src/Exception/FailedToProvidePaymentFeeException.php b/src/Exception/FailedToProvidePaymentFeeException.php index b631ead7b..8793166ed 100644 --- a/src/Exception/FailedToProvidePaymentFeeException.php +++ b/src/Exception/FailedToProvidePaymentFeeException.php @@ -1,7 +1,21 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Exception; +if (!defined('_PS_VERSION_')) { + exit; +} + class FailedToProvidePaymentFeeException extends MollieException { } diff --git a/src/Exception/MollieApiException.php b/src/Exception/MollieApiException.php index 82afd30f4..93c7d86ec 100644 --- a/src/Exception/MollieApiException.php +++ b/src/Exception/MollieApiException.php @@ -12,6 +12,10 @@ namespace Mollie\Exception; +if (!defined('_PS_VERSION_')) { + exit; +} + class MollieApiException extends \Exception { const MOLLIE_API_IS_NULL = 1; diff --git a/src/Exception/MollieException.php b/src/Exception/MollieException.php index f88ca0a32..23f6f3f9f 100644 --- a/src/Exception/MollieException.php +++ b/src/Exception/MollieException.php @@ -12,6 +12,10 @@ namespace Mollie\Exception; +if (!defined('_PS_VERSION_')) { + exit; +} + class MollieException extends \Exception { const CUSTOMER_EXCEPTION = 1; diff --git a/src/Exception/NotImplementedException.php b/src/Exception/NotImplementedException.php index 3bbbe091e..e72e4fd6d 100644 --- a/src/Exception/NotImplementedException.php +++ b/src/Exception/NotImplementedException.php @@ -12,6 +12,10 @@ namespace Mollie\Exception; +if (!defined('_PS_VERSION_')) { + exit; +} + class NotImplementedException extends MollieException { } diff --git a/src/Exception/OrderCreationException.php b/src/Exception/OrderCreationException.php index 16be340a9..56740ed16 100644 --- a/src/Exception/OrderCreationException.php +++ b/src/Exception/OrderCreationException.php @@ -12,6 +12,10 @@ namespace Mollie\Exception; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderCreationException extends \Exception { const DEFAULT_ORDER_CREATION_EXCEPTION = 1; diff --git a/src/Exception/RetryOverException.php b/src/Exception/RetryOverException.php index 1eddac6a8..3e988ec5a 100644 --- a/src/Exception/RetryOverException.php +++ b/src/Exception/RetryOverException.php @@ -12,6 +12,10 @@ namespace Mollie\Exception; +if (!defined('_PS_VERSION_')) { + exit; +} + class RetryOverException extends \Exception { } diff --git a/src/Exception/ShipmentCannotBeSentException.php b/src/Exception/ShipmentCannotBeSentException.php index e9ba07947..ab8238dcb 100644 --- a/src/Exception/ShipmentCannotBeSentException.php +++ b/src/Exception/ShipmentCannotBeSentException.php @@ -14,6 +14,10 @@ use Exception; +if (!defined('_PS_VERSION_')) { + exit; +} + class ShipmentCannotBeSentException extends Exception { const NO_SHIPPING_INFORMATION = 1; diff --git a/src/Exception/TransactionException.php b/src/Exception/TransactionException.php index 91e5e89e8..28bf7ceb3 100644 --- a/src/Exception/TransactionException.php +++ b/src/Exception/TransactionException.php @@ -12,6 +12,10 @@ namespace Mollie\Exception; +if (!defined('_PS_VERSION_')) { + exit; +} + class TransactionException extends MollieException { } diff --git a/src/Factory/ContextFactory.php b/src/Factory/ContextFactory.php index e8d094e1e..36278d6f4 100644 --- a/src/Factory/ContextFactory.php +++ b/src/Factory/ContextFactory.php @@ -14,6 +14,10 @@ use Context; +if (!defined('_PS_VERSION_')) { + exit; +} + class ContextFactory { public static function getContext() diff --git a/src/Factory/CustomerFactory.php b/src/Factory/CustomerFactory.php index 0f39cce95..119c841e1 100644 --- a/src/Factory/CustomerFactory.php +++ b/src/Factory/CustomerFactory.php @@ -15,6 +15,10 @@ use Customer; use Mollie\Utility\ContextUtility; +if (!defined('_PS_VERSION_')) { + exit; +} + class CustomerFactory { public function recreateFromRequest($customerId, $customerSecureKey, $context) diff --git a/src/Factory/ModuleFactory.php b/src/Factory/ModuleFactory.php index 607650e0f..36fc31aa6 100644 --- a/src/Factory/ModuleFactory.php +++ b/src/Factory/ModuleFactory.php @@ -14,6 +14,10 @@ use Module; +if (!defined('_PS_VERSION_')) { + exit; +} + class ModuleFactory { public function getModuleVersion() @@ -38,4 +42,12 @@ public function getModuleName() { return Module::getInstanceByName('mollie')->name; } + + public function getModule(): \Mollie + { + /** @var \Mollie $module */ + $module = Module::getInstanceByName('mollie'); + + return $module; + } } diff --git a/src/Grid/Action/Type/SecondChanceRowAction.php b/src/Grid/Action/Type/SecondChanceRowAction.php index ccf01e738..148bef3d0 100644 --- a/src/Grid/Action/Type/SecondChanceRowAction.php +++ b/src/Grid/Action/Type/SecondChanceRowAction.php @@ -16,6 +16,10 @@ use PrestaShop\PrestaShop\Core\Grid\Action\Row\AccessibilityChecker\AccessibilityCheckerInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +if (!defined('_PS_VERSION_')) { + exit; +} + final class SecondChanceRowAction extends AbstractRowAction { /** diff --git a/src/Grid/Definition/Modifier/GridDefinitionModifierInterface.php b/src/Grid/Definition/Modifier/GridDefinitionModifierInterface.php index 7880d2a18..8e25148ca 100644 --- a/src/Grid/Definition/Modifier/GridDefinitionModifierInterface.php +++ b/src/Grid/Definition/Modifier/GridDefinitionModifierInterface.php @@ -14,6 +14,10 @@ use PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + interface GridDefinitionModifierInterface { /** diff --git a/src/Grid/Definition/Modifier/OrderGridDefinitionModifier.php b/src/Grid/Definition/Modifier/OrderGridDefinitionModifier.php index 0a55623e2..e5638d06a 100644 --- a/src/Grid/Definition/Modifier/OrderGridDefinitionModifier.php +++ b/src/Grid/Definition/Modifier/OrderGridDefinitionModifier.php @@ -13,19 +13,24 @@ namespace Mollie\Grid\Definition\Modifier; use Mollie; +use Mollie\Factory\ModuleFactory; use Mollie\Grid\Action\Type\SecondChanceRowAction; use Mollie\Grid\Row\AccessibilityChecker\SecondChanceAccessibilityChecker; use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; use PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderGridDefinitionModifier implements GridDefinitionModifierInterface { private $module; - public function __construct(Mollie $module) + public function __construct(ModuleFactory $moduleFactory) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); } /** @@ -47,7 +52,7 @@ public function modify(GridDefinitionInterface $gridDefinition) 'route_param_field' => 'id_order', 'route_param_name' => 'orderId', 'use_inline_display' => true, - 'accessibility_checker' => $this->module->getMollieContainer( + 'accessibility_checker' => $this->module->getService( SecondChanceAccessibilityChecker::class ), ]) diff --git a/src/Grid/Query/Modifier/GridQueryModifierInterface.php b/src/Grid/Query/Modifier/GridQueryModifierInterface.php index 5706f3709..6b002fa94 100644 --- a/src/Grid/Query/Modifier/GridQueryModifierInterface.php +++ b/src/Grid/Query/Modifier/GridQueryModifierInterface.php @@ -14,6 +14,10 @@ use Doctrine\DBAL\Query\QueryBuilder; +if (!defined('_PS_VERSION_')) { + exit; +} + interface GridQueryModifierInterface { /** diff --git a/src/Grid/Query/Modifier/OrderGridQueryModifier.php b/src/Grid/Query/Modifier/OrderGridQueryModifier.php index e144733ef..0bd9a3f94 100644 --- a/src/Grid/Query/Modifier/OrderGridQueryModifier.php +++ b/src/Grid/Query/Modifier/OrderGridQueryModifier.php @@ -14,6 +14,10 @@ use Doctrine\DBAL\Query\QueryBuilder; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderGridQueryModifier implements GridQueryModifierInterface { /** diff --git a/src/Grid/Row/AccessibilityChecker/SecondChanceAccessibilityChecker.php b/src/Grid/Row/AccessibilityChecker/SecondChanceAccessibilityChecker.php index 21b22df51..522cc4b4f 100644 --- a/src/Grid/Row/AccessibilityChecker/SecondChanceAccessibilityChecker.php +++ b/src/Grid/Row/AccessibilityChecker/SecondChanceAccessibilityChecker.php @@ -14,6 +14,10 @@ use Mollie\Repository\PaymentMethodRepositoryInterface; use PrestaShop\PrestaShop\Core\Grid\Action\Row\AccessibilityChecker\AccessibilityCheckerInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + /** * Checks if second chance email option can be visible in order list. */ diff --git a/src/Handler/Api/OrderEndpointPaymentTypeHandler.php b/src/Handler/Api/OrderEndpointPaymentTypeHandler.php index 04b9d6c36..df8f24f6d 100644 --- a/src/Handler/Api/OrderEndpointPaymentTypeHandler.php +++ b/src/Handler/Api/OrderEndpointPaymentTypeHandler.php @@ -15,6 +15,10 @@ use Mollie\Enum\PaymentTypeEnum; use Mollie\Verification\PaymentType\PaymentTypeVerificationInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderEndpointPaymentTypeHandler implements OrderEndpointPaymentTypeHandlerInterface { /** diff --git a/src/Handler/Api/OrderEndpointPaymentTypeHandlerInterface.php b/src/Handler/Api/OrderEndpointPaymentTypeHandlerInterface.php index 8bf657d52..839f1ad7b 100644 --- a/src/Handler/Api/OrderEndpointPaymentTypeHandlerInterface.php +++ b/src/Handler/Api/OrderEndpointPaymentTypeHandlerInterface.php @@ -12,6 +12,10 @@ namespace Mollie\Handler\Api; +if (!defined('_PS_VERSION_')) { + exit; +} + interface OrderEndpointPaymentTypeHandlerInterface { /** diff --git a/src/Handler/CartRule/CartRuleQuantityChangeHandler.php b/src/Handler/CartRule/CartRuleQuantityChangeHandler.php index f57ef1ac0..e7db95fdc 100644 --- a/src/Handler/CartRule/CartRuleQuantityChangeHandler.php +++ b/src/Handler/CartRule/CartRuleQuantityChangeHandler.php @@ -15,12 +15,15 @@ use Cart; use CartRule; use Mollie\Repository\CartRuleRepositoryInterface; -use Mollie\Repository\OrderCartRuleRepositoryInterface; use Mollie\Repository\OrderRepositoryInterface; use Mollie\Repository\PendingOrderCartRuleRepositoryInterface; use MolPendingOrderCartRule; use Order; +if (!defined('_PS_VERSION_')) { + exit; +} + class CartRuleQuantityChangeHandler implements CartRuleQuantityChangeHandlerInterface { /** @@ -28,11 +31,6 @@ class CartRuleQuantityChangeHandler implements CartRuleQuantityChangeHandlerInte */ private $pendingOrderCartRuleRepository; - /** - * @var OrderCartRuleRepositoryInterface - */ - private $orderCartRuleRepository; - /** * @var CartRuleRepositoryInterface */ @@ -45,12 +43,10 @@ class CartRuleQuantityChangeHandler implements CartRuleQuantityChangeHandlerInte public function __construct( PendingOrderCartRuleRepositoryInterface $pendingOrderCartRuleRepository, - OrderCartRuleRepositoryInterface $orderCartRuleRepository, CartRuleRepositoryInterface $cartRuleRepository, OrderRepositoryInterface $orderRepository ) { $this->pendingOrderCartRuleRepository = $pendingOrderCartRuleRepository; - $this->orderCartRuleRepository = $orderCartRuleRepository; $this->cartRuleRepository = $cartRuleRepository; $this->orderRepository = $orderRepository; } diff --git a/src/Handler/CartRule/CartRuleQuantityChangeHandlerInterface.php b/src/Handler/CartRule/CartRuleQuantityChangeHandlerInterface.php index 87edf85ca..c5aeeebee 100644 --- a/src/Handler/CartRule/CartRuleQuantityChangeHandlerInterface.php +++ b/src/Handler/CartRule/CartRuleQuantityChangeHandlerInterface.php @@ -14,6 +14,10 @@ use Cart; +if (!defined('_PS_VERSION_')) { + exit; +} + interface CartRuleQuantityChangeHandlerInterface { /** diff --git a/src/Handler/CartRule/CartRuleQuantityResetHandler.php b/src/Handler/CartRule/CartRuleQuantityResetHandler.php index ec47078ea..aa9469cc7 100644 --- a/src/Handler/CartRule/CartRuleQuantityResetHandler.php +++ b/src/Handler/CartRule/CartRuleQuantityResetHandler.php @@ -21,6 +21,10 @@ use Order; use OrderCartRule; +if (!defined('_PS_VERSION_')) { + exit; +} + class CartRuleQuantityResetHandler implements CartRuleQuantityResetHandlerInterface { /** diff --git a/src/Handler/CartRule/CartRuleQuantityResetHandlerInterface.php b/src/Handler/CartRule/CartRuleQuantityResetHandlerInterface.php index 8a5ac65a4..e89e65004 100644 --- a/src/Handler/CartRule/CartRuleQuantityResetHandlerInterface.php +++ b/src/Handler/CartRule/CartRuleQuantityResetHandlerInterface.php @@ -14,6 +14,10 @@ use Cart; +if (!defined('_PS_VERSION_')) { + exit; +} + interface CartRuleQuantityResetHandlerInterface { /** diff --git a/src/Handler/Certificate/ApplePayDirectCertificateHandler.php b/src/Handler/Certificate/ApplePayDirectCertificateHandler.php index bf871b219..b975ce451 100644 --- a/src/Handler/Certificate/ApplePayDirectCertificateHandler.php +++ b/src/Handler/Certificate/ApplePayDirectCertificateHandler.php @@ -13,9 +13,14 @@ namespace Mollie\Handler\Certificate; use Mollie; +use Mollie\Factory\ModuleFactory; use Mollie\Handler\Certificate\Exception\ApplePayDirectCertificateCreation; use Mollie\Utility\FileUtility; +if (!defined('_PS_VERSION_')) { + exit; +} + class ApplePayDirectCertificateHandler implements CertificateHandlerInterface { const FILE_NAME = 'ApplePayDirectCertificateHandler'; @@ -30,9 +35,9 @@ class ApplePayDirectCertificateHandler implements CertificateHandlerInterface private $mollie; private $serverRoot; - public function __construct(Mollie $mollie) + public function __construct(ModuleFactory $moduleFactory) { - $this->mollie = $mollie; + $this->mollie = $moduleFactory->getModule(); $this->serverRoot = $_SERVER['DOCUMENT_ROOT']; } diff --git a/src/Handler/Certificate/CertificateHandlerInterface.php b/src/Handler/Certificate/CertificateHandlerInterface.php index ba9af16f9..a95bd1d5c 100644 --- a/src/Handler/Certificate/CertificateHandlerInterface.php +++ b/src/Handler/Certificate/CertificateHandlerInterface.php @@ -14,6 +14,10 @@ use Mollie\Handler\Certificate\Exception\CertificationException; +if (!defined('_PS_VERSION_')) { + exit; +} + interface CertificateHandlerInterface { /** diff --git a/src/Handler/Certificate/Exception/ApplePayDirectCertificateCreation.php b/src/Handler/Certificate/Exception/ApplePayDirectCertificateCreation.php index eb1b9d1ce..06fd25f42 100644 --- a/src/Handler/Certificate/Exception/ApplePayDirectCertificateCreation.php +++ b/src/Handler/Certificate/Exception/ApplePayDirectCertificateCreation.php @@ -12,6 +12,10 @@ namespace Mollie\Handler\Certificate\Exception; +if (!defined('_PS_VERSION_')) { + exit; +} + class ApplePayDirectCertificateCreation extends CertificationException { } diff --git a/src/Handler/Certificate/Exception/CertificationException.php b/src/Handler/Certificate/Exception/CertificationException.php index b0b9c10b6..1ea00a0ce 100644 --- a/src/Handler/Certificate/Exception/CertificationException.php +++ b/src/Handler/Certificate/Exception/CertificationException.php @@ -14,6 +14,10 @@ use Exception; +if (!defined('_PS_VERSION_')) { + exit; +} + class CertificationException extends Exception { const FILE_COPY_EXCEPTON = 0; diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index 298118c85..3b29fa582 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -20,6 +20,10 @@ use Mollie\Config\Env; use Raven_Client; +if (!defined('_PS_VERSION_')) { + exit; +} + /** * Handle Error. */ @@ -35,11 +39,8 @@ class ErrorHandler */ private static $instance; - public function __construct($module) + public function __construct(Mollie $module) { - /** @var Env $env */ - $env = $module->getMollieContainer(Env::class); - try { $this->client = new ModuleFilteredRavenClient( Config::SENTRY_KEY, @@ -51,7 +52,7 @@ public function __construct($module) 'prestashop_version' => _PS_VERSION_, 'mollie_is_enabled' => \Module::isEnabled('mollie'), 'mollie_is_installed' => \Module::isInstalled('mollie'), - 'env' => $env->get('SENTRY_ENV'), + 'env' => (new Env())->get('SENTRY_ENV'), ], ] ); diff --git a/src/Handler/ErrorHandler/ModuleFilteredRavenClient.php b/src/Handler/ErrorHandler/ModuleFilteredRavenClient.php index 772d2f4e9..9af33779c 100644 --- a/src/Handler/ErrorHandler/ModuleFilteredRavenClient.php +++ b/src/Handler/ErrorHandler/ModuleFilteredRavenClient.php @@ -14,6 +14,10 @@ use Raven_Client; +if (!defined('_PS_VERSION_')) { + exit; +} + /** * Inheritance allow us to check data generated by Raven and filter errors * that are not related to the module. diff --git a/src/Handler/Exception/ExceptionHandlerInterface.php b/src/Handler/Exception/ExceptionHandlerInterface.php index 19ac6a8b8..c33e83eb1 100644 --- a/src/Handler/Exception/ExceptionHandlerInterface.php +++ b/src/Handler/Exception/ExceptionHandlerInterface.php @@ -14,6 +14,10 @@ use Exception; +if (!defined('_PS_VERSION_')) { + exit; +} + interface ExceptionHandlerInterface { public function handle(Exception $e); diff --git a/src/Handler/Exception/OrderExceptionHandler.php b/src/Handler/Exception/OrderExceptionHandler.php index cdc39ac10..eb78838fb 100644 --- a/src/Handler/Exception/OrderExceptionHandler.php +++ b/src/Handler/Exception/OrderExceptionHandler.php @@ -15,6 +15,10 @@ use Exception; use Mollie\Exception\OrderCreationException; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderExceptionHandler implements ExceptionHandlerInterface { /** diff --git a/src/Handler/Order/OrderCreationHandler.php b/src/Handler/Order/OrderCreationHandler.php index 62cd01fc9..4da3b177f 100644 --- a/src/Handler/Order/OrderCreationHandler.php +++ b/src/Handler/Order/OrderCreationHandler.php @@ -46,6 +46,7 @@ use Mollie\DTO\Line; use Mollie\DTO\OrderData; use Mollie\DTO\PaymentData; +use Mollie\Factory\ModuleFactory; use Mollie\Provider\PaymentFeeProviderInterface; use Mollie\Repository\PaymentMethodRepositoryInterface; use Mollie\Service\OrderStatusService; @@ -56,6 +57,10 @@ use Order; use PrestaShop\Decimal\Number; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderCreationHandler { /** @@ -78,14 +83,14 @@ class OrderCreationHandler private $paymentFeeProvider; public function __construct( - Mollie $module, + ModuleFactory $moduleFactory, PaymentMethodRepositoryInterface $paymentMethodRepository, PaymentMethodService $paymentMethodService, OrderPaymentFeeHandler $orderPaymentFeeHandler, OrderStatusService $orderStatusService, PaymentFeeProviderInterface $paymentFeeProvider ) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->paymentMethodRepository = $paymentMethodRepository; $this->paymentMethodService = $paymentMethodService; $this->orderPaymentFeeHandler = $orderPaymentFeeHandler; @@ -98,9 +103,9 @@ public function __construct( * * @throws \Exception */ - public function createOrder($apiPayment, int $cartId, bool $isKlarnaOrder = false): int + public function createOrder($apiPayment, int $cartId, bool $isAuthorizablePayment = false): int { - $orderStatus = $isKlarnaOrder ? + $orderStatus = $isAuthorizablePayment ? (int) Config::getStatuses()[PaymentStatus::STATUS_AUTHORIZED] : (int) Config::getStatuses()[PaymentStatus::STATUS_PAID]; @@ -189,7 +194,7 @@ public function createOrder($apiPayment, int $cartId, bool $isKlarnaOrder = fals public function createBankTransferOrder($paymentData, Cart $cart) { /** @var PaymentMethodRepositoryInterface $paymentMethodRepository */ - $paymentMethodRepository = $this->module->getMollieContainer(PaymentMethodRepositoryInterface::class); + $paymentMethodRepository = $this->module->getService(PaymentMethodRepositoryInterface::class); $this->module->validateOrder( (int) $cart->id, (int) Configuration::get(Config::MOLLIE_STATUS_OPEN), diff --git a/src/Handler/Order/OrderPaymentFeeHandler.php b/src/Handler/Order/OrderPaymentFeeHandler.php index dbcf2e2b1..cb0e1ccde 100644 --- a/src/Handler/Order/OrderPaymentFeeHandler.php +++ b/src/Handler/Order/OrderPaymentFeeHandler.php @@ -47,6 +47,10 @@ use OrderDetail; use PrestaShop\Decimal\Number; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderPaymentFeeHandler { /** @var OrderPaymentFeeService */ diff --git a/src/Handler/PaymentOption/PaymentOptionHandler.php b/src/Handler/PaymentOption/PaymentOptionHandler.php index 3bd0f449a..a49dbd694 100644 --- a/src/Handler/PaymentOption/PaymentOptionHandler.php +++ b/src/Handler/PaymentOption/PaymentOptionHandler.php @@ -47,6 +47,10 @@ use Mollie\Provider\PaymentOption\IdealPaymentOptionProvider; use MolPaymentMethod; +if (!defined('_PS_VERSION_')) { + exit; +} + class PaymentOptionHandler implements PaymentOptionHandlerInterface { /** diff --git a/src/Handler/PaymentOption/PaymentOptionHandlerInterface.php b/src/Handler/PaymentOption/PaymentOptionHandlerInterface.php index cf40ca2a6..eedc4c30b 100644 --- a/src/Handler/PaymentOption/PaymentOptionHandlerInterface.php +++ b/src/Handler/PaymentOption/PaymentOptionHandlerInterface.php @@ -39,6 +39,10 @@ use MolPaymentMethod; use PrestaShop\PrestaShop\Core\Payment\PaymentOption; +if (!defined('_PS_VERSION_')) { + exit; +} + interface PaymentOptionHandlerInterface { /** diff --git a/src/Handler/RetryHandler.php b/src/Handler/RetryHandler.php index d47db6905..90d6362db 100644 --- a/src/Handler/RetryHandler.php +++ b/src/Handler/RetryHandler.php @@ -14,6 +14,10 @@ use Mollie\Exception\RetryOverException; +if (!defined('_PS_VERSION_')) { + exit; +} + class RetryHandler implements RetryHandlerInterface { const DEFAULT_MAX_RETRY = 3; diff --git a/src/Handler/RetryHandlerInterface.php b/src/Handler/RetryHandlerInterface.php index 197988de3..6d5cb036b 100644 --- a/src/Handler/RetryHandlerInterface.php +++ b/src/Handler/RetryHandlerInterface.php @@ -12,6 +12,10 @@ namespace Mollie\Handler; +if (!defined('_PS_VERSION_')) { + exit; +} + interface RetryHandlerInterface { public function retry($function, array $options = [], $moreOptions = []); diff --git a/src/Handler/Settings/PaymentMethodPositionHandler.php b/src/Handler/Settings/PaymentMethodPositionHandler.php index 64262761e..c89a02104 100644 --- a/src/Handler/Settings/PaymentMethodPositionHandler.php +++ b/src/Handler/Settings/PaymentMethodPositionHandler.php @@ -14,6 +14,10 @@ use Mollie\Repository\PaymentMethodRepositoryInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + final class PaymentMethodPositionHandler implements PaymentMethodPositionHandlerInterface { private $paymentMethodRepository; diff --git a/src/Handler/Settings/PaymentMethodPositionHandlerInterface.php b/src/Handler/Settings/PaymentMethodPositionHandlerInterface.php index 5ce149f77..eb85ee8d5 100644 --- a/src/Handler/Settings/PaymentMethodPositionHandlerInterface.php +++ b/src/Handler/Settings/PaymentMethodPositionHandlerInterface.php @@ -12,6 +12,10 @@ namespace Mollie\Handler\Settings; +if (!defined('_PS_VERSION_')) { + exit; +} + interface PaymentMethodPositionHandlerInterface { /** diff --git a/src/Handler/Shipment/ShipmentSenderHandler.php b/src/Handler/Shipment/ShipmentSenderHandler.php index 598274498..26b7a8630 100644 --- a/src/Handler/Shipment/ShipmentSenderHandler.php +++ b/src/Handler/Shipment/ShipmentSenderHandler.php @@ -20,6 +20,10 @@ use Order; use OrderState; +if (!defined('_PS_VERSION_')) { + exit; +} + class ShipmentSenderHandler implements ShipmentSenderHandlerInterface { /** diff --git a/src/Handler/Shipment/ShipmentSenderHandlerInterface.php b/src/Handler/Shipment/ShipmentSenderHandlerInterface.php index a21d0303d..c98515094 100644 --- a/src/Handler/Shipment/ShipmentSenderHandlerInterface.php +++ b/src/Handler/Shipment/ShipmentSenderHandlerInterface.php @@ -18,6 +18,10 @@ use Order; use OrderState; +if (!defined('_PS_VERSION_')) { + exit; +} + interface ShipmentSenderHandlerInterface { /** diff --git a/src/Install/DatabaseTableInstaller.php b/src/Install/DatabaseTableInstaller.php index bbb970720..2d92081ce 100644 --- a/src/Install/DatabaseTableInstaller.php +++ b/src/Install/DatabaseTableInstaller.php @@ -14,6 +14,10 @@ use Db; +if (!defined('_PS_VERSION_')) { + exit; +} + final class DatabaseTableInstaller implements InstallerInterface { public function install() diff --git a/src/Install/DatabaseTableUninstaller.php b/src/Install/DatabaseTableUninstaller.php index f888de443..06eb63d22 100644 --- a/src/Install/DatabaseTableUninstaller.php +++ b/src/Install/DatabaseTableUninstaller.php @@ -14,6 +14,10 @@ use Db; +if (!defined('_PS_VERSION_')) { + exit; +} + final class DatabaseTableUninstaller implements UninstallerInterface { public function uninstall() diff --git a/src/Install/Installer.php b/src/Install/Installer.php index ece66424a..e319a508f 100644 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -22,15 +22,19 @@ use Mollie\Adapter\ConfigurationAdapter; use Mollie\Config\Config; use Mollie\Exception\CouldNotInstallModule; +use Mollie\Factory\ModuleFactory; use Mollie\Handler\ErrorHandler\ErrorHandler; use Mollie\Tracker\Segment; use Mollie\Utility\MultiLangUtility; use OrderState; use PrestaShopException; -use Tab; use Tools; use Validate; +if (!defined('_PS_VERSION_')) { + exit; +} + class Installer implements InstallerInterface { const FILE_NAME = 'Installer'; @@ -46,7 +50,7 @@ class Installer implements InstallerInterface private $module; /** - * @var InstallerInterface + * @var DatabaseTableInstaller */ private $databaseTableInstaller; @@ -63,13 +67,13 @@ class Installer implements InstallerInterface private $orderStateInstaller; public function __construct( - Mollie $module, - InstallerInterface $databaseTableInstaller, + ModuleFactory $moduleFactory, + DatabaseTableInstaller $databaseTableInstaller, Segment $segment, ConfigurationAdapter $configurationAdapter, OrderStateInstaller $orderStateInstaller ) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->databaseTableInstaller = $databaseTableInstaller; $this->segment = $segment; $this->configurationAdapter = $configurationAdapter; @@ -116,16 +120,6 @@ public function install() return false; } - try { - $this->installTab('AdminMollieAjax', 0, 'AdminMollieAjax', false); - $this->installTab('AdminMollieModule', 'IMPROVE', 'Mollie', true, 'mollie'); - } catch (Exception $e) { - $errorHandler->handle($e, $e->getCode(), false); - $this->errors[] = $this->module->l('Unable to install new controllers', self::FILE_NAME); - - return false; - } - try { $this->installVoucherFeatures(); } catch (Exception $e) { @@ -225,28 +219,6 @@ public function setDefaultCarrierStatuses() $this->configurationAdapter->updateValue(Config::MOLLIE_AUTO_SHIP_STATUSES, json_encode($defaultStatuses)); } - public function installTab($className, $parent, $name, $active = true, $icon = '') - { - $idParent = is_int($parent) ? $parent : Tab::getIdFromClassName($parent); - - $moduleTab = new Tab(); - $moduleTab->class_name = $className; - $moduleTab->id_parent = $idParent; - $moduleTab->module = $this->module->name; - $moduleTab->active = $active; - $moduleTab->icon = $icon; /** @phpstan-ignore-line */ - $languages = Language::getLanguages(true); - foreach ($languages as $language) { - $moduleTab->name[$language['id_lang']] = $name; - } - - if (!$moduleTab->save()) { - return false; - } - - return true; - } - /** * @return bool */ diff --git a/src/Install/InstallerInterface.php b/src/Install/InstallerInterface.php index 0bba15f92..1d773e9ff 100644 --- a/src/Install/InstallerInterface.php +++ b/src/Install/InstallerInterface.php @@ -12,6 +12,10 @@ namespace Mollie\Install; +if (!defined('_PS_VERSION_')) { + exit; +} + interface InstallerInterface { /** diff --git a/src/Install/ModuleTabInstaller.php b/src/Install/ModuleTabInstaller.php new file mode 100644 index 000000000..0abf3fc79 --- /dev/null +++ b/src/Install/ModuleTabInstaller.php @@ -0,0 +1,106 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Install; + +use Mollie\Adapter\Language; +use Mollie\Adapter\Tab; +use Mollie\Bootstrap\ModuleTabs; +use Mollie\Exception\CouldNotInstallModule; +use Mollie\Factory\ModuleFactory; +use Mollie\Service\EntityManager\EntityManagerInterface; +use Mollie\Service\EntityManager\ObjectModelUnitOfWork; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class ModuleTabInstaller +{ + private $tab; + private $language; + private $moduleTabs; + private $entityManager; + private $module; + + public function __construct( + ModuleFactory $moduleFactory, + Tab $tab, + Language $language, + ModuleTabs $moduleTabs, + EntityManagerInterface $entityManager + ) { + $this->tab = $tab; + $this->language = $language; + $this->moduleTabs = $moduleTabs; + $this->entityManager = $entityManager; + $this->module = $moduleFactory->getModule(); + } + + /** + * @throws CouldNotInstallModule + */ + public function init() + { + $tabs = $this->moduleTabs->getTabs(); + + foreach ($tabs as $tab) { + if ($this->tab->getIdFromClassName($tab['class_name'])) { + continue; + } + + $this->installTab( + $tab['class_name'], + $tab['parent_class_name'], + $tab['name'], + $tab['icon'], + $tab['visible'] + ); + } + } + + /** + * @throws CouldNotInstallModule + */ + private function installTab( + string $className, + string $parent, + array $name, + string $icon, + bool $visible + ) { + $idParent = $this->tab->getIdFromClassName($parent . '_MTR'); + + if (!$idParent) { + $idParent = $this->tab->getIdFromClassName($parent); + } + + $moduleTab = $this->tab->initTab(); + $moduleTab->class_name = $className; + $moduleTab->id_parent = $idParent; + $moduleTab->module = $this->module->name; + $moduleTab->icon = $icon; + $moduleTab->active = $visible; + + $languages = $this->language->getAllLanguages(); + foreach ($languages as $language) { + $moduleTab->name[$language['id_lang']] = isset($name[$language['iso_code']]) ? pSQL($name[$language['iso_code']]) : pSQL($name['en']); + } + + try { + $this->entityManager->persist($moduleTab, ObjectModelUnitOfWork::UNIT_OF_WORK_SAVE); + $this->entityManager->flush(); + } catch (\Exception $exception) { + throw CouldNotInstallModule::failedToInstallModuleTab($exception, $className); + } + } +} diff --git a/src/Install/OrderStateInstaller.php b/src/Install/OrderStateInstaller.php index 9a07dcac7..3937313c3 100644 --- a/src/Install/OrderStateInstaller.php +++ b/src/Install/OrderStateInstaller.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Install; @@ -11,6 +21,10 @@ use Mollie\Service\OrderStateImageService; use OrderState; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderStateInstaller implements InstallerInterface { /** @var ModuleFactory */ @@ -33,7 +47,7 @@ public function __construct( /** * @throws CouldNotInstallModule */ - public function install() + public function install(): bool { $this->installOrderState( Config::MOLLIE_STATUS_PARTIAL_REFUND, @@ -69,9 +83,9 @@ public function install() ); $this->installOrderState( - Config::MOLLIE_STATUS_KLARNA_AUTHORIZED, + Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED, new OrderStateData( - 'Klarna payment authorized', + 'Order payment authorized', '#8A2BE2', true, true, @@ -85,9 +99,9 @@ public function install() ); $this->installOrderState( - Config::MOLLIE_STATUS_KLARNA_SHIPPED, + Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED, new OrderStateData( - 'Klarna payment shipped', + 'Order payment shipped', '#8A2BE2', true, true, diff --git a/src/Install/Uninstall.php b/src/Install/Uninstall.php index 4eee14010..8bfe21969 100644 --- a/src/Install/Uninstall.php +++ b/src/Install/Uninstall.php @@ -15,7 +15,10 @@ use Mollie\Adapter\ConfigurationAdapter; use Mollie\Config\Config; use Mollie\Tracker\Segment; -use Tab; + +if (!defined('_PS_VERSION_')) { + exit; +} class Uninstall implements UninstallerInterface { @@ -53,8 +56,6 @@ public function uninstall() $this->deleteConfig(); - $this->uninstallTabs(); - $this->databaseUninstaller->uninstall(); return true; @@ -105,25 +106,4 @@ private function deleteConfigurations(array $configurations) $this->configurationAdapter->delete($configuration); } } - - private function uninstallTabs() - { - $tabs = [ - 'AdminMollieAjax', - 'AdminMollieModule', - ]; - - foreach ($tabs as $tab) { - $idTab = Tab::getIdFromClassName($tab); - - if (!$idTab) { - continue; - } - - $tab = new Tab($idTab); - if (!$tab->delete()) { - return false; - } - } - } } diff --git a/src/Install/UninstallerInterface.php b/src/Install/UninstallerInterface.php index c36fecfc2..98647c27a 100644 --- a/src/Install/UninstallerInterface.php +++ b/src/Install/UninstallerInterface.php @@ -12,6 +12,10 @@ namespace Mollie\Install; +if (!defined('_PS_VERSION_')) { + exit; +} + interface UninstallerInterface { /** diff --git a/src/Logger/PrestaLogger.php b/src/Logger/PrestaLogger.php index 67afcc3c8..13f93b61b 100644 --- a/src/Logger/PrestaLogger.php +++ b/src/Logger/PrestaLogger.php @@ -14,6 +14,10 @@ use Mollie\Exception\NotImplementedException; +if (!defined('_PS_VERSION_')) { + exit; +} + class PrestaLogger implements PrestaLoggerInterface { public function emergency($message, array $context = []) diff --git a/src/Logger/PrestaLoggerInterface.php b/src/Logger/PrestaLoggerInterface.php index 5d55bd00f..7f0c448ed 100644 --- a/src/Logger/PrestaLoggerInterface.php +++ b/src/Logger/PrestaLoggerInterface.php @@ -1,9 +1,23 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Logger; use Psr\Log\LoggerInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + interface PrestaLoggerInterface extends LoggerInterface { } diff --git a/src/Presenter/OrderListActionBuilder.php b/src/Presenter/OrderListActionBuilder.php index 5e2f476ca..8b382d49b 100644 --- a/src/Presenter/OrderListActionBuilder.php +++ b/src/Presenter/OrderListActionBuilder.php @@ -13,8 +13,13 @@ namespace Mollie\Presenter; use Mollie; +use Mollie\Factory\ModuleFactory; use Smarty_Data; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderListActionBuilder { const FILE_NAME = 'OrderListActionBuilder'; @@ -23,9 +28,9 @@ class OrderListActionBuilder */ private $mollie; - public function __construct(Mollie $mollie) + public function __construct(ModuleFactory $moduleFactory) { - $this->mollie = $mollie; + $this->mollie = $moduleFactory->getModule(); } public function buildOrderPaymentResendButton(Smarty_Data $smarty, $orderId) diff --git a/src/Provider/AbstractCustomLogoProvider.php b/src/Provider/AbstractCustomLogoProvider.php index 5c9976e7a..e26f6450c 100644 --- a/src/Provider/AbstractCustomLogoProvider.php +++ b/src/Provider/AbstractCustomLogoProvider.php @@ -12,6 +12,10 @@ namespace Mollie\Provider; +if (!defined('_PS_VERSION_')) { + exit; +} + abstract class AbstractCustomLogoProvider implements CustomLogoProviderInterface { /** diff --git a/src/Provider/CreditCardLogoProvider.php b/src/Provider/CreditCardLogoProvider.php index befcbea43..bc1dee093 100644 --- a/src/Provider/CreditCardLogoProvider.php +++ b/src/Provider/CreditCardLogoProvider.php @@ -14,10 +14,15 @@ use Configuration; use Mollie\Config\Config; +use Mollie\Factory\ModuleFactory; use Mollie\Utility\CustomLogoUtility; use Mollie\Utility\ImageUtility; use MolPaymentMethod; +if (!defined('_PS_VERSION_')) { + exit; +} + final class CreditCardLogoProvider extends AbstractCustomLogoProvider { /** @@ -30,10 +35,10 @@ final class CreditCardLogoProvider extends AbstractCustomLogoProvider */ private $pathUri; - public function __construct($localPath, $pathUri) + public function __construct(ModuleFactory $moduleFactory) { - $this->localPath = $localPath; - $this->pathUri = $pathUri; + $this->localPath = $moduleFactory->getLocalPath(); + $this->pathUri = $moduleFactory->getPathUri(); } public function getName() diff --git a/src/Provider/CustomLogoProviderInterface.php b/src/Provider/CustomLogoProviderInterface.php index 63d03848a..e91977710 100644 --- a/src/Provider/CustomLogoProviderInterface.php +++ b/src/Provider/CustomLogoProviderInterface.php @@ -14,6 +14,10 @@ use MolPaymentMethod; +if (!defined('_PS_VERSION_')) { + exit; +} + interface CustomLogoProviderInterface { /** diff --git a/src/Provider/EnvironmentVersionProvider.php b/src/Provider/EnvironmentVersionProvider.php index 259519a5e..36ba3ac19 100644 --- a/src/Provider/EnvironmentVersionProvider.php +++ b/src/Provider/EnvironmentVersionProvider.php @@ -12,6 +12,10 @@ namespace Mollie\Provider; +if (!defined('_PS_VERSION_')) { + exit; +} + class EnvironmentVersionProvider implements EnvironmentVersionProviderInterface { /** diff --git a/src/Provider/EnvironmentVersionProviderInterface.php b/src/Provider/EnvironmentVersionProviderInterface.php index b511cfcdf..8829ce917 100644 --- a/src/Provider/EnvironmentVersionProviderInterface.php +++ b/src/Provider/EnvironmentVersionProviderInterface.php @@ -12,6 +12,10 @@ namespace Mollie\Provider; +if (!defined('_PS_VERSION_')) { + exit; +} + interface EnvironmentVersionProviderInterface { /** diff --git a/src/Provider/OrderTotal/OrderTotalProvider.php b/src/Provider/OrderTotal/OrderTotalProvider.php index b2c52a4f8..a9cba59d7 100644 --- a/src/Provider/OrderTotal/OrderTotalProvider.php +++ b/src/Provider/OrderTotal/OrderTotalProvider.php @@ -37,16 +37,20 @@ namespace Mollie\Provider\OrderTotal; use Exception; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; + +if (!defined('_PS_VERSION_')) { + exit; +} class OrderTotalProvider implements OrderTotalProviderInterface { /** - * @var LegacyContext + * @var Context */ private $context; - public function __construct(LegacyContext $context) + public function __construct(Context $context) { $this->context = $context; } diff --git a/src/Provider/OrderTotal/OrderTotalProviderInterface.php b/src/Provider/OrderTotal/OrderTotalProviderInterface.php index 00a0a1f5c..8816c845a 100644 --- a/src/Provider/OrderTotal/OrderTotalProviderInterface.php +++ b/src/Provider/OrderTotal/OrderTotalProviderInterface.php @@ -36,6 +36,10 @@ namespace Mollie\Provider\OrderTotal; +if (!defined('_PS_VERSION_')) { + exit; +} + interface OrderTotalProviderInterface { public function getOrderTotal(): float; diff --git a/src/Provider/PaymentFeeProvider.php b/src/Provider/PaymentFeeProvider.php index 3db86eff5..426bd9228 100644 --- a/src/Provider/PaymentFeeProvider.php +++ b/src/Provider/PaymentFeeProvider.php @@ -37,7 +37,7 @@ namespace Mollie\Provider; use Address; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; use Mollie\Calculator\PaymentFeeCalculator; use Mollie\Config\Config; use Mollie\DTO\PaymentFeeData; @@ -46,9 +46,13 @@ use Mollie\Repository\AddressRepositoryInterface; use MolPaymentMethod; +if (!defined('_PS_VERSION_')) { + exit; +} + class PaymentFeeProvider implements PaymentFeeProviderInterface { - /** @var LegacyContext */ + /** @var Context */ private $context; /** @var AddressRepositoryInterface */ private $addressRepository; @@ -56,7 +60,7 @@ class PaymentFeeProvider implements PaymentFeeProviderInterface private $taxProvider; public function __construct( - LegacyContext $context, + Context $context, AddressRepositoryInterface $addressRepository, TaxCalculatorProvider $taxProvider ) { diff --git a/src/Provider/PaymentFeeProviderInterface.php b/src/Provider/PaymentFeeProviderInterface.php index 756795c6f..878fdb837 100644 --- a/src/Provider/PaymentFeeProviderInterface.php +++ b/src/Provider/PaymentFeeProviderInterface.php @@ -40,6 +40,10 @@ use Mollie\Exception\FailedToProvidePaymentFeeException; use MolPaymentMethod; +if (!defined('_PS_VERSION_')) { + exit; +} + interface PaymentFeeProviderInterface { /** diff --git a/src/Provider/PaymentOption/BancontactPaymentOptionProvider.php b/src/Provider/PaymentOption/BancontactPaymentOptionProvider.php index 3ebffeb9a..8e38a8878 100644 --- a/src/Provider/PaymentOption/BancontactPaymentOptionProvider.php +++ b/src/Provider/PaymentOption/BancontactPaymentOptionProvider.php @@ -37,8 +37,9 @@ namespace Mollie\Provider\PaymentOption; use Mollie; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; use Mollie\Api\Types\PaymentMethod; +use Mollie\Factory\ModuleFactory; use Mollie\Provider\CreditCardLogoProvider; use Mollie\Provider\OrderTotal\OrderTotalProviderInterface; use Mollie\Provider\PaymentFeeProviderInterface; @@ -47,6 +48,10 @@ use PrestaShop\PrestaShop\Core\Payment\PaymentOption; use Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + class BancontactPaymentOptionProvider implements PaymentOptionProviderInterface { const FILE_NAME = 'BancontactPaymentOptionProvider'; @@ -57,7 +62,7 @@ class BancontactPaymentOptionProvider implements PaymentOptionProviderInterface private $module; /** - * @var LegacyContext + * @var Context */ private $context; @@ -79,14 +84,14 @@ class BancontactPaymentOptionProvider implements PaymentOptionProviderInterface private $orderTotalProvider; public function __construct( - Mollie $module, - LegacyContext $context, + ModuleFactory $moduleFactory, + Context $context, CreditCardLogoProvider $creditCardLogoProvider, PaymentFeeProviderInterface $paymentFeeProvider, LanguageService $languageService, OrderTotalProviderInterface $orderTotalProvider ) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->context = $context; $this->creditCardLogoProvider = $creditCardLogoProvider; $this->paymentFeeProvider = $paymentFeeProvider; diff --git a/src/Provider/PaymentOption/BasePaymentOptionProvider.php b/src/Provider/PaymentOption/BasePaymentOptionProvider.php index 33580b119..166aed82d 100644 --- a/src/Provider/PaymentOption/BasePaymentOptionProvider.php +++ b/src/Provider/PaymentOption/BasePaymentOptionProvider.php @@ -37,7 +37,8 @@ namespace Mollie\Provider\PaymentOption; use Mollie; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; +use Mollie\Factory\ModuleFactory; use Mollie\Provider\CreditCardLogoProvider; use Mollie\Provider\OrderTotal\OrderTotalProviderInterface; use Mollie\Provider\PaymentFeeProviderInterface; @@ -46,6 +47,10 @@ use PrestaShop\PrestaShop\Core\Payment\PaymentOption; use Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + class BasePaymentOptionProvider implements PaymentOptionProviderInterface { const FILE_NAME = 'BasePaymentOptionProvider'; @@ -56,7 +61,7 @@ class BasePaymentOptionProvider implements PaymentOptionProviderInterface private $module; /** - * @var LegacyContext + * @var Context */ private $context; @@ -78,14 +83,14 @@ class BasePaymentOptionProvider implements PaymentOptionProviderInterface private $orderTotalProvider; public function __construct( - Mollie $module, - LegacyContext $context, + ModuleFactory $moduleFactory, + Context $context, CreditCardLogoProvider $creditCardLogoProvider, PaymentFeeProviderInterface $paymentFeeProvider, LanguageService $languageService, OrderTotalProviderInterface $orderTotalProvider ) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->context = $context; $this->creditCardLogoProvider = $creditCardLogoProvider; $this->paymentFeeProvider = $paymentFeeProvider; diff --git a/src/Provider/PaymentOption/CreditCardPaymentOptionProvider.php b/src/Provider/PaymentOption/CreditCardPaymentOptionProvider.php index cd141bb62..1d993d0a4 100644 --- a/src/Provider/PaymentOption/CreditCardPaymentOptionProvider.php +++ b/src/Provider/PaymentOption/CreditCardPaymentOptionProvider.php @@ -36,12 +36,12 @@ namespace Mollie\Provider\PaymentOption; -use Customer; use MolCustomer; use Mollie; use Mollie\Adapter\ConfigurationAdapter; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; use Mollie\Config\Config; +use Mollie\Factory\ModuleFactory; use Mollie\Provider\CreditCardLogoProvider; use Mollie\Provider\OrderTotal\OrderTotalProviderInterface; use Mollie\Provider\PaymentFeeProviderInterface; @@ -52,6 +52,10 @@ use PrestaShop\PrestaShop\Core\Payment\PaymentOption; use Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + class CreditCardPaymentOptionProvider implements PaymentOptionProviderInterface { const FILE_NAME = 'CreditCardPaymentOptionProvider'; @@ -62,7 +66,7 @@ class CreditCardPaymentOptionProvider implements PaymentOptionProviderInterface private $module; /** - * @var LegacyContext + * @var Context */ private $context; @@ -85,10 +89,6 @@ class CreditCardPaymentOptionProvider implements PaymentOptionProviderInterface * @var LanguageService */ private $languageService; - /** - * @var Customer - */ - private $customer; /** * @var MolCustomerRepository */ @@ -97,23 +97,21 @@ class CreditCardPaymentOptionProvider implements PaymentOptionProviderInterface private $configurationAdapter; public function __construct( - Mollie $module, - LegacyContext $context, + ModuleFactory $moduleFactory, + Context $context, CreditCardLogoProvider $creditCardLogoProvider, OrderTotalProviderInterface $orderTotalProvider, PaymentFeeProviderInterface $paymentFeeProvider, LanguageService $languageService, - Customer $customer, MolCustomerRepository $customerRepository, ConfigurationAdapter $configurationAdapter ) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->context = $context; $this->creditCardLogoProvider = $creditCardLogoProvider; $this->orderTotalProvider = $orderTotalProvider; $this->paymentFeeProvider = $paymentFeeProvider; $this->languageService = $languageService; - $this->customer = $customer; $this->customerRepository = $customerRepository; $this->configurationAdapter = $configurationAdapter; } @@ -137,13 +135,13 @@ public function getPaymentOption(MolPaymentMethod $paymentMethod): PaymentOption true )); - $fullName = CustomerUtility::getCustomerFullName($this->customer->id); + $fullName = CustomerUtility::getCustomerFullName($this->context->getCustomerId()); /** @var MolCustomer|null $molCustomer */ $molCustomer = $this->customerRepository->findOneBy( [ 'name' => $fullName, - 'email' => $this->customer->email, + 'email' => $this->context->getCustomerEmail(), ] ); @@ -179,7 +177,7 @@ public function getPaymentOption(MolPaymentMethod $paymentMethod): PaymentOption 'methodId' => $paymentMethod->getPaymentMethodName(), 'isSingleClickPayment' => (bool) (int) $this->configurationAdapter->get(Mollie\Config\Config::MOLLIE_SINGLE_CLICK_PAYMENT), 'mollieUseSavedCard' => $useSavedUser, - 'isGuest' => $this->customer->isGuest(), + 'isGuest' => $this->context->isCustomerGuest(), ]); $paymentOption->setLogo($this->creditCardLogoProvider->getMethodOptionLogo($paymentMethod)); diff --git a/src/Provider/PaymentOption/CreditCardSingleClickPaymentOptionProvider.php b/src/Provider/PaymentOption/CreditCardSingleClickPaymentOptionProvider.php index 287ecd898..67a6bd15a 100644 --- a/src/Provider/PaymentOption/CreditCardSingleClickPaymentOptionProvider.php +++ b/src/Provider/PaymentOption/CreditCardSingleClickPaymentOptionProvider.php @@ -36,12 +36,12 @@ namespace Mollie\Provider\PaymentOption; -use Customer; use MolCustomer; use Mollie; use Mollie\Adapter\ConfigurationAdapter; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; use Mollie\Config\Config; +use Mollie\Factory\ModuleFactory; use Mollie\Provider\CreditCardLogoProvider; use Mollie\Provider\OrderTotal\OrderTotalProviderInterface; use Mollie\Provider\PaymentFeeProviderInterface; @@ -52,6 +52,10 @@ use PrestaShop\PrestaShop\Core\Payment\PaymentOption; use Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + class CreditCardSingleClickPaymentOptionProvider implements PaymentOptionProviderInterface { const FILE_NAME = 'CreditCardSingleClickPaymentOptionProvider'; @@ -62,7 +66,7 @@ class CreditCardSingleClickPaymentOptionProvider implements PaymentOptionProvide private $module; /** - * @var LegacyContext + * @var Context */ private $context; @@ -85,10 +89,6 @@ class CreditCardSingleClickPaymentOptionProvider implements PaymentOptionProvide * @var LanguageService */ private $languageService; - /** - * @var Customer - */ - private $customer; /** * @var MolCustomerRepository */ @@ -97,23 +97,21 @@ class CreditCardSingleClickPaymentOptionProvider implements PaymentOptionProvide private $configurationAdapter; public function __construct( - Mollie $module, - LegacyContext $context, + ModuleFactory $moduleFactory, + Context $context, CreditCardLogoProvider $creditCardLogoProvider, OrderTotalProviderInterface $orderTotalProvider, PaymentFeeProviderInterface $paymentFeeProvider, LanguageService $languageService, - Customer $customer, MolCustomerRepository $customerRepository, ConfigurationAdapter $configurationAdapter ) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->context = $context; $this->creditCardLogoProvider = $creditCardLogoProvider; $this->orderTotalProvider = $orderTotalProvider; $this->paymentFeeProvider = $paymentFeeProvider; $this->languageService = $languageService; - $this->customer = $customer; $this->customerRepository = $customerRepository; $this->configurationAdapter = $configurationAdapter; } @@ -136,13 +134,13 @@ public function getPaymentOption(MolPaymentMethod $paymentMethod): PaymentOption ['method' => $paymentMethod->getPaymentMethodName(), 'rand' => Mollie\Utility\TimeUtility::getCurrentTimeStamp()], true )); - $fullName = CustomerUtility::getCustomerFullName($this->customer->id); + $fullName = CustomerUtility::getCustomerFullName($this->context->getCustomerId()); /** @var MolCustomer|null $molCustomer */ $molCustomer = $this->customerRepository->findOneBy( [ 'name' => $fullName, - 'email' => $this->customer->email, + 'email' => $this->context->getCustomerEmail(), ] ); @@ -177,7 +175,7 @@ public function getPaymentOption(MolPaymentMethod $paymentMethod): PaymentOption 'methodId' => $paymentMethod->getPaymentMethodName(), 'isSingleClickPayment' => (bool) (int) $this->configurationAdapter->get(Mollie\Config\Config::MOLLIE_SINGLE_CLICK_PAYMENT), 'mollieUseSavedCard' => $useSavedUser, - 'isGuest' => $this->customer->isGuest(), + 'isGuest' => $this->context->isCustomerGuest(), ]); $paymentOption->setLogo($this->creditCardLogoProvider->getMethodOptionLogo($paymentMethod)); diff --git a/src/Provider/PaymentOption/IdealPaymentOptionProvider.php b/src/Provider/PaymentOption/IdealPaymentOptionProvider.php index d089700d8..4ccd88ecd 100644 --- a/src/Provider/PaymentOption/IdealPaymentOptionProvider.php +++ b/src/Provider/PaymentOption/IdealPaymentOptionProvider.php @@ -37,8 +37,9 @@ namespace Mollie\Provider\PaymentOption; use Mollie; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; use Mollie\Builder\Content\PaymentOption\IdealDropdownInfoBlock; +use Mollie\Factory\ModuleFactory; use Mollie\Provider\CreditCardLogoProvider; use Mollie\Provider\OrderTotal\OrderTotalProviderInterface; use Mollie\Provider\PaymentFeeProviderInterface; @@ -48,6 +49,10 @@ use PrestaShop\PrestaShop\Core\Payment\PaymentOption; use Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + class IdealPaymentOptionProvider implements PaymentOptionProviderInterface { const FILE_NAME = 'IdealPaymentOptionProvider'; @@ -58,7 +63,7 @@ class IdealPaymentOptionProvider implements PaymentOptionProviderInterface private $module; /** - * @var LegacyContext + * @var Context */ private $context; @@ -90,8 +95,8 @@ class IdealPaymentOptionProvider implements PaymentOptionProviderInterface private $orderTotalProvider; public function __construct( - Mollie $module, - LegacyContext $context, + ModuleFactory $moduleFactory, + Context $context, CreditCardLogoProvider $creditCardLogoProvider, PaymentFeeProviderInterface $paymentFeeProvider, TemplateParserInterface $templateParser, @@ -99,7 +104,7 @@ public function __construct( LanguageService $languageService, OrderTotalProviderInterface $orderTotalProvider ) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->context = $context; $this->creditCardLogoProvider = $creditCardLogoProvider; $this->paymentFeeProvider = $paymentFeeProvider; diff --git a/src/Provider/PaymentOption/PaymentOptionProviderInterface.php b/src/Provider/PaymentOption/PaymentOptionProviderInterface.php index 8d463f0c8..b9b001416 100644 --- a/src/Provider/PaymentOption/PaymentOptionProviderInterface.php +++ b/src/Provider/PaymentOption/PaymentOptionProviderInterface.php @@ -39,6 +39,10 @@ use MolPaymentMethod; use PrestaShop\PrestaShop\Core\Payment\PaymentOption; +if (!defined('_PS_VERSION_')) { + exit; +} + interface PaymentOptionProviderInterface { /** diff --git a/src/Provider/PaymentType/PaymentTypeIdentificationProvider.php b/src/Provider/PaymentType/PaymentTypeIdentificationProviderInterface.php similarity index 81% rename from src/Provider/PaymentType/PaymentTypeIdentificationProvider.php rename to src/Provider/PaymentType/PaymentTypeIdentificationProviderInterface.php index 9cc3e174b..c3efeebee 100644 --- a/src/Provider/PaymentType/PaymentTypeIdentificationProvider.php +++ b/src/Provider/PaymentType/PaymentTypeIdentificationProviderInterface.php @@ -12,7 +12,11 @@ namespace Mollie\Provider\PaymentType; -interface PaymentTypeIdentificationProvider +if (!defined('_PS_VERSION_')) { + exit; +} + +interface PaymentTypeIdentificationProviderInterface { /** * @return string diff --git a/src/Provider/PaymentType/RegularPaymentTypeIdentification.php b/src/Provider/PaymentType/RegularPaymentTypeIdentification.php index aaeb008ac..7cbd0fb2f 100644 --- a/src/Provider/PaymentType/RegularPaymentTypeIdentification.php +++ b/src/Provider/PaymentType/RegularPaymentTypeIdentification.php @@ -14,7 +14,11 @@ use Mollie\Api\Endpoints\OrderEndpoint; -class RegularPaymentTypeIdentification implements PaymentTypeIdentificationProvider +if (!defined('_PS_VERSION_')) { + exit; +} + +class RegularPaymentTypeIdentification implements PaymentTypeIdentificationProviderInterface { /** * @return string diff --git a/src/Provider/PhoneNumberProvider.php b/src/Provider/PhoneNumberProvider.php index 11e5e5c5c..022d144a5 100644 --- a/src/Provider/PhoneNumberProvider.php +++ b/src/Provider/PhoneNumberProvider.php @@ -14,6 +14,10 @@ use Address; +if (!defined('_PS_VERSION_')) { + exit; +} + final class PhoneNumberProvider implements PhoneNumberProviderInterface { public function getFromAddress(Address $address) diff --git a/src/Provider/PhoneNumberProviderInterface.php b/src/Provider/PhoneNumberProviderInterface.php index d16bc073f..624ef4b1f 100644 --- a/src/Provider/PhoneNumberProviderInterface.php +++ b/src/Provider/PhoneNumberProviderInterface.php @@ -14,6 +14,10 @@ use Address; +if (!defined('_PS_VERSION_')) { + exit; +} + interface PhoneNumberProviderInterface { /** diff --git a/src/Provider/ProfileIdProvider.php b/src/Provider/ProfileIdProvider.php index 962b42abe..de2eb09e1 100644 --- a/src/Provider/ProfileIdProvider.php +++ b/src/Provider/ProfileIdProvider.php @@ -15,6 +15,10 @@ use Mollie\Api\Exceptions\ApiException; use Mollie\Api\MollieApiClient; +if (!defined('_PS_VERSION_')) { + exit; +} + class ProfileIdProvider implements ProfileIdProviderInterface { public function getProfileId(MollieApiClient $apiClient): string diff --git a/src/Provider/ProfileIdProviderInterface.php b/src/Provider/ProfileIdProviderInterface.php index d01674502..3f6fa3116 100644 --- a/src/Provider/ProfileIdProviderInterface.php +++ b/src/Provider/ProfileIdProviderInterface.php @@ -14,6 +14,10 @@ use Mollie\Api\MollieApiClient; +if (!defined('_PS_VERSION_')) { + exit; +} + interface ProfileIdProviderInterface { public function getProfileId(MollieApiClient $apiClient): string; diff --git a/src/Provider/Shipment/AutomaticShipmentSenderStatusesProvider.php b/src/Provider/Shipment/AutomaticShipmentSenderStatusesProvider.php index e23cd1132..9aa7d4d5c 100644 --- a/src/Provider/Shipment/AutomaticShipmentSenderStatusesProvider.php +++ b/src/Provider/Shipment/AutomaticShipmentSenderStatusesProvider.php @@ -16,6 +16,10 @@ use Mollie\Config\Config; use Mollie\Utility\Decoder\DecoderInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + class AutomaticShipmentSenderStatusesProvider implements AutomaticShipmentSenderStatusesProviderInterface { /** diff --git a/src/Provider/Shipment/AutomaticShipmentSenderStatusesProviderInterface.php b/src/Provider/Shipment/AutomaticShipmentSenderStatusesProviderInterface.php index ec12b4812..cbf1a951b 100644 --- a/src/Provider/Shipment/AutomaticShipmentSenderStatusesProviderInterface.php +++ b/src/Provider/Shipment/AutomaticShipmentSenderStatusesProviderInterface.php @@ -12,6 +12,10 @@ namespace Mollie\Provider\Shipment; +if (!defined('_PS_VERSION_')) { + exit; +} + interface AutomaticShipmentSenderStatusesProviderInterface { /** diff --git a/src/Provider/TaxCalculatorProvider.php b/src/Provider/TaxCalculatorProvider.php index d26388972..1e5c2ed6e 100644 --- a/src/Provider/TaxCalculatorProvider.php +++ b/src/Provider/TaxCalculatorProvider.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Provider; @@ -7,6 +17,10 @@ use Tax; use TaxCalculator; +if (!defined('_PS_VERSION_')) { + exit; +} + class TaxCalculatorProvider { /** @var TaxRuleRepositoryInterface */ diff --git a/src/Provider/UpdateMessageProvider.php b/src/Provider/UpdateMessageProvider.php index 58a38fc9c..5a096c67b 100755 --- a/src/Provider/UpdateMessageProvider.php +++ b/src/Provider/UpdateMessageProvider.php @@ -14,9 +14,14 @@ use Context; use Mollie; +use Mollie\Factory\ModuleFactory; use SimpleXMLElement; use Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + class UpdateMessageProvider implements UpdateMessageProviderInterface { const FILE_NAME = 'UpdateMessageProvider'; @@ -26,9 +31,9 @@ class UpdateMessageProvider implements UpdateMessageProviderInterface */ private $module; - public function __construct(Mollie $module) + public function __construct(ModuleFactory $moduleFactory) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); } /** diff --git a/src/Provider/UpdateMessageProviderInterface.php b/src/Provider/UpdateMessageProviderInterface.php index a723f0226..fda8f68dd 100644 --- a/src/Provider/UpdateMessageProviderInterface.php +++ b/src/Provider/UpdateMessageProviderInterface.php @@ -12,6 +12,10 @@ namespace Mollie\Provider; +if (!defined('_PS_VERSION_')) { + exit; +} + interface UpdateMessageProviderInterface { /** diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index 749912f0e..145037830 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -16,6 +16,10 @@ use PrestaShopCollection; use PrestaShopException; +if (!defined('_PS_VERSION_')) { + exit; +} + class AbstractRepository implements ReadOnlyRepositoryInterface { /** @@ -26,7 +30,7 @@ class AbstractRepository implements ReadOnlyRepositoryInterface /** * @param string $fullyClassifiedClassName */ - public function __construct($fullyClassifiedClassName) + public function __construct(string $fullyClassifiedClassName) { $this->fullyClassifiedClassName = $fullyClassifiedClassName; } diff --git a/src/Repository/AddressFormatRepository.php b/src/Repository/AddressFormatRepository.php new file mode 100644 index 000000000..cb419c13c --- /dev/null +++ b/src/Repository/AddressFormatRepository.php @@ -0,0 +1,25 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Repository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class AddressFormatRepository extends AbstractRepository implements AddressFormatRepositoryInterface +{ + public function __construct() + { + parent::__construct(\AddressFormat::class); + } +} diff --git a/src/Repository/AddressFormatRepositoryInterface.php b/src/Repository/AddressFormatRepositoryInterface.php new file mode 100644 index 000000000..f7ec691c6 --- /dev/null +++ b/src/Repository/AddressFormatRepositoryInterface.php @@ -0,0 +1,21 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Repository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +interface AddressFormatRepositoryInterface extends ReadOnlyRepositoryInterface +{ +} diff --git a/src/Repository/AddressRepository.php b/src/Repository/AddressRepository.php index 867c90f2d..23bc7543a 100644 --- a/src/Repository/AddressRepository.php +++ b/src/Repository/AddressRepository.php @@ -1,9 +1,23 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Repository; use Address; +if (!defined('_PS_VERSION_')) { + exit; +} + class AddressRepository extends AbstractRepository implements AddressRepositoryInterface { public function __construct() diff --git a/src/Repository/AddressRepositoryInterface.php b/src/Repository/AddressRepositoryInterface.php index a25dd6ce4..b88eb911b 100644 --- a/src/Repository/AddressRepositoryInterface.php +++ b/src/Repository/AddressRepositoryInterface.php @@ -1,7 +1,21 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Repository; +if (!defined('_PS_VERSION_')) { + exit; +} + interface AddressRepositoryInterface extends ReadOnlyRepositoryInterface { } diff --git a/src/Repository/AttributeRepository.php b/src/Repository/AttributeRepository.php index 4940e83ad..70b9fb0a2 100644 --- a/src/Repository/AttributeRepository.php +++ b/src/Repository/AttributeRepository.php @@ -15,6 +15,10 @@ use Db; use DbQuery; +if (!defined('_PS_VERSION_')) { + exit; +} + class AttributeRepository { public function hasAttributeInCombination($attrCombinationId, $attributeId) diff --git a/src/Repository/CartRuleRepository.php b/src/Repository/CartRuleRepository.php index 5d1ffa966..21566ca07 100644 --- a/src/Repository/CartRuleRepository.php +++ b/src/Repository/CartRuleRepository.php @@ -14,6 +14,10 @@ use CartRule; +if (!defined('_PS_VERSION_')) { + exit; +} + final class CartRuleRepository extends AbstractRepository implements CartRuleRepositoryInterface { public function __construct() diff --git a/src/Repository/CartRuleRepositoryInterface.php b/src/Repository/CartRuleRepositoryInterface.php index c09c805d8..aad9a5914 100644 --- a/src/Repository/CartRuleRepositoryInterface.php +++ b/src/Repository/CartRuleRepositoryInterface.php @@ -12,6 +12,10 @@ namespace Mollie\Repository; +if (!defined('_PS_VERSION_')) { + exit; +} + interface CartRuleRepositoryInterface extends ReadOnlyRepositoryInterface { } diff --git a/src/Repository/CountryRepository.php b/src/Repository/CountryRepository.php index f7615e59a..d1a2349a8 100644 --- a/src/Repository/CountryRepository.php +++ b/src/Repository/CountryRepository.php @@ -15,6 +15,10 @@ use Country; use Db; +if (!defined('_PS_VERSION_')) { + exit; +} + final class CountryRepository extends AbstractRepository { public function __construct() diff --git a/src/Repository/CurrencyRepository.php b/src/Repository/CurrencyRepository.php index 9a3529907..440b55379 100644 --- a/src/Repository/CurrencyRepository.php +++ b/src/Repository/CurrencyRepository.php @@ -38,6 +38,10 @@ use Currency; +if (!defined('_PS_VERSION_')) { + exit; +} + class CurrencyRepository extends AbstractRepository implements CurrencyRepositoryInterface { public function __construct() diff --git a/src/Repository/CurrencyRepositoryInterface.php b/src/Repository/CurrencyRepositoryInterface.php index b7a98c617..891e93609 100644 --- a/src/Repository/CurrencyRepositoryInterface.php +++ b/src/Repository/CurrencyRepositoryInterface.php @@ -36,6 +36,10 @@ namespace Mollie\Repository; +if (!defined('_PS_VERSION_')) { + exit; +} + interface CurrencyRepositoryInterface extends ReadOnlyRepositoryInterface { } diff --git a/src/Repository/CustomerRepository.php b/src/Repository/CustomerRepository.php new file mode 100644 index 000000000..178230bc5 --- /dev/null +++ b/src/Repository/CustomerRepository.php @@ -0,0 +1,25 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Repository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class CustomerRepository extends AbstractRepository implements CustomerRepositoryInterface +{ + public function __construct() + { + parent::__construct(\Customer::class); + } +} diff --git a/src/Repository/CustomerRepositoryInterface.php b/src/Repository/CustomerRepositoryInterface.php new file mode 100644 index 000000000..eee2e18e4 --- /dev/null +++ b/src/Repository/CustomerRepositoryInterface.php @@ -0,0 +1,21 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Repository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +interface CustomerRepositoryInterface extends ReadOnlyRepositoryInterface +{ +} diff --git a/src/Repository/GenderRepository.php b/src/Repository/GenderRepository.php index beb9b3832..807dc21bc 100644 --- a/src/Repository/GenderRepository.php +++ b/src/Repository/GenderRepository.php @@ -36,6 +36,10 @@ namespace Mollie\Repository; +if (!defined('_PS_VERSION_')) { + exit; +} + class GenderRepository extends AbstractRepository implements GenderRepositoryInterface { public function __construct() diff --git a/src/Repository/GenderRepositoryInterface.php b/src/Repository/GenderRepositoryInterface.php index e5f6bd0fb..6b49adfd6 100644 --- a/src/Repository/GenderRepositoryInterface.php +++ b/src/Repository/GenderRepositoryInterface.php @@ -36,6 +36,10 @@ namespace Mollie\Repository; +if (!defined('_PS_VERSION_')) { + exit; +} + interface GenderRepositoryInterface extends ReadOnlyRepositoryInterface { } diff --git a/src/Repository/MethodCountryRepository.php b/src/Repository/MethodCountryRepository.php index 693ce8bae..41bc05697 100644 --- a/src/Repository/MethodCountryRepository.php +++ b/src/Repository/MethodCountryRepository.php @@ -15,6 +15,10 @@ use Db; use DbQuery; +if (!defined('_PS_VERSION_')) { + exit; +} + /** * Repository related with payment methods country. */ diff --git a/src/Repository/ModuleRepository.php b/src/Repository/ModuleRepository.php index a97fe8dea..36fbc9d10 100644 --- a/src/Repository/ModuleRepository.php +++ b/src/Repository/ModuleRepository.php @@ -15,6 +15,10 @@ use Db; use DbQuery; +if (!defined('_PS_VERSION_')) { + exit; +} + class ModuleRepository { public function getModuleDatabaseVersion($moduleName) diff --git a/src/Repository/MolCarrierInformationRepository.php b/src/Repository/MolCarrierInformationRepository.php index 6b0938575..63b123838 100644 --- a/src/Repository/MolCarrierInformationRepository.php +++ b/src/Repository/MolCarrierInformationRepository.php @@ -15,6 +15,10 @@ use Db; use DbQuery; +if (!defined('_PS_VERSION_')) { + exit; +} + class MolCarrierInformationRepository { public function getMollieCarrierInformationIdByCarrierId($carrierId) diff --git a/src/Repository/MolCustomerRepository.php b/src/Repository/MolCustomerRepository.php index 41c7001f7..cc57a0b65 100644 --- a/src/Repository/MolCustomerRepository.php +++ b/src/Repository/MolCustomerRepository.php @@ -12,6 +12,14 @@ namespace Mollie\Repository; +if (!defined('_PS_VERSION_')) { + exit; +} + class MolCustomerRepository extends AbstractRepository { + public function __construct() + { + parent::__construct(\MolCustomer::class); + } } diff --git a/src/Repository/MolOrderPaymentFeeRepository.php b/src/Repository/MolOrderPaymentFeeRepository.php index b9694d710..4cca4fdf7 100644 --- a/src/Repository/MolOrderPaymentFeeRepository.php +++ b/src/Repository/MolOrderPaymentFeeRepository.php @@ -14,6 +14,10 @@ use MolOrderPaymentFee; +if (!defined('_PS_VERSION_')) { + exit; +} + class MolOrderPaymentFeeRepository extends AbstractRepository implements MolOrderPaymentFeeRepositoryInterface { public function __construct() diff --git a/src/Repository/MolOrderPaymentFeeRepositoryInterface.php b/src/Repository/MolOrderPaymentFeeRepositoryInterface.php index 390e2a0d7..9d39dec27 100644 --- a/src/Repository/MolOrderPaymentFeeRepositoryInterface.php +++ b/src/Repository/MolOrderPaymentFeeRepositoryInterface.php @@ -1,7 +1,21 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Repository; +if (!defined('_PS_VERSION_')) { + exit; +} + interface MolOrderPaymentFeeRepositoryInterface extends ReadOnlyRepositoryInterface { } diff --git a/src/Repository/OrderCartRuleRepository.php b/src/Repository/OrderCartRuleRepository.php index 186b9ec97..b0f71d435 100644 --- a/src/Repository/OrderCartRuleRepository.php +++ b/src/Repository/OrderCartRuleRepository.php @@ -15,6 +15,10 @@ use Db; use OrderCartRule; +if (!defined('_PS_VERSION_')) { + exit; +} + final class OrderCartRuleRepository extends AbstractRepository implements OrderCartRuleRepositoryInterface { public function __construct() diff --git a/src/Repository/OrderCartRuleRepositoryInterface.php b/src/Repository/OrderCartRuleRepositoryInterface.php index 8e769a826..d7c4d73d5 100644 --- a/src/Repository/OrderCartRuleRepositoryInterface.php +++ b/src/Repository/OrderCartRuleRepositoryInterface.php @@ -12,6 +12,10 @@ namespace Mollie\Repository; +if (!defined('_PS_VERSION_')) { + exit; +} + interface OrderCartRuleRepositoryInterface extends ReadOnlyRepositoryInterface { /** diff --git a/src/Repository/OrderRepository.php b/src/Repository/OrderRepository.php index ee1f5b0a7..82d43d1f4 100644 --- a/src/Repository/OrderRepository.php +++ b/src/Repository/OrderRepository.php @@ -14,6 +14,10 @@ use Order; +if (!defined('_PS_VERSION_')) { + exit; +} + final class OrderRepository extends AbstractRepository implements OrderRepositoryInterface { public function __construct() diff --git a/src/Repository/OrderRepositoryInterface.php b/src/Repository/OrderRepositoryInterface.php index 418c2b939..b4ede2e80 100644 --- a/src/Repository/OrderRepositoryInterface.php +++ b/src/Repository/OrderRepositoryInterface.php @@ -14,6 +14,10 @@ use Order; +if (!defined('_PS_VERSION_')) { + exit; +} + interface OrderRepositoryInterface extends ReadOnlyRepositoryInterface { /** diff --git a/src/Repository/OrderShipmentRepository.php b/src/Repository/OrderShipmentRepository.php index 207581cb7..902418129 100644 --- a/src/Repository/OrderShipmentRepository.php +++ b/src/Repository/OrderShipmentRepository.php @@ -15,6 +15,10 @@ use Db; use DbQuery; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderShipmentRepository { public function getShipmentInformation($table, $orderId) diff --git a/src/Repository/OrderStateRepository.php b/src/Repository/OrderStateRepository.php index 76f8838d6..4971cd423 100644 --- a/src/Repository/OrderStateRepository.php +++ b/src/Repository/OrderStateRepository.php @@ -15,6 +15,10 @@ use Db; use Mollie\Config\Config; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderStateRepository { public function deleteStatuses() diff --git a/src/Repository/PaymentMethodRepository.php b/src/Repository/PaymentMethodRepository.php index 17564cac7..8531934a6 100644 --- a/src/Repository/PaymentMethodRepository.php +++ b/src/Repository/PaymentMethodRepository.php @@ -22,10 +22,10 @@ use PDOStatement; use PrestaShopDatabaseException; -/** - * @deprecated - outside code must always use interface. Use PaymentMethodRepositoryInterface instead. - * In Containers use PaymentMethodRepositoryInterface::class - */ +if (!defined('_PS_VERSION_')) { + exit; +} + class PaymentMethodRepository extends AbstractRepository implements PaymentMethodRepositoryInterface { public function __construct() @@ -88,7 +88,7 @@ public function getPaymentMethodIdByMethodId($paymentMethodId, $environment, $sh } $sql = 'SELECT id_payment_method FROM `' . _DB_PREFIX_ . 'mol_payment_method` - WHERE id_method = "' . pSQL($paymentMethodId) . '" AND live_environment = "' . (int) $environment . '" + WHERE id_method = "' . pSQL($paymentMethodId) . '" AND live_environment = "' . (int) $environment . '" AND id_shop = ' . (int) $shopId; return Db::getInstance()->getValue($sql); diff --git a/src/Repository/PaymentMethodRepositoryInterface.php b/src/Repository/PaymentMethodRepositoryInterface.php index 1106e7440..7725fa546 100644 --- a/src/Repository/PaymentMethodRepositoryInterface.php +++ b/src/Repository/PaymentMethodRepositoryInterface.php @@ -12,6 +12,10 @@ namespace Mollie\Repository; +if (!defined('_PS_VERSION_')) { + exit; +} + interface PaymentMethodRepositoryInterface extends ReadOnlyRepositoryInterface { public function getPaymentMethodIssuersByPaymentMethodId($paymentMethodId); diff --git a/src/Repository/PendingOrderCartRepository.php b/src/Repository/PendingOrderCartRepository.php index 2b9aa54b1..1f796b5f9 100644 --- a/src/Repository/PendingOrderCartRepository.php +++ b/src/Repository/PendingOrderCartRepository.php @@ -12,6 +12,14 @@ namespace Mollie\Repository; +if (!defined('_PS_VERSION_')) { + exit; +} + final class PendingOrderCartRepository extends AbstractRepository { + public function __construct() + { + parent::__construct(\MolPendingOrderCart::class); + } } diff --git a/src/Repository/PendingOrderCartRuleRepository.php b/src/Repository/PendingOrderCartRuleRepository.php index 4b4ce3510..7ae87c8ae 100644 --- a/src/Repository/PendingOrderCartRuleRepository.php +++ b/src/Repository/PendingOrderCartRuleRepository.php @@ -17,6 +17,10 @@ use Order; use OrderCartRule; +if (!defined('_PS_VERSION_')) { + exit; +} + final class PendingOrderCartRuleRepository extends AbstractRepository implements PendingOrderCartRuleRepositoryInterface { public function __construct() diff --git a/src/Repository/PendingOrderCartRuleRepositoryInterface.php b/src/Repository/PendingOrderCartRuleRepositoryInterface.php index bf7f5f3c2..c6f2e98a1 100644 --- a/src/Repository/PendingOrderCartRuleRepositoryInterface.php +++ b/src/Repository/PendingOrderCartRuleRepositoryInterface.php @@ -16,6 +16,10 @@ use Order; use OrderCartRule; +if (!defined('_PS_VERSION_')) { + exit; +} + interface PendingOrderCartRuleRepositoryInterface extends ReadOnlyRepositoryInterface { /** diff --git a/src/Repository/ReadOnlyRepositoryInterface.php b/src/Repository/ReadOnlyRepositoryInterface.php index f7d5fe12e..783717dc7 100644 --- a/src/Repository/ReadOnlyRepositoryInterface.php +++ b/src/Repository/ReadOnlyRepositoryInterface.php @@ -15,6 +15,10 @@ use ObjectModel; use PrestaShopCollection; +if (!defined('_PS_VERSION_')) { + exit; +} + interface ReadOnlyRepositoryInterface { /** diff --git a/src/Repository/TaxRepository.php b/src/Repository/TaxRepository.php index e317edb82..446177045 100644 --- a/src/Repository/TaxRepository.php +++ b/src/Repository/TaxRepository.php @@ -1,7 +1,21 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Repository; +if (!defined('_PS_VERSION_')) { + exit; +} + class TaxRepository extends AbstractRepository implements TaxRepositoryInterface { public function __construct() diff --git a/src/Repository/TaxRepositoryInterface.php b/src/Repository/TaxRepositoryInterface.php index 046cb9532..04c602b56 100644 --- a/src/Repository/TaxRepositoryInterface.php +++ b/src/Repository/TaxRepositoryInterface.php @@ -1,7 +1,21 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Repository; +if (!defined('_PS_VERSION_')) { + exit; +} + interface TaxRepositoryInterface extends ReadOnlyRepositoryInterface { } diff --git a/src/Repository/TaxRuleRepository.php b/src/Repository/TaxRuleRepository.php index 293d37bf4..759c22276 100644 --- a/src/Repository/TaxRuleRepository.php +++ b/src/Repository/TaxRuleRepository.php @@ -1,10 +1,24 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Repository; use Db; use DbQuery; +if (!defined('_PS_VERSION_')) { + exit; +} + class TaxRuleRepository extends AbstractRepository implements TaxRuleRepositoryInterface { public function __construct() diff --git a/src/Repository/TaxRuleRepositoryInterface.php b/src/Repository/TaxRuleRepositoryInterface.php index 34338c709..269478abf 100644 --- a/src/Repository/TaxRuleRepositoryInterface.php +++ b/src/Repository/TaxRuleRepositoryInterface.php @@ -1,7 +1,21 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Repository; +if (!defined('_PS_VERSION_')) { + exit; +} + interface TaxRuleRepositoryInterface extends ReadOnlyRepositoryInterface { public function getTaxRule(int $taxRulesGroupId, int $countryId, int $stateId): array; diff --git a/src/Repository/TaxRulesGroupRepository.php b/src/Repository/TaxRulesGroupRepository.php index 45d5fe81f..5899bd576 100644 --- a/src/Repository/TaxRulesGroupRepository.php +++ b/src/Repository/TaxRulesGroupRepository.php @@ -1,10 +1,24 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Repository; use Db; use DbQuery; +if (!defined('_PS_VERSION_')) { + exit; +} + class TaxRulesGroupRepository extends AbstractRepository implements TaxRulesGroupRepositoryInterface { public function __construct() diff --git a/src/Repository/TaxRulesGroupRepositoryInterface.php b/src/Repository/TaxRulesGroupRepositoryInterface.php index f88334d94..4666ea9c1 100644 --- a/src/Repository/TaxRulesGroupRepositoryInterface.php +++ b/src/Repository/TaxRulesGroupRepositoryInterface.php @@ -1,7 +1,21 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Repository; +if (!defined('_PS_VERSION_')) { + exit; +} + interface TaxRulesGroupRepositoryInterface extends ReadOnlyRepositoryInterface { public function getTaxRulesGroups(int $shopId): array; diff --git a/src/Service/ApiKeyService.php b/src/Service/ApiKeyService.php index 3a95ea692..1157a78ae 100644 --- a/src/Service/ApiKeyService.php +++ b/src/Service/ApiKeyService.php @@ -18,6 +18,10 @@ use Mollie\Api\MollieApiClient; use Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + class ApiKeyService { /** diff --git a/src/Service/ApiService.php b/src/Service/ApiService.php index c3cc74204..75481c529 100644 --- a/src/Service/ApiService.php +++ b/src/Service/ApiService.php @@ -14,7 +14,7 @@ use Exception; use Mollie\Adapter\ConfigurationAdapter; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; use Mollie\Api\Exceptions\ApiException; use Mollie\Api\MollieApiClient; use Mollie\Api\Resources\BaseCollection; @@ -32,7 +32,10 @@ use MolPaymentMethod; use PrestaShopDatabaseException; use PrestaShopException; -use Shop; + +if (!defined('_PS_VERSION_')) { + exit; +} class ApiService implements ApiServiceInterface { @@ -68,13 +71,9 @@ class ApiService implements ApiServiceInterface */ private $transactionService; - /** - * @var Shop - */ - private $shop; /** @var TaxCalculatorProvider */ private $taxCalculatorProvider; - /** @var LegacyContext */ + /** @var Context */ private $context; public function __construct( @@ -83,9 +82,8 @@ public function __construct( PaymentMethodSortProviderInterface $paymentMethodSortProvider, ConfigurationAdapter $configurationAdapter, TransactionService $transactionService, - Shop $shop, TaxCalculatorProvider $taxCalculatorProvider, - LegacyContext $context + Context $context ) { $this->countryRepository = $countryRepository; $this->paymentMethodSortProvider = $paymentMethodSortProvider; @@ -93,7 +91,6 @@ public function __construct( $this->configurationAdapter = $configurationAdapter; $this->environment = (int) $this->configurationAdapter->get(Config::MOLLIE_ENVIRONMENT); $this->transactionService = $transactionService; - $this->shop = $shop; $this->taxCalculatorProvider = $taxCalculatorProvider; $this->context = $context; } @@ -412,7 +409,7 @@ public function requestApplePayPaymentSession($api, string $validationUrl): stri throw new MollieApiException('Mollie API is null. Check if API key is correct', MollieApiException::MOLLIE_API_IS_NULL); } - return $api->wallets->requestApplePayPaymentSession($this->shop->domain, $validationUrl); + return $api->wallets->requestApplePayPaymentSession($this->context->getShopDomain(), $validationUrl); } private function getSurchargeFixedAmountTaxInclPrice(float $priceTaxExcl, int $taxRulesGroupId, int $countryId): float diff --git a/src/Service/ApiServiceInterface.php b/src/Service/ApiServiceInterface.php index 6febdc97a..317ffdeab 100644 --- a/src/Service/ApiServiceInterface.php +++ b/src/Service/ApiServiceInterface.php @@ -16,6 +16,10 @@ use Mollie\Api\MollieApiClient; use Mollie\Exception\MollieApiException; +if (!defined('_PS_VERSION_')) { + exit; +} + interface ApiServiceInterface { /** diff --git a/src/Service/CancelService.php b/src/Service/CancelService.php index a34af7abc..672bbb1ec 100644 --- a/src/Service/CancelService.php +++ b/src/Service/CancelService.php @@ -15,9 +15,14 @@ use Mollie; use Mollie\Api\Exceptions\ApiException; use Mollie\Api\Resources\Order; +use Mollie\Factory\ModuleFactory; use PrestaShopDatabaseException; use PrestaShopException; +if (!defined('_PS_VERSION_')) { + exit; +} + class CancelService { const FILE_NAME = 'CancelService'; @@ -26,15 +31,9 @@ class CancelService */ private $module; - /** - * @var TransactionService - */ - private $transactionService; - - public function __construct(Mollie $module, TransactionService $transactionService) + public function __construct(ModuleFactory $moduleFactory) { - $this->module = $module; - $this->transactionService = $transactionService; + $this->module = $moduleFactory->getModule(); } /** diff --git a/src/Service/CarrierService.php b/src/Service/CarrierService.php index 021b6cc4e..07768877c 100644 --- a/src/Service/CarrierService.php +++ b/src/Service/CarrierService.php @@ -17,6 +17,10 @@ use Context; use Mollie\Config\Config; +if (!defined('_PS_VERSION_')) { + exit; +} + class CarrierService { /** diff --git a/src/Service/CartLinesService.php b/src/Service/CartLinesService.php index 7ac75dfc6..a8d966d27 100644 --- a/src/Service/CartLinesService.php +++ b/src/Service/CartLinesService.php @@ -13,7 +13,7 @@ namespace Mollie\Service; use Cart; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; use Mollie\Adapter\ToolsAdapter; use Mollie\Config\Config; use Mollie\DTO\Line; @@ -24,6 +24,10 @@ use Mollie\Utility\NumberUtility; use Mollie\Utility\TextFormatUtility; +if (!defined('_PS_VERSION_')) { + exit; +} + class CartLinesService { /** @@ -40,10 +44,10 @@ class CartLinesService * @var ToolsAdapter */ private $tools; - /** @var LegacyContext */ + /** @var Context */ private $context; - public function __construct(LanguageService $languageService, VoucherService $voucherService, ToolsAdapter $tools, LegacyContext $context) + public function __construct(LanguageService $languageService, VoucherService $voucherService, ToolsAdapter $tools, Context $context) { $this->voucherService = $voucherService; $this->languageService = $languageService; diff --git a/src/Service/ConfigFieldService.php b/src/Service/ConfigFieldService.php index 0a150b18a..774c04186 100644 --- a/src/Service/ConfigFieldService.php +++ b/src/Service/ConfigFieldService.php @@ -12,11 +12,16 @@ namespace Mollie\Service; -use Configuration; use Mollie; use Mollie\Adapter\ConfigurationAdapter; use Mollie\Config\Config; +use Mollie\Factory\ModuleFactory; use Mollie\Repository\CountryRepository; +use Mollie\Utility\EnvironmentUtility; + +if (!defined('_PS_VERSION_')) { + exit; +} class ConfigFieldService { @@ -36,12 +41,12 @@ class ConfigFieldService private $configurationAdapter; public function __construct( - Mollie $module, + ModuleFactory $moduleFactory, ApiService $apiService, CountryRepository $countryRepository, ConfigurationAdapter $configurationAdapter ) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->apiService = $apiService; $this->countryRepository = $countryRepository; $this->configurationAdapter = $configurationAdapter; @@ -53,67 +58,71 @@ public function __construct( public function getConfigFieldsValues() { $configFields = [ - Config::MOLLIE_ENVIRONMENT => Configuration::get(Config::MOLLIE_ENVIRONMENT), - Config::MOLLIE_API_KEY => Configuration::get(Config::MOLLIE_API_KEY), - Config::MOLLIE_API_KEY_TEST => Configuration::get(Config::MOLLIE_API_KEY_TEST), - Config::MOLLIE_PAYMENTSCREEN_LOCALE => Configuration::get(Config::MOLLIE_PAYMENTSCREEN_LOCALE), - Config::MOLLIE_SEND_ORDER_CONFIRMATION => Configuration::get(Config::MOLLIE_SEND_ORDER_CONFIRMATION), + Config::MOLLIE_ENVIRONMENT => $this->configurationAdapter->get(Config::MOLLIE_ENVIRONMENT), + Config::MOLLIE_API_KEY => $this->configurationAdapter->get(Config::MOLLIE_API_KEY), + Config::MOLLIE_API_KEY_TEST => $this->configurationAdapter->get(Config::MOLLIE_API_KEY_TEST), + Config::MOLLIE_PAYMENTSCREEN_LOCALE => $this->configurationAdapter->get(Config::MOLLIE_PAYMENTSCREEN_LOCALE), + Config::MOLLIE_SEND_ORDER_CONFIRMATION => $this->configurationAdapter->get(Config::MOLLIE_SEND_ORDER_CONFIRMATION), Config::MOLLIE_IFRAME[(int) $this->configurationAdapter->get(Config::MOLLIE_ENVIRONMENT) ? 'production' : 'sandbox'] => $this->configurationAdapter->get(Config::MOLLIE_IFRAME), Config::MOLLIE_SINGLE_CLICK_PAYMENT[(int) $this->configurationAdapter->get(Config::MOLLIE_ENVIRONMENT) ? 'production' : 'sandbox'] => $this->configurationAdapter->get(Config::MOLLIE_SINGLE_CLICK_PAYMENT), - Config::MOLLIE_CSS => Configuration::get(Config::MOLLIE_CSS), - Config::MOLLIE_IMAGES => Configuration::get(Config::MOLLIE_IMAGES), - Config::MOLLIE_SHOW_RESEND_PAYMENT_LINK => Configuration::get(Config::MOLLIE_SHOW_RESEND_PAYMENT_LINK), + Config::MOLLIE_CSS => $this->configurationAdapter->get(Config::MOLLIE_CSS), + Config::MOLLIE_IMAGES => $this->configurationAdapter->get(Config::MOLLIE_IMAGES), + Config::MOLLIE_SHOW_RESEND_PAYMENT_LINK => $this->configurationAdapter->get(Config::MOLLIE_SHOW_RESEND_PAYMENT_LINK), Config::MOLLIE_ISSUERS[(int) $this->configurationAdapter->get(Config::MOLLIE_ENVIRONMENT) ? 'production' : 'sandbox'] => $this->configurationAdapter->get(Config::MOLLIE_ISSUERS), - Config::MOLLIE_METHOD_COUNTRIES => Configuration::get(Config::MOLLIE_METHOD_COUNTRIES), - Config::MOLLIE_METHOD_COUNTRIES_DISPLAY => Configuration::get(Config::MOLLIE_METHOD_COUNTRIES_DISPLAY), - - Config::MOLLIE_STATUS_OPEN => Configuration::get(Config::MOLLIE_STATUS_OPEN), - Config::MOLLIE_STATUS_AWAITING => Configuration::get(Config::MOLLIE_STATUS_AWAITING), - Config::MOLLIE_STATUS_PAID => Configuration::get(Config::MOLLIE_STATUS_PAID), - Config::MOLLIE_STATUS_COMPLETED => Configuration::get(Config::MOLLIE_STATUS_COMPLETED), - Config::MOLLIE_STATUS_CANCELED => Configuration::get(Config::MOLLIE_STATUS_CANCELED), - Config::MOLLIE_STATUS_EXPIRED => Configuration::get(Config::MOLLIE_STATUS_EXPIRED), - Config::MOLLIE_STATUS_PARTIAL_REFUND => Configuration::get(Config::MOLLIE_STATUS_PARTIAL_REFUND), - Config::MOLLIE_STATUS_REFUNDED => Configuration::get(Config::MOLLIE_STATUS_REFUNDED), - Config::MOLLIE_STATUS_CHARGEBACK => Configuration::get(Config::MOLLIE_STATUS_CHARGEBACK), - Config::MOLLIE_MAIL_WHEN_OPEN => Configuration::get(Config::MOLLIE_MAIL_WHEN_OPEN), - Config::MOLLIE_MAIL_WHEN_AWAITING => Configuration::get(Config::MOLLIE_MAIL_WHEN_AWAITING), - Config::MOLLIE_MAIL_WHEN_PAID => Configuration::get(Config::MOLLIE_MAIL_WHEN_PAID), - Config::MOLLIE_MAIL_WHEN_COMPLETED => Configuration::get(Config::MOLLIE_MAIL_WHEN_COMPLETED), - Config::MOLLIE_MAIL_WHEN_CANCELED => Configuration::get(Config::MOLLIE_MAIL_WHEN_CANCELED), - Config::MOLLIE_MAIL_WHEN_EXPIRED => Configuration::get(Config::MOLLIE_MAIL_WHEN_EXPIRED), - Config::MOLLIE_MAIL_WHEN_REFUNDED => Configuration::get(Config::MOLLIE_MAIL_WHEN_REFUNDED), - Config::MOLLIE_MAIL_WHEN_CHARGEBACK => Configuration::get(Config::MOLLIE_MAIL_WHEN_CHARGEBACK), - Config::MOLLIE_ACCOUNT_SWITCH => Configuration::get(Config::MOLLIE_ACCOUNT_SWITCH), - - Config::MOLLIE_DISPLAY_ERRORS => Configuration::get(Config::MOLLIE_DISPLAY_ERRORS), - Config::MOLLIE_DEBUG_LOG => Configuration::get(Config::MOLLIE_DEBUG_LOG), - Config::MOLLIE_API => Configuration::get(Config::MOLLIE_API), - - Config::MOLLIE_AUTO_SHIP_MAIN => Configuration::get(Config::MOLLIE_AUTO_SHIP_MAIN), - - Config::MOLLIE_STATUS_SHIPPING => Configuration::get(Config::MOLLIE_STATUS_SHIPPING), - Config::MOLLIE_MAIL_WHEN_SHIPPING => Configuration::get(Config::MOLLIE_MAIL_WHEN_SHIPPING), - Config::MOLLIE_KLARNA_INVOICE_ON => Configuration::get(Config::MOLLIE_KLARNA_INVOICE_ON), + Config::MOLLIE_METHOD_COUNTRIES => $this->configurationAdapter->get(Config::MOLLIE_METHOD_COUNTRIES), + Config::MOLLIE_METHOD_COUNTRIES_DISPLAY => $this->configurationAdapter->get(Config::MOLLIE_METHOD_COUNTRIES_DISPLAY), + + Config::MOLLIE_STATUS_OPEN => $this->configurationAdapter->get(Config::MOLLIE_STATUS_OPEN), + Config::MOLLIE_STATUS_AWAITING => $this->configurationAdapter->get(Config::MOLLIE_STATUS_AWAITING), + Config::MOLLIE_STATUS_PAID => $this->configurationAdapter->get(Config::MOLLIE_STATUS_PAID), + Config::MOLLIE_STATUS_COMPLETED => $this->configurationAdapter->get(Config::MOLLIE_STATUS_COMPLETED), + Config::MOLLIE_STATUS_CANCELED => $this->configurationAdapter->get(Config::MOLLIE_STATUS_CANCELED), + Config::MOLLIE_STATUS_EXPIRED => $this->configurationAdapter->get(Config::MOLLIE_STATUS_EXPIRED), + Config::MOLLIE_STATUS_PARTIAL_REFUND => $this->configurationAdapter->get(Config::MOLLIE_STATUS_PARTIAL_REFUND), + Config::MOLLIE_STATUS_REFUNDED => $this->configurationAdapter->get(Config::MOLLIE_STATUS_REFUNDED), + Config::MOLLIE_STATUS_CHARGEBACK => $this->configurationAdapter->get(Config::MOLLIE_STATUS_CHARGEBACK), + Config::MOLLIE_MAIL_WHEN_OPEN => $this->configurationAdapter->get(Config::MOLLIE_MAIL_WHEN_OPEN), + Config::MOLLIE_MAIL_WHEN_AWAITING => $this->configurationAdapter->get(Config::MOLLIE_MAIL_WHEN_AWAITING), + Config::MOLLIE_MAIL_WHEN_PAID => $this->configurationAdapter->get(Config::MOLLIE_MAIL_WHEN_PAID), + Config::MOLLIE_MAIL_WHEN_COMPLETED => $this->configurationAdapter->get(Config::MOLLIE_MAIL_WHEN_COMPLETED), + Config::MOLLIE_MAIL_WHEN_CANCELED => $this->configurationAdapter->get(Config::MOLLIE_MAIL_WHEN_CANCELED), + Config::MOLLIE_MAIL_WHEN_EXPIRED => $this->configurationAdapter->get(Config::MOLLIE_MAIL_WHEN_EXPIRED), + Config::MOLLIE_MAIL_WHEN_REFUNDED => $this->configurationAdapter->get(Config::MOLLIE_MAIL_WHEN_REFUNDED), + Config::MOLLIE_MAIL_WHEN_CHARGEBACK => $this->configurationAdapter->get(Config::MOLLIE_MAIL_WHEN_CHARGEBACK), + Config::MOLLIE_ACCOUNT_SWITCH => $this->configurationAdapter->get(Config::MOLLIE_ACCOUNT_SWITCH), + + Config::MOLLIE_DISPLAY_ERRORS => $this->configurationAdapter->get(Config::MOLLIE_DISPLAY_ERRORS), + Config::MOLLIE_DEBUG_LOG => $this->configurationAdapter->get(Config::MOLLIE_DEBUG_LOG), + Config::MOLLIE_API => $this->configurationAdapter->get(Config::MOLLIE_API), + + Config::MOLLIE_AUTO_SHIP_MAIN => $this->configurationAdapter->get(Config::MOLLIE_AUTO_SHIP_MAIN), + + Config::MOLLIE_STATUS_SHIPPING => $this->configurationAdapter->get(Config::MOLLIE_STATUS_SHIPPING), + Config::MOLLIE_MAIL_WHEN_SHIPPING => $this->configurationAdapter->get(Config::MOLLIE_MAIL_WHEN_SHIPPING), + Config::MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS => $this->configurationAdapter->get(Config::MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS), ]; - if (Mollie\Utility\EnvironmentUtility::getApiKey() && $this->module->getApiClient() !== null) { + if (EnvironmentUtility::getApiKey() && $this->module->getApiClient() !== null) { foreach ($this->apiService->getMethodsForConfig($this->module->getApiClient()) as $method) { $countryIds = $this->countryRepository->getMethodCountryIds($method['id']); + if ($countryIds) { - $configFields = array_merge($configFields, [Config::MOLLIE_COUNTRIES . $method['id'] . '[]' => $countryIds]); + $configFields[Config::MOLLIE_COUNTRIES . $method['id'] . '[]'] = $countryIds; + continue; } - $configFields = array_merge($configFields, [Config::MOLLIE_COUNTRIES . $method['id'] . '[]' => []]); + + $configFields[Config::MOLLIE_COUNTRIES . $method['id'] . '[]'] = []; } } $checkStatuses = []; - if (Configuration::get(Config::MOLLIE_AUTO_SHIP_STATUSES)) { - $checkConfs = @json_decode(Configuration::get(Config::MOLLIE_AUTO_SHIP_STATUSES), true); + if ($this->configurationAdapter->get(Config::MOLLIE_AUTO_SHIP_STATUSES)) { + $checkConfs = @json_decode($this->configurationAdapter->get(Config::MOLLIE_AUTO_SHIP_STATUSES), true); } + if (!isset($checkConfs) || !is_array($checkConfs)) { $checkConfs = []; } @@ -122,8 +131,6 @@ public function getConfigFieldsValues() $checkStatuses[Config::MOLLIE_AUTO_SHIP_STATUSES . '_' . (int) $conf] = true; } - $configFields = array_merge($configFields, $checkStatuses); - - return $configFields; + return array_merge($configFields, $checkStatuses); } } diff --git a/src/Service/Content/SmartyTemplateParser.php b/src/Service/Content/SmartyTemplateParser.php index 9538315fb..095eda0dd 100644 --- a/src/Service/Content/SmartyTemplateParser.php +++ b/src/Service/Content/SmartyTemplateParser.php @@ -15,6 +15,10 @@ use Mollie\Builder\TemplateBuilderInterface; use Smarty; +if (!defined('_PS_VERSION_')) { + exit; +} + class SmartyTemplateParser implements TemplateParserInterface { /** diff --git a/src/Service/Content/TemplateParserInterface.php b/src/Service/Content/TemplateParserInterface.php index 85c3fba26..c325477c0 100644 --- a/src/Service/Content/TemplateParserInterface.php +++ b/src/Service/Content/TemplateParserInterface.php @@ -15,6 +15,10 @@ use Mollie\Builder\TemplateBuilderInterface; use Smarty; +if (!defined('_PS_VERSION_')) { + exit; +} + interface TemplateParserInterface { /** diff --git a/src/Service/CountryService.php b/src/Service/CountryService.php index af9f41fd1..d77d2bb68 100644 --- a/src/Service/CountryService.php +++ b/src/Service/CountryService.php @@ -15,6 +15,11 @@ use Context; use Country; use Mollie; +use Mollie\Factory\ModuleFactory; + +if (!defined('_PS_VERSION_')) { + exit; +} class CountryService { @@ -25,9 +30,9 @@ class CountryService */ private $module; - public function __construct(Mollie $module) + public function __construct(ModuleFactory $moduleFactory) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); } public function getActiveCountriesList($onlyActive = true) diff --git a/src/Service/CustomerService.php b/src/Service/CustomerService.php index 73bd4c4d9..514e042ad 100644 --- a/src/Service/CustomerService.php +++ b/src/Service/CustomerService.php @@ -16,9 +16,14 @@ use Mollie; use Mollie\Config\Config; use Mollie\Exception\MollieException; +use Mollie\Factory\ModuleFactory; use Mollie\Repository\MolCustomerRepository; use Mollie\Utility\CustomerUtility; +if (!defined('_PS_VERSION_')) { + exit; +} + class CustomerService { /** @@ -31,9 +36,9 @@ class CustomerService */ private $customerRepository; - public function __construct(Mollie $mollie, MolCustomerRepository $customerRepository) + public function __construct(ModuleFactory $moduleFactory, MolCustomerRepository $customerRepository) { - $this->mollie = $mollie; + $this->mollie = $moduleFactory->getModule(); $this->customerRepository = $customerRepository; } diff --git a/src/Service/EntityManager/EntityManagerInterface.php b/src/Service/EntityManager/EntityManagerInterface.php index 849e4610e..769343bae 100644 --- a/src/Service/EntityManager/EntityManagerInterface.php +++ b/src/Service/EntityManager/EntityManagerInterface.php @@ -12,15 +12,29 @@ namespace Mollie\Service\EntityManager; -use ObjectModel; -use PrestaShopException; +if (!defined('_PS_VERSION_')) { + exit; +} interface EntityManagerInterface { /** - * @param ObjectModel $model + * @param \ObjectModel $model + * @param string $unitOfWorkType - @see ObjectModelUnitOfWork + * @param string|null $specificKey + * + * @return EntityManagerInterface + */ + public function persist( + \ObjectModel $model, + string $unitOfWorkType, + $specificKey = null + ): EntityManagerInterface; + + /** + * @return array<\ObjectModel> * - * @throws PrestaShopException + * @throws \PrestaShopException */ - public function flush(ObjectModel $model); + public function flush(): array; } diff --git a/src/Service/EntityManager/ObjectModelManager.php b/src/Service/EntityManager/ObjectModelManager.php index 55e0a8b30..218b2659d 100644 --- a/src/Service/EntityManager/ObjectModelManager.php +++ b/src/Service/EntityManager/ObjectModelManager.php @@ -12,17 +12,66 @@ namespace Mollie\Service\EntityManager; -use ObjectModel; +if (!defined('_PS_VERSION_')) { + exit; +} class ObjectModelManager implements EntityManagerInterface { + private $unitOfWork; + + public function __construct(ObjectModelUnitOfWork $unitOfWork) + { + $this->unitOfWork = $unitOfWork; + } + + /** + * @param \ObjectModel $model + * @param string $unitOfWorkType + * @param string|null $specificKey + * for example external_id key to make it easier to keep + * track of which object model is related to which external_id + * + * @return EntityManagerInterface + */ + public function persist( + \ObjectModel $model, + string $unitOfWorkType, + $specificKey = null + ): EntityManagerInterface { + $this->unitOfWork->setWork($model, $unitOfWorkType, $specificKey); + + return $this; + } + /** - * @param ObjectModel $model + * @return array<\ObjectModel> * - * @throws \PrestaShopException + * @throws \Throwable */ - public function flush(ObjectModel $model) + public function flush(): array { - $model->save(); + $persistenceModels = $this->unitOfWork->getWork(); + $persistedModels = []; + + foreach ($persistenceModels as $externalId => $persistenceModel) { + if ($persistenceModel['unit_of_work_type'] === ObjectModelUnitOfWork::UNIT_OF_WORK_SAVE) { + $persistenceModel['object']->save(); + } + + if ($persistenceModel['unit_of_work_type'] === ObjectModelUnitOfWork::UNIT_OF_WORK_DELETE) { + $persistenceModel['object']->delete(); + } + + if (!empty($externalId)) { + $persistedModels[$externalId] = $persistenceModel['object']; + } else { + $persistedModels[] = $persistenceModel['object']; + } + } + + $this->unitOfWork->clearWork(); + + return $persistedModels; } } diff --git a/src/Service/EntityManager/ObjectModelUnitOfWork.php b/src/Service/EntityManager/ObjectModelUnitOfWork.php new file mode 100644 index 000000000..b3390b31d --- /dev/null +++ b/src/Service/EntityManager/ObjectModelUnitOfWork.php @@ -0,0 +1,60 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Service\EntityManager; + +if (!defined('_PS_VERSION_')) { + exit; +} + +/** In memory entity manager object model unit of work */ +class ObjectModelUnitOfWork +{ + const UNIT_OF_WORK_SAVE = 'UNIT_OF_WORK_SAVE'; + const UNIT_OF_WORK_DELETE = 'UNIT_OF_WORK_DELETE'; + + private $work = []; + + /** + * @param \ObjectModel $objectModel + * @param string $unitOfWorkType + * @param string|null $specificKey + * + * @return void + */ + public function setWork(\ObjectModel $objectModel, string $unitOfWorkType, $specificKey) + { + $work = [ + 'unit_of_work_type' => $unitOfWorkType, + 'object' => $objectModel, + ]; + + if (!is_null($specificKey)) { + $this->work[$specificKey] = $work; + } else { + $this->work[] = $work; + } + } + + /** + * @return array + */ + public function getWork(): array + { + return $this->work; + } + + public function clearWork() + { + $this->work = []; + } +} diff --git a/src/Service/ErrorDisplayService.php b/src/Service/ErrorDisplayService.php index b037cd644..cd4963f55 100644 --- a/src/Service/ErrorDisplayService.php +++ b/src/Service/ErrorDisplayService.php @@ -14,6 +14,10 @@ use Context; use Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + class ErrorDisplayService { public function showCookieError($id) diff --git a/src/Service/ExceptionService.php b/src/Service/ExceptionService.php index 403a04b6e..87cd16635 100644 --- a/src/Service/ExceptionService.php +++ b/src/Service/ExceptionService.php @@ -15,6 +15,11 @@ use Mollie; use Mollie\Exception\OrderCreationException; use Mollie\Exception\ShipmentCannotBeSentException; +use Mollie\Factory\ModuleFactory; + +if (!defined('_PS_VERSION_')) { + exit; +} class ExceptionService { @@ -25,9 +30,9 @@ class ExceptionService */ private $module; - public function __construct(Mollie $module) + public function __construct(ModuleFactory $moduleFactory) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); } public function getErrorMessages() diff --git a/src/Service/IssuerService.php b/src/Service/IssuerService.php index 7ef2fc50f..dd3df7a89 100644 --- a/src/Service/IssuerService.php +++ b/src/Service/IssuerService.php @@ -16,12 +16,17 @@ use Context; use Mollie; use Mollie\Api\Types\PaymentMethod; -use Mollie\Repository\PaymentMethodRepository; +use Mollie\Factory\ModuleFactory; +use Mollie\Repository\PaymentMethodRepositoryInterface; + +if (!defined('_PS_VERSION_')) { + exit; +} class IssuerService { /** - * @var PaymentMethodRepository + * @var PaymentMethodRepositoryInterface */ private $paymentMethodRepository; /** @@ -29,10 +34,10 @@ class IssuerService */ private $module; - public function __construct(Mollie $module, PaymentMethodRepository $paymentMethodRepository) + public function __construct(ModuleFactory $moduleFactory, PaymentMethodRepositoryInterface $paymentMethodRepository) { $this->paymentMethodRepository = $paymentMethodRepository; - $this->module = $module; + $this->module = $moduleFactory; } public function getIdealIssuers() diff --git a/src/Service/LanguageService.php b/src/Service/LanguageService.php index 729d21cdd..a8644d771 100644 --- a/src/Service/LanguageService.php +++ b/src/Service/LanguageService.php @@ -17,6 +17,11 @@ use Mollie\Api\Types\PaymentStatus; use Mollie\Api\Types\RefundStatus; use Mollie\Config\Config; +use Mollie\Factory\ModuleFactory; + +if (!defined('_PS_VERSION_')) { + exit; +} class LanguageService { @@ -27,9 +32,9 @@ class LanguageService */ private $module; - public function __construct(Mollie $module) + public function __construct(ModuleFactory $moduleFactory) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); } public function getLang() diff --git a/src/Service/MailService.php b/src/Service/MailService.php index 5bad9a314..1c3963ab3 100644 --- a/src/Service/MailService.php +++ b/src/Service/MailService.php @@ -24,6 +24,7 @@ use Language; use Mail; use Mollie; +use Mollie\Factory\ModuleFactory; use Order; use OrderState; use PDF; @@ -31,6 +32,10 @@ use State; use Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + class MailService { const FILE_NAME = 'MailService'; @@ -45,9 +50,9 @@ class MailService */ private $context; - public function __construct(Mollie $module) + public function __construct(ModuleFactory $moduleFactory) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->context = Context::getContext(); } diff --git a/src/Service/MolCarrierInformationService.php b/src/Service/MolCarrierInformationService.php index d0524ee91..3868acc2b 100644 --- a/src/Service/MolCarrierInformationService.php +++ b/src/Service/MolCarrierInformationService.php @@ -18,6 +18,10 @@ use Mollie\Config\Config; use Mollie\Repository\MolCarrierInformationRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class MolCarrierInformationService { /** diff --git a/src/Service/MollieOrderCreationService.php b/src/Service/MollieOrderCreationService.php index 4214cbdb4..134d2431d 100644 --- a/src/Service/MollieOrderCreationService.php +++ b/src/Service/MollieOrderCreationService.php @@ -22,11 +22,16 @@ use Mollie\DTO\OrderData; use Mollie\DTO\PaymentData; use Mollie\Exception\OrderCreationException; +use Mollie\Factory\ModuleFactory; use Mollie\Handler\ErrorHandler\ErrorHandler; use Mollie\Handler\Exception\OrderExceptionHandler; use MolPaymentMethod; use PrestaShopException; +if (!defined('_PS_VERSION_')) { + exit; +} + class MollieOrderCreationService { /** @@ -38,10 +43,10 @@ class MollieOrderCreationService */ private $module; - public function __construct(OrderExceptionHandler $exceptionHandler, Mollie $module) + public function __construct(OrderExceptionHandler $exceptionHandler, ModuleFactory $moduleFactory) { $this->exceptionHandler = $exceptionHandler; - $this->module = $module; + $this->module = $moduleFactory->getModule(); } /** diff --git a/src/Service/MollieOrderInfoService.php b/src/Service/MollieOrderInfoService.php index c2c3d7ebb..dcbbed087 100644 --- a/src/Service/MollieOrderInfoService.php +++ b/src/Service/MollieOrderInfoService.php @@ -14,10 +14,15 @@ use Exception; use Mollie; +use Mollie\Factory\ModuleFactory; use Mollie\Repository\PaymentMethodRepositoryInterface; use Order; use PrestaShopLogger; +if (!defined('_PS_VERSION_')) { + exit; +} + class MollieOrderInfoService { /** @@ -50,7 +55,7 @@ class MollieOrderInfoService private $apiService; public function __construct( - Mollie $module, + ModuleFactory $moduleFactory, PaymentMethodRepositoryInterface $paymentMethodRepository, RefundService $refundService, ShipService $shipService, @@ -58,7 +63,7 @@ public function __construct( ShipmentServiceInterface $shipmentService, ApiService $apiService ) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->paymentMethodRepository = $paymentMethodRepository; $this->refundService = $refundService; $this->shipService = $shipService; diff --git a/src/Service/MolliePaymentMailService.php b/src/Service/MolliePaymentMailService.php index 5423912da..376bdd104 100644 --- a/src/Service/MolliePaymentMailService.php +++ b/src/Service/MolliePaymentMailService.php @@ -20,17 +20,22 @@ use Mollie\Api\MollieApiClient; use Mollie\Api\Resources\Payment; use Mollie\Api\Types\PaymentStatus; -use Mollie\Repository\PaymentMethodRepository; +use Mollie\Factory\ModuleFactory; +use Mollie\Repository\PaymentMethodRepositoryInterface; use Mollie\Utility\SecureKeyUtility; use Mollie\Utility\TransactionUtility; use Order; +if (!defined('_PS_VERSION_')) { + exit; +} + class MolliePaymentMailService { const FILE_NAME = 'MolliePaymentMailService'; /** - * @var PaymentMethodRepository + * @var PaymentMethodRepositoryInterface */ private $paymentMethodRepository; @@ -45,11 +50,11 @@ class MolliePaymentMailService private $mailService; public function __construct( - Mollie $module, - PaymentMethodRepository $paymentMethodRepository, + ModuleFactory $moduleFactory, + PaymentMethodRepositoryInterface $paymentMethodRepository, MailService $mailService ) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->paymentMethodRepository = $paymentMethodRepository; $this->mailService = $mailService; } diff --git a/src/Service/OrderPaymentFeeService.php b/src/Service/OrderPaymentFeeService.php index 22858338b..90bb3e690 100644 --- a/src/Service/OrderPaymentFeeService.php +++ b/src/Service/OrderPaymentFeeService.php @@ -13,6 +13,7 @@ namespace Mollie\Service; use Configuration; +use Mollie\Adapter\Context; use Mollie\Config\Config; use Mollie\DTO\PaymentFeeData; use Mollie\Provider\PaymentFeeProviderInterface; @@ -20,25 +21,28 @@ use MolOrderPaymentFee; use MolPaymentMethod; use PrestaShopException; -use Shop; + +if (!defined('_PS_VERSION_')) { + exit; +} class OrderPaymentFeeService { /** @var PaymentMethodRepositoryInterface */ private $paymentMethodRepository; - /** @var Shop */ - private $shop; /** @var PaymentFeeProviderInterface */ private $paymentFeeProvider; + /** @var Context */ + private $context; public function __construct( PaymentMethodRepositoryInterface $paymentMethodRepository, - Shop $shop, - PaymentFeeProviderInterface $paymentFeeProvider + PaymentFeeProviderInterface $paymentFeeProvider, + Context $context ) { $this->paymentMethodRepository = $paymentMethodRepository; - $this->shop = $shop; $this->paymentFeeProvider = $paymentFeeProvider; + $this->context = $context; } public function createOrderPaymentFee(int $orderId, int $cartId, PaymentFeeData $paymentFeeData) @@ -66,7 +70,7 @@ public function getPaymentFee(float $totalAmount, string $method): PaymentFeeDat // TODO order and payment fee in same service? Separate logic as this is probably used in cart context $environment = Configuration::get(Config::MOLLIE_ENVIRONMENT); - $paymentId = $this->paymentMethodRepository->getPaymentMethodIdByMethodId($method, $environment, $this->shop->id); + $paymentId = $this->paymentMethodRepository->getPaymentMethodIdByMethodId($method, $environment, $this->context->getShopId()); $molPaymentMethod = new MolPaymentMethod($paymentId); return $this->paymentFeeProvider->getPaymentFee($molPaymentMethod, $totalAmount); diff --git a/src/Service/OrderStateImageService.php b/src/Service/OrderStateImageService.php index a497b0f6b..5f11f0d40 100644 --- a/src/Service/OrderStateImageService.php +++ b/src/Service/OrderStateImageService.php @@ -11,6 +11,10 @@ namespace Mollie\Service; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderStateImageService { /** diff --git a/src/Service/OrderStatusService.php b/src/Service/OrderStatusService.php index 1d4c26d0e..bfa1dab0a 100644 --- a/src/Service/OrderStatusService.php +++ b/src/Service/OrderStatusService.php @@ -25,6 +25,10 @@ use Tools; use Validate; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderStatusService { /** @@ -157,6 +161,6 @@ private function isStatusPaid($statusId) { return ((int) $statusId === (int) Configuration::get(Config::MOLLIE_STATUS_PAID)) || ((int) $statusId === (int) Configuration::get(Config::STATUS_PS_OS_OUTOFSTOCK_PAID)) || - ((int) $statusId === (int) Configuration::get(Config::MOLLIE_STATUS_KLARNA_AUTHORIZED)); + ((int) $statusId === (int) Configuration::get(Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED)); } } diff --git a/src/Service/PaymentMethod/PaymentMethodRestrictionValidation.php b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation.php index d0cdcd30c..818f9bf1e 100644 --- a/src/Service/PaymentMethod/PaymentMethodRestrictionValidation.php +++ b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation.php @@ -42,6 +42,10 @@ use MolPaymentMethod; use PrestaShopLogger; +if (!defined('_PS_VERSION_')) { + exit; +} + class PaymentMethodRestrictionValidation implements PaymentMethodRestrictionValidationInterface { /** diff --git a/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/AmountPaymentMethodRestrictionValidator.php b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/AmountPaymentMethodRestrictionValidator.php index fb5ae183a..a1c769746 100644 --- a/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/AmountPaymentMethodRestrictionValidator.php +++ b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/AmountPaymentMethodRestrictionValidator.php @@ -36,18 +36,21 @@ namespace Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation; -use Mollie\Adapter\LegacyContext; -use MolPaymentMethod; +use Mollie\Adapter\Context; use PrestaShop\Decimal\Number; +if (!defined('_PS_VERSION_')) { + exit; +} + /** Validator to check if cart total is valid for amount restrictions */ class AmountPaymentMethodRestrictionValidator implements PaymentMethodRestrictionValidatorInterface { - /** @var LegacyContext */ + /** @var Context */ private $context; public function __construct( - LegacyContext $context + Context $context ) { $this->context = $context; } @@ -55,7 +58,7 @@ public function __construct( /** * {@inheritDoc} */ - public function isValid(MolPaymentMethod $paymentMethod) + public function isValid(\MolPaymentMethod $paymentMethod): bool { $orderTotal = $this->context->getCart()->getOrderTotal(); @@ -77,7 +80,7 @@ public function isValid(MolPaymentMethod $paymentMethod) /** * {@inheritDoc} */ - public function supports(MolPaymentMethod $paymentMethod) + public function supports(\MolPaymentMethod $paymentMethod): bool { return true; } diff --git a/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/ApplePayPaymentMethodRestrictionValidator.php b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/ApplePayPaymentMethodRestrictionValidator.php index ee210a1a9..1fabcc577 100644 --- a/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/ApplePayPaymentMethodRestrictionValidator.php +++ b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/ApplePayPaymentMethodRestrictionValidator.php @@ -37,34 +37,29 @@ namespace Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation; use Mollie\Adapter\ConfigurationAdapter; -use Mollie\Adapter\LegacyContext; -use Mollie\Config\Config; -use MolPaymentMethod; +use Mollie\Api\Types\PaymentMethod; + +if (!defined('_PS_VERSION_')) { + exit; +} class ApplePayPaymentMethodRestrictionValidator implements PaymentMethodRestrictionValidatorInterface { - /** - * @var LegacyContext - */ - private $context; - /** * @var ConfigurationAdapter */ private $configurationAdapter; public function __construct( - LegacyContext $context, ConfigurationAdapter $configurationAdapter ) { - $this->context = $context; $this->configurationAdapter = $configurationAdapter; } /** * {@inheritDoc} */ - public function isValid(MolPaymentMethod $paymentMethod) + public function isValid(\MolPaymentMethod $paymentMethod): bool { if (!$this->isSslEnabledEverywhere()) { return false; @@ -80,15 +75,15 @@ public function isValid(MolPaymentMethod $paymentMethod) /** * {@inheritDoc} */ - public function supports(MolPaymentMethod $paymentMethod) + public function supports(\MolPaymentMethod $paymentMethod): bool { - return $paymentMethod->getPaymentMethodName() == Config::MOLLIE_METHOD_ID_APPLE_PAY; + return $paymentMethod->getPaymentMethodName() === PaymentMethod::APPLEPAY; } /** * @return bool */ - private function isSslEnabledEverywhere() + private function isSslEnabledEverywhere(): bool { return (bool) $this->configurationAdapter->get('PS_SSL_ENABLED_EVERYWHERE'); } @@ -96,7 +91,7 @@ private function isSslEnabledEverywhere() /** * @return bool */ - private function isPaymentMethodInCookie() + private function isPaymentMethodInCookie(): bool { if (!isset($_COOKIE['isApplePayMethod'])) { return false; diff --git a/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/B2bPaymentMethodRestrictionValidator.php b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/B2bPaymentMethodRestrictionValidator.php new file mode 100644 index 000000000..c8464a80d --- /dev/null +++ b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/B2bPaymentMethodRestrictionValidator.php @@ -0,0 +1,118 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation; + +use Mollie\Adapter\ConfigurationAdapter; +use Mollie\Adapter\Context; +use Mollie\Config\Config; +use Mollie\Repository\AddressFormatRepositoryInterface; +use Mollie\Repository\AddressRepositoryInterface; +use Mollie\Repository\CustomerRepositoryInterface; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class B2bPaymentMethodRestrictionValidator implements PaymentMethodRestrictionValidatorInterface +{ + /** @var Context */ + private $context; + /** @var AddressRepositoryInterface */ + private $addressRepository; + /** @var CustomerRepositoryInterface */ + private $customerRepository; + /** @var ConfigurationAdapter */ + private $configuration; + /** @var AddressFormatRepositoryInterface */ + private $addressFormatRepository; + + public function __construct( + Context $context, + AddressRepositoryInterface $addressRepository, + CustomerRepositoryInterface $customerRepository, + ConfigurationAdapter $configuration, + AddressFormatRepositoryInterface $addressFormatRepository + ) { + $this->context = $context; + $this->addressRepository = $addressRepository; + $this->customerRepository = $customerRepository; + $this->configuration = $configuration; + $this->addressFormatRepository = $addressFormatRepository; + } + + /** + * {@inheritDoc} + */ + public function isValid(\MolPaymentMethod $paymentMethod): bool + { + if (!$this->isB2bEnabled()) { + return false; + } + + if (!$this->isIdentificationNumberValid()) { + return false; + } + + if (!$this->isVatNumberValid()) { + return false; + } + + return true; + } + + /** + * {@inheritDoc} + */ + public function supports(\MolPaymentMethod $paymentMethod): bool + { + return $paymentMethod->getPaymentMethodName() === Config::MOLLIE_PAYMENT_METHOD_BILLIE; + } + + private function isIdentificationNumberValid(): bool + { + $customerId = $this->context->getCustomerId(); + + /** @var \Customer $customer */ + $customer = $this->customerRepository->findOneBy([ + 'id_customer' => $customerId, + ]); + + return !empty($customer->siret); + } + + private function isVatNumberValid(): bool + { + $billingAddressId = $this->context->getInvoiceAddressId(); + + /** @var \Address $billingAddress */ + $billingAddress = $this->addressRepository->findOneBy([ + 'id_address' => $billingAddressId, + ]); + + /** @var \AddressFormat $addressFormat */ + $addressFormat = $this->addressFormatRepository->findOneBy([ + 'id_country' => $billingAddress->id_country, + ]); + + if (!str_contains($addressFormat->getFormat($billingAddress->id_country), 'vat_number')) { + return true; + } + + return !empty($billingAddress->vat_number); + } + + private function isB2bEnabled(): bool + { + return (bool) (int) $this->configuration->get('PS_B2B_ENABLE'); + } +} diff --git a/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/BasePaymentMethodRestrictionValidator.php b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/BasePaymentMethodRestrictionValidator.php index 8dafb669f..4162e56b0 100644 --- a/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/BasePaymentMethodRestrictionValidator.php +++ b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/BasePaymentMethodRestrictionValidator.php @@ -36,7 +36,9 @@ namespace Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation; -use MolPaymentMethod; +if (!defined('_PS_VERSION_')) { + exit; +} /** Validator to check all cases for every payment method */ class BasePaymentMethodRestrictionValidator implements PaymentMethodRestrictionValidatorInterface @@ -44,7 +46,7 @@ class BasePaymentMethodRestrictionValidator implements PaymentMethodRestrictionV /** * {@inheritDoc} */ - public function isValid(MolPaymentMethod $paymentMethod) + public function isValid(\MolPaymentMethod $paymentMethod): bool { if (!$this->isPaymentMethodEnabled($paymentMethod)) { return false; @@ -56,17 +58,17 @@ public function isValid(MolPaymentMethod $paymentMethod) /** * {@inheritDoc} */ - public function supports(MolPaymentMethod $paymentMethod) + public function supports(\MolPaymentMethod $paymentMethod): bool { return true; } /** - * @param MolPaymentMethod $paymentMethod + * @param \MolPaymentMethod $paymentMethod * * @return bool */ - private function isPaymentMethodEnabled($paymentMethod) + private function isPaymentMethodEnabled(\MolPaymentMethod $paymentMethod): bool { return (bool) $paymentMethod->enabled; } diff --git a/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/EnvironmentVersionSpecificPaymentMethodRestrictionValidator.php b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/EnvironmentVersionSpecificPaymentMethodRestrictionValidator.php index 0d9d14f21..91693eb36 100644 --- a/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/EnvironmentVersionSpecificPaymentMethodRestrictionValidator.php +++ b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/EnvironmentVersionSpecificPaymentMethodRestrictionValidator.php @@ -36,16 +36,19 @@ namespace Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; use Mollie\Provider\EnvironmentVersionProviderInterface; use Mollie\Repository\MethodCountryRepository; -use MolPaymentMethod; + +if (!defined('_PS_VERSION_')) { + exit; +} /** Validator to check specific cases by environment version for every payment method */ class EnvironmentVersionSpecificPaymentMethodRestrictionValidator implements PaymentMethodRestrictionValidatorInterface { /** - * @var LegacyContext + * @var Context */ private $context; @@ -60,7 +63,7 @@ class EnvironmentVersionSpecificPaymentMethodRestrictionValidator implements Pay private $methodCountryRepository; public function __construct( - LegacyContext $context, + Context $context, EnvironmentVersionProviderInterface $prestashopVersionProvider, MethodCountryRepository $methodCountryRepository ) { @@ -72,7 +75,7 @@ public function __construct( /** * {@inheritDoc} */ - public function isValid(MolPaymentMethod $paymentMethod) + public function isValid(\MolPaymentMethod $paymentMethod): bool { if (version_compare($this->prestashopVersionProvider->getPrestashopVersion(), '1.6.0.9', '>')) { if (!$this->isCountryAvailable($paymentMethod)) { @@ -86,12 +89,12 @@ public function isValid(MolPaymentMethod $paymentMethod) /** * {@inheritDoc} */ - public function supports(MolPaymentMethod $paymentMethod) + public function supports(\MolPaymentMethod $paymentMethod): bool { return true; } - private function isCountryAvailable(MolPaymentMethod $paymentMethod) + private function isCountryAvailable(\MolPaymentMethod $paymentMethod) { if ($paymentMethod->is_countries_applicable) { return $this->methodCountryRepository->checkIfMethodIsAvailableInCountry( diff --git a/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/PaymentMethodRestrictionValidatorInterface.php b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/PaymentMethodRestrictionValidatorInterface.php index 102a6aa3d..81fdf9ae0 100644 --- a/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/PaymentMethodRestrictionValidatorInterface.php +++ b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/PaymentMethodRestrictionValidatorInterface.php @@ -36,25 +36,27 @@ namespace Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation; -use MolPaymentMethod; +if (!defined('_PS_VERSION_')) { + exit; +} interface PaymentMethodRestrictionValidatorInterface { /** * Returns if payment is valid * - * @param MolPaymentMethod $paymentMethod + * @param \MolPaymentMethod $paymentMethod * * @return bool */ - public function isValid(MolPaymentMethod $paymentMethod); + public function isValid(\MolPaymentMethod $paymentMethod): bool; /** * Returns if payment restriction validator is supported by payment name * - * @param MolPaymentMethod $paymentMethod + * @param \MolPaymentMethod $paymentMethod * * @return bool */ - public function supports(MolPaymentMethod $paymentMethod); + public function supports(\MolPaymentMethod $paymentMethod): bool; } diff --git a/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/VoucherPaymentMethodRestrictionValidator.php b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/VoucherPaymentMethodRestrictionValidator.php index d7adb4413..3d88bf7c9 100644 --- a/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/VoucherPaymentMethodRestrictionValidator.php +++ b/src/Service/PaymentMethod/PaymentMethodRestrictionValidation/VoucherPaymentMethodRestrictionValidator.php @@ -36,15 +36,18 @@ namespace Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; use Mollie\Config\Config; use Mollie\Validator\VoucherValidator; -use MolPaymentMethod; + +if (!defined('_PS_VERSION_')) { + exit; +} class VoucherPaymentMethodRestrictionValidator implements PaymentMethodRestrictionValidatorInterface { /** - * @var LegacyContext + * @var Context */ private $context; @@ -53,7 +56,7 @@ class VoucherPaymentMethodRestrictionValidator implements PaymentMethodRestricti */ private $voucherValidator; - public function __construct(LegacyContext $context, VoucherValidator $voucherValidator) + public function __construct(Context $context, VoucherValidator $voucherValidator) { $this->context = $context; $this->voucherValidator = $voucherValidator; @@ -63,7 +66,7 @@ public function __construct(LegacyContext $context, VoucherValidator $voucherVal * TODO extract voucher validator internals into this class + tests. * {@inheritDoc} */ - public function isValid(MolPaymentMethod $paymentMethod) + public function isValid(\MolPaymentMethod $paymentMethod): bool { if (!$this->voucherValidator->validate($this->context->getCart()->getProducts())) { return false; @@ -75,8 +78,8 @@ public function isValid(MolPaymentMethod $paymentMethod) /** * {@inheritDoc} */ - public function supports(MolPaymentMethod $paymentMethod) + public function supports(\MolPaymentMethod $paymentMethod): bool { - return $paymentMethod->getPaymentMethodName() == Config::MOLLIE_VOUCHER_METHOD_ID; + return $paymentMethod->getPaymentMethodName() === Config::MOLLIE_VOUCHER_METHOD_ID; } } diff --git a/src/Service/PaymentMethod/PaymentMethodRestrictionValidationInterface.php b/src/Service/PaymentMethod/PaymentMethodRestrictionValidationInterface.php index 4a3479b97..93b4eec36 100644 --- a/src/Service/PaymentMethod/PaymentMethodRestrictionValidationInterface.php +++ b/src/Service/PaymentMethod/PaymentMethodRestrictionValidationInterface.php @@ -38,6 +38,10 @@ use MolPaymentMethod; +if (!defined('_PS_VERSION_')) { + exit; +} + interface PaymentMethodRestrictionValidationInterface { /** diff --git a/src/Service/PaymentMethod/PaymentMethodSortProvider.php b/src/Service/PaymentMethod/PaymentMethodSortProvider.php index a073ccdbe..57ec2b792 100644 --- a/src/Service/PaymentMethod/PaymentMethodSortProvider.php +++ b/src/Service/PaymentMethod/PaymentMethodSortProvider.php @@ -12,6 +12,10 @@ namespace Mollie\Service\PaymentMethod; +if (!defined('_PS_VERSION_')) { + exit; +} + final class PaymentMethodSortProvider implements PaymentMethodSortProviderInterface { public function getSortedInAscendingWayForCheckout(array $paymentMethods) diff --git a/src/Service/PaymentMethod/PaymentMethodSortProviderInterface.php b/src/Service/PaymentMethod/PaymentMethodSortProviderInterface.php index 3ca77efdd..7c7d7941c 100644 --- a/src/Service/PaymentMethod/PaymentMethodSortProviderInterface.php +++ b/src/Service/PaymentMethod/PaymentMethodSortProviderInterface.php @@ -12,6 +12,10 @@ namespace Mollie\Service\PaymentMethod; +if (!defined('_PS_VERSION_')) { + exit; +} + /** * Payment methods are being retrieved both from api and the ones stored in database. The ones that are stored * can be dragged in admin so this service can be used to call anywhere and sort payment options accordingly. diff --git a/src/Service/PaymentMethodService.php b/src/Service/PaymentMethodService.php index f99a75759..dd1f8dd45 100644 --- a/src/Service/PaymentMethodService.php +++ b/src/Service/PaymentMethodService.php @@ -21,15 +21,18 @@ use Gender; use Mollie; use Mollie\Adapter\ConfigurationAdapter; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; use Mollie\Api\Resources\BaseCollection; use Mollie\Api\Resources\MethodCollection; use Mollie\Api\Types\PaymentMethod; use Mollie\Config\Config; use Mollie\DTO\Object\Amount; +use Mollie\DTO\Object\Company; +use Mollie\DTO\Object\Payment; use Mollie\DTO\OrderData; use Mollie\DTO\PaymentData; use Mollie\Exception\OrderCreationException; +use Mollie\Factory\ModuleFactory; use Mollie\Provider\CreditCardLogoProvider; use Mollie\Provider\OrderTotal\OrderTotalProviderInterface; use Mollie\Provider\PaymentFeeProviderInterface; @@ -45,9 +48,12 @@ use MolPaymentMethod; use PrestaShopDatabaseException; use PrestaShopException; -use Shop; use Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + class PaymentMethodService { /** @@ -89,23 +95,19 @@ class PaymentMethodService */ private $paymentMethodRestrictionValidation; - /** - * @var Shop - */ - private $shop; /** @var GenderRepositoryInterface */ private $genderRepository; /** @var ConfigurationAdapter */ private $configurationAdapter; /** @var PaymentFeeProviderInterface */ private $paymentFeeProvider; - /** @var LegacyContext */ + /** @var Context */ private $context; /** @var OrderTotalProviderInterface */ private $orderTotalProvider; public function __construct( - Mollie $module, + ModuleFactory $moduleFactory, PaymentMethodRepositoryInterface $methodRepository, CartLinesService $cartLinesService, PaymentsTranslationService $paymentsTranslationService, @@ -114,14 +116,13 @@ public function __construct( PaymentMethodSortProviderInterface $paymentMethodSortProvider, PhoneNumberProviderInterface $phoneNumberProvider, PaymentMethodRestrictionValidationInterface $paymentMethodRestrictionValidation, - Shop $shop, GenderRepositoryInterface $genderRepository, ConfigurationAdapter $configurationAdapter, PaymentFeeProviderInterface $paymentFeeProvider, - LegacyContext $context, + Context $context, OrderTotalProviderInterface $orderTotalProvider ) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->methodRepository = $methodRepository; $this->cartLinesService = $cartLinesService; $this->paymentsTranslationService = $paymentsTranslationService; @@ -130,7 +131,6 @@ public function __construct( $this->paymentMethodSortProvider = $paymentMethodSortProvider; $this->phoneNumberProvider = $phoneNumberProvider; $this->paymentMethodRestrictionValidation = $paymentMethodRestrictionValidation; - $this->shop = $shop; $this->genderRepository = $genderRepository; $this->configurationAdapter = $configurationAdapter; $this->paymentFeeProvider = $paymentFeeProvider; @@ -196,7 +196,7 @@ public function getMethodsForCheckout() return []; } $apiEnvironment = Configuration::get(Config::MOLLIE_ENVIRONMENT); - $methods = $this->methodRepository->getMethodsForCheckout($apiEnvironment, $this->shop->id) ?: []; + $methods = $this->methodRepository->getMethodsForCheckout($apiEnvironment, $this->context->getShopId()) ?: []; try { $mollieMethods = $this->getSupportedMollieMethods(); @@ -358,14 +358,27 @@ public function getPaymentData( if (isset($cart->id_address_invoice)) { $billingAddress = new Address((int) $cart->id_address_invoice); + $company = new Company(); + + if (!empty($billingAddress->vat_number)) { + $company->setVatNumber($billingAddress->vat_number); + } + + if (!empty($customer->siret)) { + $company->setRegistrationNumber($customer->siret); + } + $orderData->setBillingAddress($billingAddress); $orderData->setBillingPhoneNumber($this->phoneNumberProvider->getFromAddress($billingAddress)); } + if (isset($cart->id_address_delivery)) { $shippingAddress = new Address((int) $cart->id_address_delivery); + $orderData->setShippingAddress($shippingAddress); $orderData->setDeliveryPhoneNumber($this->phoneNumberProvider->getFromAddress($shippingAddress)); } + $orderData->setOrderNumber($orderReference); $orderData->setLocale($this->getLocale($molPaymentMethod->method)); $orderData->setEmail($customer->email); @@ -397,30 +410,38 @@ public function getPaymentData( (bool) Configuration::get('PS_GIFT_WRAPPING'), $selectedVoucherCategory )); - $payment = []; - if ($cardToken) { - $payment['cardToken'] = $cardToken; + + $payment = new Payment(); + + if (!empty($cardToken)) { + $payment->setCardToken($cardToken); } - $payment['webhookUrl'] = $this->context->getModuleLink( + + $payment->setWebhookUrl($this->context->getModuleLink( 'mollie', 'webhook', [], true - ); + )); - if ($issuer) { - $payment['issuer'] = $issuer; + if (!empty($issuer)) { + $payment->setIssuer($issuer); } if ($molPaymentMethod->id_method === PaymentMethod::CREDITCARD) { $molCustomer = $this->handleCustomerInfo($cart->id_customer, $saveCard, $useSavedCard); - if ($molCustomer) { - $payment['customerId'] = $molCustomer->customer_id; + + if ($molCustomer && !empty($molCustomer->customer_id)) { + $payment->setCustomerId($molCustomer->customer_id); } } - if ($molPaymentMethod->id_method === PaymentMethod::APPLEPAY && $applePayToken) { - $payment['applePayPaymentToken'] = $applePayToken; + if ($molPaymentMethod->id_method === PaymentMethod::APPLEPAY && !empty($applePayToken)) { + $payment->setApplePayPaymentToken($applePayToken); + } + + if (isset($company)) { + $payment->setCompany($company); } $orderData->setPayment($payment); @@ -472,7 +493,7 @@ private function removeNotSupportedMethods($methods, $mollieMethods) private function getSupportedMollieMethods() { - $address = new Address($this->context->getAddressInvoiceId()); + $address = new Address($this->context->getInvoiceAddressId()); $country = new Country($address->id_country); $cartAmount = $this->orderTotalProvider->getOrderTotal(); diff --git a/src/Service/PaymentReturnService.php b/src/Service/PaymentReturnService.php index 8a7bf1688..4350bc0bb 100644 --- a/src/Service/PaymentReturnService.php +++ b/src/Service/PaymentReturnService.php @@ -16,10 +16,14 @@ use CartRule; use Context; use Mollie; +use Mollie\Factory\ModuleFactory; use Mollie\Handler\CartRule\CartRuleQuantityChangeHandlerInterface; -use Mollie\Repository\PaymentMethodRepository; use Order; +if (!defined('_PS_VERSION_')) { + exit; +} + class PaymentReturnService { const PENDING = 1; @@ -36,38 +40,24 @@ class PaymentReturnService */ private $context; - /** - * @var PaymentMethodRepository - */ - private $paymentMethodRepository; - /** * @var RepeatOrderLinkFactory */ private $orderLinkFactory; - /** - * @var TransactionService - */ - private $transactionService; - /** * @var CartRuleQuantityChangeHandlerInterface */ private $cartRuleQuantityChangeHandlerInterface; public function __construct( - Mollie $module, - PaymentMethodRepository $paymentMethodRepository, + ModuleFactory $moduleFactory, RepeatOrderLinkFactory $orderLinkFactory, - TransactionService $transactionService, CartRuleQuantityChangeHandlerInterface $cartRuleQuantityChangeHandlerInterface ) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->context = Context::getContext(); - $this->paymentMethodRepository = $paymentMethodRepository; $this->orderLinkFactory = $orderLinkFactory; - $this->transactionService = $transactionService; $this->cartRuleQuantityChangeHandlerInterface = $cartRuleQuantityChangeHandlerInterface; } diff --git a/src/Service/PaymentsTranslationService.php b/src/Service/PaymentsTranslationService.php index 817324eb5..8d36f546b 100644 --- a/src/Service/PaymentsTranslationService.php +++ b/src/Service/PaymentsTranslationService.php @@ -12,24 +12,19 @@ namespace Mollie\Service; -use Mollie; +if (!defined('_PS_VERSION_')) { + exit; +} class PaymentsTranslationService { - /** - * @var Mollie - */ - private $module; /** * @var LanguageService */ private $languageService; - public function __construct( - Mollie $module, - LanguageService $languageService - ) { - $this->module = $module; + public function __construct(LanguageService $languageService) + { $this->languageService = $languageService; } diff --git a/src/Service/RefundService.php b/src/Service/RefundService.php index f21e1ece5..9b2218961 100644 --- a/src/Service/RefundService.php +++ b/src/Service/RefundService.php @@ -17,11 +17,16 @@ use Mollie\Api\Resources\Order as MollieOrderAlias; use Mollie\Api\Resources\Payment; use Mollie\Api\Resources\PaymentCollection; +use Mollie\Factory\ModuleFactory; use Mollie\Utility\RefundUtility; use Mollie\Utility\TextFormatUtility; use PrestaShopDatabaseException; use PrestaShopException; +if (!defined('_PS_VERSION_')) { + exit; +} + class RefundService { const FILE_NAME = 'RefundService'; @@ -31,15 +36,9 @@ class RefundService */ private $module; - /** - * @var TransactionService - */ - private $transactionService; - - public function __construct(Mollie $module, TransactionService $transactionService) + public function __construct(ModuleFactory $moduleFactory) { - $this->module = $module; - $this->transactionService = $transactionService; + $this->module = $moduleFactory->getModule(); } /** diff --git a/src/Service/RepeatOrderLinkFactory.php b/src/Service/RepeatOrderLinkFactory.php index 1a3ca5d7e..4289e3ad6 100644 --- a/src/Service/RepeatOrderLinkFactory.php +++ b/src/Service/RepeatOrderLinkFactory.php @@ -12,6 +12,10 @@ namespace Mollie\Service; +if (!defined('_PS_VERSION_')) { + exit; +} + class RepeatOrderLinkFactory { public function getLink() diff --git a/src/Service/SettingsSaveService.php b/src/Service/SettingsSaveService.php index 5244aa095..647b23b06 100644 --- a/src/Service/SettingsSaveService.php +++ b/src/Service/SettingsSaveService.php @@ -13,28 +13,31 @@ namespace Mollie\Service; use Carrier; -use Configuration; -use Context; use Exception; use Mollie; use Mollie\Adapter\ConfigurationAdapter; +use Mollie\Adapter\Context; use Mollie\Api\Exceptions\ApiException; use Mollie\Api\Types\PaymentStatus; use Mollie\Config\Config; use Mollie\Exception\MollieException; +use Mollie\Factory\ModuleFactory; use Mollie\Handler\Certificate\CertificateHandlerInterface; use Mollie\Handler\Certificate\Exception\ApplePayDirectCertificateCreation; use Mollie\Handler\Settings\PaymentMethodPositionHandlerInterface; use Mollie\Repository\CountryRepository; -use Mollie\Repository\PaymentMethodRepository; +use Mollie\Repository\PaymentMethodRepositoryInterface; use Mollie\Utility\TagsUtility; use MolPaymentMethodIssuer; use OrderState; use PrestaShopDatabaseException; use PrestaShopException; -use Shop; use Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + class SettingsSaveService { const FILE_NAME = 'SettingsSaveService'; @@ -50,7 +53,7 @@ class SettingsSaveService private $countryRepository; /** - * @var PaymentMethodRepository + * @var PaymentMethodRepositoryInterface */ private $paymentMethodRepository; @@ -84,25 +87,25 @@ class SettingsSaveService */ private $applePayDirectCertificateHandler; - /** @var Shop */ - private $shop; /** @var ConfigurationAdapter */ private $configurationAdapter; + /** @var Context */ + private $context; public function __construct( - Mollie $module, + ModuleFactory $moduleFactory, CountryRepository $countryRepository, - PaymentMethodRepository $paymentMethodRepository, + PaymentMethodRepositoryInterface $paymentMethodRepository, PaymentMethodService $paymentMethodService, ApiService $apiService, MolCarrierInformationService $carrierInformationService, PaymentMethodPositionHandlerInterface $paymentMethodPositionHandler, ApiKeyService $apiKeyService, CertificateHandlerInterface $applePayDirectCertificateHandler, - Shop $shop, - ConfigurationAdapter $configurationAdapter + ConfigurationAdapter $configurationAdapter, + Context $context ) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->countryRepository = $countryRepository; $this->paymentMethodRepository = $paymentMethodRepository; $this->paymentMethodService = $paymentMethodService; @@ -111,8 +114,8 @@ public function __construct( $this->paymentMethodPositionHandler = $paymentMethodPositionHandler; $this->apiService = $apiService; $this->applePayDirectCertificateHandler = $applePayDirectCertificateHandler; - $this->shop = $shop; $this->configurationAdapter = $configurationAdapter; + $this->context = $context; } /** @@ -126,7 +129,7 @@ public function __construct( */ public function saveSettings(&$errors = []) { - $oldEnvironment = (int) Configuration::get(Config::MOLLIE_ENVIRONMENT); + $oldEnvironment = (int) $this->configurationAdapter->get(Config::MOLLIE_ENVIRONMENT); $environment = (int) Tools::getValue(Config::MOLLIE_ENVIRONMENT); $mollieApiKey = Tools::getValue(Config::MOLLIE_API_KEY); $mollieApiKeyTest = Tools::getValue(Config::MOLLIE_API_KEY_TEST); @@ -203,7 +206,7 @@ public function saveSettings(&$errors = []) $this->countryRepository->updatePaymentMethodCountries($paymentMethodId, $countries); $this->countryRepository->updatePaymentMethodExcludedCountries($paymentMethodId, $excludedCountries); } - $this->paymentMethodRepository->deleteOldPaymentMethods($savedPaymentMethods, $environment, (int) $this->shop->id); + $this->paymentMethodRepository->deleteOldPaymentMethods($savedPaymentMethods, $environment, $this->context->getShopId()); } if ($paymentOptionPositions) { @@ -281,9 +284,9 @@ public function saveSettings(&$errors = []) } } try { - $this->handleKlarnaInvoiceStatus(); + $this->handleAuthorizablePaymentInvoiceStatus(); } catch (Exception $e) { - $errors[] = $this->module->l('There are issues with your Klarna statuses, please try resetting Mollie module.', self::FILE_NAME); + $errors[] = $this->module->l('There are issues with your authorizable payment statuses, please try resetting Mollie module.', self::FILE_NAME); } if (empty($errors)) { @@ -321,7 +324,7 @@ public function saveSettings(&$errors = []) json_encode(@json_decode(Tools::getValue(Config::MOLLIE_TRACKING_URLS))) ); $carriers = Carrier::getCarriers( - Context::getContext()->language->id, + $this->context->getLanguageId(), false, false, false, @@ -374,8 +377,8 @@ public function saveSettings(&$errors = []) private function getStatusesValue($key) { $statesEnabled = []; - $context = Context::getContext(); - foreach (OrderState::getOrderStates($context->language->id) as $state) { + + foreach (OrderState::getOrderStates($this->context->getLanguageId()) as $state) { if (Tools::isSubmit($key . '_' . $state['id_order_state'])) { $statesEnabled[] = $state['id_order_state']; } @@ -384,30 +387,33 @@ private function getStatusesValue($key) return $statesEnabled; } - private function handleKlarnaInvoiceStatus() + private function handleAuthorizablePaymentInvoiceStatus() { - $klarnaInvoiceStatus = Tools::getValue(Config::MOLLIE_KLARNA_INVOICE_ON); - $this->configurationAdapter->updateValue(Config::MOLLIE_KLARNA_INVOICE_ON, $klarnaInvoiceStatus); - if (Config::MOLLIE_STATUS_KLARNA_SHIPPED === $klarnaInvoiceStatus) { - $this->updateKlarnaStatuses(true); + $authorizablePaymentInvoiceOnStatus = (string) Tools::getValue(Config::MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS); + + $this->configurationAdapter->updateValue(Config::MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS, $authorizablePaymentInvoiceOnStatus); + + if (Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED === $authorizablePaymentInvoiceOnStatus) { + $this->updateAuthorizablePaymentOrderStatus(true); return; } - $this->updateKlarnaStatuses(false); + $this->updateAuthorizablePaymentOrderStatus(false); } - private function updateKlarnaStatuses($isShipped = true) + private function updateAuthorizablePaymentOrderStatus(bool $isShipped = true) { - $klarnaInvoiceShippedId = Configuration::get(Config::MOLLIE_STATUS_KLARNA_SHIPPED); - $klarnaInvoiceShipped = new OrderState((int) $klarnaInvoiceShippedId); - $klarnaInvoiceShipped->invoice = $isShipped; - $klarnaInvoiceShipped->update(); + $authorizablePaymentStatusShippedId = $this->configurationAdapter->get(Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED); + $authorizablePaymentStatusShipped = new OrderState((int) $authorizablePaymentStatusShippedId); + + $authorizablePaymentStatusShipped->invoice = $isShipped; + $authorizablePaymentStatusShipped->update(); - $klarnaInvoiceAcceptedId = Configuration::get(Config::MOLLIE_STATUS_KLARNA_AUTHORIZED); - $klarnaInvoiceAccepted = new OrderState((int) $klarnaInvoiceAcceptedId); + $authorizablePaymentStatusAuthorizedId = $this->configurationAdapter->get(Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED); + $authorizablePaymentStatusAuthorized = new OrderState((int) $authorizablePaymentStatusAuthorizedId); - $klarnaInvoiceAccepted->invoice = !$isShipped; - $klarnaInvoiceAccepted->update(); + $authorizablePaymentStatusAuthorized->invoice = !$isShipped; + $authorizablePaymentStatusAuthorized->update(); } } diff --git a/src/Service/ShipService.php b/src/Service/ShipService.php index 333139a12..280104a1f 100644 --- a/src/Service/ShipService.php +++ b/src/Service/ShipService.php @@ -15,6 +15,11 @@ use Mollie; use Mollie\Api\Exceptions\ApiException; use Mollie\Api\Resources\Order as MollieOrderAlias; +use Mollie\Factory\ModuleFactory; + +if (!defined('_PS_VERSION_')) { + exit; +} class ShipService { @@ -25,9 +30,9 @@ class ShipService */ private $module; - public function __construct(Mollie $module) + public function __construct(ModuleFactory $moduleFactory) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); } /** diff --git a/src/Service/Shipment/ShipmentInformationSender.php b/src/Service/Shipment/ShipmentInformationSender.php index 3a758d153..5a01f2c6c 100644 --- a/src/Service/Shipment/ShipmentInformationSender.php +++ b/src/Service/Shipment/ShipmentInformationSender.php @@ -17,6 +17,10 @@ use Mollie\Service\ShipmentServiceInterface; use Order; +if (!defined('_PS_VERSION_')) { + exit; +} + class ShipmentInformationSender implements ShipmentInformationSenderInterface { /** diff --git a/src/Service/Shipment/ShipmentInformationSenderInterface.php b/src/Service/Shipment/ShipmentInformationSenderInterface.php index d88432621..d3f996347 100644 --- a/src/Service/Shipment/ShipmentInformationSenderInterface.php +++ b/src/Service/Shipment/ShipmentInformationSenderInterface.php @@ -16,6 +16,10 @@ use Mollie\Api\MollieApiClient; use Order; +if (!defined('_PS_VERSION_')) { + exit; +} + interface ShipmentInformationSenderInterface { /** diff --git a/src/Service/ShipmentService.php b/src/Service/ShipmentService.php index b3b4f1e0f..c7be0b171 100644 --- a/src/Service/ShipmentService.php +++ b/src/Service/ShipmentService.php @@ -29,6 +29,10 @@ use Tools; use Validate; +if (!defined('_PS_VERSION_')) { + exit; +} + class ShipmentService implements ShipmentServiceInterface { /** diff --git a/src/Service/ShipmentServiceInterface.php b/src/Service/ShipmentServiceInterface.php index 091121842..dd44128c4 100644 --- a/src/Service/ShipmentServiceInterface.php +++ b/src/Service/ShipmentServiceInterface.php @@ -15,6 +15,10 @@ use PrestaShopDatabaseException; use PrestaShopException; +if (!defined('_PS_VERSION_')) { + exit; +} + interface ShipmentServiceInterface { /** diff --git a/src/Service/TransactionService.php b/src/Service/TransactionService.php index c4451156c..3ff6bb82a 100644 --- a/src/Service/TransactionService.php +++ b/src/Service/TransactionService.php @@ -13,10 +13,10 @@ namespace Mollie\Service; use Cart; -use Configuration; use Currency; use Db; use Mollie; +use Mollie\Adapter\ConfigurationAdapter; use Mollie\Api\Exceptions\ApiException; use Mollie\Api\Resources\Order as MollieOrderAlias; use Mollie\Api\Resources\Payment; @@ -27,6 +27,7 @@ use Mollie\Errors\Http\HttpStatusCode; use Mollie\Exception\ShipmentCannotBeSentException; use Mollie\Exception\TransactionException; +use Mollie\Factory\ModuleFactory; use Mollie\Handler\Order\OrderCreationHandler; use Mollie\Handler\Order\OrderPaymentFeeHandler; use Mollie\Handler\Shipment\ShipmentSenderHandlerInterface; @@ -44,6 +45,10 @@ use PrestaShopException; use PrestaShopLogger; +if (!defined('_PS_VERSION_')) { + exit; +} + class TransactionService { /** @@ -78,9 +83,11 @@ class TransactionService private $logger; /** @var ExceptionService */ private $exceptionService; + /** @var ConfigurationAdapter */ + private $configurationAdapter; public function __construct( - Mollie $module, + ModuleFactory $moduleFactory, OrderStatusService $orderStatusService, PaymentMethodRepositoryInterface $paymentMethodRepository, OrderCreationHandler $orderCreationHandler, @@ -89,9 +96,10 @@ public function __construct( OrderPaymentFeeHandler $orderPaymentFeeHandler, ShipmentSenderHandlerInterface $shipmentSenderHandler, PrestaLoggerInterface $logger, - ExceptionService $exceptionService + ExceptionService $exceptionService, + ConfigurationAdapter $configurationAdapter ) { - $this->module = $module; + $this->module = $moduleFactory->getModule(); $this->orderStatusService = $orderStatusService; $this->paymentMethodRepository = $paymentMethodRepository; $this->orderCreationHandler = $orderCreationHandler; @@ -101,6 +109,7 @@ public function __construct( $this->shipmentSenderHandler = $shipmentSenderHandler; $this->logger = $logger; $this->exceptionService = $exceptionService; + $this->configurationAdapter = $configurationAdapter; } /** @@ -120,7 +129,7 @@ public function __construct( public function processTransaction($apiPayment) { if (empty($apiPayment)) { - if (Configuration::get(Config::MOLLIE_DEBUG_LOG) >= Config::DEBUG_LOG_ERRORS) { + if ($this->configurationAdapter->get(Config::MOLLIE_DEBUG_LOG) >= Config::DEBUG_LOG_ERRORS) { PrestaShopLogger::addLog(__METHOD__ . ' said: Received webhook request without proper transaction ID.', Config::WARNING); } @@ -198,10 +207,10 @@ public function processTransaction($apiPayment) throw new TransactionException('Cart id is missing in transaction metadata', HttpStatusCode::HTTP_UNPROCESSABLE_ENTITY); } - $isKlarnaOrder = in_array($apiPayment->method, Config::KLARNA_PAYMENTS, false); + $isAuthorizablePayment = in_array($apiPayment->method, Config::AUTHORIZABLE_PAYMENTS, false); if (!$orderId && $isPaymentFinished) { - $orderId = $this->orderCreationHandler->createOrder($apiPayment, $cart->id, $isKlarnaOrder); + $orderId = $this->orderCreationHandler->createOrder($apiPayment, $cart->id, $isAuthorizablePayment); if (!$orderId) { throw new TransactionException('Order is already created', HttpStatusCode::HTTP_METHOD_NOT_ALLOWED); @@ -256,9 +265,16 @@ public function processTransaction($apiPayment) $this->handleOrderDescription($apiPayment); } } else { - $isKlarnaDefault = Configuration::get(Config::MOLLIE_KLARNA_INVOICE_ON) === Config::MOLLIE_STATUS_DEFAULT; - if (in_array($apiPayment->method, Config::KLARNA_PAYMENTS) && !$isKlarnaDefault && $apiPayment->status === OrderStatus::STATUS_COMPLETED) { - $this->orderStatusService->setOrderStatus($orderId, Config::MOLLIE_STATUS_KLARNA_SHIPPED); + $isAuthorizablePaymentInvoiceOnStatusDefault = + $this->configurationAdapter->get(Config::MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS) + === Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_DEFAULT; + + if ( + !$isAuthorizablePaymentInvoiceOnStatusDefault + && $apiPayment->status === OrderStatus::STATUS_COMPLETED + && in_array($apiPayment->method, Config::AUTHORIZABLE_PAYMENTS, true) + ) { + $this->orderStatusService->setOrderStatus($orderId, Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED); } else { $this->orderStatusService->setOrderStatus($orderId, $apiPayment->status); } @@ -283,7 +299,7 @@ public function processTransaction($apiPayment) $this->savePaymentStatus($apiPayment->id, $apiPayment->status, $orderId); // Log successful webhook requests in extended log mode only - if (Config::DEBUG_LOG_ALL == Configuration::get(Config::MOLLIE_DEBUG_LOG)) { + if (Config::DEBUG_LOG_ALL == $this->configurationAdapter->get(Config::MOLLIE_DEBUG_LOG)) { PrestaShopLogger::addLog(__METHOD__ . ' said: Received webhook request for order ' . (int) $orderId . ' / transaction ' . $apiPayment->id, Config::NOTICE); } @@ -367,7 +383,7 @@ private function savePaymentStatus($transactionId, $status, $orderId) throw $e; } - if (!$result && Configuration::get(Config::MOLLIE_DEBUG_LOG) >= Config::DEBUG_LOG_ERRORS) { + if (!$result && $this->configurationAdapter->get(Config::MOLLIE_DEBUG_LOG) >= Config::DEBUG_LOG_ERRORS) { PrestaShopLogger::addLog(__METHOD__ . ' said: Could not save Mollie payment status for transaction "' . $transactionId . '". Reason: ' . Db::getInstance()->getMsgError(), Config::WARNING); } @@ -445,7 +461,7 @@ private function updateOrderPayments(array $transactionInfos, $orderReference) private function updateOrderDescription(MollieOrderAlias $apiPayment, int $orderId) { - $environment = (int) Configuration::get(Mollie\Config\Config::MOLLIE_ENVIRONMENT); + $environment = (int) $this->configurationAdapter->get(Mollie\Config\Config::MOLLIE_ENVIRONMENT); $paymentMethodId = $this->paymentMethodRepository->getPaymentMethodIdByMethodId($apiPayment->method, $environment); $paymentMethodObj = new MolPaymentMethod((int) $paymentMethodId); $orderNumber = TextGeneratorUtility::generateDescriptionFromCart($paymentMethodObj->description, $orderId); @@ -471,7 +487,7 @@ private function updatePaymentDescription(Payment $apiPayment, int $orderId): Pa if (!$orderId) { throw new TransactionException('Order does not exist', HttpStatusCode::HTTP_METHOD_NOT_ALLOWED); } - $environment = (int) Configuration::get(Mollie\Config\Config::MOLLIE_ENVIRONMENT); + $environment = (int) $this->configurationAdapter->get(Mollie\Config\Config::MOLLIE_ENVIRONMENT); $paymentMethodId = $this->paymentMethodRepository->getPaymentMethodIdByMethodId($apiPayment->method, $environment); $paymentMethodObj = new MolPaymentMethod((int) $paymentMethodId); $apiPayment->description = TextGeneratorUtility::generateDescriptionFromCart($paymentMethodObj->description, $orderId); diff --git a/src/Service/UpgradeNoticeService.php b/src/Service/UpgradeNoticeService.php index c86e3b755..f9a95762e 100644 --- a/src/Service/UpgradeNoticeService.php +++ b/src/Service/UpgradeNoticeService.php @@ -15,6 +15,10 @@ use Mollie\Config\Config; use Mollie\Utility\TimeUtility; +if (!defined('_PS_VERSION_')) { + exit; +} + class UpgradeNoticeService { /** diff --git a/src/Service/VoucherService.php b/src/Service/VoucherService.php index 81ac23239..1ed1a548f 100644 --- a/src/Service/VoucherService.php +++ b/src/Service/VoucherService.php @@ -16,6 +16,10 @@ use Mollie\Config\Config; use Mollie\Repository\AttributeRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class VoucherService { /** diff --git a/src/ServiceProvider/BaseServiceProvider.php b/src/ServiceProvider/BaseServiceProvider.php new file mode 100644 index 000000000..335c59deb --- /dev/null +++ b/src/ServiceProvider/BaseServiceProvider.php @@ -0,0 +1,237 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\ServiceProvider; + +use League\Container\Container; +use Mollie\Builder\ApiTestFeedbackBuilder; +use Mollie\Config\Config; +use Mollie\Factory\ModuleFactory; +use Mollie\Handler\Api\OrderEndpointPaymentTypeHandler; +use Mollie\Handler\Api\OrderEndpointPaymentTypeHandlerInterface; +use Mollie\Handler\CartRule\CartRuleQuantityChangeHandler; +use Mollie\Handler\CartRule\CartRuleQuantityChangeHandlerInterface; +use Mollie\Handler\Certificate\ApplePayDirectCertificateHandler; +use Mollie\Handler\Certificate\CertificateHandlerInterface; +use Mollie\Handler\PaymentOption\PaymentOptionHandler; +use Mollie\Handler\PaymentOption\PaymentOptionHandlerInterface; +use Mollie\Handler\RetryHandler; +use Mollie\Handler\RetryHandlerInterface; +use Mollie\Handler\Settings\PaymentMethodPositionHandler; +use Mollie\Handler\Settings\PaymentMethodPositionHandlerInterface; +use Mollie\Handler\Shipment\ShipmentSenderHandler; +use Mollie\Handler\Shipment\ShipmentSenderHandlerInterface; +use Mollie\Install\DatabaseTableUninstaller; +use Mollie\Install\UninstallerInterface; +use Mollie\Logger\PrestaLogger; +use Mollie\Logger\PrestaLoggerInterface; +use Mollie\Provider\CreditCardLogoProvider; +use Mollie\Provider\CustomLogoProviderInterface; +use Mollie\Provider\EnvironmentVersionProvider; +use Mollie\Provider\EnvironmentVersionProviderInterface; +use Mollie\Provider\OrderTotal\OrderTotalProvider; +use Mollie\Provider\OrderTotal\OrderTotalProviderInterface; +use Mollie\Provider\PaymentFeeProvider; +use Mollie\Provider\PaymentFeeProviderInterface; +use Mollie\Provider\PaymentType\PaymentTypeIdentificationProviderInterface; +use Mollie\Provider\PaymentType\RegularPaymentTypeIdentification; +use Mollie\Provider\PhoneNumberProvider; +use Mollie\Provider\PhoneNumberProviderInterface; +use Mollie\Provider\ProfileIdProvider; +use Mollie\Provider\ProfileIdProviderInterface; +use Mollie\Provider\Shipment\AutomaticShipmentSenderStatusesProvider; +use Mollie\Provider\Shipment\AutomaticShipmentSenderStatusesProviderInterface; +use Mollie\Provider\UpdateMessageProvider; +use Mollie\Provider\UpdateMessageProviderInterface; +use Mollie\Repository\AddressFormatRepository; +use Mollie\Repository\AddressFormatRepositoryInterface; +use Mollie\Repository\AddressRepository; +use Mollie\Repository\AddressRepositoryInterface; +use Mollie\Repository\CartRuleRepository; +use Mollie\Repository\CartRuleRepositoryInterface; +use Mollie\Repository\CurrencyRepository; +use Mollie\Repository\CurrencyRepositoryInterface; +use Mollie\Repository\CustomerRepository; +use Mollie\Repository\CustomerRepositoryInterface; +use Mollie\Repository\GenderRepository; +use Mollie\Repository\GenderRepositoryInterface; +use Mollie\Repository\MolCustomerRepository; +use Mollie\Repository\MolOrderPaymentFeeRepository; +use Mollie\Repository\MolOrderPaymentFeeRepositoryInterface; +use Mollie\Repository\OrderCartRuleRepository; +use Mollie\Repository\OrderCartRuleRepositoryInterface; +use Mollie\Repository\OrderRepository; +use Mollie\Repository\OrderRepositoryInterface; +use Mollie\Repository\PaymentMethodRepository; +use Mollie\Repository\PaymentMethodRepositoryInterface; +use Mollie\Repository\PendingOrderCartRuleRepository; +use Mollie\Repository\PendingOrderCartRuleRepositoryInterface; +use Mollie\Repository\TaxRepository; +use Mollie\Repository\TaxRepositoryInterface; +use Mollie\Repository\TaxRuleRepository; +use Mollie\Repository\TaxRuleRepositoryInterface; +use Mollie\Repository\TaxRulesGroupRepository; +use Mollie\Repository\TaxRulesGroupRepositoryInterface; +use Mollie\Service\ApiKeyService; +use Mollie\Service\ApiService; +use Mollie\Service\ApiServiceInterface; +use Mollie\Service\Content\SmartyTemplateParser; +use Mollie\Service\Content\TemplateParserInterface; +use Mollie\Service\EntityManager\EntityManagerInterface; +use Mollie\Service\EntityManager\ObjectModelManager; +use Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation; +use Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\AmountPaymentMethodRestrictionValidator; +use Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\ApplePayPaymentMethodRestrictionValidator; +use Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\B2bPaymentMethodRestrictionValidator; +use Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\BasePaymentMethodRestrictionValidator; +use Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\EnvironmentVersionSpecificPaymentMethodRestrictionValidator; +use Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\VoucherPaymentMethodRestrictionValidator; +use Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidationInterface; +use Mollie\Service\PaymentMethod\PaymentMethodSortProvider; +use Mollie\Service\PaymentMethod\PaymentMethodSortProviderInterface; +use Mollie\Service\Shipment\ShipmentInformationSender; +use Mollie\Service\Shipment\ShipmentInformationSenderInterface; +use Mollie\Service\ShipmentService; +use Mollie\Service\ShipmentServiceInterface; +use Mollie\Utility\Decoder\DecoderInterface; +use Mollie\Utility\Decoder\JsonDecoder; +use Mollie\Verification\PaymentType\CanBeRegularPaymentType; +use Mollie\Verification\PaymentType\PaymentTypeVerificationInterface; +use Mollie\Verification\Shipment\CanSendShipment; +use Mollie\Verification\Shipment\ShipmentVerificationInterface; +use PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts; +use PrestaShop\PsAccountsInstaller\Installer\Installer as PsAccountsInstaller; + +if (!defined('_PS_VERSION_')) { + exit; +} + +/** + * Load base services here which are usually required + */ +final class BaseServiceProvider +{ + private $extendedServices; + + public function __construct($extendedServices) + { + $this->extendedServices = $extendedServices; + } + + public function register(Container $container) + { + /* Logger */ + $this->addService($container, PrestaLoggerInterface::class, $container->get(PrestaLogger::class)); + + $this->addService($container, RetryHandlerInterface::class, $container->get(RetryHandler::class)); + + $this->addService($container, UninstallerInterface::class, $container->get(DatabaseTableUninstaller::class)); + + $this->addService($container, DecoderInterface::class, JsonDecoder::class); + + $this->addService($container, AddressRepositoryInterface::class, $container->get(AddressRepository::class)); + $this->addService($container, TaxRulesGroupRepositoryInterface::class, $container->get(TaxRulesGroupRepository::class)); + $this->addService($container, TaxRuleRepositoryInterface::class, $container->get(TaxRuleRepository::class)); + $this->addService($container, TaxRepositoryInterface::class, $container->get(TaxRepository::class)); + $this->addService($container, CustomerRepositoryInterface::class, CustomerRepository::class); + $this->addService($container, AddressFormatRepositoryInterface::class, AddressFormatRepository::class); + $this->addService($container, PendingOrderCartRuleRepositoryInterface::class, $container->get(PendingOrderCartRuleRepository::class)); + $this->addService($container, CartRuleRepositoryInterface::class, $container->get(CartRuleRepository::class)); + $this->addService($container, OrderRepositoryInterface::class, $container->get(OrderRepository::class)); + $this->addService($container, CurrencyRepositoryInterface::class, $container->get(CurrencyRepository::class)); + $this->addService($container, MolOrderPaymentFeeRepositoryInterface::class, $container->get(MolOrderPaymentFeeRepository::class)); + $this->addService($container, PaymentMethodRepositoryInterface::class, $container->get(PaymentMethodRepository::class)); + $this->addService($container, GenderRepositoryInterface::class, $container->get(GenderRepository::class)); + $this->addService($container, OrderCartRuleRepositoryInterface::class, $container->get(OrderCartRuleRepository::class)); + $this->addService($container, MolCustomerRepository::class, MolCustomerRepository::class) + ->withArgument('MolCustomer'); + + /* shipping */ + $this->addService($container, PaymentTypeIdentificationProviderInterface::class, $container->get(RegularPaymentTypeIdentification::class)); + $this->addService($container, ShipmentServiceInterface::class, $container->get(ShipmentService::class)); + $this->addService($container, AutomaticShipmentSenderStatusesProviderInterface::class, $container->get(AutomaticShipmentSenderStatusesProvider::class)); + $this->addService($container, PaymentTypeVerificationInterface::class, $container->get(CanBeRegularPaymentType::class)); + $this->addService($container, OrderEndpointPaymentTypeHandlerInterface::class, $container->get(OrderEndpointPaymentTypeHandler::class)); + $this->addService($container, ShipmentVerificationInterface::class, $container->get(CanSendShipment::class)); + $this->addService($container, ShipmentInformationSenderInterface::class, $container->get(ShipmentInformationSender::class)); + $this->addService($container, ShipmentSenderHandlerInterface::class, ShipmentSenderHandler::class) + ->withArguments( + [ + $container->get(ShipmentVerificationInterface::class), + $container->get(ShipmentInformationSenderInterface::class), + ] + ); + + $this->addService($container, CartRuleQuantityChangeHandlerInterface::class, $container->get(CartRuleQuantityChangeHandler::class)); + + $this->addService($container, OrderTotalProviderInterface::class, $container->get(OrderTotalProvider::class)); + $this->addService($container, PaymentFeeProviderInterface::class, $container->get(PaymentFeeProvider::class)); + + $this->addService($container, EnvironmentVersionProviderInterface::class, $container->get(EnvironmentVersionProvider::class)); + + $this->addService($container, TemplateParserInterface::class, SmartyTemplateParser::class); + + $this->addService($container, UpdateMessageProviderInterface::class, $container->get(UpdateMessageProvider::class)); + + $this->addService($container, PaymentMethodSortProviderInterface::class, PaymentMethodSortProvider::class); + $this->addService($container, PhoneNumberProviderInterface::class, PhoneNumberProvider::class); + $this->addService($container, PaymentMethodRestrictionValidationInterface::class, PaymentMethodRestrictionValidation::class) + ->withArgument([ + $container->get(BasePaymentMethodRestrictionValidator::class), + $container->get(VoucherPaymentMethodRestrictionValidator::class), + $container->get(EnvironmentVersionSpecificPaymentMethodRestrictionValidator::class), + $container->get(ApplePayPaymentMethodRestrictionValidator::class), + $container->get(AmountPaymentMethodRestrictionValidator::class), + $container->get(B2bPaymentMethodRestrictionValidator::class), + ]); + + $this->addService($container, ApiServiceInterface::class, $container->get(ApiService::class)); + + $this->addService($container, CustomLogoProviderInterface::class, $container->get(CreditCardLogoProvider::class)); + + $this->addService($container, PaymentMethodPositionHandlerInterface::class, PaymentMethodPositionHandler::class) + ->withArgument(PaymentMethodRepositoryInterface::class); + + $this->addService($container, CertificateHandlerInterface::class, $container->get(ApplePayDirectCertificateHandler::class)); + + $this->addService($container, ProfileIdProviderInterface::class, ProfileIdProvider::class); + + $this->addService($container, PaymentOptionHandlerInterface::class, $container->get(PaymentOptionHandler::class)); + + $this->addService($container, EntityManagerInterface::class, $container->get(ObjectModelManager::class)); + + $this->addService($container, ApiTestFeedbackBuilder::class, ApiTestFeedbackBuilder::class) + ->withArgument($container->get(ModuleFactory::class)->getModuleVersion() ?? '') + ->withArgument(ApiKeyService::class); + + $this->addService($container, PsAccountsInstaller::class, PsAccountsInstaller::class) + ->withArgument(Config::PRESTASHOP_ACCOUNTS_INSTALLER_VERSION); + + $this->addService($container, PsAccounts::class, PsAccounts::class) + ->withArgument(PsAccountsInstaller::class); + } + + private function addService(Container $container, $className, $service) + { + return $container->add($className, $this->getService($className, $service)); + } + + //NOTE need to call this as extended services should be initialized everywhere. + public function getService($className, $service) + { + if (isset($this->extendedServices[$className])) { + return $this->extendedServices[$className]; + } + + return $service; + } +} diff --git a/src/ServiceProvider/LeagueServiceContainerProvider.php b/src/ServiceProvider/LeagueServiceContainerProvider.php new file mode 100644 index 000000000..713656062 --- /dev/null +++ b/src/ServiceProvider/LeagueServiceContainerProvider.php @@ -0,0 +1,44 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\ServiceProvider; + +use League\Container\Container; +use League\Container\ReflectionContainer; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class LeagueServiceContainerProvider implements ServiceContainerProviderInterface +{ + private $extendedServices = []; + + /** {@inheritDoc} */ + public function getService(string $serviceName) + { + $container = new Container(); + + $container->delegate(new ReflectionContainer()); + + (new BaseServiceProvider($this->extendedServices))->register($container); + + return $container->get($serviceName); + } + + public function extend(string $id, string $concrete = null) + { + $this->extendedServices[$id] = $concrete; + + return $this; + } +} diff --git a/src/ServiceProvider/ServiceContainerProviderInterface.php b/src/ServiceProvider/ServiceContainerProviderInterface.php new file mode 100644 index 000000000..a51d38dff --- /dev/null +++ b/src/ServiceProvider/ServiceContainerProviderInterface.php @@ -0,0 +1,37 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\ServiceProvider; + +if (!defined('_PS_VERSION_')) { + exit; +} + +interface ServiceContainerProviderInterface +{ + /** + * Gets service that is defined by module container. + * + * @param string $serviceName + */ + public function getService(string $serviceName); + + /** + * Extending the service. Useful for tests to dynamically change the implementations + * + * @param string $id + * @param string $concrete - a class name + * + * @return mixed + */ + public function extend(string $id, string $concrete = null); +} diff --git a/src/ServiceProvider/index.php b/src/ServiceProvider/index.php new file mode 100644 index 000000000..d3343995f --- /dev/null +++ b/src/ServiceProvider/index.php @@ -0,0 +1,20 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ +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; diff --git a/src/Tracker/Segment.php b/src/Tracker/Segment.php index 55c7af75b..2ab0ccdca 100644 --- a/src/Tracker/Segment.php +++ b/src/Tracker/Segment.php @@ -36,11 +36,15 @@ namespace Mollie\Tracker; -use Context; use Module; +use Mollie\Adapter\Context; use Mollie\Config\Config; use Mollie\Config\Env; +if (!defined('_PS_VERSION_')) { + exit; +} + class Segment implements TrackerInterface { /** @@ -69,7 +73,7 @@ class Segment implements TrackerInterface */ private $env; - public function __construct(Context $context, $env) + public function __construct(Context $context, Env $env) { $this->context = $context; $this->init(); @@ -125,7 +129,7 @@ private function segmentTrack($userId) 'context' => [ 'ip' => $ip, 'userAgent' => $userAgent, - 'locale' => $this->context->language->iso_code, + 'locale' => $this->context->getLanguageIso(), 'page' => [ 'referrer' => $referer, 'url' => $url, @@ -152,17 +156,17 @@ private function dispatchTrack() { $dictionary = [ \Shop::CONTEXT_SHOP => function () { - return $this->trackShop(); + $this->trackShop(); }, \Shop::CONTEXT_GROUP => function () { - return $this->trackShopGroup(); + $this->trackShopGroup(); }, \Shop::CONTEXT_ALL => function () { - return $this->trackAllShops(); + $this->trackAllShops(); }, ]; - return call_user_func($dictionary[$this->context->shop->getContext()]); + return call_user_func($dictionary[$this->context->getShopContext()]); } /** @@ -170,7 +174,7 @@ private function dispatchTrack() */ private function trackShop() { - $userId = $this->context->shop->domain; + $userId = $this->context->getShopDomain(); $this->segmentTrack($userId); } @@ -180,7 +184,8 @@ private function trackShop() */ private function trackShopGroup() { - $shops = $this->context->shop->getShops(true, $this->context->shop->getContextShopGroupID()); + $shops = $this->context->getShops(true, $this->context->getContextShopGroupID()); + foreach ($shops as $shop) { $this->segmentTrack($shop['domain']); } @@ -191,7 +196,7 @@ private function trackShopGroup() */ private function trackAllShops() { - $shops = $this->context->shop->getShops(); + $shops = $this->context->getShops(); foreach ($shops as $shop) { $this->segmentTrack($shop['domain']); } diff --git a/src/Tracker/TrackerInterface.php b/src/Tracker/TrackerInterface.php index e4710e39b..aa4e7631d 100644 --- a/src/Tracker/TrackerInterface.php +++ b/src/Tracker/TrackerInterface.php @@ -36,6 +36,10 @@ namespace Mollie\Tracker; +if (!defined('_PS_VERSION_')) { + exit; +} + interface TrackerInterface { /** diff --git a/src/Utility/ApplePayDirect/ShippingMethodUtility.php b/src/Utility/ApplePayDirect/ShippingMethodUtility.php index b89aafbed..0646125d7 100644 --- a/src/Utility/ApplePayDirect/ShippingMethodUtility.php +++ b/src/Utility/ApplePayDirect/ShippingMethodUtility.php @@ -15,6 +15,10 @@ use Cart; use Mollie\DTO\ApplePay\Carrier\Carrier as AppleCarrier; +if (!defined('_PS_VERSION_')) { + exit; +} + class ShippingMethodUtility { /** diff --git a/src/Utility/ArrayUtility.php b/src/Utility/ArrayUtility.php index d3ac4b69a..e769dd2ba 100644 --- a/src/Utility/ArrayUtility.php +++ b/src/Utility/ArrayUtility.php @@ -12,6 +12,10 @@ namespace Mollie\Utility; +if (!defined('_PS_VERSION_')) { + exit; +} + class ArrayUtility { public static function getLastElement($array) diff --git a/src/Utility/AssortUtility.php b/src/Utility/AssortUtility.php index 949ed03b4..8b357369d 100644 --- a/src/Utility/AssortUtility.php +++ b/src/Utility/AssortUtility.php @@ -12,6 +12,10 @@ namespace Mollie\Utility; +if (!defined('_PS_VERSION_')) { + exit; +} + class AssortUtility { /** diff --git a/src/Utility/CalculationUtility.php b/src/Utility/CalculationUtility.php index b015d7241..67a5269c6 100644 --- a/src/Utility/CalculationUtility.php +++ b/src/Utility/CalculationUtility.php @@ -12,6 +12,10 @@ namespace Mollie\Utility; +if (!defined('_PS_VERSION_')) { + exit; +} + class CalculationUtility { /** diff --git a/src/Utility/CartPriceUtility.php b/src/Utility/CartPriceUtility.php index d24b170fe..7fff1afa0 100644 --- a/src/Utility/CartPriceUtility.php +++ b/src/Utility/CartPriceUtility.php @@ -15,6 +15,10 @@ use Mollie\Config\Config; use PrestaShop\Decimal\Number; +if (!defined('_PS_VERSION_')) { + exit; +} + class CartPriceUtility { /** diff --git a/src/Utility/ContextUtility.php b/src/Utility/ContextUtility.php index e05c64daa..34b0eb5bb 100644 --- a/src/Utility/ContextUtility.php +++ b/src/Utility/ContextUtility.php @@ -15,6 +15,10 @@ use Context; use Customer; +if (!defined('_PS_VERSION_')) { + exit; +} + class ContextUtility { public static function setCustomerToContext(Context $context, Customer $customer) diff --git a/src/Utility/CustomLogoUtility.php b/src/Utility/CustomLogoUtility.php index 5b18c3cf1..7acbdded8 100644 --- a/src/Utility/CustomLogoUtility.php +++ b/src/Utility/CustomLogoUtility.php @@ -15,6 +15,10 @@ use Configuration; use Mollie\Config\Config; +if (!defined('_PS_VERSION_')) { + exit; +} + class CustomLogoUtility { /** diff --git a/src/Utility/CustomerUtility.php b/src/Utility/CustomerUtility.php index 6143de4b2..e27253f9b 100644 --- a/src/Utility/CustomerUtility.php +++ b/src/Utility/CustomerUtility.php @@ -15,6 +15,10 @@ use Customer; use Validate; +if (!defined('_PS_VERSION_')) { + exit; +} + class CustomerUtility { /** diff --git a/src/Utility/Decoder/DecoderInterface.php b/src/Utility/Decoder/DecoderInterface.php index 4c2848dbf..c9909584f 100644 --- a/src/Utility/Decoder/DecoderInterface.php +++ b/src/Utility/Decoder/DecoderInterface.php @@ -12,6 +12,10 @@ namespace Mollie\Utility\Decoder; +if (!defined('_PS_VERSION_')) { + exit; +} + interface DecoderInterface { /** diff --git a/src/Utility/Decoder/JsonDecoder.php b/src/Utility/Decoder/JsonDecoder.php index 8917f45cf..c1ca53f6b 100644 --- a/src/Utility/Decoder/JsonDecoder.php +++ b/src/Utility/Decoder/JsonDecoder.php @@ -12,6 +12,10 @@ namespace Mollie\Utility\Decoder; +if (!defined('_PS_VERSION_')) { + exit; +} + class JsonDecoder implements DecoderInterface { /** diff --git a/src/Utility/EnvironmentUtility.php b/src/Utility/EnvironmentUtility.php index 9d8d9cd79..e24a36ba9 100644 --- a/src/Utility/EnvironmentUtility.php +++ b/src/Utility/EnvironmentUtility.php @@ -15,6 +15,10 @@ use Configuration; use Mollie\Config\Config; +if (!defined('_PS_VERSION_')) { + exit; +} + class EnvironmentUtility { public static function getApiKey() diff --git a/src/Utility/FileUtility.php b/src/Utility/FileUtility.php index 6a82c090a..4a96609f3 100644 --- a/src/Utility/FileUtility.php +++ b/src/Utility/FileUtility.php @@ -12,6 +12,10 @@ namespace Mollie\Utility; +if (!defined('_PS_VERSION_')) { + exit; +} + class FileUtility { public static function isWritable(string $folderUrl): bool diff --git a/src/Utility/HashUtility.php b/src/Utility/HashUtility.php index 2538147c1..2130e2cc9 100644 --- a/src/Utility/HashUtility.php +++ b/src/Utility/HashUtility.php @@ -12,6 +12,10 @@ namespace Mollie\Utility; +if (!defined('_PS_VERSION_')) { + exit; +} + class HashUtility { /** diff --git a/src/Utility/ImageUtility.php b/src/Utility/ImageUtility.php index e250353f4..1753d66b1 100644 --- a/src/Utility/ImageUtility.php +++ b/src/Utility/ImageUtility.php @@ -14,6 +14,10 @@ use Mollie\Config\Config; +if (!defined('_PS_VERSION_')) { + exit; +} + class ImageUtility { public static function setOptionImage($image, $imageConfig) diff --git a/src/Utility/LocaleUtility.php b/src/Utility/LocaleUtility.php index 55edb8d65..060da98cd 100644 --- a/src/Utility/LocaleUtility.php +++ b/src/Utility/LocaleUtility.php @@ -17,6 +17,10 @@ use Language; use Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + class LocaleUtility { /** diff --git a/src/Utility/MenuLocationUtility.php b/src/Utility/MenuLocationUtility.php index 84c41181c..cd3c19213 100644 --- a/src/Utility/MenuLocationUtility.php +++ b/src/Utility/MenuLocationUtility.php @@ -18,6 +18,10 @@ use Tab; use Validate; +if (!defined('_PS_VERSION_')) { + exit; +} + class MenuLocationUtility { /** diff --git a/src/Utility/MollieStatusUtility.php b/src/Utility/MollieStatusUtility.php index 119161323..efbf246f0 100644 --- a/src/Utility/MollieStatusUtility.php +++ b/src/Utility/MollieStatusUtility.php @@ -16,6 +16,10 @@ use Mollie\Api\Types\PaymentStatus; use Mollie\Config\Config; +if (!defined('_PS_VERSION_')) { + exit; +} + class MollieStatusUtility { public static function isPaymentFinished($paymentStatus) diff --git a/src/Utility/MultiLangUtility.php b/src/Utility/MultiLangUtility.php index e5f7fdf84..93d85ff8c 100644 --- a/src/Utility/MultiLangUtility.php +++ b/src/Utility/MultiLangUtility.php @@ -14,6 +14,10 @@ use Language; +if (!defined('_PS_VERSION_')) { + exit; +} + class MultiLangUtility { public static function createMultiLangField($field, $languageIds = null) diff --git a/src/Utility/NumberUtility.php b/src/Utility/NumberUtility.php index 8429560eb..22de95e85 100644 --- a/src/Utility/NumberUtility.php +++ b/src/Utility/NumberUtility.php @@ -16,6 +16,10 @@ use PrestaShop\Decimal\Number; use PrestaShop\Decimal\Operation\Rounding; +if (!defined('_PS_VERSION_')) { + exit; +} + class NumberUtility { const DECIMAL_PRECISION = 2; diff --git a/src/Utility/OrderNumberUtility.php b/src/Utility/OrderNumberUtility.php index 76acab6f0..bd26c0805 100644 --- a/src/Utility/OrderNumberUtility.php +++ b/src/Utility/OrderNumberUtility.php @@ -12,6 +12,10 @@ namespace Mollie\Utility; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderNumberUtility { const ORDER_NUMBER_PREFIX = 'mol_'; diff --git a/src/Utility/OrderRecoverUtility.php b/src/Utility/OrderRecoverUtility.php index 1bbab6c57..9f9916ab6 100644 --- a/src/Utility/OrderRecoverUtility.php +++ b/src/Utility/OrderRecoverUtility.php @@ -14,6 +14,10 @@ use Customer; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderRecoverUtility { public static function recoverCreatedOrder($context, int $customerId) diff --git a/src/Utility/OrderStatusUtility.php b/src/Utility/OrderStatusUtility.php index 5d07977f0..f77db42c6 100644 --- a/src/Utility/OrderStatusUtility.php +++ b/src/Utility/OrderStatusUtility.php @@ -19,6 +19,10 @@ use Mollie\Api\Types\RefundStatus; use Mollie\Config\Config; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderStatusUtility { /** diff --git a/src/Utility/PaymentMethodUtility.php b/src/Utility/PaymentMethodUtility.php index b295b04bb..6e95100b7 100644 --- a/src/Utility/PaymentMethodUtility.php +++ b/src/Utility/PaymentMethodUtility.php @@ -14,6 +14,10 @@ use Mollie\Config\Config; +if (!defined('_PS_VERSION_')) { + exit; +} + class PaymentMethodUtility { public static function getPaymentMethodName($method) diff --git a/src/Utility/PsVersionUtility.php b/src/Utility/PsVersionUtility.php index 9626b5793..20a286faa 100644 --- a/src/Utility/PsVersionUtility.php +++ b/src/Utility/PsVersionUtility.php @@ -12,6 +12,10 @@ namespace Mollie\Utility; +if (!defined('_PS_VERSION_')) { + exit; +} + class PsVersionUtility { public static function isPsVersionHigherThen(string $psVersion, string $higherThen, string $operator = '>='): bool diff --git a/src/Utility/RefundUtility.php b/src/Utility/RefundUtility.php index 37403c209..cc10bb408 100644 --- a/src/Utility/RefundUtility.php +++ b/src/Utility/RefundUtility.php @@ -14,6 +14,10 @@ use Mollie\Config\Config; +if (!defined('_PS_VERSION_')) { + exit; +} + class RefundUtility { public static function getRefundLines(array $lines) diff --git a/src/Utility/SecureKeyUtility.php b/src/Utility/SecureKeyUtility.php index 36a4bae19..2eab43bd2 100644 --- a/src/Utility/SecureKeyUtility.php +++ b/src/Utility/SecureKeyUtility.php @@ -12,6 +12,10 @@ namespace Mollie\Utility; +if (!defined('_PS_VERSION_')) { + exit; +} + class SecureKeyUtility { public static function generateReturnKey($customerId, $cartId, $moduleName) diff --git a/src/Utility/TagsUtility.php b/src/Utility/TagsUtility.php index 216f3c46e..27aa89022 100644 --- a/src/Utility/TagsUtility.php +++ b/src/Utility/TagsUtility.php @@ -12,6 +12,10 @@ namespace Mollie\Utility; +if (!defined('_PS_VERSION_')) { + exit; +} + class TagsUtility { /** diff --git a/src/Utility/TextFormatUtility.php b/src/Utility/TextFormatUtility.php index 013d5ea8d..975f657a5 100644 --- a/src/Utility/TextFormatUtility.php +++ b/src/Utility/TextFormatUtility.php @@ -11,6 +11,10 @@ namespace Mollie\Utility; +if (!defined('_PS_VERSION_')) { + exit; +} + class TextFormatUtility { public static function formatNumber($unitPrice, $apiRoundingPrecision, $docPoint = '.', $thousandSep = '') diff --git a/src/Utility/TextGeneratorUtility.php b/src/Utility/TextGeneratorUtility.php index 5565decc7..0cded2162 100644 --- a/src/Utility/TextGeneratorUtility.php +++ b/src/Utility/TextGeneratorUtility.php @@ -19,6 +19,10 @@ use Customer; use Order; +if (!defined('_PS_VERSION_')) { + exit; +} + class TextGeneratorUtility { /** diff --git a/src/Utility/TimeUtility.php b/src/Utility/TimeUtility.php index e23e9b8f1..35522d172 100644 --- a/src/Utility/TimeUtility.php +++ b/src/Utility/TimeUtility.php @@ -14,6 +14,10 @@ use DateTime; +if (!defined('_PS_VERSION_')) { + exit; +} + class TimeUtility { const HOURS_IN_DAY = 24; diff --git a/src/Utility/TransactionUtility.php b/src/Utility/TransactionUtility.php index 19520667b..3f6e6b6b6 100644 --- a/src/Utility/TransactionUtility.php +++ b/src/Utility/TransactionUtility.php @@ -14,6 +14,10 @@ use Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + class TransactionUtility { public static function isOrderTransaction($transactionId) diff --git a/src/Utility/UrlPathUtility.php b/src/Utility/UrlPathUtility.php index 5435dd0c5..58b5ce9d9 100644 --- a/src/Utility/UrlPathUtility.php +++ b/src/Utility/UrlPathUtility.php @@ -14,6 +14,10 @@ use Tools; +if (!defined('_PS_VERSION_')) { + exit; +} + class UrlPathUtility { /** diff --git a/src/Validator/MailValidatorInterface.php b/src/Validator/MailValidatorInterface.php index 0a2c814a6..5f98b0a5d 100644 --- a/src/Validator/MailValidatorInterface.php +++ b/src/Validator/MailValidatorInterface.php @@ -12,6 +12,10 @@ namespace Mollie\Validator; +if (!defined('_PS_VERSION_')) { + exit; +} + interface MailValidatorInterface { /** diff --git a/src/Validator/OrderCallBackValidator.php b/src/Validator/OrderCallBackValidator.php index d40bd6358..3bdd45eaf 100644 --- a/src/Validator/OrderCallBackValidator.php +++ b/src/Validator/OrderCallBackValidator.php @@ -12,27 +12,28 @@ namespace Mollie\Validator; -use Context; -use Customer; use Mollie; +use Mollie\Adapter\Context; +use Mollie\Factory\ModuleFactory; use Mollie\Utility\SecureKeyUtility; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderCallBackValidator { - /** - * @var Customer - */ - private $customer; - /** * @var Mollie */ private $module; + /** @var Context */ + private $context; - public function __construct(Context $context, Mollie $module) + public function __construct(Context $context, ModuleFactory $moduleFactory) { - $this->customer = $context->customer; - $this->module = $module; + $this->context = $context; + $this->module = $moduleFactory->getModule(); } public function validate($key, $cartId) @@ -51,7 +52,7 @@ public function validate($key, $cartId) public function isSignatureMatches($key, $cartId) { return $key === SecureKeyUtility::generateReturnKey( - $this->customer->id, + $this->context->getCustomerId(), $cartId, $this->module->name ); diff --git a/src/Validator/OrderConfMailValidator.php b/src/Validator/OrderConfMailValidator.php index a8901029e..e02a5e7ce 100644 --- a/src/Validator/OrderConfMailValidator.php +++ b/src/Validator/OrderConfMailValidator.php @@ -15,6 +15,10 @@ use Mollie\Adapter\ConfigurationAdapter; use Mollie\Config\Config; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderConfMailValidator implements MailValidatorInterface { /** @@ -59,7 +63,7 @@ private function validateOrderState($orderStateId) return true; } - if ((int) $this->configurationAdapter->get(Config::MOLLIE_STATUS_KLARNA_AUTHORIZED) === $orderStateId) { + if ((int) $this->configurationAdapter->get(Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED) === $orderStateId) { return true; } diff --git a/src/Validator/VoucherValidator.php b/src/Validator/VoucherValidator.php index c885a1310..317476ebe 100644 --- a/src/Validator/VoucherValidator.php +++ b/src/Validator/VoucherValidator.php @@ -16,6 +16,10 @@ use Mollie\Config\Config; use Mollie\Service\VoucherService; +if (!defined('_PS_VERSION_')) { + exit; +} + class VoucherValidator { /** diff --git a/src/Verification/IsPaymentInformationAvailable.php b/src/Verification/IsPaymentInformationAvailable.php index 5ae93a5ee..f6c49450e 100644 --- a/src/Verification/IsPaymentInformationAvailable.php +++ b/src/Verification/IsPaymentInformationAvailable.php @@ -1,9 +1,23 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Verification; use Mollie\Repository\PaymentMethodRepositoryInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + class IsPaymentInformationAvailable { /** @var PaymentMethodRepositoryInterface */ diff --git a/src/Verification/PaymentType/CanBeRegularPaymentType.php b/src/Verification/PaymentType/CanBeRegularPaymentType.php index 754332fcd..65f80d70b 100644 --- a/src/Verification/PaymentType/CanBeRegularPaymentType.php +++ b/src/Verification/PaymentType/CanBeRegularPaymentType.php @@ -13,12 +13,16 @@ namespace Mollie\Verification\PaymentType; use Mollie\Adapter\ToolsAdapter; -use Mollie\Provider\PaymentType\PaymentTypeIdentificationProvider; +use Mollie\Provider\PaymentType\PaymentTypeIdentificationProviderInterface; + +if (!defined('_PS_VERSION_')) { + exit; +} class CanBeRegularPaymentType implements PaymentTypeVerificationInterface { /** - * @var PaymentTypeIdentificationProvider + * @var PaymentTypeIdentificationProviderInterface */ private $regularPaymentTypeIdentification; @@ -29,7 +33,7 @@ class CanBeRegularPaymentType implements PaymentTypeVerificationInterface public function __construct( ToolsAdapter $toolsAdapter, - PaymentTypeIdentificationProvider $regularPaymentTypeIdentification + PaymentTypeIdentificationProviderInterface $regularPaymentTypeIdentification ) { $this->regularPaymentTypeIdentification = $regularPaymentTypeIdentification; $this->toolsAdapter = $toolsAdapter; diff --git a/src/Verification/PaymentType/PaymentTypeVerificationInterface.php b/src/Verification/PaymentType/PaymentTypeVerificationInterface.php index 0dccbfb4d..7ebe011b0 100644 --- a/src/Verification/PaymentType/PaymentTypeVerificationInterface.php +++ b/src/Verification/PaymentType/PaymentTypeVerificationInterface.php @@ -12,6 +12,10 @@ namespace Mollie\Verification\PaymentType; +if (!defined('_PS_VERSION_')) { + exit; +} + interface PaymentTypeVerificationInterface { /** diff --git a/src/Verification/Shipment/CanSendShipment.php b/src/Verification/Shipment/CanSendShipment.php index 2a0cc1267..b4dae5363 100644 --- a/src/Verification/Shipment/CanSendShipment.php +++ b/src/Verification/Shipment/CanSendShipment.php @@ -26,6 +26,10 @@ use OrderState; use PrestaShopLogger; +if (!defined('_PS_VERSION_')) { + exit; +} + class CanSendShipment implements ShipmentVerificationInterface { /** diff --git a/src/Verification/Shipment/ShipmentVerificationInterface.php b/src/Verification/Shipment/ShipmentVerificationInterface.php index d2b5165eb..b58e934e2 100644 --- a/src/Verification/Shipment/ShipmentVerificationInterface.php +++ b/src/Verification/Shipment/ShipmentVerificationInterface.php @@ -16,6 +16,10 @@ use Order; use OrderState; +if (!defined('_PS_VERSION_')) { + exit; +} + interface ShipmentVerificationInterface { /** diff --git a/tests/Integration/Application/CommandHandler/RequestApplePayPaymentSessionHandlerTest.php b/tests/Integration/Application/CommandHandler/RequestApplePayPaymentSessionHandlerTest.php index 5aca037a2..81e68bad7 100644 --- a/tests/Integration/Application/CommandHandler/RequestApplePayPaymentSessionHandlerTest.php +++ b/tests/Integration/Application/CommandHandler/RequestApplePayPaymentSessionHandlerTest.php @@ -1,7 +1,20 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Tests\Integration\Application\CommandHandler; use Mollie\Application\Command\RequestApplePayPaymentSession; use Mollie\Application\CommandHandler\RequestApplePayPaymentSessionHandler; +use Mollie\Factory\ModuleFactory; use Mollie\Tests\Integration\BaseTestCase; use Mollie\Tests\Mocks\Service\ApiServiceMock; @@ -12,10 +25,10 @@ class RequestApplePayPaymentSessionHandlerTest extends BaseTestCase */ public function testHandle(RequestApplePayPaymentSession $command) { - /** @var Mollie $mollie */ - $mollie = Module::getInstanceByName('mollie'); + /** @var ModuleFactory $moduleFactory */ + $moduleFactory = $this->getService(ModuleFactory::class); $apiServiceMock = new ApiServiceMock(); - $handler = new RequestApplePayPaymentSessionHandler($mollie, $apiServiceMock); + $handler = new RequestApplePayPaymentSessionHandler($moduleFactory, $apiServiceMock); $result = $handler->handle($command); $this->assertArrayHasKey('cartId', $result); diff --git a/tests/Integration/BaseTestCase.php b/tests/Integration/BaseTestCase.php index 7c417e306..b51e0c551 100644 --- a/tests/Integration/BaseTestCase.php +++ b/tests/Integration/BaseTestCase.php @@ -100,7 +100,7 @@ protected function getService($serviceName) /** @var Mollie $mollie */ $mollie = Module::getInstanceByName('mollie'); - return $mollie->getMollieContainer($serviceName); + return $mollie->getService($serviceName); } public function getContextBuilder() diff --git a/tests/Integration/Factory/AddressFactory.php b/tests/Integration/Factory/AddressFactory.php new file mode 100644 index 000000000..88a09c473 --- /dev/null +++ b/tests/Integration/Factory/AddressFactory.php @@ -0,0 +1,38 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Tests\Integration\Factory; + +class AddressFactory implements FactoryInterface +{ + public static function create(array $data = []): \Address + { + $address = new \Address(null, (int) \Configuration::get('PS_LANG_DEFAULT')); + + $address->firstname = $data['first_name'] ?? 'test-first-name'; + $address->lastname = $data['last_name'] ?? 'test-last-name'; + $address->country = $data['country'] ?? 'test-country'; + $address->id_country = $data['id_country'] ?? \Configuration::get('PS_COUNTRY_DEFAULT'); + $address->city = $data['city'] ?? 'test-city'; + $address->postcode = $data['postcode'] ?? '97222'; //max 12 chars + $address->address1 = $data['address1'] ?? 'test-address1'; + $address->address2 = $data['address2'] ?? 'test-address2'; + $address->phone_mobile = $data['phone_mobile'] ?? '5555555'; //letters or symbols cause errors + $address->alias = $data['alias'] ?? 'test-alias'; + $address->vat_number = $data['vat_number'] ?? 'test-vat'; + $address->company = $data['company'] ?? 'test-company'; + + $address->save(); + + return $address; + } +} diff --git a/tests/Integration/Factory/CarrierFactory.php b/tests/Integration/Factory/CarrierFactory.php new file mode 100644 index 000000000..49f2ca719 --- /dev/null +++ b/tests/Integration/Factory/CarrierFactory.php @@ -0,0 +1,65 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Tests\Integration\Factory; + +class CarrierFactory implements FactoryInterface +{ + public static function create(array $data = []) + { + $carrier = new \Carrier(null, (int) \Configuration::get('PS_LANG_DEFAULT')); + + $carrier->name = $data['name'] ?? 'test-name'; + $carrier->active = $data['active'] ?? true; + $carrier->delay = $data['delay'] ?? '28 days later'; + + //NOTE to if true would add PS_SHIPPING_HANDLING from configuration to shipping price. + $carrier->shipping_handling = $data['shipping_handling'] ?? false; + + //NOTE need to do it like this because otherwise it would not show up as option. + if (isset($data['price']) && !empty((int) $data['price'])) { + $carrier->shipping_method = \Carrier::SHIPPING_METHOD_PRICE; + } else { + $carrier->shipping_method = \Carrier::SHIPPING_METHOD_FREE; + } + + $carrier->shipping_method = $data['shipping_method'] ?? $carrier->shipping_method; + + $carrier->save(); + + $rangePrice = new \RangePrice(); + $rangePrice->id_carrier = $carrier->id; + $rangePrice->delimiter1 = 0; + $rangePrice->delimiter2 = 1; + + $rangePrice->save(); + + $zones = \Zone::getZones(); + $prices = []; + + foreach ($zones as $zone) { + $carrier->addZone($zone['id_zone']); + + $prices[] = [ + 'id_range_price' => $rangePrice->id, + 'id_range_weight' => null, + 'id_carrier' => (int) $carrier->id, + 'id_zone' => (int) $zone['id_zone'], + 'price' => $data['price'] ?? 0, + ]; + } + // enable all zones + $carrier->addDeliveryPrice($prices); + + return $carrier; + } +} diff --git a/tests/Integration/Factory/CartFactory.php b/tests/Integration/Factory/CartFactory.php new file mode 100644 index 000000000..c2eafb84d --- /dev/null +++ b/tests/Integration/Factory/CartFactory.php @@ -0,0 +1,34 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Tests\Integration\Factory; + +class CartFactory implements FactoryInterface +{ + public static function create(array $data = []): \Cart + { + $cart = new \Cart(); + + $cart->id_lang = $data['id_lang'] ?? \Configuration::get('PS_LANG_DEFAULT'); + $cart->id_currency = $data['id_currency'] ?? \Configuration::get('PS_CURRENCY_DEFAULT'); + $cart->id_carrier = $data['id_carrier'] ?? CarrierFactory::create()->id; + $cart->id_address_delivery = $data['id_address_delivery'] ?? AddressFactory::create()->id; + $cart->id_address_invoice = $data['id_address_invoice'] ?? AddressFactory::create()->id; + $cart->id_customer = $data['id_customer'] ?? CustomerFactory::create()->id; + + $cart->save(); + + \Context::getContext()->cart = $cart; + + return $cart; + } +} diff --git a/tests/Integration/Factory/CustomerFactory.php b/tests/Integration/Factory/CustomerFactory.php new file mode 100644 index 000000000..18c2ff9bb --- /dev/null +++ b/tests/Integration/Factory/CustomerFactory.php @@ -0,0 +1,34 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Tests\Integration\Factory; + +class CustomerFactory implements FactoryInterface +{ + public static function create(array $data = []): \Customer + { + $customer = new \Customer(); + + $customer->firstname = $data['first_name'] ?? 'test-first-name'; + $customer->lastname = $data['last_name'] ?? 'test-last-name'; + $customer->email = $data['email'] ?? 'test-email@email.com'; + $customer->passwd = $data['passwd'] ?? 'test-passwd'; + $customer->is_guest = $data['is_guest'] ?? false; + $customer->siret = $data['siret'] ?? 'test-siret'; + + $customer->save(); + + \Context::getContext()->customer = $customer; + + return $customer; + } +} diff --git a/tests/Integration/Factory/FactoryInterface.php b/tests/Integration/Factory/FactoryInterface.php new file mode 100644 index 000000000..2b0cbc72f --- /dev/null +++ b/tests/Integration/Factory/FactoryInterface.php @@ -0,0 +1,18 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Tests\Integration\Factory; + +interface FactoryInterface +{ + public static function create(array $data = []); +} diff --git a/tests/Integration/Factory/index.php b/tests/Integration/Factory/index.php new file mode 100644 index 000000000..d3343995f --- /dev/null +++ b/tests/Integration/Factory/index.php @@ -0,0 +1,20 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ +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; diff --git a/tests/Integration/Install/ModuleTabInstallerTest.php b/tests/Integration/Install/ModuleTabInstallerTest.php new file mode 100644 index 000000000..00b918fdd --- /dev/null +++ b/tests/Integration/Install/ModuleTabInstallerTest.php @@ -0,0 +1,53 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Tests\Integration\Install; + +use Mollie\Bootstrap\ModuleTabs; +use Mollie\Install\ModuleTabInstaller; +use Mollie\Tests\Integration\BaseTestCase; + +class ModuleTabInstallerTest extends BaseTestCase +{ + protected function setUp() + { + parent::setUp(); + + \Db::getInstance()->delete('tab', '`module` = "mollie"'); + \Db::getInstance()->delete('authorization_role', '`slug` LIKE "%mollie%"'); + } + + public function testItSuccessfullyHandlesModuleTabInstall() + { + /** @var ModuleTabs $moduleTabs */ + $moduleTabs = $this->getService(ModuleTabs::class); + + /** @var ModuleTabInstaller $moduleTabInstaller */ + $moduleTabInstaller = $this->getService(ModuleTabInstaller::class); + + $tabs = $moduleTabs->getTabs(); + + foreach ($tabs as $tab) { + $this->assertDatabaseHasNot(\Tab::class, [ + 'class_name' => $tab['class_name'], + ]); + } + + $moduleTabInstaller->init(); + + foreach ($tabs as $tab) { + $this->assertDatabaseHas(\Tab::class, [ + 'class_name' => $tab['class_name'], + ]); + } + } +} diff --git a/tests/Integration/Install/OrderStateInstallerTest.php b/tests/Integration/Install/OrderStateInstallerTest.php index a6f5598ae..445a35fac 100644 --- a/tests/Integration/Install/OrderStateInstallerTest.php +++ b/tests/Integration/Install/OrderStateInstallerTest.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Tests\Integration\Install; @@ -86,7 +96,7 @@ public function requiredOrderStatusesDataProvider() 'pdfInvoice' => false, ], [ - 'key' => Config::MOLLIE_STATUS_KLARNA_AUTHORIZED, + 'key' => Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED, 'color' => '#8A2BE2', 'sendEmail' => true, 'logable' => true, @@ -97,7 +107,7 @@ public function requiredOrderStatusesDataProvider() 'pdfInvoice' => true, ], [ - 'key' => Config::MOLLIE_STATUS_KLARNA_SHIPPED, + 'key' => Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED, 'color' => '#8A2BE2', 'sendEmail' => true, 'logable' => true, diff --git a/tests/Integration/Install/index.php b/tests/Integration/Install/index.php new file mode 100644 index 000000000..d3343995f --- /dev/null +++ b/tests/Integration/Install/index.php @@ -0,0 +1,20 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ +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; diff --git a/tests/Integration/Service/PaymentMethod/PaymentMethodRestrictionValidation/B2bPaymentMethodRestrictionValidatorTest.php b/tests/Integration/Service/PaymentMethod/PaymentMethodRestrictionValidation/B2bPaymentMethodRestrictionValidatorTest.php new file mode 100644 index 000000000..afb434719 --- /dev/null +++ b/tests/Integration/Service/PaymentMethod/PaymentMethodRestrictionValidation/B2bPaymentMethodRestrictionValidatorTest.php @@ -0,0 +1,273 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Tests\Integration\Service\PaymentMethod\PaymentMethodRestrictionValidation; + +use Configuration; +use Mollie\Config\Config; +use Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\B2bPaymentMethodRestrictionValidator; +use Mollie\Tests\Integration\BaseTestCase; +use Mollie\Tests\Integration\Factory\AddressFactory; +use Mollie\Tests\Integration\Factory\CartFactory; +use Mollie\Tests\Integration\Factory\CustomerFactory; + +class B2bPaymentMethodRestrictionValidatorTest extends BaseTestCase +{ + /** @var int */ + private $originalB2bValue; + + public function setUp() + { + $this->originalB2bValue = (int) Configuration::get('PS_B2B_ENABLE'); + + parent::setUp(); + } + + public function tearDown() + { + Configuration::set('PS_B2B_ENABLE', $this->originalB2bValue); + + parent::tearDown(); + } + + public function testItSuccessfullyValidatedIsValid() + { + Configuration::set('PS_B2B_ENABLE', 1); + + $molPaymentMethod = new \MolPaymentMethod(); + $molPaymentMethod->id_method = Config::MOLLIE_PAYMENT_METHOD_BILLIE; + + $customer = CustomerFactory::create([ + 'siret' => 'test-siret-number', + ]); + + $billingAddress = AddressFactory::create([ + 'vat_number' => 'vat-number', + ]); + + $this->contextBuilder->setCart(CartFactory::create()); + $this->contextBuilder->getContext()->cart->id_address_invoice = $billingAddress->id; + $this->contextBuilder->getContext()->cart->id_customer = $customer->id; + + /** @var B2bPaymentMethodRestrictionValidator $b2bPaymentMethodRestrictionValidator */ + $b2bPaymentMethodRestrictionValidator = $this->getService(B2bPaymentMethodRestrictionValidator::class); + + $supports = $b2bPaymentMethodRestrictionValidator->supports($molPaymentMethod); + + $valid = $b2bPaymentMethodRestrictionValidator->isValid($molPaymentMethod); + + $this->assertEquals(true, $supports); + $this->assertEquals(true, $valid); + } + + public function testItSuccessfullyValidatedIsValidMissingVatNumberInFormat() + { + Configuration::set('PS_B2B_ENABLE', 1); + + $molPaymentMethod = new \MolPaymentMethod(); + $molPaymentMethod->id_method = Config::MOLLIE_PAYMENT_METHOD_BILLIE; + + $customer = CustomerFactory::create([ + 'siret' => 'test-siret-number', + ]); + + $billingAddress = AddressFactory::create([ + 'vat_number' => 'vat-number', + ]); + + $addressFormat = new \AddressFormat($billingAddress->id_country); + + $originalCountryFormat = $addressFormat->format; + + $addressFormat->format = 'test-format'; + $addressFormat->save(); + + $this->contextBuilder->setCart(CartFactory::create()); + $this->contextBuilder->getContext()->cart->id_address_invoice = $billingAddress->id; + $this->contextBuilder->getContext()->cart->id_customer = $customer->id; + + /** @var B2bPaymentMethodRestrictionValidator $b2bPaymentMethodRestrictionValidator */ + $b2bPaymentMethodRestrictionValidator = $this->getService(B2bPaymentMethodRestrictionValidator::class); + + $supports = $b2bPaymentMethodRestrictionValidator->supports($molPaymentMethod); + + $valid = $b2bPaymentMethodRestrictionValidator->isValid($molPaymentMethod); + + $addressFormat->format = $originalCountryFormat; + $addressFormat->save(); + + $this->assertEquals(true, $supports); + $this->assertEquals(true, $valid); + } + + public function testItUnsuccessfullyValidatedIsValidMethodNotSupported() + { + Configuration::set('PS_B2B_ENABLE', 1); + + $molPaymentMethod = new \MolPaymentMethod(); + $molPaymentMethod->id_method = 'not-supported-method'; + + $customer = CustomerFactory::create([ + 'siret' => 'test-siret-number', + ]); + + $billingAddress = AddressFactory::create([ + 'vat_number' => 'vat-number', + ]); + + $this->contextBuilder->setCart(CartFactory::create()); + $this->contextBuilder->getContext()->cart->id_address_invoice = $billingAddress->id; + $this->contextBuilder->getContext()->cart->id_customer = $customer->id; + + /** @var B2bPaymentMethodRestrictionValidator $b2bPaymentMethodRestrictionValidator */ + $b2bPaymentMethodRestrictionValidator = $this->getService(B2bPaymentMethodRestrictionValidator::class); + + $supports = $b2bPaymentMethodRestrictionValidator->supports($molPaymentMethod); + + $valid = $b2bPaymentMethodRestrictionValidator->isValid($molPaymentMethod); + + $this->assertEquals(false, $supports); + $this->assertEquals(true, $valid); + } + + public function testItUnsuccessfullyValidatedIsValidMissingSiretNumber() + { + Configuration::set('PS_B2B_ENABLE', 1); + + $molPaymentMethod = new \MolPaymentMethod(); + $molPaymentMethod->id_method = Config::MOLLIE_PAYMENT_METHOD_BILLIE; + + $customer = CustomerFactory::create([ + 'siret' => '', + ]); + + $billingAddress = AddressFactory::create([ + 'vat_number' => 'vat-number', + ]); + + $this->contextBuilder->setCart(CartFactory::create([ + 'id_customer' => $customer->id, + 'id_address_delivery' => $billingAddress->id, + 'id_address_invoice' => $billingAddress->id, + ])); + + /** @var B2bPaymentMethodRestrictionValidator $b2bPaymentMethodRestrictionValidator */ + $b2bPaymentMethodRestrictionValidator = $this->getService(B2bPaymentMethodRestrictionValidator::class); + + $supports = $b2bPaymentMethodRestrictionValidator->supports($molPaymentMethod); + + $valid = $b2bPaymentMethodRestrictionValidator->isValid($molPaymentMethod); + + $this->assertEquals(true, $supports); + $this->assertEquals(false, $valid); + } + + public function testItUnsuccessfullyValidatedIsValidB2bNotEnabled() + { + Configuration::set('PS_B2B_ENABLE', 0); + + $molPaymentMethod = new \MolPaymentMethod(); + $molPaymentMethod->id_method = Config::MOLLIE_PAYMENT_METHOD_BILLIE; + + $customer = CustomerFactory::create([ + 'siret' => 'test-siret', + ]); + + $billingAddress = AddressFactory::create([ + 'vat_number' => 'vat-number', + ]); + + $this->contextBuilder->setCart(CartFactory::create([ + 'id_customer' => $customer->id, + 'id_address_delivery' => $billingAddress->id, + 'id_address_invoice' => $billingAddress->id, + ])); + + /** @var B2bPaymentMethodRestrictionValidator $b2bPaymentMethodRestrictionValidator */ + $b2bPaymentMethodRestrictionValidator = $this->getService(B2bPaymentMethodRestrictionValidator::class); + + $supports = $b2bPaymentMethodRestrictionValidator->supports($molPaymentMethod); + + $valid = $b2bPaymentMethodRestrictionValidator->isValid($molPaymentMethod); + + $this->assertEquals(true, $supports); + $this->assertEquals(false, $valid); + } + + public function testItUnsuccessfullyValidatedIsValidMissingVatNumberInBothAddresses() + { + Configuration::set('PS_B2B_ENABLE', 1); + + $molPaymentMethod = new \MolPaymentMethod(); + $molPaymentMethod->id_method = Config::MOLLIE_PAYMENT_METHOD_BILLIE; + + $customer = CustomerFactory::create([ + 'siret' => 'test-siret', + ]); + + $billingAddress = AddressFactory::create([ + 'vat_number' => '', + ]); + + $this->contextBuilder->setCart(CartFactory::create([ + 'id_customer' => $customer->id, + 'id_address_delivery' => $billingAddress->id, + 'id_address_invoice' => $billingAddress->id, + ])); + + /** @var B2bPaymentMethodRestrictionValidator $b2bPaymentMethodRestrictionValidator */ + $b2bPaymentMethodRestrictionValidator = $this->getService(B2bPaymentMethodRestrictionValidator::class); + + $supports = $b2bPaymentMethodRestrictionValidator->supports($molPaymentMethod); + + $valid = $b2bPaymentMethodRestrictionValidator->isValid($molPaymentMethod); + + $this->assertEquals(true, $supports); + $this->assertEquals(false, $valid); + } + + public function testItUnsuccessfullyValidatedIsValidMissingVatNumberInBillingAddress() + { + Configuration::set('PS_B2B_ENABLE', 1); + + $molPaymentMethod = new \MolPaymentMethod(); + $molPaymentMethod->id_method = Config::MOLLIE_PAYMENT_METHOD_BILLIE; + + $customer = CustomerFactory::create([ + 'siret' => 'test-siret', + ]); + + $billingAddress = AddressFactory::create([ + 'vat_number' => '', + ]); + + $shippingAddress = AddressFactory::create([ + 'vat_number' => 'test-vat-number', + ]); + + $this->contextBuilder->setCart(CartFactory::create([ + 'id_customer' => $customer->id, + 'id_address_delivery' => $shippingAddress->id, + 'id_address_invoice' => $billingAddress->id, + ])); + + /** @var B2bPaymentMethodRestrictionValidator $b2bPaymentMethodRestrictionValidator */ + $b2bPaymentMethodRestrictionValidator = $this->getService(B2bPaymentMethodRestrictionValidator::class); + + $supports = $b2bPaymentMethodRestrictionValidator->supports($molPaymentMethod); + + $valid = $b2bPaymentMethodRestrictionValidator->isValid($molPaymentMethod); + + $this->assertEquals(true, $supports); + $this->assertEquals(false, $valid); + } +} diff --git a/tests/Integration/Service/PaymentMethod/PaymentMethodRestrictionValidation/index.php b/tests/Integration/Service/PaymentMethod/PaymentMethodRestrictionValidation/index.php new file mode 100644 index 000000000..d3343995f --- /dev/null +++ b/tests/Integration/Service/PaymentMethod/PaymentMethodRestrictionValidation/index.php @@ -0,0 +1,20 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ +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; diff --git a/tests/Integration/Service/PaymentMethod/index.php b/tests/Integration/Service/PaymentMethod/index.php new file mode 100644 index 000000000..d3343995f --- /dev/null +++ b/tests/Integration/Service/PaymentMethod/index.php @@ -0,0 +1,20 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ +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; diff --git a/tests/Integration/Service/index.php b/tests/Integration/Service/index.php new file mode 100644 index 000000000..d3343995f --- /dev/null +++ b/tests/Integration/Service/index.php @@ -0,0 +1,20 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ +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; diff --git a/tests/Unit/Builder/InvoicePdfTemplateBuilderTest.php b/tests/Unit/Builder/InvoicePdfTemplateBuilderTest.php index 56c437c86..a56361403 100644 --- a/tests/Unit/Builder/InvoicePdfTemplateBuilderTest.php +++ b/tests/Unit/Builder/InvoicePdfTemplateBuilderTest.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Tests\Unit\Builder; diff --git a/tests/Unit/Calculator/PaymentFeeCalculatorTest.php b/tests/Unit/Calculator/PaymentFeeCalculatorTest.php index ca6b8740b..43d3310bc 100644 --- a/tests/Unit/Calculator/PaymentFeeCalculatorTest.php +++ b/tests/Unit/Calculator/PaymentFeeCalculatorTest.php @@ -1,10 +1,20 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Calculator; namespace Unit\Calculator; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; use Mollie\Calculator\PaymentFeeCalculator; use PHPUnit\Framework\TestCase; use TaxCalculator; @@ -13,7 +23,7 @@ class PaymentFeeCalculatorTest extends TestCase { /** @var TaxCalculator */ private $taxCalculator; - /** @var LegacyContext */ + /** @var Context */ private $context; public function setUp() @@ -21,7 +31,7 @@ public function setUp() parent::setUp(); $this->taxCalculator = $this->createMock(TaxCalculator::class); - $this->context = $this->createMock(LegacyContext::class); + $this->context = $this->createMock(Context::class); } public function testItCalculatesFixedFee() diff --git a/tests/Unit/Calculator/index.php b/tests/Unit/Calculator/index.php new file mode 100644 index 000000000..d3343995f --- /dev/null +++ b/tests/Unit/Calculator/index.php @@ -0,0 +1,20 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ +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; diff --git a/tests/Unit/Collector/ApplePayDirect/OrderTotalCollectorTest.php b/tests/Unit/Collector/ApplePayDirect/OrderTotalCollectorTest.php index 1acf7ced3..a5407922a 100644 --- a/tests/Unit/Collector/ApplePayDirect/OrderTotalCollectorTest.php +++ b/tests/Unit/Collector/ApplePayDirect/OrderTotalCollectorTest.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Tests\Unit\Collector\ApplePayDirect; diff --git a/tests/Unit/Handler/Api/OrderEndpointPaymentTypeHandlerTest.php b/tests/Unit/Handler/Api/OrderEndpointPaymentTypeHandlerTest.php index 7c0236a2b..a91818884 100644 --- a/tests/Unit/Handler/Api/OrderEndpointPaymentTypeHandlerTest.php +++ b/tests/Unit/Handler/Api/OrderEndpointPaymentTypeHandlerTest.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ use Mollie\Enum\PaymentTypeEnum; use Mollie\Handler\Api\OrderEndpointPaymentTypeHandler; diff --git a/tests/Unit/Handler/RetryHandlerTest.php b/tests/Unit/Handler/RetryHandlerTest.php index 22a16e428..418b13724 100644 --- a/tests/Unit/Handler/RetryHandlerTest.php +++ b/tests/Unit/Handler/RetryHandlerTest.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ use Mollie\Exception\OrderCreationException; use Mollie\Exception\RetryOverException; diff --git a/tests/Unit/Handler/Shipment/ShipmentSenderHandlerTest.php b/tests/Unit/Handler/Shipment/ShipmentSenderHandlerTest.php index 6d90992a0..73362b43e 100644 --- a/tests/Unit/Handler/Shipment/ShipmentSenderHandlerTest.php +++ b/tests/Unit/Handler/Shipment/ShipmentSenderHandlerTest.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ use Mollie\Api\MollieApiClient; use Mollie\Exception\ShipmentCannotBeSentException; diff --git a/tests/Unit/Provider/PaymentFeeProviderTest.php b/tests/Unit/Provider/PaymentFeeProviderTest.php index 7051d1a0b..e86d60ac6 100644 --- a/tests/Unit/Provider/PaymentFeeProviderTest.php +++ b/tests/Unit/Provider/PaymentFeeProviderTest.php @@ -1,9 +1,19 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Tests\Unit\Provider; use Address; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; use Mollie\Config\Config; use Mollie\Exception\ExceptionCode; use Mollie\Exception\FailedToProvidePaymentFeeException; @@ -16,7 +26,7 @@ class PaymentFeeProviderTest extends TestCase { - /** @var LegacyContext */ + /** @var Context */ private $context; /** @var AddressRepositoryInterface */ private $addressRepository; @@ -37,7 +47,7 @@ public function setUp() { parent::setUp(); - $this->context = $this->createMock(LegacyContext::class); + $this->context = $this->createMock(Context::class); $this->addressRepository = $this->createMock(AddressRepositoryInterface::class); $this->taxCalculatorProvider = $this->createMock(TaxCalculatorProvider::class); diff --git a/tests/Unit/Provider/TaxCalculatorProviderTest.php b/tests/Unit/Provider/TaxCalculatorProviderTest.php index 9d0c941e4..c335917a7 100644 --- a/tests/Unit/Provider/TaxCalculatorProviderTest.php +++ b/tests/Unit/Provider/TaxCalculatorProviderTest.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Tests\Unit\Provider; diff --git a/tests/Unit/Service/CartLinesServiceTest.php b/tests/Unit/Service/CartLinesServiceTest.php index f16bddf3c..c4aee83a9 100644 --- a/tests/Unit/Service/CartLinesServiceTest.php +++ b/tests/Unit/Service/CartLinesServiceTest.php @@ -13,7 +13,7 @@ namespace Service; use Mollie\Adapter\ConfigurationAdapter; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; use Mollie\Adapter\ToolsAdapter; use Mollie\DTO\Line; use Mollie\DTO\Object\Amount; @@ -74,7 +74,7 @@ public function testGetCartLines( } $voucherService = $this->getMockBuilder(VoucherService::class)->disableOriginalConstructor()->getMock(); - $context = $this->getMockBuilder(LegacyContext::class)->getMock(); + $context = $this->getMockBuilder(Context::class)->getMock(); $cartLineService = new CartLinesService($languageService, $voucherService, $toolsAdapter, $context); diff --git a/tests/Unit/Service/PaymentMethod/PaymentMethodRestrictionValidation/AmountPaymentRestrictionValidationTest.php b/tests/Unit/Service/PaymentMethod/PaymentMethodRestrictionValidation/AmountPaymentRestrictionValidationTest.php index 4c3fac144..ae347e396 100644 --- a/tests/Unit/Service/PaymentMethod/PaymentMethodRestrictionValidation/AmountPaymentRestrictionValidationTest.php +++ b/tests/Unit/Service/PaymentMethod/PaymentMethodRestrictionValidation/AmountPaymentRestrictionValidationTest.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ use Mollie\Config\Config; use Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\AmountPaymentMethodRestrictionValidator; diff --git a/tests/Unit/Service/PaymentMethod/PaymentMethodRestrictionValidation/ApplePayPaymentRestrictionValidationTest.php b/tests/Unit/Service/PaymentMethod/PaymentMethodRestrictionValidation/ApplePayPaymentRestrictionValidationTest.php index 7958a0bd0..6a655079e 100644 --- a/tests/Unit/Service/PaymentMethod/PaymentMethodRestrictionValidation/ApplePayPaymentRestrictionValidationTest.php +++ b/tests/Unit/Service/PaymentMethod/PaymentMethodRestrictionValidation/ApplePayPaymentRestrictionValidationTest.php @@ -1,6 +1,17 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Tests\Unit\Service\PaymentMethod\PaymentMethodRestrictionValidation; -use Mollie\Adapter\LegacyContext; use Mollie\Config\Config; use Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidation\ApplePayPaymentMethodRestrictionValidator; use Mollie\Tests\Unit\Tools\UnitTestCase; @@ -13,11 +24,7 @@ class ApplePayPaymentRestrictionValidationTest extends UnitTestCase public function testIsValid($isApple, $configurationAdapter, $expectedResult) { $_COOKIE['isApplePayMethod'] = $isApple; - $contextMock = $this->getMockBuilder(LegacyContext::class) - ->disableOriginalConstructor() - ->getMock(); $applePayValidation = new ApplePayPaymentMethodRestrictionValidator( - $contextMock, $configurationAdapter ); @@ -60,7 +67,6 @@ public function getApplePayPaymentRestrictionValidationDataProvider() public function testIsSupported($paymentName, $expectedResult) { $applePayValidation = new ApplePayPaymentMethodRestrictionValidator( - $this->mockContext('AT', 'AUD'), $this->mockConfigurationAdapter([ 'PS_SSL_ENABLED_EVERYWHERE' => true, ]) diff --git a/tests/Unit/Service/PaymentMethod/PaymentMethodRestrictionValidation/VersionSpecificPaymentRestrictionValidationTest.php b/tests/Unit/Service/PaymentMethod/PaymentMethodRestrictionValidation/VersionSpecificPaymentRestrictionValidationTest.php index 2316daf93..3b1920586 100644 --- a/tests/Unit/Service/PaymentMethod/PaymentMethodRestrictionValidation/VersionSpecificPaymentRestrictionValidationTest.php +++ b/tests/Unit/Service/PaymentMethod/PaymentMethodRestrictionValidation/VersionSpecificPaymentRestrictionValidationTest.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ use Mollie\Config\Config; use Mollie\Provider\EnvironmentVersionProvider; @@ -24,7 +34,7 @@ class VersionSpecificPaymentRestrictionValidationTest extends UnitTestCase private $paymentMethod; /** - * @var \Mollie\Adapter\LegacyContext|PHPUnit_Framework_MockObject_MockObject + * @var \Mollie\Adapter\Context|PHPUnit_Framework_MockObject_MockObject */ private $context; diff --git a/tests/Unit/Service/PaymentMethod/PaymentMethodSortProviderTest.php b/tests/Unit/Service/PaymentMethod/PaymentMethodSortProviderTest.php index 0a9f2551e..bf5fa27cb 100644 --- a/tests/Unit/Service/PaymentMethod/PaymentMethodSortProviderTest.php +++ b/tests/Unit/Service/PaymentMethod/PaymentMethodSortProviderTest.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ use Mollie\Service\PaymentMethod\PaymentMethodSortProvider; use PHPUnit\Framework\TestCase; diff --git a/tests/Unit/Service/UpgradeNoticeServiceTest.php b/tests/Unit/Service/UpgradeNoticeServiceTest.php index 5e446232d..84102f94e 100644 --- a/tests/Unit/Service/UpgradeNoticeServiceTest.php +++ b/tests/Unit/Service/UpgradeNoticeServiceTest.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ use Mollie\Service\UpgradeNoticeService; use PHPUnit\Framework\TestCase; diff --git a/tests/Unit/Service/index.php b/tests/Unit/Service/index.php index 2701cf51a..d3343995f 100644 --- a/tests/Unit/Service/index.php +++ b/tests/Unit/Service/index.php @@ -1,30 +1,14 @@ -* @copyright 2007-2016 PrestaShop SA -* @version Release: $Revision$ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); diff --git a/tests/Unit/Tools/UnitTestCase.php b/tests/Unit/Tools/UnitTestCase.php index 593382289..e996f2ef2 100644 --- a/tests/Unit/Tools/UnitTestCase.php +++ b/tests/Unit/Tools/UnitTestCase.php @@ -15,7 +15,7 @@ use Cart; use Currency; use Mollie\Adapter\ConfigurationAdapter; -use Mollie\Adapter\LegacyContext; +use Mollie\Adapter\Context; use Mollie\Api\Resources\Method; use Mollie\Repository\PaymentMethodRepositoryInterface; use MolPaymentMethod; @@ -42,7 +42,7 @@ public function mockMethodResponse($minimumAmountValue, $maximumAmountValue) public function mockContext($countryCode, $currencyCode) { - $contextMock = $this->getMockBuilder(LegacyContext::class) + $contextMock = $this->getMockBuilder(Context::class) ->disableOriginalConstructor() ->getMock(); @@ -76,7 +76,7 @@ public function mockContext($countryCode, $currencyCode) public function mockContextWithCookie($cookieValue) { - $contextMock = $this->getMockBuilder(LegacyContext::class) + $contextMock = $this->getMockBuilder(Context::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Unit/Utility/ApplePayDirect/ShippingMethodUtilityTest.php b/tests/Unit/Utility/ApplePayDirect/ShippingMethodUtilityTest.php index fca9fce2d..387e820a9 100644 --- a/tests/Unit/Utility/ApplePayDirect/ShippingMethodUtilityTest.php +++ b/tests/Unit/Utility/ApplePayDirect/ShippingMethodUtilityTest.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ use Mollie\DTO\ApplePay\Carrier\Carrier as AppleCarrier; use Mollie\Utility\ApplePayDirect\ShippingMethodUtility; diff --git a/tests/Unit/Utility/CalculationUtilityTest.php b/tests/Unit/Utility/CalculationUtilityTest.php index d293248ce..606a31fcd 100644 --- a/tests/Unit/Utility/CalculationUtilityTest.php +++ b/tests/Unit/Utility/CalculationUtilityTest.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ use Mollie\Utility\CalculationUtility; use PHPUnit\Framework\TestCase; diff --git a/tests/Unit/Utility/NumberUtilityTest.php b/tests/Unit/Utility/NumberUtilityTest.php index 8e0f2300b..2373d1107 100644 --- a/tests/Unit/Utility/NumberUtilityTest.php +++ b/tests/Unit/Utility/NumberUtilityTest.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ namespace Mollie\Tests\Unit\Utility; diff --git a/tests/Unit/Validator/OrderConfirmationMailValidatorTest.php b/tests/Unit/Validator/OrderConfirmationMailValidatorTest.php index 7372340ea..fb71a4528 100644 --- a/tests/Unit/Validator/OrderConfirmationMailValidatorTest.php +++ b/tests/Unit/Validator/OrderConfirmationMailValidatorTest.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ use Mollie\Adapter\ConfigurationAdapter; use Mollie\Config\Config; diff --git a/tests/Unit/Verification/PaymentType/CanBeRegularPaymentTypeTest.php b/tests/Unit/Verification/PaymentType/CanBeRegularPaymentTypeTest.php index 8b6ba333b..e4e126e83 100644 --- a/tests/Unit/Verification/PaymentType/CanBeRegularPaymentTypeTest.php +++ b/tests/Unit/Verification/PaymentType/CanBeRegularPaymentTypeTest.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ use PHPUnit\Framework\TestCase; diff --git a/tests/Unit/Verification/Shipment/CanSendShipmentTest.php b/tests/Unit/Verification/Shipment/CanSendShipmentTest.php index f309de0d8..2175dde56 100644 --- a/tests/Unit/Verification/Shipment/CanSendShipmentTest.php +++ b/tests/Unit/Verification/Shipment/CanSendShipmentTest.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ use Mollie\Config\Config; use Mollie\Enum\PaymentTypeEnum; diff --git a/tests/Unit/index.php b/tests/Unit/index.php index 2701cf51a..d3343995f 100644 --- a/tests/Unit/index.php +++ b/tests/Unit/index.php @@ -1,30 +1,14 @@ -* @copyright 2007-2016 PrestaShop SA -* @version Release: $Revision$ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index f29c2f9d7..840c15dd1 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,5 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ $projectDir = __DIR__ . '/../'; require_once $projectDir . 'vendor/autoload.php'; diff --git a/tests/index.php b/tests/index.php index 2701cf51a..d3343995f 100644 --- a/tests/index.php +++ b/tests/index.php @@ -1,30 +1,14 @@ -* @copyright 2007-2016 PrestaShop SA -* @version Release: $Revision$ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); diff --git a/tests/phpstan/index.php b/tests/phpstan/index.php index 2701cf51a..d3343995f 100644 --- a/tests/phpstan/index.php +++ b/tests/phpstan/index.php @@ -1,30 +1,14 @@ -* @copyright 2007-2016 PrestaShop SA -* @version Release: $Revision$ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); diff --git a/tests/phpstan/phpstan_base.neon b/tests/phpstan/phpstan_base.neon index 779b83bec..0f38232ac 100644 --- a/tests/phpstan/phpstan_base.neon +++ b/tests/phpstan/phpstan_base.neon @@ -35,5 +35,8 @@ parameters: - '#Access to an undefined property Cookie\:\:\$[a-zA-Z0-9_]+#' - '#Parameter \#1 \$value of method ControllerCore\:\:ajaxRender\(\) expects null, string\|false given.#' - '#Call to function is_subclass_of\(\) with.*will always evaluate to false.#' + - '#ps_eventbus#' + - '#Ps_eventbus#' + - '#PsEventbus#' level: 5 diff --git a/tests/seed/settings/defines.inc.php b/tests/seed/settings/defines.inc.php index 47f30550d..5c3ffbaf8 100644 --- a/tests/seed/settings/defines.inc.php +++ b/tests/seed/settings/defines.inc.php @@ -1,27 +1,13 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * 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 license@prestashop.com 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 https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ /* Debug only */ diff --git a/tests/seed/settings/parameters.php b/tests/seed/settings/parameters.php index cb2cebadc..e2167a41d 100644 --- a/tests/seed/settings/parameters.php +++ b/tests/seed/settings/parameters.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ return [ 'parameters' => [ diff --git a/tests/seed/settings1784/defines.inc.php b/tests/seed/settings1784/defines.inc.php index 47f30550d..5c3ffbaf8 100644 --- a/tests/seed/settings1784/defines.inc.php +++ b/tests/seed/settings1784/defines.inc.php @@ -1,27 +1,13 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * 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 license@prestashop.com 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 https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ /* Debug only */ diff --git a/tests/seed/settings1784/parameters.php b/tests/seed/settings1784/parameters.php index cb2cebadc..e2167a41d 100644 --- a/tests/seed/settings1784/parameters.php +++ b/tests/seed/settings1784/parameters.php @@ -1,4 +1,14 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ return [ 'parameters' => [ diff --git a/translations/de.php b/translations/de.php index bac682647..5a9cf41bf 100644 --- a/translations/de.php +++ b/translations/de.php @@ -1,4 +1,15 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + global $_MODULE; $_MODULE = array(); diff --git a/translations/en.php b/translations/en.php index 13a3c1d27..ebad9f7b5 100644 --- a/translations/en.php +++ b/translations/en.php @@ -1,4 +1,15 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + global $_MODULE; $_MODULE = array(); diff --git a/translations/fr.php b/translations/fr.php index 9ef7b5590..490de177c 100644 --- a/translations/fr.php +++ b/translations/fr.php @@ -1,4 +1,15 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + global $_MODULE; $_MODULE = array(); diff --git a/translations/nl.php b/translations/nl.php index 6b63e1d76..1228fe757 100644 --- a/translations/nl.php +++ b/translations/nl.php @@ -1,4 +1,15 @@ + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + global $_MODULE; $_MODULE = array(); diff --git a/upgrade/Upgrade-4.0.7.php b/upgrade/Upgrade-4.0.7.php index c5bde049a..94ba08647 100644 --- a/upgrade/Upgrade-4.0.7.php +++ b/upgrade/Upgrade-4.0.7.php @@ -51,7 +51,7 @@ function upgrade_module_4_0_7($module) $module->registerHook('actionValidateOrder'); /** @var Installer $installer */ - $installer = $module->getMollieContainer(Installer::class); + $installer = $module->getService(Installer::class); $installed = true; $installed &= $installer->installTab('AdminMollieAjax', 0, 'AdminMollieAjax', false); diff --git a/upgrade/Upgrade-4.0.8.php b/upgrade/Upgrade-4.0.8.php index 688313ad6..851752182 100644 --- a/upgrade/Upgrade-4.0.8.php +++ b/upgrade/Upgrade-4.0.8.php @@ -26,7 +26,7 @@ function upgrade_module_4_0_8(Mollie $module) { /** @var ConfigurationAdapter $configuration */ - $configuration = $module->getMollieContainer(ConfigurationAdapter::class); + $configuration = $module->getService(ConfigurationAdapter::class); $configuration->updateValue(Config::MOLLIE_ENVIRONMENT, Config::ENVIRONMENT_LIVE); $configuration->updateValue(Config::MOLLIE_SINGLE_CLICK_PAYMENT, 0); diff --git a/upgrade/Upgrade-4.1.0.php b/upgrade/Upgrade-4.1.0.php index b0533ee5b..29d4c406c 100644 --- a/upgrade/Upgrade-4.1.0.php +++ b/upgrade/Upgrade-4.1.0.php @@ -12,6 +12,7 @@ use Mollie\Config\Config; use Mollie\Install\Installer; +use Mollie\Repository\PaymentMethodRepositoryInterface; if (!defined('_PS_VERSION_')) { exit; @@ -25,7 +26,7 @@ function upgrade_module_4_1_0($module) { /** @var Installer $installer */ - $installer = $module->getMollieContainer(Installer::class); + $installer = $module->getService(Installer::class); $awaitingOrderStatusId = Configuration::get(Config::MOLLIE_STATUS_AWAITING); $orderStatus = new OrderState($awaitingOrderStatusId); @@ -45,12 +46,12 @@ function upgrade_module_4_1_0($module) return false; } - /** @var \Mollie\Repository\PaymentMethodRepositoryInterface $paymentMethodsRepo */ - $paymentMethodsRepo = $module->getMollieContainer(\Mollie\Repository\PaymentMethodRepositoryInterface::class); + /** @var PaymentMethodRepositoryInterface $paymentMethodsRepo */ + $paymentMethodsRepo = $module->getService(PaymentMethodRepositoryInterface::class); $paymentMethods = $paymentMethodsRepo->findAll(); /** @var Installer $installer */ - $installer = $module->getMollieContainer(Installer::class); + $installer = $module->getService(Installer::class); $installer->installVoucherFeatures(); foreach ($installer::getHooks() as $hook) { diff --git a/upgrade/Upgrade-4.2.0.php b/upgrade/Upgrade-4.2.0.php index 2ad5c508b..ea901920d 100644 --- a/upgrade/Upgrade-4.2.0.php +++ b/upgrade/Upgrade-4.2.0.php @@ -11,6 +11,7 @@ use Mollie\Config\Config; use Mollie\Install\Installer; +use Mollie\Install\OrderStateInstaller; use Mollie\Service\OrderStateImageService; if (!defined('_PS_VERSION_')) { @@ -25,19 +26,18 @@ function upgrade_module_4_2_0($module) { /** @var Mollie\Tracker\Segment $segment */ - $segment = $module->getMollieContainer(Mollie\Tracker\Segment::class); + $segment = $module->getService(Mollie\Tracker\Segment::class); $segment->setMessage('Mollie upgrade 4.2.0'); $segment->track(); - /** @var Installer $installer */ - $installer = $module->getMollieContainer(Installer::class); + /** @var OrderStateInstaller $orderStateInstaller */ + $orderStateInstaller = $module->getService(OrderStateInstaller::class); - $installer->klarnaPaymentAuthorizedState(); - $installer->klarnaPaymentShippedState(); + $orderStateInstaller->install(); - $acceptedStatusId = Configuration::get(Config::MOLLIE_STATUS_KLARNA_AUTHORIZED); - Configuration::updateValue(Config::MOLLIE_KLARNA_INVOICE_ON, $acceptedStatusId); + $acceptedStatusId = Configuration::get(Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED); + Configuration::updateValue(Config::MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS, $acceptedStatusId); $module->registerHook('actionOrderGridQueryBuilderModifier'); $module->registerHook('actionOrderGridDefinitionModifier'); @@ -64,7 +64,7 @@ function upgrade_module_4_2_0($module) /** * @var OrderStateImageService $imageService */ - $imageService = $module->getMollieContainer(OrderStateImageService::class); + $imageService = $module->getService(OrderStateImageService::class); $mollieOrderStatuses = Config::getMollieOrderStatuses(); foreach ($mollieOrderStatuses as $mollieOrderStatus) { diff --git a/upgrade/Upgrade-4.3.0.php b/upgrade/Upgrade-4.3.0.php index 3a43c79bb..cea716fa5 100644 --- a/upgrade/Upgrade-4.3.0.php +++ b/upgrade/Upgrade-4.3.0.php @@ -39,7 +39,7 @@ function upgrade_module_4_3_0($module) } /** @var \Mollie\Repository\PaymentMethodRepositoryInterface $paymentMethodRepo */ - $paymentMethodRepo = $module->getMollieContainer(\Mollie\Repository\PaymentMethodRepositoryInterface::class); + $paymentMethodRepo = $module->getService(\Mollie\Repository\PaymentMethodRepositoryInterface::class); $sql = new DbQuery(); $sql->select('`id_mol_country`, `id_method`'); diff --git a/upgrade/Upgrade-4.4.0.php b/upgrade/Upgrade-4.4.0.php index df3e46104..7d48defdb 100644 --- a/upgrade/Upgrade-4.4.0.php +++ b/upgrade/Upgrade-4.4.0.php @@ -24,7 +24,7 @@ function upgrade_module_4_4_0($module) { /** @var ConfigurationAdapter $configurationAdapter */ - $configurationAdapter = $module->getMollieContainer(ConfigurationAdapter::class); + $configurationAdapter = $module->getService(ConfigurationAdapter::class); $shops = Shop::getShops(); foreach ($shops as $shop) { if ((int) $configurationAdapter->get(Config::MOLLIE_SEND_ORDER_CONFIRMATION, $shop['id_shop']) !== Config::NEW_ORDER_MAIL_SEND_ON_NEVER) { diff --git a/upgrade/Upgrade-5.3.0.php b/upgrade/Upgrade-5.3.0.php index 2f4960108..1ac1647a7 100644 --- a/upgrade/Upgrade-5.3.0.php +++ b/upgrade/Upgrade-5.3.0.php @@ -25,7 +25,7 @@ function upgrade_module_5_3_0(Mollie $module) Configuration::updateValue(Config::MOLLIE_MAIL_WHEN_CHARGEBACK, true); /** @var Installer $installer */ - $installer = $module->getMollieContainer(Installer::class); + $installer = $module->getService(Installer::class); $installer->createChargedbackState(); diff --git a/upgrade/Upgrade-5.4.1.php b/upgrade/Upgrade-5.4.1.php index b63034e60..5ed116b03 100644 --- a/upgrade/Upgrade-5.4.1.php +++ b/upgrade/Upgrade-5.4.1.php @@ -1,5 +1,4 @@ getMollieContainer(ConfigurationAdapter::class); + $configuration = $module->getService(ConfigurationAdapter::class); $configuration->updateValue(Config::MOLLIE_IFRAME['production'], Configuration::get('MOLLIE_IFRAME')); $configuration->updateValue(Config::MOLLIE_IFRAME['sandbox'], Configuration::get('MOLLIE_IFRAME')); diff --git a/upgrade/Upgrade-5.4.2.php b/upgrade/Upgrade-5.4.2.php index 4eb467563..c818b9455 100644 --- a/upgrade/Upgrade-5.4.2.php +++ b/upgrade/Upgrade-5.4.2.php @@ -1,5 +1,4 @@ getMollieContainer(ConfigurationAdapter::class); + $configuration = $module->getService(ConfigurationAdapter::class); $configuration->updateValue(Config::MOLLIE_APPLE_PAY_DIRECT_PRODUCT, (int) $configuration->get('MOLLIE_APPLE_PAY_DIRECT')); $configuration->updateValue(Config::MOLLIE_APPLE_PAY_DIRECT_CART, (int) $configuration->get('MOLLIE_APPLE_PAY_DIRECT')); diff --git a/upgrade/Upgrade-5.4.3.php b/upgrade/Upgrade-5.4.3.php new file mode 100644 index 000000000..4a142c931 --- /dev/null +++ b/upgrade/Upgrade-5.4.3.php @@ -0,0 +1,179 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + */ + +use Mollie\Adapter\ConfigurationAdapter; +use Mollie\Config\Config; +use Mollie\Install\ModuleTabInstaller; +use Mollie\Logger\PrestaLoggerInterface; +use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder; +use PrestaShop\PsAccountsInstaller\Installer\Installer as PsAccountsInstaller; + +if (!defined('_PS_VERSION_')) { + exit; +} + +function upgrade_module_5_4_3(Mollie $module): bool +{ + /** @var ModuleTabInstaller $moduleTabInstaller */ + $moduleTabInstaller = $module->getService(ModuleTabInstaller::class); + + /** @var PrestaLoggerInterface $logger */ + $logger = $module->getService(PrestaLoggerInterface::class); + + try { + $moduleTabInstaller->init(); + } catch (\Throwable $exception) { + $logger->error('Failed to install module tabs. Please contact support.', [ + 'Exception message' => $exception->getMessage(), + 'Exception code' => $exception->getCode(), + ]); + + return false; + } + + updateConfigurationValues543($module); + updateOrderStatusNames543($module); + + return installPsAccounts543($module) + && installCloudSync543($module); +} + +function installPsAccounts543(Mollie $module): bool +{ + /** @var PrestaLoggerInterface $logger */ + $logger = $module->getService(PrestaLoggerInterface::class); + + try { + /** @var PsAccountsInstaller $prestashopAccountsInstaller */ + $prestashopAccountsInstaller = $module->getService(PsAccountsInstaller::class); + + if (!$prestashopAccountsInstaller->install()) { + $logger->error('Failed to install Prestashop Accounts module. Please contact support.'); + + return false; + } + } catch (\Throwable $exception) { + $logger->error('Failed to install Prestashop Accounts module. Please contact support.', [ + 'Exception message' => $exception->getMessage(), + 'Exception code' => $exception->getCode(), + ]); + + return false; + } + + return true; +} + +function installCloudSync543(Mollie $module): bool +{ + /** @var PrestaLoggerInterface $logger */ + $logger = $module->getService(PrestaLoggerInterface::class); + + $moduleManager = ModuleManagerBuilder::getInstance()->build(); + + try { + if ( + $moduleManager->isInstalled('ps_eventbus') && + !$moduleManager->isEnabled('ps_eventbus') + ) { + $moduleManager->enable('ps_eventbus'); + } + + $moduleManager->install('ps_eventbus'); + } catch (Exception $exception) { + $logger->error('Failed to install/upgrade Prestashop event bus module. Please contact support.', [ + 'Exception message' => $exception->getMessage(), + 'Exception code' => $exception->getCode(), + ]); + + return false; + } + + return true; +} + +function updateConfigurationValues543(Mollie $module) +{ + /** @var ConfigurationAdapter $configuration */ + $configuration = $module->getService(ConfigurationAdapter::class); + + if ( + !empty($configuration->get(Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED)) + && !empty($configuration->get(Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED)) + && !empty($configuration->get(Config::MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS)) + && empty($configuration->get('MOLLIE_STATUS_KLARNA_AUTHORIZED')) + && empty($configuration->get('MOLLIE_STATUS_KLARNA_SHIPPED')) + && empty($configuration->get('MOLLIE_KLARNA_INVOICE_ON')) + ) { + return; + } + + $klarnaInvoiceOn = $configuration->get('MOLLIE_KLARNA_INVOICE_ON'); + + switch ($klarnaInvoiceOn) { + case 'MOLLIE_STATUS_KLARNA_AUTHORIZED': + $configuration->updateValue( + Config::MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS, + Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED + ); + break; + case 'MOLLIE_STATUS_KLARNA_SHIPPED': + $configuration->updateValue( + Config::MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS, + Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED + ); + break; + default: + $configuration->updateValue( + Config::MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS, + Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_DEFAULT + ); + } + + $configuration->updateValue(Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED, (int) $configuration->get('MOLLIE_STATUS_KLARNA_AUTHORIZED')); + $configuration->updateValue(Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED, (int) $configuration->get('MOLLIE_STATUS_KLARNA_SHIPPED')); + + $configuration->delete('MOLLIE_STATUS_KLARNA_AUTHORIZED'); + $configuration->delete('MOLLIE_STATUS_KLARNA_SHIPPED'); + $configuration->delete('MOLLIE_KLARNA_INVOICE_ON'); +} + +function updateOrderStatusNames543(Mollie $module) +{ + /** @var ConfigurationAdapter $configuration */ + $configuration = $module->getService(ConfigurationAdapter::class); + + $authorizablePaymentStatusShippedId = (int) $configuration->get(Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED); + $authorizablePaymentStatusShipped = new OrderState((int) $authorizablePaymentStatusShippedId); + + if (is_array($authorizablePaymentStatusShipped->name)) { + foreach ($authorizablePaymentStatusShipped->name as $langId => $name) { + $authorizablePaymentStatusShipped->name[$langId] = 'Order payment shipped'; + } + } else { + $authorizablePaymentStatusShipped->name = 'Order payment shipped'; + } + + $authorizablePaymentStatusShipped->save(); + + $authorizablePaymentStatusAuthorizedId = (int) $configuration->get(Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED); + $authorizablePaymentStatusAuthorized = new OrderState((int) $authorizablePaymentStatusAuthorizedId); + + if (is_array($authorizablePaymentStatusAuthorized->name)) { + foreach ($authorizablePaymentStatusAuthorized->name as $langId => $name) { + $authorizablePaymentStatusAuthorized->name[$langId] = 'Order payment authorized'; + } + } else { + $authorizablePaymentStatusAuthorized->name = 'Order payment authorized'; + } + + $authorizablePaymentStatusAuthorized->save(); +} diff --git a/views/PrestaShop/Admin/Common/Grid/Actions/Row/second_chance.html.twig b/views/PrestaShop/Admin/Common/Grid/Actions/Row/second_chance.html.twig index bbf09e51b..ed6e2e5af 100644 --- a/views/PrestaShop/Admin/Common/Grid/Actions/Row/second_chance.html.twig +++ b/views/PrestaShop/Admin/Common/Grid/Actions/Row/second_chance.html.twig @@ -1,3 +1,13 @@ +{#** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + *#} {% set route_params = { (action.options.route_param_name) : (record[action.options.route_param_field]) } %} diff --git a/views/css/admin/logo_input.css b/views/css/admin/logo_input.css index 96c64bf7c..a185c69f5 100644 --- a/views/css/admin/logo_input.css +++ b/views/css/admin/logo_input.css @@ -1,3 +1,16 @@ +.header-logo { + width: 263px; + align-content: center; + text-align: left; + padding: 20px 0; +} + +.header-logo img { + max-width:100%; + height:auto; + margin: 0 auto; +} + .mollie-input-file { width: 0.1px; height: 0.1px; diff --git a/views/css/admin/menu.css b/views/css/admin/menu.css index 30ebf711b..45fd2f223 100644 --- a/views/css/admin/menu.css +++ b/views/css/admin/menu.css @@ -1,13 +1,3 @@ -/** - * Mollie https://www.mollie.nl - * - * @author Mollie B.V. - * @copyright Mollie B.V. - * - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * - * @see https://github.com/mollie/PrestaShop - */ /** * Mollie https://www.mollie.nl * diff --git a/views/css/admin/order-list.css b/views/css/admin/order-list.css index d143d7ebe..e19ba6114 100644 --- a/views/css/admin/order-list.css +++ b/views/css/admin/order-list.css @@ -1,13 +1,3 @@ -/** - * Mollie https://www.mollie.nl - * - * @author Mollie B.V. - * @copyright Mollie B.V. - * - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * - * @see https://github.com/mollie/PrestaShop - */ /** * Mollie https://www.mollie.nl * diff --git a/views/css/front.css b/views/css/front.css index 28789577c..e3ec0f5cc 100644 --- a/views/css/front.css +++ b/views/css/front.css @@ -1,13 +1,3 @@ -/** - * Mollie https://www.mollie.nl - * - * @author Mollie B.V. - * @copyright Mollie B.V. - * - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * - * @see https://github.com/mollie/PrestaShop - */ /** * Mollie https://www.mollie.nl * diff --git a/views/css/front/bancontact_qr_code.css b/views/css/front/bancontact_qr_code.css index 5db67e8b4..cb3bb8e2a 100644 --- a/views/css/front/bancontact_qr_code.css +++ b/views/css/front/bancontact_qr_code.css @@ -1,3 +1,13 @@ +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ #mollie-bancontact-qr-code { width: 180px; height: 180px; diff --git a/views/js/admin/_configure/configuration.js b/views/js/admin/_configure/configuration.js new file mode 100644 index 000000000..ccc6a88e7 --- /dev/null +++ b/views/js/admin/_configure/configuration.js @@ -0,0 +1,23 @@ +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ +$(document).ready(function () { + window?.psaccountsVue?.init(); + // CloudSync + 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); + }); +}); diff --git a/views/js/admin/_configure/index.php b/views/js/admin/_configure/index.php new file mode 100644 index 000000000..d3343995f --- /dev/null +++ b/views/js/admin/_configure/index.php @@ -0,0 +1,20 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ +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; diff --git a/views/js/admin/api_key_test.js b/views/js/admin/api_key_test.js index 7b7981c70..2d1cac691 100644 --- a/views/js/admin/api_key_test.js +++ b/views/js/admin/api_key_test.js @@ -1,13 +1,3 @@ -/** - * Mollie https://www.mollie.nl - * - * @author Mollie B.V. - * @copyright Mollie B.V. - * - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * - * @see https://github.com/mollie/PrestaShop - */ /** * Mollie https://www.mollie.nl * diff --git a/views/js/admin/commands/translation_commands.js b/views/js/admin/commands/translation_commands.js index e94d4f826..6519fe859 100644 --- a/views/js/admin/commands/translation_commands.js +++ b/views/js/admin/commands/translation_commands.js @@ -1,13 +1,3 @@ -/** - * Mollie https://www.mollie.nl - * - * @author Mollie B.V. - * @copyright Mollie B.V. - * - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * - * @see https://github.com/mollie/PrestaShop - */ /** * Mollie https://www.mollie.nl * diff --git a/views/js/admin/custom_logo.js b/views/js/admin/custom_logo.js index f9c5ac85d..64aa145c2 100644 --- a/views/js/admin/custom_logo.js +++ b/views/js/admin/custom_logo.js @@ -1,13 +1,3 @@ -/** - * Mollie https://www.mollie.nl - * - * @author Mollie B.V. - * @copyright Mollie B.V. - * - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * - * @see https://github.com/mollie/PrestaShop - */ /** * Mollie https://www.mollie.nl * diff --git a/views/js/admin/init_mollie_account.js b/views/js/admin/init_mollie_account.js index ef5be982d..1a7ea3a1c 100644 --- a/views/js/admin/init_mollie_account.js +++ b/views/js/admin/init_mollie_account.js @@ -1,13 +1,3 @@ -/** - * Mollie https://www.mollie.nl - * - * @author Mollie B.V. - * @copyright Mollie B.V. - * - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * - * @see https://github.com/mollie/PrestaShop - */ /** * Mollie https://www.mollie.nl * diff --git a/views/js/admin/order_add.js b/views/js/admin/order_add.js index 8770269b3..47f3e4213 100644 --- a/views/js/admin/order_add.js +++ b/views/js/admin/order_add.js @@ -1,13 +1,3 @@ -/** - * Mollie https://www.mollie.nl - * - * @author Mollie B.V. - * @copyright Mollie B.V. - * - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * - * @see https://github.com/mollie/PrestaShop - */ /** * Mollie https://www.mollie.nl * diff --git a/views/js/admin/order_list.js b/views/js/admin/order_list.js index 74e64e053..20aafabdf 100644 --- a/views/js/admin/order_list.js +++ b/views/js/admin/order_list.js @@ -1,13 +1,3 @@ -/** - * Mollie https://www.mollie.nl - * - * @author Mollie B.V. - * @copyright Mollie B.V. - * - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * - * @see https://github.com/mollie/PrestaShop - */ /** * Mollie https://www.mollie.nl * diff --git a/views/js/admin/payment_methods.js b/views/js/admin/payment_methods.js index 9b028a118..272789cc7 100644 --- a/views/js/admin/payment_methods.js +++ b/views/js/admin/payment_methods.js @@ -1,13 +1,3 @@ -/** - * Mollie https://www.mollie.nl - * - * @author Mollie B.V. - * @copyright Mollie B.V. - * - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * - * @see https://github.com/mollie/PrestaShop - */ /** * Mollie https://www.mollie.nl * diff --git a/views/js/admin/settings.js b/views/js/admin/settings.js index 8392f8e13..19bf06534 100644 --- a/views/js/admin/settings.js +++ b/views/js/admin/settings.js @@ -1,13 +1,3 @@ -/** - * Mollie https://www.mollie.nl - * - * @author Mollie B.V. - * @copyright Mollie B.V. - * - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * - * @see https://github.com/mollie/PrestaShop - */ /** * Mollie https://www.mollie.nl * diff --git a/views/js/admin/upgrade_notice.js b/views/js/admin/upgrade_notice.js index ceed4d266..9d10981b0 100644 --- a/views/js/admin/upgrade_notice.js +++ b/views/js/admin/upgrade_notice.js @@ -1,13 +1,3 @@ -/** - * Mollie https://www.mollie.nl - * - * @author Mollie B.V. - * @copyright Mollie B.V. - * - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * - * @see https://github.com/mollie/PrestaShop - */ /** * Mollie https://www.mollie.nl * diff --git a/views/js/apple_payment.js b/views/js/apple_payment.js index 2d9f5d7db..37bec2442 100644 --- a/views/js/apple_payment.js +++ b/views/js/apple_payment.js @@ -1,13 +1,3 @@ -/** - * Mollie https://www.mollie.nl - * - * @author Mollie B.V. - * @copyright Mollie B.V. - * - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * - * @see https://github.com/mollie/PrestaShop - */ /** * Mollie https://www.mollie.nl * diff --git a/views/js/dist/0.min.js b/views/js/dist/0.min.js index 5a209e842..05932d94d 100644 --- a/views/js/dist/0.min.js +++ b/views/js/dist/0.min.js @@ -1,10 +1,11 @@ -/*! - * - * Mollie https://www.mollie.nl - * @author Mollie B.V. - * @copyright Mollie B.V. - * @link https://github.com/mollie/PrestaShop - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ (window.webpackJsonP_mollie=window.webpackJsonP_mollie||[]).push([[0],{205:function(e,n,t){"use strict";t.r(n),t.d(n,"default",(function(){return d}));var a=t(56),r=t.n(a),l=t(59),u=t(83),o=Object(a.lazy)((function(){return Promise.all([t.e("vendors~transactionOrder~transactionRefund~updater"),t.e("vendors~transactionOrder~transactionRefund"),t.e("transactionRefund")]).then(t.bind(null,273))})),c=Object(a.lazy)((function(){return Promise.all([t.e("vendors~transactionOrder~transactionRefund~updater"),t.e("vendors~transactionOrder~transactionRefund"),t.e("vendors~transactionOrder"),t.e("transactionOrder")]).then(t.bind(null,272))}));function d(){var e=Object(a.useMemo)((function(){return u.default.getState()}),[]),n=e.payment,t=e.order;return r.a.createElement(l.a.Provider,{value:u.default},r.a.createElement(r.a.Fragment,null,n&&r.a.createElement(a.Suspense,{fallback:null},r.a.createElement(o,null)),t&&r.a.createElement(a.Suspense,{fallback:null},r.a.createElement(c,null))))}}}]); \ No newline at end of file diff --git a/views/js/dist/1.min.js b/views/js/dist/1.min.js index ea7193b0e..2b668d7b8 100644 --- a/views/js/dist/1.min.js +++ b/views/js/dist/1.min.js @@ -1,11 +1,12 @@ -/*! - * - * Mollie https://www.mollie.nl - * @author Mollie B.V. - * @copyright Mollie B.V. - * @link https://github.com/mollie/PrestaShop - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ (window["webpackJsonP_mollie"] = window["webpackJsonP_mollie"] || []).push([[1],{ diff --git a/views/js/dist/app.min.js b/views/js/dist/app.min.js index 710891a49..b8ad1fca0 100644 --- a/views/js/dist/app.min.js +++ b/views/js/dist/app.min.js @@ -1,10 +1,11 @@ -/*! - * - * Mollie https://www.mollie.nl - * @author Mollie B.V. - * @copyright Mollie B.V. - * @link https://github.com/mollie/PrestaShop - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ var MollieModule="object"==typeof MollieModule?MollieModule:{};MollieModule.app=function(r){function n(n){for(var t,c,s=n[0],u=n[1],d=n[2],f=n[3]||[],p=0,g=[];p - * @copyright Mollie B.V. - * @link https://github.com/mollie/PrestaShop - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ (window.webpackJsonP_mollie=window.webpackJsonP_mollie||[]).push([["banks","vendors~transactionOrder~transactionRefund~updater","vendors~sweetalert"],{100:function(t,e,n){var r=n(3),o=n(10),i=n(1)("match");t.exports=function(t){var e;return r(t)&&(void 0!==(e=t[i])?!!e:"RegExp"==o(t))}},104:function(t,e,n){var r=n(25),o=n(113)(!1);r(r.S,"Object",{values:function(t){return o(t)}})},105:function(t,e,n){(function(e,n){t.exports=function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=8)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="swal-button";e.CLASS_NAMES={MODAL:"swal-modal",OVERLAY:"swal-overlay",SHOW_MODAL:"swal-overlay--show-modal",MODAL_TITLE:"swal-title",MODAL_TEXT:"swal-text",ICON:"swal-icon",ICON_CUSTOM:"swal-icon--custom",CONTENT:"swal-content",FOOTER:"swal-footer",BUTTON_CONTAINER:"swal-button-container",BUTTON:r,CONFIRM_BUTTON:r+"--confirm",CANCEL_BUTTON:r+"--cancel",DANGER_BUTTON:r+"--danger",BUTTON_LOADING:r+"--loading",BUTTON_LOADER:r+"__loader"},e.default=e.CLASS_NAMES},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getNode=function(t){var e="."+t;return document.querySelector(e)},e.stringToNode=function(t){var e=document.createElement("div");return e.innerHTML=t.trim(),e.firstChild},e.insertAfter=function(t,e){var n=e.nextSibling;e.parentNode.insertBefore(t,n)},e.removeNode=function(t){t.parentElement.removeChild(t)},e.throwErr=function(t){throw"SweetAlert: "+(t=t.replace(/ +(?= )/g,"")).trim()},e.isPlainObject=function(t){if("[object Object]"!==Object.prototype.toString.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype},e.ordinalSuffixOf=function(t){var e=t%10,n=t%100;return 1===e&&11!==n?t+"st":2===e&&12!==n?t+"nd":3===e&&13!==n?t+"rd":t+"th"}},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),r(n(25));var o=n(26);e.overlayMarkup=o.default,r(n(27)),r(n(28)),r(n(29));var i=n(0),a=i.default.MODAL_TITLE,s=i.default.MODAL_TEXT,c=i.default.ICON,l=i.default.FOOTER;e.iconMarkup='\n
',e.titleMarkup='\n
\n',e.textMarkup='\n
',e.footerMarkup='\n
\n'},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(1);e.CONFIRM_KEY="confirm",e.CANCEL_KEY="cancel";var o={visible:!0,text:null,value:null,className:"",closeModal:!0},i=Object.assign({},o,{visible:!1,text:"Cancel",value:null}),a=Object.assign({},o,{text:"OK",value:!0});e.defaultButtonList={cancel:i,confirm:a};var s=function(t){switch(t){case e.CONFIRM_KEY:return a;case e.CANCEL_KEY:return i;default:var n=t.charAt(0).toUpperCase()+t.slice(1);return Object.assign({},o,{text:n,value:t})}},c=function(t,e){var n=s(t);return!0===e?Object.assign({},n,{visible:!0}):"string"==typeof e?Object.assign({},n,{visible:!0,text:e}):r.isPlainObject(e)?Object.assign({visible:!0},n,e):Object.assign({},n,{visible:!1})},l=function(t){var n={};switch(t.length){case 1:n[e.CANCEL_KEY]=Object.assign({},i,{visible:!1});break;case 2:n[e.CANCEL_KEY]=c(e.CANCEL_KEY,t[0]),n[e.CONFIRM_KEY]=c(e.CONFIRM_KEY,t[1]);break;default:r.throwErr("Invalid number of 'buttons' in array ("+t.length+").\n If you want more than 2 buttons, you need to use an object!")}return n};e.getButtonListOpts=function(t){var n=e.defaultButtonList;return"string"==typeof t?n[e.CONFIRM_KEY]=c(e.CONFIRM_KEY,t):Array.isArray(t)?n=l(t):r.isPlainObject(t)?n=function(t){for(var e={},n=0,r=Object.keys(t);n=0&&w.splice(e,1)}function s(t){var e=document.createElement("style");return t.attrs.type="text/css",l(e,t.attrs),i(t,e),e}function c(t){var e=document.createElement("link");return t.attrs.type="text/css",t.attrs.rel="stylesheet",l(e,t.attrs),i(t,e),e}function l(t,e){Object.keys(e).forEach((function(n){t.setAttribute(n,e[n])}))}function u(t,e){var n,r,o,i;if(e.transform&&t.css){if(!(i=e.transform(t.css)))return function(){};t.css=i}if(e.singleton){var l=v++;n=b||(b=s(e)),r=f.bind(null,n,l,!1),o=f.bind(null,n,l,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=c(e),r=p.bind(null,n,e),o=function(){a(n),n.href&&URL.revokeObjectURL(n.href)}):(n=s(e),r=d.bind(null,n),o=function(){a(n)});return r(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;r(t=e)}else o()}}function f(t,e,n,r){var o=n?"":r.css;if(t.styleSheet)t.styleSheet.cssText=x(e,o);else{var i=document.createTextNode(o),a=t.childNodes;a[e]&&t.removeChild(a[e]),a.length?t.insertBefore(i,a[e]):t.appendChild(i)}}function d(t,e){var n=e.css,r=e.media;if(r&&t.setAttribute("media",r),t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}function p(t,e,n){var r=n.css,o=n.sourceMap,i=void 0===e.convertToAbsoluteUrls&&o;(e.convertToAbsoluteUrls||i)&&(r=y(r)),o&&(r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");var a=new Blob([r],{type:"text/css"}),s=t.href;t.href=URL.createObjectURL(a),s&&URL.revokeObjectURL(s)}var m={},h=function(t){var e;return function(){return void 0===e&&(e=t.apply(this,arguments)),e}}((function(){return window&&document&&document.all&&!window.atob})),g=function(t){var e={};return function(n){return void 0===e[n]&&(e[n]=t.call(this,n)),e[n]}}((function(t){return document.querySelector(t)})),b=null,v=0,w=[],y=n(15);t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||(e.singleton=h()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var n=o(t,e);return r(n,e),function(t){for(var i=[],a=0;athis.length)&&-1!==this.indexOf(t,e)}),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(t,e){if(null==this)throw new TypeError('"this" is null or not defined');var n=Object(this),r=n.length>>>0;if(0===r)return!1;for(var o=0|e,i=Math.max(o>=0?o:r-Math.abs(o),0);i=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},o(19),r.setImmediate=e,r.clearImmediate=n},function(t,e,n){(function(t,e){!function(t,n){"use strict";function r(t){delete s[t]}function o(t){if(c)setTimeout(o,0,t);else{var e=s[t];if(e){c=!0;try{!function(t){var e=t.callback,n=t.args;switch(n.length){case 0:e();break;case 1:e(n[0]);break;case 2:e(n[0],n[1]);break;case 3:e(n[0],n[1],n[2]);break;default:e.apply(void 0,n)}}(e)}finally{r(t),c=!1}}}}if(!t.setImmediate){var i,a=1,s={},c=!1,l=t.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(t);u=u&&u.setTimeout?u:t,"[object process]"==={}.toString.call(t.process)?i=function(t){e.nextTick((function(){o(t)}))}:function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=n,e}}()?function(){var e="setImmediate$"+Math.random()+"$",n=function(n){n.source===t&&"string"==typeof n.data&&0===n.data.indexOf(e)&&o(+n.data.slice(e.length))};t.addEventListener?t.addEventListener("message",n,!1):t.attachEvent("onmessage",n),i=function(n){t.postMessage(e+n,"*")}}():t.MessageChannel?function(){var t=new MessageChannel;t.port1.onmessage=function(t){o(t.data)},i=function(e){t.port2.postMessage(e)}}():l&&"onreadystatechange"in l.createElement("script")?function(){var t=l.documentElement;i=function(e){var n=l.createElement("script");n.onreadystatechange=function(){o(e),n.onreadystatechange=null,t.removeChild(n),n=null},t.appendChild(n)}}():i=function(t){setTimeout(o,0,t)},u.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n1)for(var n=1;n',e.default=e.modalMarkup},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r='
\n
';e.default=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(0).default.ICON;e.errorIconMarkup=function(){var t=r+"--error",e=t+"__line";return'\n
\n \n \n
\n '},e.warningIconMarkup=function(){var t=r+"--warning";return'\n \n \n \n '},e.successIconMarkup=function(){var t=r+"--success";return'\n \n \n\n
\n
\n '}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(0).default.CONTENT;e.contentMarkup='\n
\n\n
\n'},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(0),o=r.default.BUTTON_CONTAINER,i=r.default.BUTTON,a=r.default.BUTTON_LOADER;e.buttonMarkup='\n
\n\n \n\n
\n
\n
\n
\n
\n\n
\n'},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(4),o=n(2),i=n(0),a=i.default.ICON,s=i.default.ICON_CUSTOM,c=["error","warning","success","info"],l={error:o.errorIconMarkup(),warning:o.warningIconMarkup(),success:o.successIconMarkup()};e.default=function(t){if(t){var e=r.injectElIntoModal(o.iconMarkup);c.includes(t)?function(t,e){var n=a+"--"+t;e.classList.add(n);var r=l[t];r&&(e.innerHTML=r)}(t,e):function(t,e){e.classList.add(s);var n=document.createElement("img");n.src=t,e.appendChild(n)}(t,e)}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(2),o=n(4),i=function(t){navigator.userAgent.includes("AppleWebKit")&&(t.style.display="none",t.offsetHeight,t.style.display="")};e.initTitle=function(t){if(t){var e=o.injectElIntoModal(r.titleMarkup);e.textContent=t,i(e)}},e.initText=function(t){if(t){var e=document.createDocumentFragment();t.split("\n").forEach((function(t,n,r){e.appendChild(document.createTextNode(t)),n0})).forEach((function(t){h.classList.add(t)})),n&&t===c.CONFIRM_KEY&&h.classList.add(s),h.textContent=o;var b={};return b[t]=i,f.setActionValue(b),f.setActionOptionsFor(t,{closeModal:p}),h.addEventListener("click",(function(){return u.onAction(t)})),m};e.default=function(t,e){var n=o.injectElIntoModal(l.footerMarkup);for(var r in t){var i=t[r],a=d(r,i,e);i.visible&&n.appendChild(a)}0===n.children.length&&n.remove()}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(3),o=n(4),i=n(2),a=n(5),s=n(6),c=n(0).default.CONTENT,l=function(t){t.addEventListener("input",(function(t){var e=t.target.value;a.setActionValue(e)})),t.addEventListener("keyup",(function(t){if("Enter"===t.key)return s.onAction(r.CONFIRM_KEY)})),setTimeout((function(){t.focus(),a.setActionValue("")}),0)};e.default=function(t){if(t){var e=o.injectElIntoModal(i.contentMarkup),n=t.element,r=t.attributes;"string"==typeof n?function(t,e,n){var r=document.createElement(e),o=c+"__"+e;for(var i in r.classList.add(o),n){var a=n[i];r[i]=a}"input"===e&&l(r),t.appendChild(r)}(e,n,r):e.appendChild(n)}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(1),o=n(2);e.default=function(){var t=r.stringToNode(o.overlayMarkup);document.body.appendChild(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(5),o=n(6),i=n(1),a=n(3),s=n(0),c=s.default.MODAL,l=s.default.BUTTON,u=s.default.OVERLAY,f=function(t){if(r.default.isOpen)switch(t.key){case"Escape":return o.onAction(a.CANCEL_KEY)}},d=function(t){if(r.default.isOpen)switch(t.key){case"Tab":return function(t){t.preventDefault(),m()}(t)}},p=function(t){if(r.default.isOpen)return"Tab"===t.key&&t.shiftKey?function(t){t.preventDefault(),h()}(t):void 0},m=function(){var t=i.getNode(l);t&&(t.tabIndex=0,t.focus())},h=function(){var t=i.getNode(c).querySelectorAll("."+l),e=t[t.length-1];e&&e.focus()},g=function(){var t=i.getNode(c).querySelectorAll("."+l);t.length&&(function(t){t[t.length-1].addEventListener("keydown",d)}(t),function(t){t[0].addEventListener("keydown",p)}(t))},b=function(t){if(i.getNode(u)===t.target)return o.onAction(a.CANCEL_KEY)};e.default=function(t){t.closeOnEsc?document.addEventListener("keyup",f):document.removeEventListener("keyup",f),t.dangerMode?m():h(),g(),function(t){var e=i.getNode(u);e.removeEventListener("click",b),t&&e.addEventListener("click",b)}(t.closeOnClickOutside),function(t){r.default.timer&&clearTimeout(r.default.timer),t&&(r.default.timer=window.setTimeout((function(){return o.onAction(a.CANCEL_KEY)}),t))}(t.timer)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(1),o=n(3),i=n(37),a=n(38),s={title:null,text:null,icon:null,buttons:o.defaultButtonList,content:null,className:null,closeOnClickOutside:!0,closeOnEsc:!0,dangerMode:!1,timer:null},c=Object.assign({},s);e.setDefaults=function(t){c=Object.assign({},s,t)};var l=function(t){var e=t&&t.button,n=t&&t.buttons;return void 0!==e&&void 0!==n&&r.throwErr("Cannot set both 'button' and 'buttons' options!"),void 0!==e?{confirm:e}:n},u=function(t){return r.ordinalSuffixOf(t+1)},f=function(t,e){r.throwErr(u(e)+" argument ('"+t+"') is invalid")},d=function(t,e){var n=t+1,o=e[n];r.isPlainObject(o)||void 0===o||r.throwErr("Expected "+u(n)+" argument ('"+o+"') to be a plain object")},p=function(t,e,n,o){var i=e instanceof Element;if("string"==typeof e){if(0===n)return{text:e};if(1===n)return{text:e,title:o[0]};if(2===n)return d(n,o),{icon:e};f(e,n)}else{if(i&&0===n)return d(n,o),{content:e};if(r.isPlainObject(e))return function(t,e){var n=t+1,o=e[n];void 0!==o&&r.throwErr("Unexpected "+u(n)+" argument ("+o+")")}(n,o),e;f(e,n)}};e.getOpts=function(){for(var t=[],e=0;e1||"".split(/.?/)[p]?function(t,e){var o=String(this);if(void 0===t&&0===e)return[];if(!r(t))return n.call(o,t,e);for(var i,a,s,c=[],u=(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.unicode?"u":"")+(t.sticky?"y":""),f=0,m=void 0===e?4294967295:e>>>0,h=new RegExp(t.source,u+"g");(i=l.call(h,o))&&!((a=h.lastIndex)>f&&(c.push(o.slice(f,i.index)),i[p]>1&&i.index=m));)h.lastIndex===i.index&&h.lastIndex++;return f===o[p]?!s&&h.test("")||c.push(""):c.push(o.slice(f)),c[p]>m?c.slice(0,m):c}:"0".split(void 0,0)[p]?function(t,e){return void 0===t&&0===e?[]:n.call(this,t,e)}:n,[function(n,r){var o=t(this),i=null==n?void 0:n[e];return void 0!==i?i.call(n,o,r):h.call(String(o),n,r)},function(t,e){var r=u(h,t,this,e,h!==n);if(r.done)return r.value;var l=o(t),d=String(this),p=i(l,RegExp),g=l.unicode,b=(l.ignoreCase?"i":"")+(l.multiline?"m":"")+(l.unicode?"u":"")+(m?"y":"g"),v=new p(m?l:"^(?:"+l.source+")",b),w=void 0===e?4294967295:e>>>0;if(0===w)return[];if(0===d.length)return null===c(v,d)?[d]:[];for(var y=0,x=0,k=[];xu;)n=c[u++],r&&!a.call(s,n)||f.push(t?[n,s[n]]:s[n]);return f}}},114:function(t,e,n){var r=n(95),o=n(115);n(96);function i(t){return null==t}function a(t){(t=function(t){var e={};for(var n in t)e[n]=t[n];return e}(t||{})).whiteList=t.whiteList||r.whiteList,t.onAttr=t.onAttr||r.onAttr,t.onIgnoreAttr=t.onIgnoreAttr||r.onIgnoreAttr,t.safeAttrValue=t.safeAttrValue||r.safeAttrValue,this.options=t}a.prototype.process=function(t){if(!(t=(t=t||"").toString()))return"";var e=this.options,n=e.whiteList,r=e.onAttr,a=e.onIgnoreAttr,s=e.safeAttrValue;return o(t,(function(t,e,o,c,l){var u=n[o],f=!1;if(!0===u?f=u:"function"==typeof u?f=u(c):u instanceof RegExp&&(f=u.test(c)),!0!==f&&(f=!1),c=s(o,c)){var d,p={position:e,sourcePosition:t,source:l,isWhite:f};return f?i(d=r(o,c,p))?o+":"+c:d:i(d=a(o,c,p))?void 0:d}}))},t.exports=a},115:function(t,e,n){var r=n(96);t.exports=function(t,e){";"!==(t=r.trimRight(t))[t.length-1]&&(t+=";");var n=t.length,o=!1,i=0,a=0,s="";function c(){if(!o){var n=r.trim(t.slice(i,a)),c=n.indexOf(":");if(-1!==c){var l=r.trim(n.slice(0,c)),u=r.trim(n.slice(c+1));if(l){var f=e(i,s.length,l,u,n);f&&(s+=f+"; ")}}}i=a+1}for(;a";var v=function(t){var e=c.spaceIndex(t);if(-1===e)return{html:"",closing:"/"===t[t.length-2]};var n="/"===(t=c.trim(t.slice(e+1,-1)))[t.length-1];return n&&(t=c.trim(t.slice(0,-1))),{html:t,closing:n}}(a),w=n[o],y=s(v.html,(function(t,e){var n,r=-1!==c.indexOf(w,t);return l(n=u(o,t,e,r))?r?(e=d(o,t,e,m))?t+'="'+e+'"':t:l(n=f(o,t,e,r))?void 0:n:n}));a="<"+o;return y&&(a+=" "+y),v.closing&&(a+=" /"),a+=">"}return l(g=i(o,a,b))?p(a):g}),p);return h&&(g=h.remove(g)),g},t.exports=u},117:function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));n(62);var r=n(56),o=n.n(r);function i(){var t=function(t,e){e||(e=t.slice(0));return Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}(["\n&&&& {\n position: absolute;\n top: 110px;\n left: 90px;\n}\n\n&&&& > div {\n width: 18px;\n height: 18px;\n background-color: #333;\n\n border-radius: 100%;\n display: inline-block;\n -webkit-animation: sk-bouncedelay 1.4s infinite ease-in-out both;\n animation: sk-bouncedelay 1.4s infinite ease-in-out both;\n}\n\n&&&& .bounce1 {\n -webkit-animation-delay: -0.32s;\n animation-delay: -0.32s;\n}\n\n&&&& .bounce2 {\n -webkit-animation-delay: -0.16s;\n animation-delay: -0.16s;\n}\n\n@-webkit-keyframes sk-bouncedelay {\n 0%, 80%, 100% { -webkit-transform: scale(0) }\n 40% { -webkit-transform: scale(1.0) }\n}\n\n@keyframes sk-bouncedelay {\n0%, 80%, 100% {\n -webkit-transform: scale(0);\n transform: scale(0);\n } 40% {\n -webkit-transform: scale(1.0);\n transform: scale(1.0);\n }\n}\n"]);return i=function(){return t},t}var a=n(60).default.div(i());function s(){return o.a.createElement(a,null,o.a.createElement("div",{className:"bounce1"}),o.a.createElement("div",{className:"bounce2"}),o.a.createElement("div",{className:"bounce3"}))}},154:function(t,e,n){"use strict";n.r(e),n.d(e,"default",(function(){return x}));n(23),n(72),n(69),n(65),n(70),n(71),n(22),n(61),n(66),n(67),n(62),n(109),n(24),n(196);var r,o=n(56),i=n.n(o),a=n(60),s=n(63),c=n(117),l=n(79);function u(t,e,n,r,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void n(t)}s.done?e(c):Promise.resolve(c).then(r,o)}function f(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function a(t){u(i,r,o,a,s,"next",t)}function s(t){u(i,r,o,a,s,"throw",t)}a(void 0)}))}}function d(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==s.return||s.return()}finally{if(o)throw i}}return n}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return p(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return p(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n-1&&window.localStorage.removeItem(t)}function C(){p(window.innerWidth>800&&window.innerHeight>860)}function L(){return S.apply(this,arguments)}function S(){return(S=f(regeneratorRuntime.mark((function t(){var e,n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,l.a.get(window.MollieModule.urls.qrCodeNew);case 3:return e=t.sent,n=e.data,window.localStorage.setItem("mollieqrcache-"+n.expires+"-"+n.amount,JSON.stringify({url:n.href,idTransaction:n.idTransaction})),_(n.href),t.abrupt("return",n.idTransaction);case 10:t.prev=10,t.t0=t.catch(0),console.error(t.t0);case 13:case"end":return t.stop()}}),t,null,[[0,10]])})))).apply(this,arguments)}function N(t){A&&setTimeout(f(regeneratorRuntime.mark((function e(){var n,o,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,l.a.get("".concat(window.MollieModule.urls.qrCodeStatus,"&transaction_id=").concat(t));case 3:n=e.sent,(o=n.data).status===r.success?(M(),(i=document.createElement("A")).href=o.href,i.hostname===window.location.hostname&&(window.location.href=o.href)):o.status===r.refresh?(M(),L().then()):o.status===r.pending?N(t):console.error("Invalid payment status"),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),N(t);case 11:case"end":return e.stop()}}),e,null,[[0,8]])}))),5e3)}function R(){return(R=f(regeneratorRuntime.mark((function t(){var e,n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,l.a.get(window.MollieModule.urls.cartAmount);case 3:return e=t.sent,n=e.data.amount,t.abrupt("return",n);case 8:t.prev=8,t.t0=t.catch(0),console.error(t.t0);case 11:case"end":return t.stop()}}),t,null,[[0,8]])})))).apply(this,arguments)}function P(t){var e=null,n=null;if(void 0!==window.localStorage){for(var r in window.localStorage)if(r.indexOf("mollieqrcache")>-1){var o=r.split("-");if(parseInt(o[1],10)>+new Date+6e4&&parseInt(o[2],10)===t){var i=JSON.parse(window.localStorage.getItem(r)),a=document.createElement("A");if(a.href=i.url,!/\.ideal\.nl$/i.test(a.hostname)||"https:"!==a.protocol){window.localStorage.removeItem(r);continue}e=i.url,n=i.idTransaction;break}window.localStorage.removeItem(r)}e&&n?(_(e),N(n)):L().then(N)}}var F=Object(o.useRef)(null),z=Object(s.throttle)((function(){C()}),200);return Object(o.useEffect)((function(){j(!0);var t=new IntersectionObserver((function(e){e.forEach((function(e){var n=e.isIntersecting,r=e.intersectionRatio;(!0===n||r>0)&&(g(!0),t.disconnect(),t=null)}))}),{});return t.observe(F.current),C(),window.addEventListener("resize",z),function(){j(!1),null!=t&&(t.disconnect(),t=null),window.removeEventListener("resize",z)}}),[]),Object(o.useEffect)((function(){u&&h&&!k&&!T&&(E(!0),function(){return R.apply(this,arguments)}().then(P))}),[u,h,k,T]),u&&h&&!b?i.a.createElement(i.a.Fragment,null,i.a.createElement(v,null,e),i.a.createElement(w,{center:n},!k&&i.a.createElement(c.a,null),k&&i.a.createElement(y,{src:k,center:n}))):i.a.createElement("p",{ref:F,style:{width:"20px"}}," ")}},195:function(t,e,n){"use strict";n.r(e),n.d(e,"default",(function(){return d}));n(62),n(65),n(61),n(68),n(22),n(104);var r=n(56),o=n.n(r),i=n(91),a=n.n(i),s=n(60),c=n(117);function l(){var t=function(t,e){e||(e=t.slice(0));return Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}(['\n&&&& {\n padding-left: 80px;\n cursor: pointer;\n text-align: left;\n}\n\n&&&& label {\n display: inline-block;\n position: relative;\n padding-left: 5px;\n cursor: pointer;\n}\n\n&&&& label::before {\n content: "";\n display: inline-block;\n position: absolute;\n width: 17px;\n height: 17px;\n left: 0;\n top: 7px;\n margin-left: -20px;\n border: 1px solid #cccccc;\n border-radius: 50%;\n background-color: #fff;\n -webkit-transition: border 0.15s ease-in-out;\n -o-transition: border 0.15s ease-in-out;\n transition: border 0.15s ease-in-out;\n}\n\n&&&& label::after {\n display: inline-block;\n position: absolute;\n content: " ";\n width: 11px;\n height: 11px;\n left: 3px;\n top: 10px;\n margin-left: -20px;\n border-radius: 50%;\n background-color: #555555;\n -webkit-transform: scale(0, 0);\n -ms-transform: scale(0, 0);\n -o-transform: scale(0, 0);\n transform: scale(0, 0);\n -webkit-transition: -webkit-transform 0.1s cubic-bezier(0.8, -0.33, 0.2, 1.33);\n -moz-transition: -moz-transform 0.1s cubic-bezier(0.8, -0.33, 0.2, 1.33);\n -o-transition: -o-transform 0.1s cubic-bezier(0.8, -0.33, 0.2, 1.33);\n transition: transform 0.1s cubic-bezier(0.8, -0.33, 0.2, 1.33);\n}\n\n&&&& input[type="radio"] {\n opacity: 0;\n}\n\n&&&& input[type="radio"]:focus + label::before {\n outline: 5px auto -webkit-focus-ring-color;\n outline-offset: -2px;\n}\n\n&&&& input[type="radio"]:checked + label::after {\n -webkit-transform: scale(1, 1);\n -ms-transform: scale(1, 1);\n -o-transform: scale(1, 1);\n transform: scale(1, 1);\n}\n\n&&&& input[type="radio"]:disabled + label {\n opacity: 0.65;\n}\n\n&&&& input[type="radio"]:disabled + label::before {\n cursor: not-allowed;\n}\n\n&&&&&&&&-inline {\n margin-top: 0;\n}\n\n&&&& input[type="radio"] + label::after {\n background-color: #7cd1f9;\n}\n\n&&&& input[type="radio"]:checked + label::before {\n border-color: #7cd1f9;\n}\n\n&&&& input[type="radio"]:checked + label::after {\n background-color: #7cd1f9;\n}\n']);return l=function(){return t},t}var u=Object(r.lazy)((function(){return Promise.resolve().then(n.bind(null,154))})),f=s.default.div(l());function d(t){var e=t.banks,n=t.translations,i=t.setIssuer;function s(t){var e=t.target.value;i(e)}var l=Object.values(e)[0].id;return o.a.createElement("div",null,o.a.createElement("ul",null,Object.values(e).map((function(t){return o.a.createElement(f,{key:t.id},o.a.createElement("input",{type:"radio",defaultChecked:t.id===l,id:t.id,name:"mollie-bank",value:t.id,onChange:s}),o.a.createElement("label",{htmlFor:t.id,style:{lineHeight:"24px"}},o.a.createElement("img",{src:t.image.size2x,alt:a()(t.name),style:{height:"24px",width:"auto"}})," ",t.name))}))),window.mollieQrEnabled&&o.a.createElement(r.Suspense,{fallback:o.a.createElement(c.a,null)},o.a.createElement(u,{title:n.orPayByIdealQr,center:!0})))}},196:function(t,e){!function(t,e){"use strict";if("IntersectionObserver"in t&&"IntersectionObserverEntry"in t&&"intersectionRatio"in t.IntersectionObserverEntry.prototype)"isIntersecting"in t.IntersectionObserverEntry.prototype||Object.defineProperty(t.IntersectionObserverEntry.prototype,"isIntersecting",{get:function(){return this.intersectionRatio>0}});else{var n=[];o.prototype.THROTTLE_TIMEOUT=100,o.prototype.POLL_INTERVAL=null,o.prototype.USE_MUTATION_OBSERVER=!0,o.prototype.observe=function(t){if(!this._observationTargets.some((function(e){return e.element==t}))){if(!t||1!=t.nodeType)throw new Error("target must be an Element");this._registerInstance(),this._observationTargets.push({element:t,entry:null}),this._monitorIntersections(),this._checkForIntersections()}},o.prototype.unobserve=function(t){this._observationTargets=this._observationTargets.filter((function(e){return e.element!=t})),this._observationTargets.length||(this._unmonitorIntersections(),this._unregisterInstance())},o.prototype.disconnect=function(){this._observationTargets=[],this._unmonitorIntersections(),this._unregisterInstance()},o.prototype.takeRecords=function(){var t=this._queuedEntries.slice();return this._queuedEntries=[],t},o.prototype._initThresholds=function(t){var e=t||[0];return Array.isArray(e)||(e=[e]),e.sort().filter((function(t,e,n){if("number"!=typeof t||isNaN(t)||t<0||t>1)throw new Error("threshold must be a number between 0 and 1 inclusively");return t!==n[e-1]}))},o.prototype._parseRootMargin=function(t){var e=(t||"0px").split(/\s+/).map((function(t){var e=/^(-?\d*\.?\d+)(px|%)$/.exec(t);if(!e)throw new Error("rootMargin must be specified in pixels or percent");return{value:parseFloat(e[1]),unit:e[2]}}));return e[1]=e[1]||e[0],e[2]=e[2]||e[0],e[3]=e[3]||e[1],e},o.prototype._monitorIntersections=function(){this._monitoringIntersections||(this._monitoringIntersections=!0,this.POLL_INTERVAL?this._monitoringInterval=setInterval(this._checkForIntersections,this.POLL_INTERVAL):(i(t,"resize",this._checkForIntersections,!0),i(e,"scroll",this._checkForIntersections,!0),this.USE_MUTATION_OBSERVER&&"MutationObserver"in t&&(this._domObserver=new MutationObserver(this._checkForIntersections),this._domObserver.observe(e,{attributes:!0,childList:!0,characterData:!0,subtree:!0}))))},o.prototype._unmonitorIntersections=function(){this._monitoringIntersections&&(this._monitoringIntersections=!1,clearInterval(this._monitoringInterval),this._monitoringInterval=null,a(t,"resize",this._checkForIntersections,!0),a(e,"scroll",this._checkForIntersections,!0),this._domObserver&&(this._domObserver.disconnect(),this._domObserver=null))},o.prototype._checkForIntersections=function(){var e=this._rootIsInDom(),n=e?this._getRootRect():{top:0,bottom:0,left:0,right:0,width:0,height:0};this._observationTargets.forEach((function(o){var i=o.element,a=s(i),c=this._rootContainsTarget(i),l=o.entry,u=e&&c&&this._computeTargetAndRootIntersection(i,n),f=o.entry=new r({time:t.performance&&performance.now&&performance.now(),target:i,boundingClientRect:a,rootBounds:n,intersectionRect:u});l?e&&c?this._hasCrossedThreshold(l,f)&&this._queuedEntries.push(f):l&&l.isIntersecting&&this._queuedEntries.push(f):this._queuedEntries.push(f)}),this),this._queuedEntries.length&&this._callback(this.takeRecords(),this)},o.prototype._computeTargetAndRootIntersection=function(n,r){if("none"!=t.getComputedStyle(n).display){for(var o,i,a,c,u,f,d,p,m=s(n),h=l(n),g=!1;!g;){var b=null,v=1==h.nodeType?t.getComputedStyle(h):{};if("none"==v.display)return;if(h==this.root||h==e?(g=!0,b=r):h!=e.body&&h!=e.documentElement&&"visible"!=v.overflow&&(b=s(h)),b&&(o=b,i=m,a=void 0,c=void 0,u=void 0,f=void 0,d=void 0,p=void 0,a=Math.max(o.top,i.top),c=Math.min(o.bottom,i.bottom),u=Math.max(o.left,i.left),f=Math.min(o.right,i.right),p=c-a,!(m=(d=f-u)>=0&&p>=0&&{top:a,bottom:c,left:u,right:f,width:d,height:p})))break;h=l(h)}return m}},o.prototype._getRootRect=function(){var t;if(this.root)t=s(this.root);else{var n=e.documentElement,r=e.body;t={top:0,left:0,right:n.clientWidth||r.clientWidth,width:n.clientWidth||r.clientWidth,bottom:n.clientHeight||r.clientHeight,height:n.clientHeight||r.clientHeight}}return this._expandRectByRootMargin(t)},o.prototype._expandRectByRootMargin=function(t){var e=this._rootMarginValues.map((function(e,n){return"px"==e.unit?e.value:e.value*(n%2?t.width:t.height)/100})),n={top:t.top-e[0],right:t.right+e[1],bottom:t.bottom+e[2],left:t.left-e[3]};return n.width=n.right-n.left,n.height=n.bottom-n.top,n},o.prototype._hasCrossedThreshold=function(t,e){var n=t&&t.isIntersecting?t.intersectionRatio||0:-1,r=e.isIntersecting?e.intersectionRatio||0:-1;if(n!==r)for(var o=0;o=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},n(78),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(64))},78:function(t,e,n){(function(t,e){!function(t,n){"use strict";if(!t.setImmediate){var r,o,i,a,s,c=1,l={},u=!1,f=t.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(t);d=d&&d.setTimeout?d:t,"[object process]"==={}.toString.call(t.process)?r=function(t){e.nextTick((function(){m(t)}))}:!function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=n,e}}()?t.MessageChannel?((i=new MessageChannel).port1.onmessage=function(t){m(t.data)},r=function(t){i.port2.postMessage(t)}):f&&"onreadystatechange"in f.createElement("script")?(o=f.documentElement,r=function(t){var e=f.createElement("script");e.onreadystatechange=function(){m(t),e.onreadystatechange=null,o.removeChild(e),e=null},o.appendChild(e)}):r=function(t){setTimeout(m,0,t)}:(a="setImmediate$"+Math.random()+"$",s=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(a)&&m(+e.data.slice(a.length))},t.addEventListener?t.addEventListener("message",s,!1):t.attachEvent("onmessage",s),r=function(e){t.postMessage(a+e,"*")}),d.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n/g,f=/"/g,d=/"/g,p=/&#([a-zA-Z0-9]*);?/gim,m=/:?/gim,h=/&newline;?/gim,g=/((j\s*a\s*v\s*a|v\s*b|l\s*i\s*v\s*e)\s*s\s*c\s*r\s*i\s*p\s*t\s*|m\s*o\s*c\s*h\s*a)\:/gi,b=/e\s*x\s*p\s*r\s*e\s*s\s*s\s*i\s*o\s*n\s*\(.*/gi,v=/u\s*r\s*l\s*\(.*/gi;function w(t){return t.replace(f,""")}function y(t){return t.replace(d,'"')}function x(t){return t.replace(p,(function(t,e){return"x"===e[0]||"X"===e[0]?String.fromCharCode(parseInt(e.substr(1),16)):String.fromCharCode(parseInt(e,10))}))}function k(t){return t.replace(m,":").replace(h," ")}function _(t){for(var e="",n=0,r=t.length;n/g;e.whiteList={a:["target","href","title"],abbr:["title"],address:[],area:["shape","coords","href","alt"],article:[],aside:[],audio:["autoplay","controls","loop","preload","src"],b:[],bdi:["dir"],bdo:["dir"],big:[],blockquote:["cite"],br:[],caption:[],center:[],cite:[],code:[],col:["align","valign","span","width"],colgroup:["align","valign","span","width"],dd:[],del:["datetime"],details:["open"],div:[],dl:[],dt:[],em:[],font:["color","size","face"],footer:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],header:[],hr:[],i:[],img:["src","alt","title","width","height"],ins:["datetime"],li:[],mark:[],nav:[],ol:[],p:[],pre:[],s:[],section:[],small:[],span:[],sub:[],sup:[],strong:[],table:["width","border","align","valign"],tbody:["align","valign"],td:["width","rowspan","colspan","align","valign"],tfoot:["align","valign"],th:["width","rowspan","colspan","align","valign"],thead:["align","valign"],tr:["rowspan","align","valign"],tt:[],u:[],ul:[],video:["autoplay","controls","loop","preload","src","height","width"]},e.getDefaultWhiteList=a,e.onTag=function(t,e,n){},e.onIgnoreTag=function(t,e,n){},e.onTagAttr=function(t,e,n){},e.onIgnoreTagAttr=function(t,e,n){},e.safeAttrValue=function(t,e,n,r){if(n=O(n),"href"===e||"src"===e){if("#"===(n=i.trim(n)))return"#";if("http://"!==n.substr(0,7)&&"https://"!==n.substr(0,8)&&"mailto:"!==n.substr(0,7)&&"tel:"!==n.substr(0,4)&&"data:image/"!==n.substr(0,11)&&"ftp://"!==n.substr(0,6)&&"./"!==n.substr(0,2)&&"../"!==n.substr(0,3)&&"#"!==n[0]&&"/"!==n[0])return""}else if("background"===e){if(g.lastIndex=0,g.test(n))return""}else if("style"===e){if(b.lastIndex=0,b.test(n))return"";if(v.lastIndex=0,v.test(n)&&(g.lastIndex=0,g.test(n)))return"";!1!==r&&(n=(r=r||s).process(n))}return n=T(n)},e.escapeHtml=c,e.escapeQuote=w,e.unescapeQuote=y,e.escapeHtmlEntities=x,e.escapeDangerHtml5Entities=k,e.clearNonPrintableCharacter=_,e.friendlyAttrValue=O,e.escapeAttrValue=T,e.onIgnoreTagStripAll=function(){return""},e.StripTagBody=function(t,e){"function"!=typeof e&&(e=function(){});var n=!Array.isArray(t),r=[],o=!1;return{onIgnoreTag:function(a,s,c){if(function(e){return!!n||-1!==i.indexOf(t,e)}(a)){if(c.isClosing){var l="[/removed]",u=c.position+l.length;return r.push([!1!==o?o:c.position,u]),o=!1,l}return o||(o=c.position),"[removed]"}return e(a,s,c)},remove:function(t){var e="",n=0;return i.forEach(r,(function(r){e+=t.slice(n,r[0]),n=r[1]})),e+=t.slice(n)}}},e.stripCommentTag=function(t){return t.replace(E,"")},e.stripBlankChar=function(t){var e=t.split("");return(e=e.filter((function(t){var e=t.charCodeAt(0);return 127!==e&&(!(e<=31)||(10===e||13===e))}))).join("")},e.cssFilter=s,e.getDefaultCSSWhiteList=o},95:function(t,e){function n(){var t={"align-content":!1,"align-items":!1,"align-self":!1,"alignment-adjust":!1,"alignment-baseline":!1,all:!1,"anchor-point":!1,animation:!1,"animation-delay":!1,"animation-direction":!1,"animation-duration":!1,"animation-fill-mode":!1,"animation-iteration-count":!1,"animation-name":!1,"animation-play-state":!1,"animation-timing-function":!1,azimuth:!1,"backface-visibility":!1,background:!0,"background-attachment":!0,"background-clip":!0,"background-color":!0,"background-image":!0,"background-origin":!0,"background-position":!0,"background-repeat":!0,"background-size":!0,"baseline-shift":!1,binding:!1,bleed:!1,"bookmark-label":!1,"bookmark-level":!1,"bookmark-state":!1,border:!0,"border-bottom":!0,"border-bottom-color":!0,"border-bottom-left-radius":!0,"border-bottom-right-radius":!0,"border-bottom-style":!0,"border-bottom-width":!0,"border-collapse":!0,"border-color":!0,"border-image":!0,"border-image-outset":!0,"border-image-repeat":!0,"border-image-slice":!0,"border-image-source":!0,"border-image-width":!0,"border-left":!0,"border-left-color":!0,"border-left-style":!0,"border-left-width":!0,"border-radius":!0,"border-right":!0,"border-right-color":!0,"border-right-style":!0,"border-right-width":!0,"border-spacing":!0,"border-style":!0,"border-top":!0,"border-top-color":!0,"border-top-left-radius":!0,"border-top-right-radius":!0,"border-top-style":!0,"border-top-width":!0,"border-width":!0,bottom:!1,"box-decoration-break":!0,"box-shadow":!0,"box-sizing":!0,"box-snap":!0,"box-suppress":!0,"break-after":!0,"break-before":!0,"break-inside":!0,"caption-side":!1,chains:!1,clear:!0,clip:!1,"clip-path":!1,"clip-rule":!1,color:!0,"color-interpolation-filters":!0,"column-count":!1,"column-fill":!1,"column-gap":!1,"column-rule":!1,"column-rule-color":!1,"column-rule-style":!1,"column-rule-width":!1,"column-span":!1,"column-width":!1,columns:!1,contain:!1,content:!1,"counter-increment":!1,"counter-reset":!1,"counter-set":!1,crop:!1,cue:!1,"cue-after":!1,"cue-before":!1,cursor:!1,direction:!1,display:!0,"display-inside":!0,"display-list":!0,"display-outside":!0,"dominant-baseline":!1,elevation:!1,"empty-cells":!1,filter:!1,flex:!1,"flex-basis":!1,"flex-direction":!1,"flex-flow":!1,"flex-grow":!1,"flex-shrink":!1,"flex-wrap":!1,float:!1,"float-offset":!1,"flood-color":!1,"flood-opacity":!1,"flow-from":!1,"flow-into":!1,font:!0,"font-family":!0,"font-feature-settings":!0,"font-kerning":!0,"font-language-override":!0,"font-size":!0,"font-size-adjust":!0,"font-stretch":!0,"font-style":!0,"font-synthesis":!0,"font-variant":!0,"font-variant-alternates":!0,"font-variant-caps":!0,"font-variant-east-asian":!0,"font-variant-ligatures":!0,"font-variant-numeric":!0,"font-variant-position":!0,"font-weight":!0,grid:!1,"grid-area":!1,"grid-auto-columns":!1,"grid-auto-flow":!1,"grid-auto-rows":!1,"grid-column":!1,"grid-column-end":!1,"grid-column-start":!1,"grid-row":!1,"grid-row-end":!1,"grid-row-start":!1,"grid-template":!1,"grid-template-areas":!1,"grid-template-columns":!1,"grid-template-rows":!1,"hanging-punctuation":!1,height:!0,hyphens:!1,icon:!1,"image-orientation":!1,"image-resolution":!1,"ime-mode":!1,"initial-letters":!1,"inline-box-align":!1,"justify-content":!1,"justify-items":!1,"justify-self":!1,left:!1,"letter-spacing":!0,"lighting-color":!0,"line-box-contain":!1,"line-break":!1,"line-grid":!1,"line-height":!1,"line-snap":!1,"line-stacking":!1,"line-stacking-ruby":!1,"line-stacking-shift":!1,"line-stacking-strategy":!1,"list-style":!0,"list-style-image":!0,"list-style-position":!0,"list-style-type":!0,margin:!0,"margin-bottom":!0,"margin-left":!0,"margin-right":!0,"margin-top":!0,"marker-offset":!1,"marker-side":!1,marks:!1,mask:!1,"mask-box":!1,"mask-box-outset":!1,"mask-box-repeat":!1,"mask-box-slice":!1,"mask-box-source":!1,"mask-box-width":!1,"mask-clip":!1,"mask-image":!1,"mask-origin":!1,"mask-position":!1,"mask-repeat":!1,"mask-size":!1,"mask-source-type":!1,"mask-type":!1,"max-height":!0,"max-lines":!1,"max-width":!0,"min-height":!0,"min-width":!0,"move-to":!1,"nav-down":!1,"nav-index":!1,"nav-left":!1,"nav-right":!1,"nav-up":!1,"object-fit":!1,"object-position":!1,opacity:!1,order:!1,orphans:!1,outline:!1,"outline-color":!1,"outline-offset":!1,"outline-style":!1,"outline-width":!1,overflow:!1,"overflow-wrap":!1,"overflow-x":!1,"overflow-y":!1,padding:!0,"padding-bottom":!0,"padding-left":!0,"padding-right":!0,"padding-top":!0,page:!1,"page-break-after":!1,"page-break-before":!1,"page-break-inside":!1,"page-policy":!1,pause:!1,"pause-after":!1,"pause-before":!1,perspective:!1,"perspective-origin":!1,pitch:!1,"pitch-range":!1,"play-during":!1,position:!1,"presentation-level":!1,quotes:!1,"region-fragment":!1,resize:!1,rest:!1,"rest-after":!1,"rest-before":!1,richness:!1,right:!1,rotation:!1,"rotation-point":!1,"ruby-align":!1,"ruby-merge":!1,"ruby-position":!1,"shape-image-threshold":!1,"shape-outside":!1,"shape-margin":!1,size:!1,speak:!1,"speak-as":!1,"speak-header":!1,"speak-numeral":!1,"speak-punctuation":!1,"speech-rate":!1,stress:!1,"string-set":!1,"tab-size":!1,"table-layout":!1,"text-align":!0,"text-align-last":!0,"text-combine-upright":!0,"text-decoration":!0,"text-decoration-color":!0,"text-decoration-line":!0,"text-decoration-skip":!0,"text-decoration-style":!0,"text-emphasis":!0,"text-emphasis-color":!0,"text-emphasis-position":!0,"text-emphasis-style":!0,"text-height":!0,"text-indent":!0,"text-justify":!0,"text-orientation":!0,"text-overflow":!0,"text-shadow":!0,"text-space-collapse":!0,"text-transform":!0,"text-underline-position":!0,"text-wrap":!0,top:!1,transform:!1,"transform-origin":!1,"transform-style":!1,transition:!1,"transition-delay":!1,"transition-duration":!1,"transition-property":!1,"transition-timing-function":!1,"unicode-bidi":!1,"vertical-align":!1,visibility:!1,"voice-balance":!1,"voice-duration":!1,"voice-family":!1,"voice-pitch":!1,"voice-range":!1,"voice-rate":!1,"voice-stress":!1,"voice-volume":!1,volume:!1,"white-space":!1,widows:!1,width:!0,"will-change":!1,"word-break":!0,"word-spacing":!0,"word-wrap":!0,"wrap-flow":!1,"wrap-through":!1,"writing-mode":!1,"z-index":!1};return t}var r=/javascript\s*\:/gim;e.whiteList=n(),e.getDefaultWhiteList=n,e.onAttr=function(t,e,n){},e.onIgnoreAttr=function(t,e,n){},e.safeAttrValue=function(t,e){return r.test(e)?"":e}},96:function(t,e){t.exports={indexOf:function(t,e){var n,r;if(Array.prototype.indexOf)return t.indexOf(e);for(n=0,r=t.length;n0;e--){var n=t[e];if(" "!==n)return"="===n?e:-1}}function l(t){return function(t){return'"'===t[0]&&'"'===t[t.length-1]||"'"===t[0]&&"'"===t[t.length-1]}(t)?t.substr(1,t.length-2):t}e.parseTag=function(t,e,n){"use strict";var r="",a=0,s=!1,c=!1,l=0,u=t.length,f="",d="";t:for(l=0;l"===p){r+=n(t.slice(a,s)),f=o(d=t.slice(s,l+1)),r+=e(s,r.length,f,d,i(d)),a=l+1,s=!1;continue}if('"'===p||"'"===p)for(var m=1,h=t.charAt(l-m);" "===h||"="===h;){if("="===h){c=p;continue t}h=t.charAt(l-++m)}}else if(p===c){c=!1;continue}}return a - * @copyright Mollie B.V. - * @link https://github.com/mollie/PrestaShop - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ (window.webpackJsonP_mollie=window.webpackJsonP_mollie||[]).push([["carrierconfig"],{101:function(e,t,n){"use strict";n.d(t,"a",(function(){return l})),n.d(t,"b",(function(){return c}));var r=n(123),a=function(){return Math.random().toString(36).substring(7).split("").join(".")},i={INIT:"@@redux/INIT"+a(),REPLACE:"@@redux/REPLACE"+a(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+a()}};function o(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function c(e,t,n){var a;if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error("Expected the enhancer to be a function.");return n(c)(e,t)}if("function"!=typeof e)throw new Error("Expected the reducer to be a function.");var s=e,l=t,f=[],u=f,d=!1;function m(){u===f&&(u=f.slice())}function p(){if(d)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return l}function h(e){if("function"!=typeof e)throw new Error("Expected the listener to be a function.");if(d)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribelistener for more details.");var t=!0;return m(),u.push(e),function(){if(t){if(d)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribelistener for more details.");t=!1,m();var n=u.indexOf(e);u.splice(n,1),f=null}}}function y(e){if(!o(e))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(d)throw new Error("Reducers may not dispatch actions.");try{d=!0,l=s(l,e)}finally{d=!1}for(var t=f=u,n=0;n - * @copyright Mollie B.V. - * @link https://github.com/mollie/PrestaShop - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ (window["webpackJsonP_mollie"] = window["webpackJsonP_mollie"] || []).push([["carrierconfig~transaction"],{ diff --git a/views/js/dist/methodconfig.min.js b/views/js/dist/methodconfig.min.js index 1f81bd1d3..83764f87c 100644 --- a/views/js/dist/methodconfig.min.js +++ b/views/js/dist/methodconfig.min.js @@ -1,11 +1,12 @@ -/*! - * - * Mollie https://www.mollie.nl - * @author Mollie B.V. - * @copyright Mollie B.V. - * @link https://github.com/mollie/PrestaShop - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ (window.webpackJsonP_mollie=window.webpackJsonP_mollie||[]).push([["methodconfig"],{100:function(e,n,t){var r=t(3),a=t(10),o=t(1)("match");e.exports=function(e){var n;return r(e)&&(void 0!==(n=e[o])?!!n:"RegExp"==a(e))}},102:function(e,n,t){"use strict";(function(e,r){ /*! diff --git a/views/js/dist/qrcode.min.js b/views/js/dist/qrcode.min.js index 704b49df0..f87d271ff 100644 --- a/views/js/dist/qrcode.min.js +++ b/views/js/dist/qrcode.min.js @@ -1,10 +1,11 @@ -/*! - * - * Mollie https://www.mollie.nl - * @author Mollie B.V. - * @copyright Mollie B.V. - * @link https://github.com/mollie/PrestaShop - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ (window.webpackJsonP_mollie=window.webpackJsonP_mollie||[]).push([["qrcode"],{51:function(r,n,e){"use strict";e.r(n);e(69),e(65),e(70),e(71),e(66),e(67),e(23),e(61),e(68),e(22),e(72),e(24);var t=e(56),o=e.n(t),a=e(84);function i(r,n){return function(r){if(Array.isArray(r))return r}(r)||function(r,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(r)))return;var e=[],t=!0,o=!1,a=void 0;try{for(var i,c=r[Symbol.iterator]();!(t=(i=c.next()).done)&&(e.push(i.value),!n||e.length!==n);t=!0);}catch(r){o=!0,a=r}finally{try{t||null==c.return||c.return()}finally{if(o)throw a}}return e}(r,n)||function(r,n){if(!r)return;if("string"==typeof r)return c(r,n);var e=Object.prototype.toString.call(r).slice(8,-1);"Object"===e&&r.constructor&&(e=r.constructor.name);if("Map"===e||"Set"===e)return Array.from(r);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return c(r,n)}(r,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(r,n){(null==n||n>r.length)&&(n=r.length);for(var e=0,t=new Array(n);e - * @copyright Mollie B.V. - * @link https://github.com/mollie/PrestaShop - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ (window.webpackJsonP_mollie=window.webpackJsonP_mollie||[]).push([["transaction"],{101:function(e,t,r){"use strict";r.d(t,"a",(function(){return s})),r.d(t,"b",(function(){return i}));var n=r(123),o=function(){return Math.random().toString(36).substring(7).split("").join(".")},u={INIT:"@@redux/INIT"+o(),REPLACE:"@@redux/REPLACE"+o(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+o()}};function a(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function i(e,t,r){var o;if("function"==typeof t&&"function"==typeof r||"function"==typeof r&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function.");if("function"==typeof t&&void 0===r&&(r=t,t=void 0),void 0!==r){if("function"!=typeof r)throw new Error("Expected the enhancer to be a function.");return r(i)(e,t)}if("function"!=typeof e)throw new Error("Expected the reducer to be a function.");var c=e,s=t,f=[],d=f,l=!1;function p(){d===f&&(d=f.slice())}function h(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return s}function y(e){if("function"!=typeof e)throw new Error("Expected the listener to be a function.");if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribelistener for more details.");var t=!0;return p(),d.push(e),function(){if(t){if(l)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribelistener for more details.");t=!1,p();var r=d.indexOf(e);d.splice(r,1),f=null}}}function v(e){if(!a(e))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,s=c(s,e)}finally{l=!1}for(var t=f=d,r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);re.length)&&(t=e.length);for(var r=0,n=new Array(t);r")||this}return function(e,t){function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t}(Error);function f(e){return e+1}var d=(i=function(){var e=Object(n.createContext)(null);return{StoreContext:e,useDispatch:function(){var t=Object(n.useContext)(e);if(!t)throw new s;return t.dispatch},useMappedState:function(t){var r=Object(n.useContext)(e);if(!r)throw new s;var o=Object(n.useMemo)((function(){return e=t,function(t){return n!==t&&(n=t,r=e(t)),r};var e,r,n}),[t]),i=r.getState(),d=o(i),l=Object(n.useState)(0)[1],p=Object(n.useRef)(d),h=Object(n.useRef)(o);return c((function(){p.current=d,h.current=o})),c((function(){var e=!1,t=function(){e||(function(e,t){if(a(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var o=0;o0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case u.ReduxActionTypes.updateTranslations:return t.translations;default:return e}},config:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case u.ReduxActionTypes.updateConfig:return t.config;default:return e}},order:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case u.ReduxActionTypes.updateOrder:return t.order;default:return e}},payment:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case u.ReduxActionTypes.updatePayment:return t.payment;default:return e}},currencies:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case u.ReduxActionTypes.updateCurrencies:return t.currencies;default:return e}},viewportWidth:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case u.ReduxActionTypes.updateViewportWidth:return t.width;default:return e}},orderWarning:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case u.ReduxActionTypes.updateWarning:return t.orderWarning;default:return e}}}),c=window.__REDUX_DEVTOOLS_EXTENSION__;n=Object(o.b)(i,c&&c());t.default=n},88:function(e,t,r){"use strict";r(62);var n=r(56),o=r.n(n),u=r(60);function a(){var e=s(["\n background-color: black;\n border-radius: 50%;\n width: 10px;\n height: 10px;\n margin: 0 5px;\n opacity: 0.7;\n /* Animation */\n animation: "," 0.5s linear infinite;\n animation-delay: ",";\n"]);return a=function(){return e},e}function i(){var e=s(["\n display: flex;\n align-items: flex-end;\n min-height: 30px;\n"]);return i=function(){return e},e}function c(){var e=s(["\n 0% { margin-bottom: 0; }\n 50% { margin-bottom: 15px }\n 100% { margin-bottom: 0 }\n"]);return c=function(){return e},e}function s(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var f=Object(u.keyframes)(c()),d=u.default.div(i()),l=u.default.div(a(),f,(function(e){return e.delay}));t.a=function(){return o.a.createElement(d,null,o.a.createElement(l,{delay:"0s"}),o.a.createElement(l,{delay:".1s"}),o.a.createElement(l,{delay:".2s"}))}}}]); \ No newline at end of file diff --git a/views/js/dist/transactionOrder.min.js b/views/js/dist/transactionOrder.min.js index a132f4c6c..c74b23836 100644 --- a/views/js/dist/transactionOrder.min.js +++ b/views/js/dist/transactionOrder.min.js @@ -1,10 +1,11 @@ -/*! - * - * Mollie https://www.mollie.nl - * @author Mollie B.V. - * @copyright Mollie B.V. - * @link https://github.com/mollie/PrestaShop - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ (window.webpackJsonP_mollie=window.webpackJsonP_mollie||[]).push([["transactionOrder"],{128:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(56),a=n.n(r),l=n(59);function c(){var e=Object(l.c)((function(e){return{orderWarning:e.orderWarning,translations:e.translations}})),t=e.orderWarning,n=e.translations,r="";switch(t){case"refunded":r=n.refundSuccessMessage;break;case"shipped":r=n.shipmentWarning;break;case"canceled":r=n.cancelWarning;break;default:r=""}return r?a.a.createElement(a.a.Fragment,null,a.a.createElement("div",{className:"alert alert-success"},r)):a.a.createElement(a.a.Fragment,null)}},272:function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return me}));n(61),n(68),n(22),n(110);var r=n(56),a=n.n(r),l=n(59),c=n(76),i=n.n(c),o=(n(62),n(60)),u=n(127),s=n.n(u),d=n(63),m=n(89);function f(){var e=Object(l.c)((function(e){return{order:e.order,currencies:e.currencies,translations:e.translations,config:e.config}})),t=e.translations,n=e.order,r=e.currencies,c=e.config.legacy;return a.a.createElement(a.a.Fragment,null,c&&a.a.createElement("h3",null,t.transactionInfo),!c&&a.a.createElement("h4",null,t.transactionInfo),a.a.createElement("strong",null,t.transactionId),": ",a.a.createElement("span",null,n.id),a.a.createElement("br",null),a.a.createElement("strong",null,t.method),": ",a.a.createElement("span",null,n.details.remainderMethod?n.details.remainderMethod:n.method),a.a.createElement("br",null),a.a.createElement("strong",null,t.date),": ",a.a.createElement("span",null,s()(n.createdAt).format("YYYY-MM-DD HH:mm:ss")),a.a.createElement("br",null),a.a.createElement("strong",null,t.amount),": ",a.a.createElement("span",null,Object(m.a)(parseFloat(n.amount.value),Object(d.get)(r,n.amount.currency))),a.a.createElement("br",null),a.a.createElement("strong",null,t.refundable),": ",a.a.createElement("span",null,Object(m.a)(parseFloat(n.availableRefundAmount.value),Object(d.get)(r,n.availableRefundAmount.currency))),a.a.createElement("br",null),(n.details.remainderMethod||n.details.issuer)&&a.a.createElement(a.a.Fragment,null,a.a.createElement("br",null),a.a.createElement("h4",null,t.voucherInfo)),n.details.issuer&&a.a.createElement(a.a.Fragment,null,a.a.createElement("span",null,a.a.createElement("strong",null,t.issuer),": ",a.a.createElement("span",null,n.details.issuer),a.a.createElement("br",null))),n.details.vouchers&&n.details.vouchers.map((function(e){return a.a.createElement(a.a.Fragment,null,a.a.createElement("span",null,a.a.createElement("strong",null,t.amount),": ",a.a.createElement("span",null,Object(m.a)(parseFloat(e.amount.value),Object(d.get)(r,e.amount.currency))),a.a.createElement("br",null)))})))}function p(){var e=function(e,t){t||(t=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}(["\n@media only screen and (min-width: 992px) {\n margin-left: -5px!important;\n margin-right: 5px!important;\n}\n"]);return p=function(){return e},e}var b=o.default.div(p());function g(){var e=Object(l.c)((function(e){return{translations:e.translations,order:e.order,currencies:e.currencies,config:e.config}})),t=e.translations;return e.config.legacy?a.a.createElement(f,null):a.a.createElement(b,{className:"col-md-3"},a.a.createElement("div",{className:"panel card"},a.a.createElement("div",{className:"panel-heading card-header"},t.paymentInfo),a.a.createElement("div",{className:"card-body"},a.a.createElement(f,null))))}n(75),n(69),n(70),n(71),n(66),n(67),n(23),n(72),n(24),n(65);var y=n(84),h=n(91),v=n.n(h);function E(){var e=Object(r.useCallback)(Object(l.c)((function(e){return{translations:e.translations,viewportWidth:e.viewportWidth}})),[]),t=e.translations,n=e.viewportWidth;return a.a.createElement("thead",null,a.a.createElement("tr",null,a.a.createElement("th",null,a.a.createElement("span",{className:"title_box"},a.a.createElement("strong",null,t.product))),a.a.createElement("th",null,a.a.createElement("span",{className:"title_box"},t.status)),n<1390&&a.a.createElement("th",null,a.a.createElement("span",{className:"title_box"},a.a.createElement("span",null,t.shipped),a.a.createElement("br",null)," ",a.a.createElement("span",{style:{whiteSpace:"nowrap"}},"/ ",t.canceled),a.a.createElement("br",null)," ",a.a.createElement("span",{style:{whiteSpace:"nowrap"}},"/ ",t.refunded))),n>=1390&&a.a.createElement(a.a.Fragment,null,a.a.createElement("th",null,a.a.createElement("span",{className:"title_box"},t.shipped)),a.a.createElement("th",null,a.a.createElement("span",{className:"title_box"},t.canceled)),a.a.createElement("th",null,a.a.createElement("span",{className:"title_box"},t.refunded))),a.a.createElement("th",null,a.a.createElement("span",{className:"title_box"},t.unitPrice)),a.a.createElement("th",null,a.a.createElement("span",{className:"title_box"},t.vatAmount)),a.a.createElement("th",null,a.a.createElement("span",{className:"title_box"},t.totalAmount)),a.a.createElement("th",null)))}n(104);var w=n(81),O=n(82);function j(e){var t=e.loading,n=e.ship,r=e.cancel,c=e.refund,i=Object(l.c)((function(e){return{translations:e.translations,currencies:e.currencies,order:e.order,config:e.config}})),o=i.translations,u=i.order,s=(i.currencies,i.config.legacy);function m(){for(var e=0,t=Object.values(u.lines.filter((function(e){return"discount"!==e.type})));e=1)return!0}return!1}function f(){for(var e=0,t=Object.values(u.lines.filter((function(e){return"discount"!==e.type})));e=1)return!0}return!1}function p(){for(var e=0,t=Object.values(u.lines.filter((function(e){return"discount"!==e.type})));e=1&&parseFloat(u.availableRefundAmount.value)>0)return!0}return!1}return a.a.createElement("tfoot",null,a.a.createElement("tr",null,a.a.createElement("td",{colSpan:10},a.a.createElement("div",{className:"btn-group",role:"group"},a.a.createElement("button",{type:"button",onClick:function(){return n(Object(d.compact)(u.lines.filter((function(e){return"discount"!==e.type}))))},className:"btn btn-primary",disabled:t||!f(),style:{cursor:t||!f()?"not-allowed":"pointer",opacity:t||!f()?.8:1}},s&&a.a.createElement("img",{src:"../img/admin/delivery.gif",alt:"",style:{filter:t||!f()?"grayscale(100%)":null,WebkitFilter:t||!f()?"grayscale(100%)":null}}),!s&&a.a.createElement(w.a,{icon:t?O.c:O.h,spin:t})," ",o.shipAll),a.a.createElement("button",{type:"button",onClick:function(){return c(Object(d.compact)(u.lines.filter((function(e){return"discount"!==e.type}))))},className:"btn btn-default",disabled:t||!p(),style:{cursor:t||!p()?"not-allowed":"pointer",opacity:t||!p()?.8:1}},s&&a.a.createElement("img",{src:"../img/admin/money.gif",alt:"",style:{filter:t||!p()?"grayscale(100%)":null,WebkitFilter:t||!p()?"grayscale(100%)":null}}),!s&&a.a.createElement(w.a,{icon:t?O.c:O.j,spin:t})," ",o.refundAll),a.a.createElement("button",{type:"button",onClick:function(){return r(Object(d.compact)(u.lines.filter((function(e){return"discount"!==e.type}))))},className:"btn btn-default",disabled:t||!m(),style:{cursor:t||!m()?"not-allowed":"pointer",opacity:t||!m()?.8:1}},s&&a.a.createElement("img",{src:"../img/admin/disabled.gif",alt:"",style:{filter:t||!m()?"grayscale(100%)":null,WebkitFilter:t||!m()?"grayscale(100%)":null}}),!s&&a.a.createElement(w.a,{icon:t?O.c:O.f,spin:t})," ",o.cancelAll)))))}var x=n(208);function k(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,a=!1,l=void 0;try{for(var c,i=e[Symbol.iterator]();!(r=(c=i.next()).done)&&(n.push(c.value),!t||n.length!==t);r=!0);}catch(e){a=!0,l=e}finally{try{r||null==i.return||i.return()}finally{if(a)throw l}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return S(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return S(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0}));var a=Object(d.findIndex)(r,(function(t){return t.id===e}));a<0||(n>0?r[a].newQuantity=n:r.length>1&&r.splice(a,1),o(Object(d.cloneDeep)(r)),n>0&&(r[a].quantity=r[a].newQuantity,delete r[a].newQuantity),t(r))}Object(r.useEffect)((function(){n.forEach((function(e){u(e.id,e["".concat(l,"Quantity")])}))}),[]);var s=Object(d.cloneDeep)(i);return Object(d.remove)(s,(function(e){return e["".concat(l,"Quantity")]<1})),a.a.createElement(x.Table,{bordered:!0},a.a.createElement("tbody",null,i.map((function(e){return a.a.createElement(x.Tr,{key:e.id,light:!0},a.a.createElement("td",{style:{color:"#555"}},e.name),a.a.createElement("td",{style:{color:"#555"}},a.a.createElement(_,{value:e.newQuantity||e["".concat(l,"Quantity")],onChange:function(t){var n=t.target.value;return u(e.id,parseInt(n,10))}},Object(d.range)(1,e["".concat(l,"Quantity")]+1).map((function(e){return a.a.createElement(I,{key:e,value:e},e,"x")}))),a.a.createElement(w.a,{icon:O.a,style:{marginLeft:"-20px",pointerEvents:"none"}})),a.a.createElement("td",{style:{display:i.length>1?"auto":"none"}},a.a.createElement(F,{icon:O.g,onClick:function(){return u(e.id,0)}})))}))))}function Q(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,a=!1,l=void 0;try{for(var c,i=e[Symbol.iterator]();!(r=(c=i.next()).done)&&(n.push(c.value),!t||n.length!==t);r=!0);}catch(e){a=!0,l=e}finally{try{r||null==i.return||i.return()}finally{if(a)throw l}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return P(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return P(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=1&&parseFloat(s.value)>0},b=a.a.createElement("button",{style:{cursor:n||t.shippableQuantity<1||"discount"===t.type?"not-allowed":"pointer",width:m?"100px":"auto",textAlign:m?"left":"inherit",opacity:!n&&p()||!m?1:.8},className:i()({btn:!m,"btn-default":!m}),title:"",disabled:n||t.shippableQuantity<1||"discount"===t.type,onClick:function(){return c([t])}},m&&a.a.createElement("img",{src:"../img/admin/delivery.gif",alt:f.ship,style:{filter:n||t.shippableQuantity<1?"grayscale(100%)":void 0,WebkitFilter:n||t.shippableQuantity<1?"grayscale(100%)":void 0}}),!m&&a.a.createElement(w.a,{icon:n?O.c:O.h,spin:n})," ",f.ship),g=m?a.a.createElement("button",{style:{cursor:"discount"===(n||!p()||t.type)?"not-allowed":"pointer",width:"100px",textAlign:"left",opacity:n||!p()||"discount"===t.type?.8:1},title:"",disabled:n||!p()||"discount"===t.type,onClick:function(){return u([t])}},a.a.createElement("img",{src:"../img/admin/money.gif",alt:f.refund,style:{filter:n||!p()||"discount"===t.type?"grayscale(100%)":void 0,WebkitFilter:n||!p()||"discount"===t.type?"grayscale(100%)":void 0}})," ",f.refund):a.a.createElement("a",{style:{cursor:n||!p()||"discount"===t.type?"not-allowed":"pointer",opacity:n||!p()||"discount"===t.type?.8:1},onClick:function(){return p()&&u([t])},role:"button"},a.a.createElement(w.a,{icon:n?O.c:O.i,spin:n})," ",f.refund),y=m?a.a.createElement("button",{style:{cursor:t.cancelableQuantity<1?"not-allowed":"pointer",width:"100px",textAlign:"left",opacity:n||!p()||"discount"===t.type?.8:1},title:"",disabled:n||t.cancelableQuantity<1||"discount"===t.type,onClick:function(){return o([t])}},a.a.createElement("img",{src:"../img/admin/disabled.gif",alt:f.cancel,style:{filter:n||t.cancelableQuantity<1||"discount"===t.type?"grayscale(100%)":void 0,WebkitFilter:n||t.cancelableQuantity<1||"discount"===t.type?"grayscale(100%)":void 0}})," ",f.cancel):a.a.createElement("a",{style:{cursor:n||t.cancelableQuantity<1||"discount"===t.type?"not-allowed":"pointer",opacity:n||t.cancelableQuantity<1||"discount"===t.type?.8:1},onClick:function(){return t.cancelableQuantity>=1&&o([t])},role:"button"},a.a.createElement(w.a,{icon:n?O.c:O.f,spin:n})," ",f.cancel),h=m?a.a.createElement("div",null,b,a.a.createElement("br",null),g,a.a.createElement("br",null),y):a.a.createElement("div",{className:i()({"btn-group":!m})},b,a.a.createElement("button",{type:"button",className:i()({btn:!m,"btn-default":!m,"dropdown-toggle":!m}),"data-toggle":m?null:"dropdown",disabled:n||!p()&&t.cancelableQuantity<1||"discount"===t.type},a.a.createElement("span",{className:"caret"}," ")),a.a.createElement("ul",{className:"dropdown-menu"},a.a.createElement("li",null,g),a.a.createElement("li",null,y)));return a.a.createElement("div",{className:i()({"btn-group-action":!m})},h)}function X(e,t,n,r,a,l,c){try{var i=e[l](c),o=i.value}catch(e){return void n(e)}i.done?t(o):Promise.resolve(o).then(r,a)}function Z(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var l=e.apply(t,n);function c(e){X(l,r,a,c,i,"next",e)}function i(e){X(l,r,a,c,i,"throw",e)}c(void 0)}))}}function ee(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,a=!1,l=void 0;try{for(var c,i=e[Symbol.iterator]();!(r=(c=i.next()).done)&&(n.push(c.value),!t||n.length!==t);r=!0);}catch(e){a=!0,l=e}finally{try{r||null==i.return||i.return()}finally{if(a)throw l}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return te(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return te(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function te(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0})),Object(y.render)(a.a.createElement(R,{lineType:"refundable",translations:u,lines:i,edited:function(e){return r=e}}),l),o=l.firstChild,e.next=7,n.e("vendors~sweetalert").then(n.t.bind(null,105,7));case 7:return d=e.sent,m=d.default,e.next=11,m({title:v()(u.reviewRefund),text:v()(u.reviewRefundProducts),buttons:{cancel:{text:v()(u.cancel),visible:!0},confirm:{text:v()(u.OK)}},closeOnClickOutside:!1,content:o});case 11:if(!e.sent){e.next=30;break}return e.prev=13,c(!0),e.next=17,Object($.refundOrder)(s,r);case 17:f=e.sent,p=f.success,b=f.order,p?(h(Object(J.updateWarning)("refunded")),h(Object(J.updateOrder)(b))):n.e("vendors~sweetalert").then(n.t.bind(null,105,7)).then((function(e){(0,e.default)({icon:"error",title:v()(u.anErrorOccurred),text:v()(u.unableToRefund)}).then()})),e.next=27;break;case 23:e.prev=23,e.t0=e.catch(13),"string"==typeof e.t0&&n.e("vendors~sweetalert").then(n.t.bind(null,105,7)).then((function(t){(0,t.default)({icon:"error",title:v()(u.anErrorOccurred),text:v()(e.t0)}).then()})),console.error(e.t0);case 27:return e.prev=27,c(!1),e.finish(27);case 30:case"end":return e.stop()}}),e,null,[[13,23,27,30]])})))).apply(this,arguments)}function S(e){return N.apply(this,arguments)}function N(){return(N=Z(regeneratorRuntime.mark((function e(t){var r,l,i,o,d,m,f,p;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=null,l=document.createElement("DIV"),Object(y.render)(a.a.createElement(R,{lineType:"cancelable",translations:u,lines:t,edited:function(e){return r=e}}),l),i=l.firstChild,e.next=6,n.e("vendors~sweetalert").then(n.t.bind(null,105,7));case 6:return o=e.sent,d=o.default,e.next=10,d({title:v()(u.reviewCancel),text:v()(u.reviewCancelProducts),buttons:{cancel:{text:v()(u.cancel),visible:!0},confirm:{text:v()(u.OK)}},closeOnClickOutside:!1,content:i});case 10:if(!e.sent){e.next=29;break}return e.prev=12,c(!0),e.next=16,Object($.cancelOrder)(s.id,r);case 16:m=e.sent,f=m.success,p=m.order,f?(h(Object(J.updateOrder)(p)),h(Object(J.updateWarning)("canceled"))):d({icon:"error",title:v()(u.anErrorOccurred),text:v()(u.unableToShip)}).then(),e.next=26;break;case 22:e.prev=22,e.t0=e.catch(12),"string"==typeof e.t0&&d({icon:"error",title:v()(u.anErrorOccurred),text:v()(e.t0)}).then(),console.error(e.t0);case 26:return e.prev=26,c(!1),e.finish(26);case 29:case"end":return e.stop()}}),e,null,[[12,22,26,29]])})))).apply(this,arguments)}return a.a.createElement(re,{className:i()({"table-responsive":!p}),order:s,currencies:f,translations:u,config:b,viewportWidth:g},a.a.createElement("table",{className:i()({table:!0})},a.a.createElement(E,null),a.a.createElement("tbody",null,s.lines.map((function(e){return a.a.createElement("tr",{key:e.id,style:{marginBottom:"100px"}},a.a.createElement("td",null,a.a.createElement("strong",null,e.quantity,"x")," ",e.name),a.a.createElement("td",null,e.status),g<1390&&a.a.createElement("td",null,e.quantityShipped," / ",e.quantityCanceled," / ",e.quantityRefunded),g>=1390&&a.a.createElement("td",null,e.quantityShipped),g>=1390&&a.a.createElement("td",null,e.quantityCanceled),g>=1390&&a.a.createElement("td",null,e.quantityRefunded),a.a.createElement("td",null,Object(m.a)(parseFloat(e.unitPrice.value),Object(d.get)(f,e.unitPrice.currency))),a.a.createElement("td",null,Object(m.a)(parseFloat(e.vatAmount.value),Object(d.get)(f,e.vatAmount.currency))," (",e.vatRate,"%)"),a.a.createElement("td",null,Object(m.a)(parseFloat(e.totalAmount.value),Object(d.get)(f,e.totalAmount.currency))),a.a.createElement("td",{className:i()({actions:!p})},a.a.createElement(G,{loading:t,line:e,availableRefundAmount:s.availableRefundAmount,refundLine:x,shipLine:w,cancelLine:S})))}))),a.a.createElement(j,{loading:t,ship:w,refund:x,cancel:S})))}function le(){var e=Object(r.useCallback)(Object(l.c)((function(e){return{translations:e.translations,config:e.config}})),[]),t=e.translations;return e.config.legacy?a.a.createElement("div",{className:"error"},t.thereAreNoProducts):a.a.createElement("div",{className:"table-responsive"},a.a.createElement("table",{className:"table"},a.a.createElement(E,null),a.a.createElement("tbody",null,a.a.createElement("tr",null,a.a.createElement("td",{className:"list-empty hidden-print",colSpan:3},a.a.createElement("div",{className:"list-empty-msg"},a.a.createElement("i",{className:"icon-warning-sign list-empty-icon"}),t.thereAreNoProducts))))))}function ce(){var e=function(e,t){t||(t=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}(["\n@media only screen and (min-width: 992px) {\n margin-left: 5px!important;\n margin-right: -5px!important;\n}\n"]);return ce=function(){return e},e}var ie=o.default.div(ce());function oe(){var e=Object(l.c)((function(e){return{translations:e.translations,order:e.order,currencies:e.currencies,config:e.config}})),t=e.translations,n=e.order,r=e.currencies,c=e.config.legacy;return c?a.a.createElement(a.a.Fragment,null,c&&a.a.createElement("h3",null,t.products),!c&&a.a.createElement("h4",null,t.products),!n||!n.lines.length&&a.a.createElement(le,null),!!n&&!!n.lines.length&&a.a.createElement(ae,null)):a.a.createElement(ie,{className:"col-md-9"},a.a.createElement("div",{className:"panel card"},a.a.createElement("div",{className:"panel-heading card-header"},t.products),a.a.createElement("div",{className:"card-body"},n.details.vouchers&&a.a.createElement(a.a.Fragment,null,a.a.createElement("div",{className:"alert alert-warning",role:"alert"},t.refundWarning.replace("%1s",Object(m.a)(parseFloat(n.availableRefundAmount.value),Object(d.get)(r,n.availableRefundAmount.currency))))),!n||!n.lines.length&&a.a.createElement(le,null),!!n&&!!n.lines.length&&a.a.createElement(ae,null))))}var ue=n(88);function se(){var e=Object(r.useCallback)(Object(l.c)((function(e){return{order:e.order,config:e.config}})),[]),t=e.order,n=e.config.legacy;return a.a.createElement(a.a.Fragment,null,!t&&a.a.createElement(ue.a,null),!!t&&t.status&&a.a.createElement("div",{className:i()({"panel-body card-body":!n,row:!n})},a.a.createElement(g,null),a.a.createElement(oe,null)))}var de=n(128);function me(){var e=Object(r.useCallback)(Object(l.c)((function(e){return{translations:e.translations,config:e.config,order:e.order}})),[]),t=e.config,n=t.legacy,c=t.moduleDir,i=e.config;return Object.keys(i).length<=0?null:n?a.a.createElement("fieldset",{style:{marginTop:"14px"}},a.a.createElement("legend",null,a.a.createElement("img",{src:"".concat(c,"views/img/logo_small.png"),width:"32",height:"32",alt:"Mollie logo",style:{height:"16px",width:"16px",opacity:.8}})," ",a.a.createElement("span",null,"Mollie")," "),a.a.createElement(de.a,null),a.a.createElement(se,null)):a.a.createElement("div",{className:"panel card"},a.a.createElement("div",{className:"panel-heading card-header"},a.a.createElement("img",{src:"".concat(c,"views/img/mollie_panel_icon.png"),width:"32",height:"32",alt:"Mollie logo",style:{height:"16px",width:"16px",opacity:.8}})," ",a.a.createElement("span",null,"Mollie")," "),a.a.createElement(de.a,null),a.a.createElement(se,null))}},89:function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));n(66),n(67),n(151),n(109),n(75);var r=n(152),a=n.n(r),l=n(63);function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var i=function(e,t,n,r){"string"==typeof t&&(t=parseInt(t,10)),"string"==typeof e&&(e=parseFloat(e));for(var a=(e=e.toFixed(t))+"",l=a.split("."),c=2===l.length?l[0]:a,i=("0."+(2===l.length?l[1]:0)).substr(2),o=c.length,u=1;u<4;u++)parseFloat(e)>=Math.pow(10,3*u)&&(c=c.substring(0,o-3*u)+n+c.substring(o-3*u));return 0===t?c:c+r+(i||"00")};function o(e,t){var n;return e>=0?(n=Math.floor(e+.5),(3===t&&e===-.5+n||4===t&&e===.5+2*Math.floor(n/2)||5===t&&e===.5+2*Math.floor(n/2)-1)&&(n-=1)):(n=Math.ceil(e-.5),(3===t&&e===.5+n||4===t&&e===2*Math.ceil(n/2)-.5||5===t&&e===2*Math.ceil(n/2)-.5+1)&&(n+=1)),n}var u=function(e,t){var n,r;if("string"==typeof e&&(e=parseFloat(e)),void 0===t&&(t=2),0===(n=void 0===window.roundMode?2:window.roundMode))return function(e,t){void 0===t&&(t=0);var n=0===t?1:Math.pow(10,t),r=String(e*n);return"0"===r[r.length-1]?e:Math.ceil(e*n)/n}(e,t);if(1===n)return function(e,t){void 0===t&&(t=0);var n=0===t?1:Math.pow(10,t),r=String(e*n);return"0"===r[r.length-1]?e:Math.floor(e*n)/n}(e,t);if(2===n)return function(e,t){var n=Math.pow(10,t),r=e*n;return(r=Math.floor(10*r)-10*Math.floor(r)>=5?Math.ceil(r):Math.floor(r))/n}(e,t);if(3==n||4==n||5==n){var a=14-Math.floor(function(e){return Math.log(e)/Math.LN10}(Math.abs(e))),l=Math.pow(10,Math.abs(t));if(a>t&&a-t<15){var c=Math.pow(10,Math.abs(a));r=o(r=a>=0?e*c:e/c,n),r/=c=Math.pow(10,Math.abs(t-a))}else if(r=t>=0?e*l:e/l,Math.abs(r)>=1e15)return e;return r=o(r,n),t>0?r/=l:r*=l,r}},s=function(e,t){return void 0===t?(console.error("Currency undefined"),""):"string"==typeof window._PS_VERSION_&&a()(window._PS_VERSION_,"1.7.0.0",">=")||void 0!==window.formatCurrencyCldr?new Intl.NumberFormat(Object(l.get)(document.documentElement,"lang"),{style:"currency",currency:t.iso_code}).format(e):function(e,t,n,r){"string"==typeof e&&(e=parseFloat(e));var a,l="EUR";void 0!==window.currency_iso_code&&3===window.currency_iso_code.length?l=window.currency_iso_code:"object"===c(window.currency)&&void 0!==window.currency.iso_code&&3===window.currency.iso_code.length&&(l=window.currency.iso_code),void 0!==window.priceDisplayPrecision&&(a=window.priceDisplayPrecision);try{if(void 0!==window.currencyModes&&void 0!==window.currencyModes[l]&&window.currencyModes[l]){e=u(e.toFixed(10),a);var o=document.documentElement.lang;5===o.length?o=o.substring(0,2).toLowerCase()+"-"+o.substring(3,5).toUpperCase():void 0!==window.full_language_code&&5===window.full_language_code.length?o=window.full_language_code.substring(0,2).toLowerCase()+"-"+window.full_language_code.substring(3,5).toUpperCase():5===window.getBrowserLocale().length&&(o=window.getBrowserLocale().substring(0,2).toLowerCase()+"-"+window.getBrowserLocale().substring(3,5).toUpperCase());var s=e.toLocaleString(o,{style:"currency",currency:"USD",currencyDisplay:"code"});return n&&(s=s.replace("USD",n)),s}}catch(e){}var d="";return e=u(e.toFixed(10),a),void 0!==r&&r&&(d=" "),1==t?n+d+i(e,a,",","."):2==t?i(e,a," ",",")+d+n:3==t?n+d+i(e,a,".",","):4==t?i(e,a,",",".")+d+n:5==t?n+d+i(e,a,"'","."):String(e)}(e,t.format,t.sign,t.blank)}}},0,["vendors~sweetalert"]]); \ No newline at end of file diff --git a/views/js/dist/transactionOrder~transactionRefund.min.js b/views/js/dist/transactionOrder~transactionRefund.min.js index b4223b9e3..33bb72c40 100644 --- a/views/js/dist/transactionOrder~transactionRefund.min.js +++ b/views/js/dist/transactionOrder~transactionRefund.min.js @@ -1,11 +1,12 @@ -/*! - * - * Mollie https://www.mollie.nl - * @author Mollie B.V. - * @copyright Mollie B.V. - * @link https://github.com/mollie/PrestaShop - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ (window["webpackJsonP_mollie"] = window["webpackJsonP_mollie"] || []).push([["transactionOrder~transactionRefund"],{ diff --git a/views/js/dist/transactionRefund.min.js b/views/js/dist/transactionRefund.min.js index abc986b3b..50982b4ab 100644 --- a/views/js/dist/transactionRefund.min.js +++ b/views/js/dist/transactionRefund.min.js @@ -1,10 +1,11 @@ -/*! - * - * Mollie https://www.mollie.nl - * @author Mollie B.V. - * @copyright Mollie B.V. - * @link https://github.com/mollie/PrestaShop - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ (window.webpackJsonP_mollie=window.webpackJsonP_mollie||[]).push([["transactionRefund"],{128:function(e,n,t){"use strict";t.d(n,"a",(function(){return c}));var a=t(56),r=t.n(a),l=t(59);function c(){var e=Object(l.c)((function(e){return{orderWarning:e.orderWarning,translations:e.translations}})),n=e.orderWarning,t=e.translations,a="";switch(n){case"refunded":a=t.refundSuccessMessage;break;case"shipped":a=t.shipmentWarning;break;case"canceled":a=t.cancelWarning;break;default:a=""}return a?r.a.createElement(r.a.Fragment,null,r.a.createElement("div",{className:"alert alert-success"},a)):r.a.createElement(r.a.Fragment,null)}},273:function(e,n,t){"use strict";t.r(n),t.d(n,"default",(function(){return Y}));t(61),t(68),t(22),t(110);var a=t(56),r=t.n(a),l=t(59),c=(t(62),t(60)),o=t(127),i=t.n(o),u=t(63),s=t(89);function m(){var e=Object(l.c)((function(e){return{payment:e.payment,currencies:e.currencies,translations:e.translations,config:e.config}})),n=e.translations,t=e.payment,a=e.currencies,c=e.config.legacy;return r.a.createElement(r.a.Fragment,null,c&&r.a.createElement("h3",null,n.transactionInfo),!c&&r.a.createElement("h4",null,n.transactionInfo),r.a.createElement("strong",null,n.transactionId),": ",r.a.createElement("span",null,t.id),r.a.createElement("br",null),r.a.createElement("strong",null,n.date),": ",r.a.createElement("span",null,i()(t.createdAt).format("YYYY-MM-DD HH:mm:ss")),r.a.createElement("br",null),r.a.createElement("strong",null,n.amount),": ",r.a.createElement("span",null,Object(s.a)(parseFloat(t.amount.value),Object(u.get)(a,t.amount.currency))),r.a.createElement("br",null))}function d(){var e=function(e,n){n||(n=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}(["\n@media only screen and (min-width: 992px) {\n margin-left: -5px!important;\n margin-right: 5px!important;\n}\n"]);return d=function(){return e},e}var f=c.default.div(d());function p(){var e=Object(l.c)((function(e){return{translations:e.translations,config:e.config}})),n=e.translations;return e.config.legacy?r.a.createElement(r.a.Fragment,null,r.a.createElement(m,null),r.a.createElement("br",null)):r.a.createElement(f,{className:"col-md-3"},r.a.createElement("div",{className:"panel card"},r.a.createElement("div",{className:"panel-heading card-header"},n.paymentInfo),r.a.createElement("div",{className:"card-body"},r.a.createElement(m,null))))}function g(){var e=Object(l.c)((function(e){return{translations:e.translations}})).translations;return r.a.createElement("thead",null,r.a.createElement("tr",null,r.a.createElement("th",null,r.a.createElement("span",{className:"title_box"},r.a.createElement("strong",null,e.ID))),r.a.createElement("th",null,r.a.createElement("span",{className:"title_box"},e.date)),r.a.createElement("th",null,r.a.createElement("span",{className:"title_box"},e.amount))))}function y(){var e=Object(l.c)((function(e){return{translations:e.translations}})).translations;return r.a.createElement("div",{className:"table-responsive"},r.a.createElement("table",{className:"table"},r.a.createElement(g,null),r.a.createElement("tbody",null,r.a.createElement("tr",null,r.a.createElement("td",{className:"list-empty hidden-print",colSpan:3},r.a.createElement("div",{className:"list-empty-msg"},r.a.createElement("i",{className:"icon-warning-sign list-empty-icon"}),e.thereAreNoRefunds))))))}function b(){var e=Object(l.c)((function(e){return{payment:e.payment,currencies:e.currencies}})),n=e.payment,t=e.currencies;return r.a.createElement("div",{className:"table-responsive"},r.a.createElement("table",{className:"table"},r.a.createElement(g,null),r.a.createElement("tbody",null,n.refunds.map((function(e){return r.a.createElement("tr",{key:e.id,style:{marginBottom:"100px"}},r.a.createElement("td",{style:{width:"100px"}},r.a.createElement("strong",null,e.id)),r.a.createElement("td",null,i()(e.createdAt).format("YYYY-MM-DD HH:mm:ss")),r.a.createElement("td",null,Object(s.a)(parseFloat(e.amount.value),Object(u.get)(t,e.amount.currency))))})))))}function v(){var e=Object(l.c)((function(e){return{translations:e.translations,payment:e.payment}})),n=e.translations,t=e.payment;return r.a.createElement(r.a.Fragment,null,r.a.createElement("h4",null,n.refundHistory),!t.refunds.length&&r.a.createElement(y,null),!!t.refunds.length&&r.a.createElement(b,null))}t(23),t(72),t(69),t(65),t(70),t(71),t(66),t(67),t(75),t(24);var h=t(91),E=t.n(h),w=t(103),x=t(76),N=t.n(x);function M(e){var n=e.loading,t=e.disabled,a=e.refundPayment,c=Object(l.c)((function(e){return{translations:e.translations}})).translations;return r.a.createElement("button",{type:"button",className:"btn btn-default",disabled:n||t,onClick:function(){return a(!1)},style:{marginRight:"10px"}},r.a.createElement("i",{className:N()({icon:!0,"icon-undo":!n,"icon-circle-o-notch":n,"icon-spin":n})})," ",c.refundOrder)}function O(e){var n=e.loading,t=e.disabled,a=e.refundPayment,c=Object(l.c)((function(e){return{translations:e.translations,config:e.config}})),o=c.translations,i=c.config.legacy,u=r.a.createElement("button",{className:"btn btn-default",type:"button",disabled:n||t,onClick:function(){return a(!0)}},!i&&r.a.createElement("i",{className:N()({icon:!0,"icon-undo":!n,"icon-circle-o-notch":n,"icon-spin":n})})," ",o.partialRefund);return i?u:r.a.createElement("div",{className:"input-group-btn"},u)}var j=t(126);function _(e,n,t,a,r,l,c){try{var o=e[l](c),i=o.value}catch(e){return void t(e)}o.done?n(i):Promise.resolve(i).then(a,r)}function F(e){return function(){var n=this,t=arguments;return new Promise((function(a,r){var l=e.apply(n,t);function c(e){_(l,a,r,c,o,"next",e)}function o(e){_(l,a,r,c,o,"throw",e)}c(void 0)}))}}function S(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],a=!0,r=!1,l=void 0;try{for(var c,o=e[Symbol.iterator]();!(a=(c=o.next()).done)&&(t.push(c.value),!n||t.length!==n);a=!0);}catch(e){r=!0,l=e}finally{try{a||null==o.return||o.return()}finally{if(r)throw l}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return R(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return R(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function R(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,a=new Array(n);t0&&void 0!==f[0]&&f[0])){e.next=6;break}if(n=parseFloat(m.replace(/[^0-9.,]/g,"").replace(",",".")),!isNaN(n)){e.next=6;break}return t.e("vendors~sweetalert").then(t.t.bind(null,105,7)).then((function(e){(0,e.default)({icon:"error",title:p.invalidAmount,text:p.notAValidAmount}).then()})),e.abrupt("return",!1);case 6:return e.next=8,t.e("vendors~sweetalert").then(t.t.bind(null,105,7));case 8:return a=e.sent,r=a.default,e.next=12,r({dangerMode:!0,icon:"warning",title:E()(p.areYouSure),text:E()(p.areYouSureYouWantToRefund),buttons:{cancel:{text:E()(p.cancel),visible:!0},confirm:{text:E()(p.refund)}}});case 12:if(!e.sent){e.next=32;break}return e.prev=14,o(!0),e.next=18,Object(j.refundPayment)(g,n);case 18:l=e.sent,c=l.success,i=void 0!==c&&c,u=l.payment,s=void 0===u?null:u,i?s&&(h(Object(w.updateWarning)("refunded")),h(Object(w.updatePayment)(s)),d("")):r({icon:"error",title:p.refundFailed,text:p.unableToRefund}).then(),e.next=29;break;case 26:e.prev=26,e.t0=e.catch(14),console.error(e.t0);case 29:return e.prev=29,o(!1),e.finish(29);case 32:case"end":return e.stop()}}),e,null,[[14,26,29,32]])})))).apply(this,arguments)}return v?r.a.createElement(r.a.Fragment,null,r.a.createElement("h3",null,p.refund),r.a.createElement("span",null,r.a.createElement(M,{refundPayment:x,loading:c,disabled:parseFloat(y.settlementAmount.value)<=parseFloat(y.amountRefunded.value)}),r.a.createElement("span",null,p.refundable,":"),r.a.createElement("input",{type:"text",placeholder:Object(s.a)(parseFloat(y.amountRemaining.value),Object(u.get)(b,y.amountRemaining.currency)),disabled:c,value:m,onChange:function(e){var n=e.target.value;return d(n)},style:{width:"80px",height:"15px",margin:"-2px 4px 0 4px"}}),r.a.createElement(O,{refundPayment:x,loading:c,disabled:parseFloat(y.amountRemaining.value)<=0}))):(e=y.settlementAmount?r.a.createElement(M,{refundPayment:x,loading:c,disabled:parseFloat(y.settlementAmount.value)<=parseFloat(y.amountRefunded.value)}):"",r.a.createElement(r.a.Fragment,null,r.a.createElement("h4",null,p.refund),r.a.createElement("div",{className:"well well-sm"},r.a.createElement("div",{className:"form-inline"},r.a.createElement("div",{className:"form-group"},e),r.a.createElement("div",{className:"form-group"},r.a.createElement("div",{className:"input-group",style:{minWidth:"100px"}},r.a.createElement("div",{className:"input-group-addon input-group-prepend"},r.a.createElement("span",{className:"input-group-text"},p.refundable,":")),r.a.createElement("input",{type:"text",className:"form-control",placeholder:Object(s.a)(parseFloat(y.amountRemaining.value),Object(u.get)(b,y.amountRemaining.currency)),disabled:c,value:m,onChange:function(e){var n=e.target.value;return d(n)},style:{width:"80px"}}),r.a.createElement(O,{refundPayment:x,loading:c,disabled:parseFloat(y.amountRemaining.value)<=0})))))))}function A(){var e=function(e,n){n||(n=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}(["\n@media only screen and (min-width: 992px) {\n margin-left: 5px!important;\n margin-right: -5px!important;\n}\n"]);return A=function(){return e},e}var C=c.default.div(A());function k(){var e=Object(l.c)((function(e){return{payment:e.payment,translations:e.translations,config:e.config}})),n=e.translations,t=e.config.legacy,a=e.payment;return t?r.a.createElement(r.a.Fragment,null,r.a.createElement("h3",null,n.refunds),a.amountRefunded&&r.a.createElement(v,null),a.amountRefunded&&r.a.createElement(P,null),!a.amountRefunded&&r.a.createElement("div",{className:"warn"},n.refundsAreCurrentlyUnavailable)):r.a.createElement(C,{className:"col-md-9"},r.a.createElement("div",{className:"panel card"},r.a.createElement("div",{className:"panel-heading card-header"},n.refunds),r.a.createElement("div",{className:"card-body"},a.amountRefunded&&r.a.createElement(v,null),a.amountRefunded&&r.a.createElement(P,null),!a.amountRefunded&&r.a.createElement("div",{className:"alert alert-warning"},n.refundsAreCurrentlyUnavailable))))}var I=t(88),D=t(128);function Y(){var e=Object(l.c)((function(e){return{config:e.config,payment:e.payment}})),n=e.payment,t=e.config;if(Object.keys(t).length<=0)return null;var a=t.moduleDir;return t.legacy?r.a.createElement("fieldset",{style:{marginTop:"14px"}},r.a.createElement("legend",{className:"panel-heading card-header"},r.a.createElement("img",{src:"".concat(a,"views/img/logo_small.png"),width:"32",height:"32",alt:"",style:{height:"16px",width:"16px",opacity:.8}}),r.a.createElement("span",null,"Mollie")," "),r.a.createElement(D.a,null),!n&&r.a.createElement(I.a,null),!!n&&n.status&&r.a.createElement(r.a.Fragment,null,r.a.createElement(p,null),r.a.createElement(k,null))):r.a.createElement("div",{className:"panel card"},r.a.createElement("div",{className:"panel-heading card-header"},r.a.createElement("img",{src:"".concat(a,"views/img/mollie_panel_icon.png"),width:"32",height:"32",alt:"",style:{height:"16px",width:"16px",opacity:.8}})," ",r.a.createElement("span",null,"Mollie")," "),r.a.createElement(D.a,null),!n&&r.a.createElement(I.a,null),!!n&&n.status&&r.a.createElement("div",{className:"panel-body card-body row"},r.a.createElement(p,null),r.a.createElement(k,null)))}},89:function(e,n,t){"use strict";t.d(n,"a",(function(){return s}));t(66),t(67),t(151),t(109),t(75);var a=t(152),r=t.n(a),l=t(63);function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var o=function(e,n,t,a){"string"==typeof n&&(n=parseInt(n,10)),"string"==typeof e&&(e=parseFloat(e));for(var r=(e=e.toFixed(n))+"",l=r.split("."),c=2===l.length?l[0]:r,o=("0."+(2===l.length?l[1]:0)).substr(2),i=c.length,u=1;u<4;u++)parseFloat(e)>=Math.pow(10,3*u)&&(c=c.substring(0,i-3*u)+t+c.substring(i-3*u));return 0===n?c:c+a+(o||"00")};function i(e,n){var t;return e>=0?(t=Math.floor(e+.5),(3===n&&e===-.5+t||4===n&&e===.5+2*Math.floor(t/2)||5===n&&e===.5+2*Math.floor(t/2)-1)&&(t-=1)):(t=Math.ceil(e-.5),(3===n&&e===.5+t||4===n&&e===2*Math.ceil(t/2)-.5||5===n&&e===2*Math.ceil(t/2)-.5+1)&&(t+=1)),t}var u=function(e,n){var t,a;if("string"==typeof e&&(e=parseFloat(e)),void 0===n&&(n=2),0===(t=void 0===window.roundMode?2:window.roundMode))return function(e,n){void 0===n&&(n=0);var t=0===n?1:Math.pow(10,n),a=String(e*t);return"0"===a[a.length-1]?e:Math.ceil(e*t)/t}(e,n);if(1===t)return function(e,n){void 0===n&&(n=0);var t=0===n?1:Math.pow(10,n),a=String(e*t);return"0"===a[a.length-1]?e:Math.floor(e*t)/t}(e,n);if(2===t)return function(e,n){var t=Math.pow(10,n),a=e*t;return(a=Math.floor(10*a)-10*Math.floor(a)>=5?Math.ceil(a):Math.floor(a))/t}(e,n);if(3==t||4==t||5==t){var r=14-Math.floor(function(e){return Math.log(e)/Math.LN10}(Math.abs(e))),l=Math.pow(10,Math.abs(n));if(r>n&&r-n<15){var c=Math.pow(10,Math.abs(r));a=i(a=r>=0?e*c:e/c,t),a/=c=Math.pow(10,Math.abs(n-r))}else if(a=n>=0?e*l:e/l,Math.abs(a)>=1e15)return e;return a=i(a,t),n>0?a/=l:a*=l,a}},s=function(e,n){return void 0===n?(console.error("Currency undefined"),""):"string"==typeof window._PS_VERSION_&&r()(window._PS_VERSION_,"1.7.0.0",">=")||void 0!==window.formatCurrencyCldr?new Intl.NumberFormat(Object(l.get)(document.documentElement,"lang"),{style:"currency",currency:n.iso_code}).format(e):function(e,n,t,a){"string"==typeof e&&(e=parseFloat(e));var r,l="EUR";void 0!==window.currency_iso_code&&3===window.currency_iso_code.length?l=window.currency_iso_code:"object"===c(window.currency)&&void 0!==window.currency.iso_code&&3===window.currency.iso_code.length&&(l=window.currency.iso_code),void 0!==window.priceDisplayPrecision&&(r=window.priceDisplayPrecision);try{if(void 0!==window.currencyModes&&void 0!==window.currencyModes[l]&&window.currencyModes[l]){e=u(e.toFixed(10),r);var i=document.documentElement.lang;5===i.length?i=i.substring(0,2).toLowerCase()+"-"+i.substring(3,5).toUpperCase():void 0!==window.full_language_code&&5===window.full_language_code.length?i=window.full_language_code.substring(0,2).toLowerCase()+"-"+window.full_language_code.substring(3,5).toUpperCase():5===window.getBrowserLocale().length&&(i=window.getBrowserLocale().substring(0,2).toLowerCase()+"-"+window.getBrowserLocale().substring(3,5).toUpperCase());var s=e.toLocaleString(i,{style:"currency",currency:"USD",currencyDisplay:"code"});return t&&(s=s.replace("USD",t)),s}}catch(e){}var m="";return e=u(e.toFixed(10),r),void 0!==a&&a&&(m=" "),1==n?t+m+o(e,r,",","."):2==n?o(e,r," ",",")+m+t:3==n?t+m+o(e,r,".",","):4==n?o(e,r,",",".")+m+t:5==n?t+m+o(e,r,"'","."):String(e)}(e,n.format,n.sign,n.blank)}}},0,["vendors~sweetalert"]]); \ No newline at end of file diff --git a/views/js/dist/transaction~transactionOrder~transactionRefund.min.js b/views/js/dist/transaction~transactionOrder~transactionRefund.min.js index ae8240e85..5ba7ee260 100644 --- a/views/js/dist/transaction~transactionOrder~transactionRefund.min.js +++ b/views/js/dist/transaction~transactionOrder~transactionRefund.min.js @@ -1,11 +1,12 @@ -/*! - * - * Mollie https://www.mollie.nl - * @author Mollie B.V. - * @copyright Mollie B.V. - * @link https://github.com/mollie/PrestaShop - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ (window["webpackJsonP_mollie"] = window["webpackJsonP_mollie"] || []).push([["transaction~transactionOrder~transactionRefund"],{ diff --git a/views/js/dist/updater.min.js b/views/js/dist/updater.min.js index 8c4d22541..778e448a7 100644 --- a/views/js/dist/updater.min.js +++ b/views/js/dist/updater.min.js @@ -1,10 +1,11 @@ -/*! - * - * Mollie https://www.mollie.nl - * @author Mollie B.V. - * @copyright Mollie B.V. - * @link https://github.com/mollie/PrestaShop - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ (window.webpackJsonP_mollie=window.webpackJsonP_mollie||[]).push([["updater"],{55:function(e,t,n){"use strict";n.r(t);n(69),n(65),n(70),n(71),n(66),n(67),n(23),n(61),n(68),n(22),n(72),n(24);var r=n(91),o=n.n(r),a=n(63),c=n(79);function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,a=void 0;try{for(var c,u=e[Symbol.iterator]();!(r=(c=u.next()).done)&&(n.push(c.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw a}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n - * @copyright Mollie B.V. - * @link https://github.com/mollie/PrestaShop - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ (window.webpackJsonP_mollie=window.webpackJsonP_mollie||[]).push([["vendors~app"],[function(t,n){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,n,r){var e=r(18)("wks"),o=r(16),i=r(0).Symbol,c="function"==typeof i;(t.exports=function(t){return e[t]||(e[t]=c&&i[t]||(c?i:o)("Symbol."+t))}).store=e},function(t,n,r){var e=r(3);t.exports=function(t){if(!e(t))throw TypeError(t+" is not an object!");return t}},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n){var r=t.exports={version:"2.6.11"};"number"==typeof __e&&(__e=r)},function(t,n,r){t.exports=!r(12)((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}))},function(t,n,r){var e=r(7);t.exports=function(t,n,r){if(e(t),void 0===n)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 2:return function(r,e){return t.call(n,r,e)};case 3:return function(r,e,o){return t.call(n,r,e,o)}}return function(){return t.apply(n,arguments)}}},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n,r){var e=r(2),o=r(32),i=r(30),c=Object.defineProperty;n.f=r(5)?Object.defineProperty:function(t,n,r){if(e(t),n=i(n,!0),e(r),o)try{return c(t,n,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[n]=r.value),t}},function(t,n,r){var e=r(0),o=r(13),i=r(14),c=r(16)("src"),u=r(40),a=(""+u).split("toString");r(4).inspectSource=function(t){return u.call(t)},(t.exports=function(t,n,r,u){var f="function"==typeof r;f&&(i(r,"name")||o(r,"name",n)),t[n]!==r&&(f&&(i(r,c)||o(r,c,t[n]?""+t[n]:a.join(String(n)))),t===e?t[n]=r:u?t[n]?t[n]=r:o(t,n,r):(delete t[n],o(t,n,r)))})(Function.prototype,"toString",(function(){return"function"==typeof this&&this[c]||u.call(this)}))},function(t,n){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,n,r){var e=r(10),o=r(1)("toStringTag"),i="Arguments"==e(function(){return arguments}());t.exports=function(t){var n,r,c;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=function(t,n){try{return t[n]}catch(t){}}(n=Object(t),o))?r:i?e(n):"Object"==(c=e(n))&&"function"==typeof n.callee?"Arguments":c}},function(t,n){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,n,r){var e=r(8),o=r(27);t.exports=r(5)?function(t,n,r){return e.f(t,n,o(1,r))}:function(t,n,r){return t[n]=r,t}},function(t,n){var r={}.hasOwnProperty;t.exports=function(t,n){return r.call(t,n)}},function(t,n){t.exports=!1},function(t,n){var r=0,e=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+e).toString(36))}},function(t,n){t.exports={}},function(t,n,r){var e=r(4),o=r(0),i=o["__core-js_shared__"]||(o["__core-js_shared__"]={});(t.exports=function(t,n){return i[t]||(i[t]=void 0!==n?n:{})})("versions",[]).push({version:e.version,mode:r(15)?"pure":"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})},function(t,n,r){var e=r(3),o=r(0).document,i=e(o)&&e(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},function(t,n,r){var e,o,i,c=r(6),u=r(43),a=r(36),f=r(19),s=r(0),l=s.process,h=s.setImmediate,p=s.clearImmediate,v=s.MessageChannel,d=s.Dispatch,y=0,m={},g=function(){var t=+this;if(m.hasOwnProperty(t)){var n=m[t];delete m[t],n()}},w=function(t){g.call(t.data)};h&&p||(h=function(t){for(var n=[],r=1;arguments.length>r;)n.push(arguments[r++]);return m[++y]=function(){u("function"==typeof t?t:Function(t),n)},e(y),y},p=function(t){delete m[t]},"process"==r(10)(l)?e=function(t){l.nextTick(c(g,t,1))}:d&&d.now?e=function(t){d.now(c(g,t,1))}:v?(i=(o=new v).port2,o.port1.onmessage=w,e=c(i.postMessage,i,1)):s.addEventListener&&"function"==typeof postMessage&&!s.importScripts?(e=function(t){s.postMessage(t+"","*")},s.addEventListener("message",w,!1)):e="onreadystatechange"in f("script")?function(t){a.appendChild(f("script")).onreadystatechange=function(){a.removeChild(this),g.call(t)}}:function(t){setTimeout(c(g,t,1),0)}),t.exports={set:h,clear:p}},function(t,n,r){"use strict";var e=r(7);function o(t){var n,r;this.promise=new t((function(t,e){if(void 0!==n||void 0!==r)throw TypeError("Bad Promise constructor");n=t,r=e})),this.resolve=e(n),this.reject=e(r)}t.exports.f=function(t){return new o(t)}},function(t,n,r){"use strict";var e=r(11),o={};o[r(1)("toStringTag")]="z",o+""!="[object z]"&&r(9)(Object.prototype,"toString",(function(){return"[object "+e(this)+"]"}),!0)},function(t,n,r){"use strict";var e,o,i,c,u=r(15),a=r(0),f=r(6),s=r(11),l=r(25),h=r(3),p=r(7),v=r(41),d=r(42),y=r(31),m=r(20).set,g=r(44)(),w=r(21),x=r(45),_=r(46),b=r(47),j=a.TypeError,E=a.process,P=E&&E.versions,L=P&&P.v8||"",S=a.Promise,O="process"==s(E),T=function(){},k=o=w.f,F=!!function(){try{var t=S.resolve(1),n=(t.constructor={})[r(1)("species")]=function(t){t(T,T)};return(O||"function"==typeof PromiseRejectionEvent)&&t.then(T)instanceof n&&0!==L.indexOf("6.6")&&-1===_.indexOf("Chrome/66")}catch(t){}}(),M=function(t){var n;return!(!h(t)||"function"!=typeof(n=t.then))&&n},N=function(t,n){if(!t._n){t._n=!0;var r=t._c;g((function(){for(var e=t._v,o=1==t._s,i=0,c=function(n){var r,i,c,u=o?n.ok:n.fail,a=n.resolve,f=n.reject,s=n.domain;try{u?(o||(2==t._h&&R(t),t._h=1),!0===u?r=e:(s&&s.enter(),r=u(e),s&&(s.exit(),c=!0)),r===n.promise?f(j("Promise-chain cycle")):(i=M(r))?i.call(r,a,f):a(r)):f(e)}catch(t){s&&!c&&s.exit(),f(t)}};r.length>i;)c(r[i++]);t._c=[],t._n=!1,n&&!t._h&&G(t)}))}},G=function(t){m.call(a,(function(){var n,r,e,o=t._v,i=A(t);if(i&&(n=x((function(){O?E.emit("unhandledRejection",o,t):(r=a.onunhandledrejection)?r({promise:t,reason:o}):(e=a.console)&&e.error&&e.error("Unhandled promise rejection",o)})),t._h=O||A(t)?2:1),t._a=void 0,i&&n.e)throw n.v}))},A=function(t){return 1!==t._h&&0===(t._a||t._c).length},R=function(t){m.call(a,(function(){var n;O?E.emit("rejectionHandled",t):(n=a.onrejectionhandled)&&n({promise:t,reason:t._v})}))},I=function(t){var n=this;n._d||(n._d=!0,(n=n._w||n)._v=t,n._s=2,n._a||(n._a=n._c.slice()),N(n,!0))},C=function(t){var n,r=this;if(!r._d){r._d=!0,r=r._w||r;try{if(r===t)throw j("Promise can't be resolved itself");(n=M(t))?g((function(){var e={_w:r,_d:!1};try{n.call(t,f(C,e,1),f(I,e,1))}catch(t){I.call(e,t)}})):(r._v=t,r._s=1,N(r,!1))}catch(t){I.call({_w:r,_d:!1},t)}}};F||(S=function(t){v(this,S,"Promise","_h"),p(t),e.call(this);try{t(f(C,this,1),f(I,this,1))}catch(t){I.call(this,t)}},(e=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=r(48)(S.prototype,{then:function(t,n){var r=k(y(this,S));return r.ok="function"!=typeof t||t,r.fail="function"==typeof n&&n,r.domain=O?E.domain:void 0,this._c.push(r),this._a&&this._a.push(r),this._s&&N(this,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),i=function(){var t=new e;this.promise=t,this.resolve=f(C,t,1),this.reject=f(I,t,1)},w.f=k=function(t){return t===S||t===c?new i(t):o(t)}),l(l.G+l.W+l.F*!F,{Promise:S}),r(29)(S,"Promise"),r(49)("Promise"),c=r(4).Promise,l(l.S+l.F*!F,"Promise",{reject:function(t){var n=k(this);return(0,n.reject)(t),n.promise}}),l(l.S+l.F*(u||!F),"Promise",{resolve:function(t){return b(u&&this===c?S:this,t)}}),l(l.S+l.F*!(F&&r(37)((function(t){S.all(t).catch(T)}))),"Promise",{all:function(t){var n=this,r=k(n),e=r.resolve,o=r.reject,i=x((function(){var r=[],i=0,c=1;d(t,!1,(function(t){var u=i++,a=!1;r.push(void 0),c++,n.resolve(t).then((function(t){a||(a=!0,r[u]=t,--c||e(r))}),o)})),--c||e(r)}));return i.e&&o(i.v),r.promise},race:function(t){var n=this,r=k(n),e=r.reject,o=x((function(){d(t,!1,(function(t){n.resolve(t).then(r.resolve,e)}))}));return o.e&&e(o.v),r.promise}})},function(t,n,r){var e=function(t){"use strict";var n=Object.prototype,r=n.hasOwnProperty,e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",i=e.asyncIterator||"@@asyncIterator",c=e.toStringTag||"@@toStringTag";function u(t,n,r){return Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[n]}try{u({},"")}catch(t){u=function(t,n,r){return t[n]=r}}function a(t,n,r,e){var o=n&&n.prototype instanceof l?n:l,i=Object.create(o.prototype),c=new j(e||[]);return i._invoke=function(t,n,r){var e="suspendedStart";return function(o,i){if("executing"===e)throw new Error("Generator is already running");if("completed"===e){if("throw"===o)throw i;return P()}for(r.method=o,r.arg=i;;){var c=r.delegate;if(c){var u=x(c,r);if(u){if(u===s)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===e)throw e="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);e="executing";var a=f(t,n,r);if("normal"===a.type){if(e=r.done?"completed":"suspendedYield",a.arg===s)continue;return{value:a.arg,done:r.done}}"throw"===a.type&&(e="completed",r.method="throw",r.arg=a.arg)}}}(t,r,c),i}function f(t,n,r){try{return{type:"normal",arg:t.call(n,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=a;var s={};function l(){}function h(){}function p(){}var v={};v[o]=function(){return this};var d=Object.getPrototypeOf,y=d&&d(d(E([])));y&&y!==n&&r.call(y,o)&&(v=y);var m=p.prototype=l.prototype=Object.create(v);function g(t){["next","throw","return"].forEach((function(n){u(t,n,(function(t){return this._invoke(n,t)}))}))}function w(t,n){var e;this._invoke=function(o,i){function c(){return new n((function(e,c){!function e(o,i,c,u){var a=f(t[o],t,i);if("throw"!==a.type){var s=a.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?n.resolve(l.__await).then((function(t){e("next",t,c,u)}),(function(t){e("throw",t,c,u)})):n.resolve(l).then((function(t){s.value=t,c(s)}),(function(t){return e("throw",t,c,u)}))}u(a.arg)}(o,i,e,c)}))}return e=e?e.then(c,c):c()}}function x(t,n){var r=t.iterator[n.method];if(void 0===r){if(n.delegate=null,"throw"===n.method){if(t.iterator.return&&(n.method="return",n.arg=void 0,x(t,n),"throw"===n.method))return s;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var e=f(r,t.iterator,n.arg);if("throw"===e.type)return n.method="throw",n.arg=e.arg,n.delegate=null,s;var o=e.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=void 0),n.delegate=null,s):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,s)}function _(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function b(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function E(t){if(t){var n=t[o];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,i=function n(){for(;++e=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),a=r.call(i,"finallyLoc");if(u&&a){if(this.prev=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--n){var r=this.tryEntries[n];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),b(r),s}},catch:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc===t){var e=r.completion;if("throw"===e.type){var o=e.arg;b(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:E(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=void 0),s}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}},function(t,n,r){var e=r(0),o=r(4),i=r(13),c=r(9),u=r(6),a=function(t,n,r){var f,s,l,h,p=t&a.F,v=t&a.G,d=t&a.S,y=t&a.P,m=t&a.B,g=v?e:d?e[n]||(e[n]={}):(e[n]||{}).prototype,w=v?o:o[n]||(o[n]={}),x=w.prototype||(w.prototype={});for(f in v&&(r=n),r)l=((s=!p&&g&&void 0!==g[f])?g:r)[f],h=m&&s?u(l,e):y&&"function"==typeof l?u(Function.call,l):l,g&&c(g,f,l,t&a.U),w[f]!=l&&i(w,f,h),y&&x[f]!=l&&(x[f]=l)};e.core=o,a.F=1,a.G=2,a.S=4,a.P=8,a.B=16,a.W=32,a.U=64,a.R=128,t.exports=a},function(t,n,r){var e=r(28),o=Math.min;t.exports=function(t){return t>0?o(e(t),9007199254740991):0}},function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n){var r=Math.ceil,e=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?e:r)(t)}},function(t,n,r){var e=r(8).f,o=r(14),i=r(1)("toStringTag");t.exports=function(t,n,r){t&&!o(t=r?t:t.prototype,i)&&e(t,i,{configurable:!0,value:n})}},function(t,n,r){var e=r(3);t.exports=function(t,n){if(!e(t))return t;var r,o;if(n&&"function"==typeof(r=t.toString)&&!e(o=r.call(t)))return o;if("function"==typeof(r=t.valueOf)&&!e(o=r.call(t)))return o;if(!n&&"function"==typeof(r=t.toString)&&!e(o=r.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,n,r){var e=r(2),o=r(7),i=r(1)("species");t.exports=function(t,n){var r,c=e(t).constructor;return void 0===c||null==(r=e(c)[i])?n:o(r)}},function(t,n,r){t.exports=!r(5)&&!r(12)((function(){return 7!=Object.defineProperty(r(19)("div"),"a",{get:function(){return 7}}).a}))},function(t,n,r){var e=r(2);t.exports=function(t,n,r,o){try{return o?n(e(r)[0],r[1]):n(r)}catch(n){var i=t.return;throw void 0!==i&&e(i.call(t)),n}}},function(t,n,r){var e=r(17),o=r(1)("iterator"),i=Array.prototype;t.exports=function(t){return void 0!==t&&(e.Array===t||i[o]===t)}},function(t,n,r){var e=r(11),o=r(1)("iterator"),i=r(17);t.exports=r(4).getIteratorMethod=function(t){if(null!=t)return t[o]||t["@@iterator"]||i[e(t)]}},function(t,n,r){var e=r(0).document;t.exports=e&&e.documentElement},function(t,n,r){var e=r(1)("iterator"),o=!1;try{var i=[7][e]();i.return=function(){o=!0},Array.from(i,(function(){throw 2}))}catch(t){}t.exports=function(t,n){if(!n&&!o)return!1;var r=!1;try{var i=[7],c=i[e]();c.next=function(){return{done:r=!0}},i[e]=function(){return c},t(i)}catch(t){}return r}},,,function(t,n,r){t.exports=r(18)("native-function-to-string",Function.toString)},function(t,n){t.exports=function(t,n,r,e){if(!(t instanceof n)||void 0!==e&&e in t)throw TypeError(r+": incorrect invocation!");return t}},function(t,n,r){var e=r(6),o=r(33),i=r(34),c=r(2),u=r(26),a=r(35),f={},s={};(n=t.exports=function(t,n,r,l,h){var p,v,d,y,m=h?function(){return t}:a(t),g=e(r,l,n?2:1),w=0;if("function"!=typeof m)throw TypeError(t+" is not iterable!");if(i(m)){for(p=u(t.length);p>w;w++)if((y=n?g(c(v=t[w])[0],v[1]):g(t[w]))===f||y===s)return y}else for(d=m.call(t);!(v=d.next()).done;)if((y=o(d,g,v.value,n))===f||y===s)return y}).BREAK=f,n.RETURN=s},function(t,n){t.exports=function(t,n,r){var e=void 0===r;switch(n.length){case 0:return e?t():t.call(r);case 1:return e?t(n[0]):t.call(r,n[0]);case 2:return e?t(n[0],n[1]):t.call(r,n[0],n[1]);case 3:return e?t(n[0],n[1],n[2]):t.call(r,n[0],n[1],n[2]);case 4:return e?t(n[0],n[1],n[2],n[3]):t.call(r,n[0],n[1],n[2],n[3])}return t.apply(r,n)}},function(t,n,r){var e=r(0),o=r(20).set,i=e.MutationObserver||e.WebKitMutationObserver,c=e.process,u=e.Promise,a="process"==r(10)(c);t.exports=function(){var t,n,r,f=function(){var e,o;for(a&&(e=c.domain)&&e.exit();t;){o=t.fn,t=t.next;try{o()}catch(e){throw t?r():n=void 0,e}}n=void 0,e&&e.enter()};if(a)r=function(){c.nextTick(f)};else if(!i||e.navigator&&e.navigator.standalone)if(u&&u.resolve){var s=u.resolve(void 0);r=function(){s.then(f)}}else r=function(){o.call(e,f)};else{var l=!0,h=document.createTextNode("");new i(f).observe(h,{characterData:!0}),r=function(){h.data=l=!l}}return function(e){var o={fn:e,next:void 0};n&&(n.next=o),t||(t=o,r()),n=o}}},function(t,n){t.exports=function(t){try{return{e:!1,v:t()}}catch(t){return{e:!0,v:t}}}},function(t,n,r){var e=r(0).navigator;t.exports=e&&e.userAgent||""},function(t,n,r){var e=r(2),o=r(3),i=r(21);t.exports=function(t,n){if(e(t),o(n)&&n.constructor===t)return n;var r=i.f(t);return(0,r.resolve)(n),r.promise}},function(t,n,r){var e=r(9);t.exports=function(t,n,r){for(var o in n)e(t,o,n[o],r);return t}},function(t,n,r){"use strict";var e=r(0),o=r(8),i=r(5),c=r(1)("species");t.exports=function(t){var n=e[t];i&&n&&!n[c]&&o.f(n,c,{configurable:!0,get:function(){return this}})}}]]); \ No newline at end of file diff --git a/views/js/dist/vendors~banks.min.js b/views/js/dist/vendors~banks.min.js index c1f8737e0..5f067ebca 100644 --- a/views/js/dist/vendors~banks.min.js +++ b/views/js/dist/vendors~banks.min.js @@ -1,11 +1,12 @@ -/*! - * - * Mollie https://www.mollie.nl - * @author Mollie B.V. - * @copyright Mollie B.V. - * @link https://github.com/mollie/PrestaShop - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ (window["webpackJsonP_mollie"] = window["webpackJsonP_mollie"] || []).push([["vendors~banks"],{ diff --git a/views/js/dist/vendors~banks~carrierconfig~methodconfig~qrcode~transaction.min.js b/views/js/dist/vendors~banks~carrierconfig~methodconfig~qrcode~transaction.min.js index dfb73642b..70283488f 100644 --- a/views/js/dist/vendors~banks~carrierconfig~methodconfig~qrcode~transaction.min.js +++ b/views/js/dist/vendors~banks~carrierconfig~methodconfig~qrcode~transaction.min.js @@ -1,10 +1,11 @@ -/*! - * - * Mollie https://www.mollie.nl - * @author Mollie B.V. - * @copyright Mollie B.V. - * @link https://github.com/mollie/PrestaShop - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * +/** + * Mollie https://www.mollie.nl + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart */ (window.webpackJsonP_mollie=window.webpackJsonP_mollie||[]).push([["vendors~banks~carrierconfig~methodconfig~qrcode~transaction"],{134:function(e,t,n){"use strict";var r=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;function a(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,o,u=a(e),c=1;cz.length&&z.push(e)}function R(e,t,n){return null==e?0:function e(t,n,r,l){var o=typeof t;"undefined"!==o&&"boolean"!==o||(t=null);var u=!1;if(null===t)u=!0;else switch(o){case"string":case"number":u=!0;break;case"object":switch(t.$$typeof){case i:case a:u=!0}}if(u)return r(l,t,""===n?"."+I(t,0):n),1;if(u=0,n=""===n?".":n+":",Array.isArray(t))for(var c=0;c