diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7a3833c..f33752d 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
+- Fix incorrect dependency used in logger of the Hosted Checkout payment method
+
## [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"
},
diff --git a/etc/di.xml b/etc/di.xml
index faf0b34..058e9b0 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -18,6 +18,8 @@
+
+
Magento\Config\Model\ResourceModel\Config\Data
@@ -33,7 +35,7 @@
- TnsHpfConfig
+ TnsHostedConfig
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();
+ })
}
});
}