Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
4 changes: 3 additions & 1 deletion etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<preference for="OnTap\MasterCard\Api\SessionInformationManagementInterface" type="OnTap\MasterCard\Model\SessionInformationManagement" />
<preference for="OnTap\MasterCard\Api\VerifyPaymentFlagInterface" type="OnTap\MasterCard\Model\VerifyPaymentFlag" />

<type name="OnTap\MasterCard\Gateway\Http\Client\Adapter\Rest" shared="false" />

<type name="OnTap\MasterCard\Model\System\Config\Backend\Cert">
<arguments>
<argument name="resource" xsi:type="object">Magento\Config\Model\ResourceModel\Config\Data</argument>
Expand All @@ -33,7 +35,7 @@

<virtualType name="MpgsHostedLogger" type="Magento\Payment\Model\Method\Logger">
<arguments>
<argument name="config" xsi:type="object">TnsHpfConfig</argument>
<argument name="config" xsi:type="object">TnsHostedConfig</argument>
</arguments>
</virtualType>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ define(
defaults: {
template: 'OnTap_MasterCard/payment/ach/hosted-session'
},
getFields: function () {

getCardFields: function () {
return {
ach: {
accountType: "#ach-account-type",
Expand All @@ -38,6 +39,7 @@ define(
}
}
},

errorMap: function () {
return {
'accountType': $t('Invalid account type'),
Expand All @@ -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) {
Expand All @@ -57,43 +61,86 @@ 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,
formSessionUpdate: this.formSessionUpdate.bind(this)
}
}, 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();
})
}
});
}
Expand Down