From 4fbd770463f1835a9e1b772289de4b1a8c3e8a9d Mon Sep 17 00:00:00 2001 From: Gihan Kanchana Date: Tue, 25 Oct 2022 16:32:10 +0530 Subject: [PATCH 01/10] MPGS-778: Fixed the payment.log file not genarate issue and di compliation issue under magento 2.3.2 --- Model/Method/Vault.php | 12 ++++++++++-- etc/di.xml | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Model/Method/Vault.php b/Model/Method/Vault.php index ac1912e..a3c4183 100644 --- a/Model/Method/Vault.php +++ b/Model/Method/Vault.php @@ -68,6 +68,11 @@ class Vault extends VaultPaymentMethod */ private $jsonSerializer; + /** + * @var SerializerInterface + */ + private $serializer; + /** * @param ConfigInterface $config * @param ConfigFactoryInterface $configFactory @@ -81,6 +86,7 @@ class Vault extends VaultPaymentMethod * @param VerifyPaymentFlagInterface $verifyPaymentFlag * @param Json $jsonSerializer * @param string $code + * @param SerializerInterface $serializer */ public function __construct( ConfigInterface $config, @@ -94,7 +100,8 @@ public function __construct( OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory, VerifyPaymentFlagInterface $verifyPaymentFlag, Json $jsonSerializer, - string $code + string $code, + SerializerInterface $serializer ) { parent::__construct( $config, @@ -107,7 +114,8 @@ public function __construct( $tokenManagement, $paymentExtensionFactory, $code, - $jsonSerializer + $jsonSerializer, + $jsonSerializer = $jsonSerializer ?: $this->serializer = $serializer ); $this->commandManagerPool = $commandManagerPool; diff --git a/etc/di.xml b/etc/di.xml index faf0b34..6588dd5 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -33,7 +33,7 @@ - TnsHpfConfig + TnsHostedConfig From ec38ca40ef2a61c37bedfd4966bfe30ae33cd4eb Mon Sep 17 00:00:00 2001 From: Gihan Kanchana Date: Tue, 25 Oct 2022 17:04:07 +0530 Subject: [PATCH 02/10] MPGS-778:Fixed the phpstan and phpcs issues --- Model/Method/Vault.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Model/Method/Vault.php b/Model/Method/Vault.php index a3c4183..ef7843b 100644 --- a/Model/Method/Vault.php +++ b/Model/Method/Vault.php @@ -71,7 +71,7 @@ class Vault extends VaultPaymentMethod /** * @var SerializerInterface */ - private $serializer; + private $serializer; /** * @param ConfigInterface $config @@ -99,9 +99,9 @@ public function __construct( PaymentTokenManagementInterface $tokenManagement, OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory, VerifyPaymentFlagInterface $verifyPaymentFlag, - Json $jsonSerializer, string $code, - SerializerInterface $serializer + SerializerInterface $serializer, + Json $jsonSerializer = null ) { parent::__construct( $config, @@ -114,8 +114,7 @@ public function __construct( $tokenManagement, $paymentExtensionFactory, $code, - $jsonSerializer, - $jsonSerializer = $jsonSerializer ?: $this->serializer = $serializer + $this->jsonSerializer = $jsonSerializer ?: $this->serializer = $serializer ); $this->commandManagerPool = $commandManagerPool; From d2c7168135b81065a85c5a65f3eed4a25017ce07 Mon Sep 17 00:00:00 2001 From: Gihan Kanchana Date: Tue, 25 Oct 2022 17:32:00 +0530 Subject: [PATCH 03/10] MPGS-778:Removed the SerializerInterface --- Model/Method/Vault.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Model/Method/Vault.php b/Model/Method/Vault.php index ef7843b..558cbcf 100644 --- a/Model/Method/Vault.php +++ b/Model/Method/Vault.php @@ -69,9 +69,9 @@ class Vault extends VaultPaymentMethod private $jsonSerializer; /** - * @var SerializerInterface + * @var ObjectManagerInterface */ - private $serializer; + private $objectManager; /** * @param ConfigInterface $config @@ -84,9 +84,9 @@ class Vault extends VaultPaymentMethod * @param PaymentTokenManagementInterface $tokenManagement * @param OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory * @param VerifyPaymentFlagInterface $verifyPaymentFlag - * @param Json $jsonSerializer * @param string $code * @param SerializerInterface $serializer + * @param Json|null $jsonSerializer */ public function __construct( ConfigInterface $config, @@ -114,7 +114,7 @@ public function __construct( $tokenManagement, $paymentExtensionFactory, $code, - $this->jsonSerializer = $jsonSerializer ?: $this->serializer = $serializer + $this->jsonSerializer = $jsonSerializer ?: $this->objectManager->get(Json::class) ); $this->commandManagerPool = $commandManagerPool; From 0af8565489f69e081fc5b033d1f1500fe9546343 Mon Sep 17 00:00:00 2001 From: Gihan Kanchana Date: Wed, 26 Oct 2022 00:08:41 +0530 Subject: [PATCH 04/10] MPGS-778: Removed the Object manager usage from parent constructor --- Model/Method/Vault.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Model/Method/Vault.php b/Model/Method/Vault.php index 558cbcf..086a67c 100644 --- a/Model/Method/Vault.php +++ b/Model/Method/Vault.php @@ -68,11 +68,6 @@ class Vault extends VaultPaymentMethod */ private $jsonSerializer; - /** - * @var ObjectManagerInterface - */ - private $objectManager; - /** * @param ConfigInterface $config * @param ConfigFactoryInterface $configFactory @@ -114,7 +109,7 @@ public function __construct( $tokenManagement, $paymentExtensionFactory, $code, - $this->jsonSerializer = $jsonSerializer ?: $this->objectManager->get(Json::class) + $this->jsonSerializer = $jsonSerializer ?: $serializer ); $this->commandManagerPool = $commandManagerPool; From acd872d4032da88c4780c4a60d4b0f4d3b79506b Mon Sep 17 00:00:00 2001 From: Gihan Kanchana Date: Wed, 26 Oct 2022 11:08:16 +0530 Subject: [PATCH 05/10] MPGS-778: Revert the jsonSerializer constructor changes --- Model/Method/Vault.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Model/Method/Vault.php b/Model/Method/Vault.php index 086a67c..d8863c2 100644 --- a/Model/Method/Vault.php +++ b/Model/Method/Vault.php @@ -79,9 +79,8 @@ class Vault extends VaultPaymentMethod * @param PaymentTokenManagementInterface $tokenManagement * @param OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory * @param VerifyPaymentFlagInterface $verifyPaymentFlag + * @param Json $jsonSerializer * @param string $code - * @param SerializerInterface $serializer - * @param Json|null $jsonSerializer */ public function __construct( ConfigInterface $config, @@ -94,9 +93,8 @@ public function __construct( PaymentTokenManagementInterface $tokenManagement, OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory, VerifyPaymentFlagInterface $verifyPaymentFlag, - string $code, - SerializerInterface $serializer, - Json $jsonSerializer = null + Json $jsonSerializer, + string $code ) { parent::__construct( $config, @@ -109,7 +107,7 @@ public function __construct( $tokenManagement, $paymentExtensionFactory, $code, - $this->jsonSerializer = $jsonSerializer ?: $serializer + $jsonSerializer ); $this->commandManagerPool = $commandManagerPool; @@ -223,4 +221,4 @@ private function attachCreditCardInfo(OrderPaymentInterface $payment): void $payment->addData($tokenDetails); } } -} +} \ No newline at end of file From e34e375362566c12d2dfd90986af2771af647c7d Mon Sep 17 00:00:00 2001 From: Gihan Kanchana Date: Wed, 26 Oct 2022 11:17:04 +0530 Subject: [PATCH 06/10] MPGS-778: added newline and fixed the phpcs issue --- Model/Method/Vault.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Method/Vault.php b/Model/Method/Vault.php index d8863c2..ac1912e 100644 --- a/Model/Method/Vault.php +++ b/Model/Method/Vault.php @@ -221,4 +221,4 @@ private function attachCreditCardInfo(OrderPaymentInterface $payment): void $payment->addData($tokenDetails); } } -} \ No newline at end of file +} From ace213133c0029dd659b2f124d8159f514ed17d9 Mon Sep 17 00:00:00 2001 From: Kristjan Heinaste Date: Fri, 4 Nov 2022 16:05:07 +0200 Subject: [PATCH 07/10] MPGS-798: "Invalid credentials" error message shown when trying to save module settings even for correct credentials Made REST client not-shareable --- etc/di.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/etc/di.xml b/etc/di.xml index 6588dd5..058e9b0 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -18,6 +18,8 @@ + + Magento\Config\Model\ResourceModel\Config\Data From ff2368d07ee161f0b8c4a89b5aefa42c4ab27b21 Mon Sep 17 00:00:00 2001 From: Igor Goltsov Date: Thu, 17 Nov 2022 11:23:51 +0300 Subject: [PATCH 08/10] =?UTF-8?q?MPGS-744:=20Fix=20for=20the=20issue=20-?= =?UTF-8?q?=20(2)=20Client=20side=20validation=20is=20not=20triggered=20wh?= =?UTF-8?q?ile=20click=20on=20the=20=E2=80=9CPlace=20Order=E2=80=9C=20butt?= =?UTF-8?q?on=20for=20the=20ACH=20payment=20method.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../method-renderer/ach/hosted-session.js | 71 +++++++++++++++---- 1 file changed, 59 insertions(+), 12 deletions(-) diff --git a/view/frontend/web/js/view/payment/method-renderer/ach/hosted-session.js b/view/frontend/web/js/view/payment/method-renderer/ach/hosted-session.js index cf3693e..bc9b242 100644 --- a/view/frontend/web/js/view/payment/method-renderer/ach/hosted-session.js +++ b/view/frontend/web/js/view/payment/method-renderer/ach/hosted-session.js @@ -28,7 +28,8 @@ define( defaults: { template: 'OnTap_MasterCard/payment/ach/hosted-session' }, - getFields: function () { + + getCardFields: function () { return { ach: { accountType: "#ach-account-type", @@ -38,6 +39,7 @@ define( } } }, + errorMap: function () { return { 'accountType': $t('Invalid account type'), @@ -46,9 +48,11 @@ define( 'routingNumber': $t('Invalid routing number') }; }, + load: function (callback) { require([this.component_url], callback); }, + configure: function (callback) { var elem = document.getElementById('ach-account-holder'); if (elem) { @@ -57,9 +61,10 @@ define( setTimeout(this.configure.bind(this, callback), 100); } }, + _configure: function (callback) { PaymentSession.configure({ - fields: this.getFields(), + fields: this.getCardFields(), frameEmbeddingMitigation: ['x-frame-options'], callbacks: { initialized: callback, @@ -67,33 +72,75 @@ define( } }, this.getId()); }, + formSessionUpdate: function (response) { - var fields = this.getFields(); + var fields, errors, message, elemId; + + fields = this.getCardFields(); if (response.status === "fields_in_error") { if (response.errors) { - var errors = this.errorMap(); - _.keys(response.errors).forEach(function(errorField) { - var message = errors[errorField], - elem_id = fields.ach[errorField] + '-error'; + errors = this.errorMap(); + _.keys(response.errors).forEach(function (errorField) { + message = errors[errorField]; + elemId = fields.ach[errorField] + '-error'; - $(elem_id).text(message).show(); + $(elemId).text(message).show(); }); this.sessionUpdateErrorCallback(response); } } + if (response.status === "ok") { this.sessionUpdateCallback(response); } }, + pay: function (callback, errorCallback) { - var fields = this.getFields(); + var fields, isAchValid, achResult; + + fields = this.getCardFields(); _.values(fields.ach).forEach(function (field) { $(field + '-error').hide(); }); - this.sessionUpdateErrorCallback = errorCallback; - this.sessionUpdateCallback = callback; - PaymentSession.updateSessionFromForm('ach', undefined, this.getId()); + PaymentSession.validate('ach', function (result) { + achResult = result.ach || {}; + isAchValid = achResult.isValid || false; + + if (isAchValid) { + this.sessionUpdateErrorCallback = errorCallback; + this.sessionUpdateCallback = callback; + PaymentSession.updateSessionFromForm('ach', undefined, this.getId()); + } else { + this.showValidationErrors(result); + errorCallback(result); + } + }.bind(this)); + }, + + showValidationErrors: function (result) { + var achResult, errorsMessages, fields; + + achResult = result.ach || {}; + fields = this.getCardFields(); + _.values(fields.ach).forEach(function (field) { + $(field + '-error').hide(); + }); + + errorsMessages = this.errorMap(); + _.keys(fields.ach).forEach(function (fieldKey) { + var fieldData, message, elemId; + + fieldData = achResult[fieldKey] || false; + if (!fieldData || fieldData.isValid) { + return; + } + + message = errorsMessages[fieldKey]; + elemId = fields.ach[fieldKey] + '-error'; + + $(elemId).text(message).show(); + }) } }); } From bcb14cbe177f5a14b28b80576f3e30758c27e33d Mon Sep 17 00:00:00 2001 From: Igor Goltsov Date: Wed, 23 Nov 2022 14:50:21 +0300 Subject: [PATCH 09/10] Version 103.9.1 --- CHANGELOG.md | 6 ++++++ composer.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a3833c..b57fa81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog All notable changes to this project will be documented in this file. +## [103.9.1] - 2022-11-23 +### Fixed +- Client-side validation is not triggered while clicking on the “Place Order“ button for the ACH payment method +- There is an "Invalid credentials" error message is shown when trying to save module settings even for correct credentials + + ## [103.9.0] - 2022-10-19 ### Changed - Add the “Verify and Tokenize“ Payment Option for the "Hosted Payment Session" Payment Method diff --git a/composer.json b/composer.json index 9057258..59481f9 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Official Magento2 Plugin to integrate with MasterCard Payments", "type": "magento2-module", "license": "Apache-2.0", - "version": "103.9.0", + "version": "103.9.1", "require": { "magento/framework": "^102.0.0|^103.0.0" }, From a473e58f66751a256172c461d1ea25b564ba423e Mon Sep 17 00:00:00 2001 From: Igor Goltsov Date: Wed, 23 Nov 2022 15:01:36 +0300 Subject: [PATCH 10/10] Add missed point into CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b57fa81..f33752d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. ### Fixed - Client-side validation is not triggered while clicking on the “Place Order“ button for the ACH payment method - There is an "Invalid credentials" error message is shown when trying to save module settings even for correct credentials - +- Fix incorrect dependency used in logger of the Hosted Checkout payment method ## [103.9.0] - 2022-10-19 ### Changed