From 0d61764cbbf2fe0b2646d63b777f4a033628c89b Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 18 Jun 2024 11:02:04 +0300 Subject: [PATCH 01/13] PIPRES-443: performance improvements --- composer.json | 2 +- src/ServiceProvider/PrestashopContainer.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index ab171d36f..6f4806454 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "mollie/mollie-api-php": "v2.65.0", "segmentio/analytics-php": "^1.5", "sentry/sentry": "3.17.0", - "league/container": "2.5.0", + "league/container": "3.3.3", "prestashop/module-lib-service-container": "v2.0", "webmozart/assert": "^1.11", "symfony/http-client": "^4.4", diff --git a/src/ServiceProvider/PrestashopContainer.php b/src/ServiceProvider/PrestashopContainer.php index 87b0c62bb..8f13e4f13 100644 --- a/src/ServiceProvider/PrestashopContainer.php +++ b/src/ServiceProvider/PrestashopContainer.php @@ -14,15 +14,15 @@ namespace Mollie\ServiceProvider; -use Interop\Container\ContainerInterface as InteropContainerInterface; use PrestaShop\PrestaShop\Adapter\SymfonyContainer; +use Psr\Container\ContainerInterface as PsrContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; if (!defined('_PS_VERSION_')) { exit; } -class PrestashopContainer implements InteropContainerInterface +class PrestashopContainer implements PsrContainerInterface { /** @var SymfonyContainer|ContainerInterface|null */ private $container; From 98c174e7b4c430627c1456392dcda907b8d4228f Mon Sep 17 00:00:00 2001 From: Gytautas Date: Wed, 26 Jun 2024 14:20:01 +0300 Subject: [PATCH 02/13] PIPRES-445: HTTP status handling improvements --- .php-cs-fixer.dist.php | 15 ------------ Makefile | 3 +-- changelog.md | 3 +++ controllers/front/webhook.php | 44 ++++++++++++++++++++++------------- 4 files changed, 32 insertions(+), 33 deletions(-) delete mode 100644 .php-cs-fixer.dist.php diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php deleted file mode 100644 index 8d68a2263..000000000 --- a/.php-cs-fixer.dist.php +++ /dev/null @@ -1,15 +0,0 @@ -setUsingCache(true) - ->getFinder() - ->in(__DIR__) - ->exclude('translations') - ->exclude('mails') - ->exclude('libraries') - ->exclude('vendor') - ->exclude('upgrade'); - -return $config; diff --git a/Makefile b/Makefile index 7c3ace459..194247360 100755 --- a/Makefile +++ b/Makefile @@ -90,8 +90,7 @@ npm-package-install: prepare-zip: composer install --no-dev --optimize-autoloader --classmap-authoritative composer dump-autoload --no-dev --optimize --classmap-authoritative - cp .github/.htaccess vendor/.htaccess - rm -rf .git .docker .editorconfig .github tests .php-cs-fixer.php Makefile cypress .docker cypress.config.js cypress.env.json docker-compose*.yml .gitignore bin codeception.yml package-lock.json package.json .php_cs.dist .php-cs-fixer.dist + rm -rf .git .docker .editorconfig .github tests .php-cs-fixer.php Makefile cypress .docker cypress.config.js cypress.env.json docker-compose*.yml .gitignore bin codeception.yml package-lock.json package.json .php_cs.dist .php-cs-fixer.dist .php-cs-fixer.dist.php diff --git a/changelog.md b/changelog.md index 09a8211bc..24953f1bd 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,9 @@ # Changelog # +## Changes in release 6.2.2 ## ++ Error handling improvements + ## Changes in release 6.2.1 ## + Ideal v2 payment method improvement diff --git a/controllers/front/webhook.php b/controllers/front/webhook.php index fa2710aa3..6b245fe23 100644 --- a/controllers/front/webhook.php +++ b/controllers/front/webhook.php @@ -11,8 +11,10 @@ */ use Mollie\Adapter\ToolsAdapter; +use Mollie\Api\Exceptions\ApiException; use Mollie\Controller\AbstractMollieController; use Mollie\Errors\Http\HttpStatusCode; +use Mollie\Exception\TransactionException; use Mollie\Handler\ErrorHandler\ErrorHandler; use Mollie\Infrastructure\Response\JsonResponse; use Mollie\Logger\PrestaLoggerInterface; @@ -50,9 +52,6 @@ public function initContent(): void /** @var PrestaLoggerInterface $logger */ $logger = $this->module->getService(PrestaLoggerInterface::class); - /** @var ErrorHandler $errorHandler */ - $errorHandler = $this->module->getService(ErrorHandler::class); - /** @var ToolsAdapter $tools */ $tools = $this->module->getService(ToolsAdapter::class); @@ -95,20 +94,12 @@ public function initContent(): void try { $this->executeWebhook($transactionId); + } catch (ApiException $exception) { + $this->handleException($exception, HttpStatusCode::HTTP_BAD_REQUEST, 'Api request failed'); + } catch (TransactionException $exception) { + $this->handleException($exception, $exception->getCode(), 'Failed to handle transaction'); } catch (\Throwable $exception) { - $logger->error('Failed to handle webhook', [ - 'Exception message' => $exception->getMessage(), - 'Exception code' => $exception->getCode(), - ]); - - $errorHandler->handle($exception, $exception->getCode(), false); - - $this->releaseLock(); - - $this->ajaxResponse(JsonResponse::error( - $this->module->l('Failed to handle webhook', self::FILE_NAME), - $exception->getCode() - )); + $this->handleException($exception, HttpStatusCode::HTTP_BAD_REQUEST, 'Failed to handle webhook'); } $this->releaseLock(); @@ -158,4 +149,25 @@ private function setContext(int $cartId): void $this->context->cart = $cart; } + + private function handleException(\Throwable $exception, int $httpStatusCode, string $logMessage): void + { + /** @var PrestaLoggerInterface $logger */ + $logger = $this->module->getService(PrestaLoggerInterface::class); + + /** @var ErrorHandler $errorHandler */ + $errorHandler = $this->module->getService(ErrorHandler::class); + + $logger->error($logMessage, [ + 'Exception message' => $exception->getMessage(), + 'Exception code' => $httpStatusCode + ]); + + $errorHandler->handle($exception, $httpStatusCode, false); + $this->releaseLock(); + $this->ajaxResponse(JsonResponse::error( + $this->module->l('Failed to handle webhook', self::FILE_NAME), + $httpStatusCode + )); + } } From 1ecdcdc5fc3410b80bc49f8f3cb6db57f2c1b5de Mon Sep 17 00:00:00 2001 From: Gytautas Date: Wed, 26 Jun 2024 14:22:22 +0300 Subject: [PATCH 03/13] cs fixer file reverted --- .php-cs-fixer.dist.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .php-cs-fixer.dist.php diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 000000000..59646bbb0 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,15 @@ +setUsingCache(true) + ->getFinder() + ->in(__DIR__) + ->exclude('translations') + ->exclude('mails') + ->exclude('libraries') + ->exclude('vendor') + ->exclude('upgrade'); + +return $config; \ No newline at end of file From 084001d59b5c4aaf9971eeb3f866d78fefdad623 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Wed, 3 Jul 2024 14:23:13 +0300 Subject: [PATCH 04/13] PIPRES-441: new payment methods added and giropay method deleted --- Makefile | 14 ++++++++++++-- README.md | 2 +- README_DE.md | 5 ----- README_ES.md | 5 ----- README_FR.md | 5 ----- README_NL.md | 5 ----- controllers/front/webhook.php | 2 +- .../03_mollie.ps1785.PaymentTestsOrdersAPI.js | 14 +------------- .../05_mollie.ps1785.PaymentTestsPaymentsAPI.js | 14 +------------- .../e2e/ps8/03_mollie.ps8.PaymentTestsOrdersAPI.js | 13 ------------- .../ps8/05_mollie.ps8.PaymentTestsPaymentsAPI.js | 13 ------------- cypress/support/commands.js | 4 ++-- src/Config/Config.php | 10 ++++++++-- src/Service/ApiService.php | 3 +++ src/Service/TransactionService.php | 5 +++++ 15 files changed, 34 insertions(+), 80 deletions(-) diff --git a/Makefile b/Makefile index 7c3ace459..dea5c6703 100755 --- a/Makefile +++ b/Makefile @@ -93,6 +93,16 @@ prepare-zip: cp .github/.htaccess vendor/.htaccess rm -rf .git .docker .editorconfig .github tests .php-cs-fixer.php Makefile cypress .docker cypress.config.js cypress.env.json docker-compose*.yml .gitignore bin codeception.yml package-lock.json package.json .php_cs.dist .php-cs-fixer.dist - - +# Define SQL commands +SQL_COMMANDS := \ + "UPDATE \`ps_configuration\` SET \`value\` = '1' WHERE \`name\` = 'PS_SSL_ENABLED';" \ + "UPDATE \`ps_configuration\` SET \`value\` = '1' WHERE \`name\` = 'PS_SSL_ENABLED_EVERYWHERE';" \ + "UPDATE \`ps_shop_url\` SET \`domain\` = '$(DOMAIN_NAME)' WHERE active = 1;" \ + "UPDATE \`ps_shop_url\` SET \`domain_ssl\` = '$(DOMAIN_NAME)' WHERE active = 1;" + +# Target to change shop URL +change-shop-url: + @echo "Executing SQL commands to change shop URL..." + docker exec -i $(DOCKER_CONTAINER_NAME) mysql -u$(MYSQL_USER) -p$(MYSQL_PASSWORD) $(MYSQL_DATABASE) -e "$(SQL_COMMANDS)" + @echo "Shop URL updated successfully." diff --git a/README.md b/README.md index 639346878..847b381e4 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Receive payments from European customers with ease. Mollie provides payment meth Choose the best payment provider available for your online PrestaShop store. Create your merchant account at [Mollie.com](https://www.mollie.com/). -Mollie supports the following payment methods: iDEAL, Credit card, Bancontact, SOFORT Banking, ING Home’Pay, Bank transfers, PayPal, KBC / CBC Payment Button, Belfius, CartaSi, Cartes Bancaires, EPS, Giropay, Klarna: Pay later, Klarna: Slice it +Mollie supports the following payment methods: iDEAL, Credit card, Bancontact, SOFORT Banking, ING Home’Pay, Bank transfers, PayPal, KBC / CBC Payment Button, Belfius, CartaSi, Cartes Bancaires, EPS, Klarna: Pay later, Klarna: Slice it [![Build Status](https://travis-ci.org/mollie/PrestaShop.svg?branch=master)](https://travis-ci.org/mollie/PrestaShop) [![Greenkeeper badge](https://badges.greenkeeper.io/mollie/PrestaShop.svg)](https://greenkeeper.io/) diff --git a/README_DE.md b/README_DE.md index acf6f2a01..c255125c5 100644 --- a/README_DE.md +++ b/README_DE.md @@ -128,11 +128,6 @@ Die Karten tragen ebenfalls das Markenzeichen von Visa. Dies macht sie zur wichtigsten Zahlungsmethode in Österreich, die bei österreichischen Konsumenten hohe Beliebtheit genießt. -### Giropay -[Giropay](https://www.mollie.com/de/payments/giropay). Giropay ist eine der beliebtesten Überweisungsmethoden Deutschlands. - -Deutsche Kunden schenken dieser Zahlungsmethode ihr Vertrauen, da sie von über 1.500 Banken landesweit unterstützt wird. - ### Klarna: Rechnung [Klarna: Rechnung](https://www.mollie.com/de/payments/klarna-pay-later). Klarna ist eine flexible Zahlungslösung, die Ihren Kunden verschiedene, flexible Zahlungsmöglichkeiten zur Verfügung stellt. diff --git a/README_ES.md b/README_ES.md index 1bf6155e9..df0f1fe9a 100644 --- a/README_ES.md +++ b/README_ES.md @@ -128,11 +128,6 @@ Las tarjetas que comparten marca con Visa. Esto hace que el EPS sea el principal tipo de pago por transferencia bancaria en Austria y muy popular entre los compradores austriacos. -### Giropay -[Giropay](https://www.mollie.com/es/payments/giropay). Giropay es un tipo de pago por transferencia bancaria, popular en Alemania. - -Utiliza más de 1.500 bancos alemanes, lo que lo convierte en un tipo de pago confiable para los clientes alemanes. - ### Klarna: Pay later [Klarna: Pay later](https://www.mollie.com/es/payments/klarna-pay-later). Klarna es una solución de pago flexible que les permite a sus clientes diversas formas de pago flexibles. diff --git a/README_FR.md b/README_FR.md index ccd4ff9d5..bb1cc73e5 100644 --- a/README_FR.md +++ b/README_FR.md @@ -128,11 +128,6 @@ Les cartes sont co-marquées avec Visa. Devenue très populaire auprès des consommateurs autrichiens, EPS est la référence en matière de virement bancaire en Autriche. -### Giropay -[Giropay](https://www.mollie.com/fr/payments/giropay). Giropay est une méthode de paiement très populaire de virement bancaire en Allemagne. - -Utilisé par plus de 15000 à travers le pays, cela en fait un moyen de paiement fiable, réputé auprès des consommateurs allemands. - ### Klarna : Pay later [Klarna : Pay later](https://www.mollie.com/fr/payments/klarna-pay-later). Klarna est une solution de paiement flexible, qui permet à vos clients des modes de paiement variés. diff --git a/README_NL.md b/README_NL.md index c2d142407..3b9554016 100644 --- a/README_NL.md +++ b/README_NL.md @@ -117,11 +117,6 @@ De kaarten zijn co-branded met Visa. Dit maakt EPS de belangrijkste betaalmethode voor bankoverboekingen in Oostenrijk en zeer populair bij Oostenrijkse klanten. -### Giropay -[Giropay](https://www.mollie.com/nl/payments/giropay). Giropay is een populaire bankoverboeking betaalmethode in Duitsland. - -Het maakt gebruik van meer dan 1.500 Duitse banken, waardoor het een vertrouwde betaalmethode is onder Duitse klanten. - ### Klarna: Achteraf betalen [Klarna: Achteraf betalen](https://www.mollie.com/nl/payments/klarna-pay-later). Klarna is een flexibele betaaloplossing, waarmee je je klanten diverse mogelijkheden voor uitgestelde betaling biedt. diff --git a/controllers/front/webhook.php b/controllers/front/webhook.php index fa2710aa3..251bfade8 100644 --- a/controllers/front/webhook.php +++ b/controllers/front/webhook.php @@ -131,7 +131,7 @@ protected function executeWebhook(string $transactionId): void } else { $transaction = $this->module->getApiClient()->payments->get($transactionId); - if ($transaction->orderId) { + if ($transaction->orderId && $transaction->status !== 'expired') { $transaction = $this->module->getApiClient()->orders->get($transaction->orderId, ['embed' => 'payments']); } } diff --git a/cypress/e2e/ps1785/03_mollie.ps1785.PaymentTestsOrdersAPI.js b/cypress/e2e/ps1785/03_mollie.ps1785.PaymentTestsOrdersAPI.js index 9f28a15a3..9d69131bc 100755 --- a/cypress/e2e/ps1785/03_mollie.ps1785.PaymentTestsOrdersAPI.js +++ b/cypress/e2e/ps1785/03_mollie.ps1785.PaymentTestsOrdersAPI.js @@ -215,19 +215,7 @@ it('C339365: 28 Przelewy24 Checkouting [Orders API]', () => { it('C339366: 29 Przelewy24 Order Shipping, Refunding [Orders API]', () => { cy.OrderRefundingShippingOrdersAPI() }) -it('C339367: 30 Giropay Checkouting [Orders API]', () => { - cy.navigatingToThePayment() - //Payment method choosing - cy.contains('giropay').click({force:true}) - cy.get('.condition-label > .js-terms').click({force:true}) - cy.contains('Place order').click() - cy.get('[value="paid"]').click() - cy.get('[class="button form__button"]').click() - cy.get('#content-hook_order_confirmation > .card-block').should('be.visible') -}); -it('C339368: 31 Giropay Order Shipping, Refunding [Orders API]', () => { - cy.OrderRefundingShippingOrdersAPI() -}) + it('C339369: 32 EPS Checkouting [Orders API]', () => { cy.navigatingToThePayment() //Payment method choosing diff --git a/cypress/e2e/ps1785/05_mollie.ps1785.PaymentTestsPaymentsAPI.js b/cypress/e2e/ps1785/05_mollie.ps1785.PaymentTestsPaymentsAPI.js index faffc9163..a78b25544 100755 --- a/cypress/e2e/ps1785/05_mollie.ps1785.PaymentTestsPaymentsAPI.js +++ b/cypress/e2e/ps1785/05_mollie.ps1785.PaymentTestsPaymentsAPI.js @@ -180,19 +180,7 @@ it('C339391: 56 Przelewy24 Checkouting [Payments API]', () => { it('C339392: 57 Przelewy24 BO Refunding, Partial Refunding [Payments API]', () => { cy.OrderRefundingPartialPaymentsAPI() }); -it('C339393: 58 Giropay Checkouting [Payments API]', () => { - cy.navigatingToThePayment() - //Payment method choosing - cy.contains('giropay').click({force:true}) - cy.get('.condition-label > .js-terms').click({force:true}) - cy.contains('Place order').click() - cy.get('[value="paid"]').click() - cy.get('[class="button form__button"]').click() - cy.get('#content-hook_order_confirmation > .card-block').should('be.visible') -}); -it('C339394: 59 Giropay BO Refunding, Partial Refunding [Payments API]', () => { - cy.OrderRefundingPartialPaymentsAPI() -}); + it('C339395: 60 EPS Checkouting [Payments API]', () => { cy.navigatingToThePayment() //Payment method choosing diff --git a/cypress/e2e/ps8/03_mollie.ps8.PaymentTestsOrdersAPI.js b/cypress/e2e/ps8/03_mollie.ps8.PaymentTestsOrdersAPI.js index 85586a8c3..c6964ffa2 100755 --- a/cypress/e2e/ps8/03_mollie.ps8.PaymentTestsOrdersAPI.js +++ b/cypress/e2e/ps8/03_mollie.ps8.PaymentTestsOrdersAPI.js @@ -204,19 +204,6 @@ it('C339365: 28 Przelewy24 Checkouting [Orders API]', () => { it('C339366: 29 Przelewy24 Order Shipping, Refunding [Orders API]', () => { cy.OrderRefundingShippingOrdersAPI() }) -it('C339367: 30 Giropay Checkouting [Orders API]', () => { - cy.navigatingToThePaymentPS8() - //Payment method choosing - cy.contains('giropay').click({force:true}) - cy.get('.condition-label > .js-terms').click({force:true}) - cy.contains('Place order').click() - cy.get('[value="paid"]').click() - cy.get('[class="button form__button"]').click() - cy.get('#content-hook_order_confirmation > .card-block').should('be.visible') -}); -it('C339368: 31 Giropay Order Shipping, Refunding [Orders API]', () => { - cy.OrderRefundingShippingOrdersAPI() -}) it('C339369: 32 EPS Checkouting [Orders API]', () => { cy.navigatingToThePaymentPS8() //Payment method choosing diff --git a/cypress/e2e/ps8/05_mollie.ps8.PaymentTestsPaymentsAPI.js b/cypress/e2e/ps8/05_mollie.ps8.PaymentTestsPaymentsAPI.js index fd98721ef..8b0657a29 100755 --- a/cypress/e2e/ps8/05_mollie.ps8.PaymentTestsPaymentsAPI.js +++ b/cypress/e2e/ps8/05_mollie.ps8.PaymentTestsPaymentsAPI.js @@ -170,19 +170,6 @@ it('C339391: 56 Przelewy24 Checkouting [Payments API]', () => { it('C339392: 57 Przelewy24 BO Refunding, Partial Refunding [Payments API]', () => { cy.OrderRefundingPartialPaymentsAPI() }); -it('C339393: 58 Giropay Checkouting [Payments API]', () => { - cy.navigatingToThePaymentPS8() - //Payment method choosing - cy.contains('giropay').click({force:true}) - cy.get('.condition-label > .js-terms').click({force:true}) - cy.contains('Place order').click() - cy.get('[value="paid"]').click() - cy.get('[class="button form__button"]').click() - cy.get('#content-hook_order_confirmation > .card-block').should('be.visible') -}); -it('C339394: 59 Giropay BO Refunding, Partial Refunding [Payments API]', () => { - cy.OrderRefundingPartialPaymentsAPI() -}); it('C339395: 60 EPS Checkouting [Payments API]', () => { cy.navigatingToThePaymentPS8() //Payment method choosing diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 860faab4d..c398bce51 100755 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -42,7 +42,7 @@ import 'cypress-iframe'; // Cypress.Commands.add("login", (email, password) => { ... }) Cypress.Commands.add("ConfOrdersAPI1784", () => { - const paymentMethods = ["applepay", "ideal", "creditcard", "in3", "klarnapaylater", "klarnapaynow", "klarnasliceit", "paypal", "banktransfer", "bancontact", "eps", "giropay", "przelewy24", "kbc", "belfius", "voucher", "directdebit", "billie", "klarna", "twint", "blik", "bancomatpay"]; + const paymentMethods = ["applepay", "ideal", "creditcard", "in3", "klarnapaylater", "klarnapaynow", "klarnasliceit", "paypal", "banktransfer", "bancontact", "eps", "przelewy24", "kbc", "belfius", "voucher", "directdebit", "billie", "klarna", "twint", "blik", "bancomatpay"]; // Iterate through the paymentMethods array using forEach paymentMethods.forEach(method => { @@ -59,7 +59,7 @@ Cypress.Commands.add("ConfOrdersAPI1784", () => { }) Cypress.Commands.add("ConfPaymentsAPI1784", () => { - const paymentMethods = ["giropay", "eps", "przelewy24", "kbc", "belfius", "bancontact", "creditcard", "ideal", "banktransfer", "paypal", "applepay", "twint", "blik", "bancomatpay"]; + const paymentMethods = ["eps", "przelewy24", "kbc", "belfius", "bancontact", "creditcard", "ideal", "banktransfer", "paypal", "applepay", "twint", "blik", "bancomatpay"]; // Iterate through the paymentMethods array using forEach paymentMethods.forEach(method => { diff --git a/src/Config/Config.php b/src/Config/Config.php index 6ca067414..2ce5beaab 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -47,7 +47,6 @@ class Config 'ideal' => ['nl'], 'bancontact' => ['be'], 'paypal' => [], - 'giropay' => ['de'], 'eps' => ['at'], 'belfius' => ['be'], 'inghomepay' => ['be'], @@ -64,6 +63,9 @@ class Config 'ro', 'bl', 'mf', 'pm', 'sm', 'sk', 'sl', 'es', 'se', 'ch', 'gb', 'uk', ], 'mybank' => [], + 'trustly' => ['at', 'de', 'ee', 'es', 'fi', 'lt', 'lv', 'nl'], + 'riverty' => ['nl','be','de','at'], + 'payconiq' => [], ]; const SUPPORTED_PHP_VERSION = '5.6'; @@ -240,6 +242,7 @@ class Config const MOLLIE_METHOD_ID_APPLE_PAY = 'applepay'; const MOLLIE_VOUCHER_METHOD_ID = 'voucher'; const MOLLIE_in3_METHOD_ID = 'in3'; + const RIVERTY = 'riverty'; const MOLLIE_VOUCHER_CATEGORY_NULL = 'null'; const MOLLIE_VOUCHER_CATEGORY_MEAL = 'meal'; @@ -275,6 +278,7 @@ class Config PaymentMethod::BILLIE, self::MOLLIE_VOUCHER_METHOD_ID, self::MOLLIE_in3_METHOD_ID, + self::RIVERTY, ]; const PAYMENT_API_ONLY_METHODS = [ @@ -301,7 +305,6 @@ class Config 'directdebit' => 'Direct Debit', 'eps' => 'EPS', 'giftcard' => 'Giftcard', - 'giropay' => 'Giropay', 'ideal' => 'iDEAL', 'inghomepay' => 'ING Homepay', 'kbc' => 'KBC', @@ -322,6 +325,9 @@ class Config 'alma' => 'Alma', 'blik' => 'BLIK', 'klarna' => 'Pay with Klarna.', + 'riverty' => 'Riverty', + 'payconiq' => 'Payconiq', + 'trustly' => 'Trustly', ]; const MOLLIE_BUTTON_ORDER_TOTAL_REFRESH = 'MOLLIE_BUTTON_ORDER_TOTAL_REFRESH'; diff --git a/src/Service/ApiService.php b/src/Service/ApiService.php index 4f557430c..f7629d5f8 100644 --- a/src/Service/ApiService.php +++ b/src/Service/ApiService.php @@ -123,6 +123,9 @@ public function getMethodsForConfig(MollieApiClient $api) $apiMethods = $apiMethods->getArrayCopy(); /** @var Method $method */ foreach ($apiMethods as $key => $method) { + if ($method->status === 'pending-review') { // TODO REMOVE THIS ONCE RIVERTY IS IMPLEMENTED + continue; + } if ($method->status !== 'activated') { unset($apiMethods[$key]); } diff --git a/src/Service/TransactionService.php b/src/Service/TransactionService.php index d34a154e0..2b1781ac4 100644 --- a/src/Service/TransactionService.php +++ b/src/Service/TransactionService.php @@ -170,6 +170,9 @@ public function processTransaction($apiPayment) return $apiPayment; } + /** @var PrestaLoggerInterface $logger */ + $logger = $this->module->getService(PrestaLoggerInterface::class); + $logger->error($apiPayment->resource); switch ($apiPayment->resource) { case Config::MOLLIE_API_STATUS_PAYMENT: PrestaShopLogger::addLog(__METHOD__ . ' said: Starting to process PAYMENT transaction.', Config::NOTICE); @@ -284,6 +287,8 @@ public function processTransaction($apiPayment) $this->configurationAdapter->get(Config::MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS) === Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_DEFAULT; + + $logger->error($apiPayment->method); if ( !$isAuthorizablePaymentInvoiceOnStatusDefault && $apiPayment->status === OrderStatus::STATUS_COMPLETED From 16143fec62f67e92d103a81be8255b95a4d47138 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Wed, 3 Jul 2024 14:32:48 +0300 Subject: [PATCH 05/13] not needed changes deleted --- Makefile | 14 -------------- controllers/front/webhook.php | 2 +- src/Config/Config.php | 2 +- src/Service/ApiService.php | 3 --- src/Service/TransactionService.php | 5 ----- 5 files changed, 2 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index dea5c6703..09bc04377 100755 --- a/Makefile +++ b/Makefile @@ -92,17 +92,3 @@ prepare-zip: composer dump-autoload --no-dev --optimize --classmap-authoritative cp .github/.htaccess vendor/.htaccess rm -rf .git .docker .editorconfig .github tests .php-cs-fixer.php Makefile cypress .docker cypress.config.js cypress.env.json docker-compose*.yml .gitignore bin codeception.yml package-lock.json package.json .php_cs.dist .php-cs-fixer.dist - -# Define SQL commands -SQL_COMMANDS := \ - "UPDATE \`ps_configuration\` SET \`value\` = '1' WHERE \`name\` = 'PS_SSL_ENABLED';" \ - "UPDATE \`ps_configuration\` SET \`value\` = '1' WHERE \`name\` = 'PS_SSL_ENABLED_EVERYWHERE';" \ - "UPDATE \`ps_shop_url\` SET \`domain\` = '$(DOMAIN_NAME)' WHERE active = 1;" \ - "UPDATE \`ps_shop_url\` SET \`domain_ssl\` = '$(DOMAIN_NAME)' WHERE active = 1;" - -# Target to change shop URL -change-shop-url: - @echo "Executing SQL commands to change shop URL..." - docker exec -i $(DOCKER_CONTAINER_NAME) mysql -u$(MYSQL_USER) -p$(MYSQL_PASSWORD) $(MYSQL_DATABASE) -e "$(SQL_COMMANDS)" - @echo "Shop URL updated successfully." - diff --git a/controllers/front/webhook.php b/controllers/front/webhook.php index 251bfade8..fa2710aa3 100644 --- a/controllers/front/webhook.php +++ b/controllers/front/webhook.php @@ -131,7 +131,7 @@ protected function executeWebhook(string $transactionId): void } else { $transaction = $this->module->getApiClient()->payments->get($transactionId); - if ($transaction->orderId && $transaction->status !== 'expired') { + if ($transaction->orderId) { $transaction = $this->module->getApiClient()->orders->get($transaction->orderId, ['embed' => 'payments']); } } diff --git a/src/Config/Config.php b/src/Config/Config.php index 2ce5beaab..946946d57 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -64,7 +64,7 @@ class Config ], 'mybank' => [], 'trustly' => ['at', 'de', 'ee', 'es', 'fi', 'lt', 'lv', 'nl'], - 'riverty' => ['nl','be','de','at'], + 'riverty' => ['nl', 'be', 'de', 'at'], 'payconiq' => [], ]; diff --git a/src/Service/ApiService.php b/src/Service/ApiService.php index f7629d5f8..4f557430c 100644 --- a/src/Service/ApiService.php +++ b/src/Service/ApiService.php @@ -123,9 +123,6 @@ public function getMethodsForConfig(MollieApiClient $api) $apiMethods = $apiMethods->getArrayCopy(); /** @var Method $method */ foreach ($apiMethods as $key => $method) { - if ($method->status === 'pending-review') { // TODO REMOVE THIS ONCE RIVERTY IS IMPLEMENTED - continue; - } if ($method->status !== 'activated') { unset($apiMethods[$key]); } diff --git a/src/Service/TransactionService.php b/src/Service/TransactionService.php index 2b1781ac4..d34a154e0 100644 --- a/src/Service/TransactionService.php +++ b/src/Service/TransactionService.php @@ -170,9 +170,6 @@ public function processTransaction($apiPayment) return $apiPayment; } - /** @var PrestaLoggerInterface $logger */ - $logger = $this->module->getService(PrestaLoggerInterface::class); - $logger->error($apiPayment->resource); switch ($apiPayment->resource) { case Config::MOLLIE_API_STATUS_PAYMENT: PrestaShopLogger::addLog(__METHOD__ . ' said: Starting to process PAYMENT transaction.', Config::NOTICE); @@ -287,8 +284,6 @@ public function processTransaction($apiPayment) $this->configurationAdapter->get(Config::MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS) === Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_DEFAULT; - - $logger->error($apiPayment->method); if ( !$isAuthorizablePaymentInvoiceOnStatusDefault && $apiPayment->status === OrderStatus::STATUS_COMPLETED From d78829636f2183917e9e536c2d4ed36b56ded830 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Mon, 8 Jul 2024 13:38:21 +0300 Subject: [PATCH 06/13] PIPRES-449: mobile phone fix then field is removed --- src/Provider/PhoneNumberProvider.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Provider/PhoneNumberProvider.php b/src/Provider/PhoneNumberProvider.php index 022d144a5..fa60bdce1 100644 --- a/src/Provider/PhoneNumberProvider.php +++ b/src/Provider/PhoneNumberProvider.php @@ -13,6 +13,8 @@ namespace Mollie\Provider; use Address; +use AddressFormat; +use Country; if (!defined('_PS_VERSION_')) { exit; @@ -53,6 +55,12 @@ public function getFromAddress(Address $address) private function getMobileOrPhone(Address $address) { - return $address->phone_mobile ?: $address->phone; + $addressFormat = new AddressFormat((int) $address->id_country); + + if (strpos($addressFormat->format, 'phone_mobile') !== false) { + return $address->phone_mobile ?: $address->phone; + } + + return $address->phone; } } From 9dd7463b53334294ca4555fba6af368e1ea53b85 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Mon, 8 Jul 2024 13:39:40 +0300 Subject: [PATCH 07/13] removed unused use statement --- src/Provider/PhoneNumberProvider.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Provider/PhoneNumberProvider.php b/src/Provider/PhoneNumberProvider.php index fa60bdce1..86c016dc6 100644 --- a/src/Provider/PhoneNumberProvider.php +++ b/src/Provider/PhoneNumberProvider.php @@ -14,7 +14,6 @@ use Address; use AddressFormat; -use Country; if (!defined('_PS_VERSION_')) { exit; From 3b88829bd666f87e077daf94f67a68b23ec7b049 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Mon, 8 Jul 2024 13:43:04 +0300 Subject: [PATCH 08/13] php cs fixer fix --- controllers/front/webhook.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/front/webhook.php b/controllers/front/webhook.php index 6b245fe23..abca3b115 100644 --- a/controllers/front/webhook.php +++ b/controllers/front/webhook.php @@ -150,7 +150,7 @@ private function setContext(int $cartId): void $this->context->cart = $cart; } - private function handleException(\Throwable $exception, int $httpStatusCode, string $logMessage): void + private function handleException(Throwable $exception, int $httpStatusCode, string $logMessage): void { /** @var PrestaLoggerInterface $logger */ $logger = $this->module->getService(PrestaLoggerInterface::class); @@ -160,7 +160,7 @@ private function handleException(\Throwable $exception, int $httpStatusCode, str $logger->error($logMessage, [ 'Exception message' => $exception->getMessage(), - 'Exception code' => $httpStatusCode + 'Exception code' => $httpStatusCode, ]); $errorHandler->handle($exception, $httpStatusCode, false); From dfccc8cb3480945833cbb4f76d3c4d714e4f4539 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Mon, 8 Jul 2024 14:05:23 +0300 Subject: [PATCH 09/13] cs fixer --- .php-cs-fixer.dist.php | 2 +- Makefile | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 59646bbb0..8d68a2263 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -12,4 +12,4 @@ ->exclude('vendor') ->exclude('upgrade'); -return $config; \ No newline at end of file +return $config; diff --git a/Makefile b/Makefile index 194247360..de3a68b13 100755 --- a/Makefile +++ b/Makefile @@ -91,7 +91,3 @@ prepare-zip: composer install --no-dev --optimize-autoloader --classmap-authoritative composer dump-autoload --no-dev --optimize --classmap-authoritative rm -rf .git .docker .editorconfig .github tests .php-cs-fixer.php Makefile cypress .docker cypress.config.js cypress.env.json docker-compose*.yml .gitignore bin codeception.yml package-lock.json package.json .php_cs.dist .php-cs-fixer.dist .php-cs-fixer.dist.php - - - - From a585439671785ae2321a70d2eee76f912d32bc05 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 16 Jul 2024 09:33:42 +0300 Subject: [PATCH 10/13] logs added to track installation progress --- mollie.php | 8 ++++++++ src/Install/Installer.php | 9 +++++++++ subscription/Install/Installer.php | 11 +++++++++++ 3 files changed, 28 insertions(+) diff --git a/mollie.php b/mollie.php index c68e33c91..203aff5b4 100755 --- a/mollie.php +++ b/mollie.php @@ -155,6 +155,8 @@ private function loadEnv() */ public function install() { + PrestaShopLogger::addLog('Mollie install started', 1, null, 'Mollie', 1); + if (!$this->isPhpVersionCompliant()) { $this->_errors[] = $this->l('You\'re using an outdated PHP version. Upgrade your PHP version to use this module. The Mollie module supports versions PHP 7.2.0 and higher.'); @@ -166,9 +168,11 @@ public function install() return false; } + PrestaShopLogger::addLog('Mollie prestashop install successful', 1, null, 'Mollie', 1); // TODO inject base install and subscription services $coreInstaller = $this->getService(Mollie\Install\Installer::class); + PrestaShopLogger::addLog('Mollie core install initiated', 1, null, 'Mollie', 1); if (!$coreInstaller->install()) { $this->_errors = array_merge($this->_errors, $coreInstaller->getErrors()); @@ -176,6 +180,8 @@ public function install() return false; } + PrestaShopLogger::addLog('Mollie core install successful', 1, null, 'Mollie', 1); + $subscriptionInstaller = new Installer( new DatabaseTableInstaller(), new AttributeInstaller( @@ -187,6 +193,7 @@ public function install() ), new HookInstaller($this) ); + PrestaShopLogger::addLog('Mollie subscription installer initiated', 1, null, 'Mollie', 1); if (!$subscriptionInstaller->install()) { $this->_errors = array_merge($this->_errors, $subscriptionInstaller->getErrors()); @@ -194,6 +201,7 @@ public function install() return false; } + PrestaShopLogger::addLog('Mollie subscription install successful', 1, null, 'Mollie', 1); return true; } diff --git a/src/Install/Installer.php b/src/Install/Installer.php index 60bcc10eb..2560f1359 100644 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -28,6 +28,7 @@ use Mollie\Utility\MultiLangUtility; use OrderState; use PrestaShopException; +use PrestaShopLogger; use Tab; use Tools; use Validate; @@ -96,8 +97,11 @@ public function install() $this->module->registerHook($hook); } + PrestaShopLogger::addLog('Mollie hooks registered successful', 1, null, 'Mollie', 1); + try { $this->orderStateInstaller->install(); + PrestaShopLogger::addLog('Mollie order state install successful', 1, null, 'Mollie', 1); } catch (CouldNotInstallModule $e) { $errorHandler->handle($e, $e->getCode(), false); $this->errors[] = $this->module->l('Unable to install Mollie statuses', self::FILE_NAME); @@ -107,6 +111,8 @@ public function install() try { $this->initConfig(); + PrestaShopLogger::addLog('Mollie configurations installed', 1, null, 'Mollie', 1); + } catch (Exception $e) { $errorHandler->handle($e, $e->getCode(), false); $this->errors[] = $this->module->l('Unable to install config', self::FILE_NAME); @@ -115,6 +121,7 @@ public function install() } try { $this->setDefaultCarrierStatuses(); + PrestaShopLogger::addLog('Mollie default carriers installed', 1, null, 'Mollie', 1); } catch (Exception $e) { $errorHandler->handle($e, $e->getCode(), false); $this->errors[] = $this->module->l('Unable to install default carrier statuses', self::FILE_NAME); @@ -126,6 +133,7 @@ public function install() try { $this->installVoucherFeatures(); + PrestaShopLogger::addLog('Mollie voucher features installed', 1, null, 'Mollie', 1); } catch (Exception $e) { $errorHandler->handle($e, $e->getCode(), false); $this->errors[] = $this->module->l('Unable to install voucher attributes', self::FILE_NAME); @@ -134,6 +142,7 @@ public function install() } $this->copyEmailTemplates(); + PrestaShopLogger::addLog('Mollie email templates copied', 1, null, 'Mollie', 1); return $this->databaseTableInstaller->install(); } diff --git a/subscription/Install/Installer.php b/subscription/Install/Installer.php index 6d854ad74..8cfe08d43 100644 --- a/subscription/Install/Installer.php +++ b/subscription/Install/Installer.php @@ -14,6 +14,8 @@ namespace Mollie\Subscription\Install; +use PrestaShopLogger; + if (!defined('_PS_VERSION_')) { exit; } @@ -43,22 +45,31 @@ public function install(): bool { if (!$this->databaseInstaller->install()) { $this->errors = $this->databaseInstaller->getErrors(); + PrestaShopLogger::addLog('Mollie subscription databases install failed', 1, null, 'Mollie', 1); return false; } + PrestaShopLogger::addLog('Mollie subscription databases installed', 1, null, 'Mollie', 1); + if (!$this->attributeInstaller->install()) { $this->errors = $this->attributeInstaller->getErrors(); + PrestaShopLogger::addLog('Mollie subscription attributes install failed', 1, null, 'Mollie', 1); return false; } + PrestaShopLogger::addLog('Mollie subscription attributes install successful', 1, null, 'Mollie', 1); + if (!$this->hookInstaller->install()) { $this->errors = $this->hookInstaller->getErrors(); + PrestaShopLogger::addLog('Mollie subscription hooks install failed', 1, null, 'Mollie', 1); return false; } + PrestaShopLogger::addLog('Mollie subscription hooks install successful', 1, null, 'Mollie', 1); + return true; } } From b5d1c8e1b9779d87cb4cdcb6e6a1a16fdab38ede Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 16 Jul 2024 10:05:22 +0300 Subject: [PATCH 11/13] logs added --- src/Install/Installer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Install/Installer.php b/src/Install/Installer.php index 2560f1359..f8c52300b 100644 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -112,7 +112,6 @@ public function install() try { $this->initConfig(); PrestaShopLogger::addLog('Mollie configurations installed', 1, null, 'Mollie', 1); - } catch (Exception $e) { $errorHandler->handle($e, $e->getCode(), false); $this->errors[] = $this->module->l('Unable to install config', self::FILE_NAME); From 8a25f8be3ead6be8664a5b21f19ec0e915fb7dfb Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 16 Jul 2024 10:25:41 +0300 Subject: [PATCH 12/13] version bump and changelog updated --- changelog.md | 5 +++++ mollie.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 24953f1bd..78048bcf8 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,11 @@ ## Changes in release 6.2.2 ## + Error handling improvements ++ Mobile phone fix then field is removed ++ Riverty, Trustly, Payconiq payment methods added and GiroPay removed ++ HTTP status ++ Dependencies version bump ++ Improved installation process ## Changes in release 6.2.1 ## + Ideal v2 payment method improvement diff --git a/mollie.php b/mollie.php index 203aff5b4..21621619f 100755 --- a/mollie.php +++ b/mollie.php @@ -84,7 +84,7 @@ public function __construct() { $this->name = 'mollie'; $this->tab = 'payments_gateways'; - $this->version = '6.2.1'; + $this->version = '6.2.2'; $this->author = 'Mollie B.V.'; $this->need_instance = 1; $this->bootstrap = true; From 68f873db871ac9c04e0c06dad18cc2b7d28b0e11 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 16 Jul 2024 13:53:40 +0300 Subject: [PATCH 13/13] component link fix --- views/templates/admin/mollie_components_info.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/templates/admin/mollie_components_info.tpl b/views/templates/admin/mollie_components_info.tpl index 830d8d9dc..585712b76 100644 --- a/views/templates/admin/mollie_components_info.tpl +++ b/views/templates/admin/mollie_components_info.tpl @@ -8,7 +8,7 @@ * @see https://github.com/mollie/PrestaShop * @codingStandardsIgnoreStart *} -