We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday in our country

Commit 1b9940cd authored by rikterbeek's avatar rikterbeek

Fixes #35 add aditionalValidators to payment method adyen_hpp and adyen_sepa...

Fixes #35 add aditionalValidators to payment method adyen_hpp and adyen_sepa (other payment mehthods already have this) so terms of condition is validated if it is set to manually
parent feb2463b
......@@ -29,9 +29,10 @@ define(
'Adyen_Payment/js/action/set-payment-method',
'Magento_Checkout/js/action/select-payment-method',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/checkout-data'
'Magento_Checkout/js/checkout-data',
'Magento_Checkout/js/model/payment/additional-validators'
],
function (ko, $, Component, setPaymentMethodAction, selectPaymentMethodAction,quote, checkoutData) {
function (ko, $, Component, setPaymentMethodAction, selectPaymentMethodAction,quote, checkoutData, additionalValidators) {
'use strict';
var brandCode = ko.observable(null);
var paymentMethod = ko.observable(null);
......@@ -64,6 +65,9 @@ define(
'issuerId': ko.observable(null),
getCode: function() {
return self.item.method;
},
validate: function () {
return self.validate();
}
}
} else {
......@@ -73,6 +77,9 @@ define(
'method': self.item.method,
getCode: function() {
return self.item.method;
},
validate: function () {
return self.validate();
}
}
}
......@@ -82,37 +89,43 @@ define(
},
/** Redirect to adyen */
continueToAdyen: function () {
//update payment method information if additional data was changed
this.selectPaymentMethod();
setPaymentMethodAction();
return false;
if (this.validate() && additionalValidators.validate()) {
//update payment method information if additional data was changed
this.selectPaymentMethod();
setPaymentMethodAction();
return false;
}
},
continueToAdyenBrandCode: function() {
// set payment method to adyen_hpp
var self = this;
// for ideal add brand_code in request
if(brandCode() == "ideal") {
var data = {
"method": self.method,
"po_number": null,
"additional_data": {
issuer_id: this.issuerId(),
brand_code: self.value
}
};
} else {
var data = {
"method": self.method,
"po_number": null,
"additional_data": {
brand_code: self.value
}
};
if (this.validate() && additionalValidators.validate()) {
// for ideal add brand_code in request
if(brandCode() == "ideal") {
var data = {
"method": self.method,
"po_number": null,
"additional_data": {
issuer_id: this.issuerId(),
brand_code: self.value
}
};
} else {
var data = {
"method": self.method,
"po_number": null,
"additional_data": {
brand_code: self.value
}
};
}
selectPaymentMethodAction(data);
setPaymentMethodAction();
}
selectPaymentMethodAction(data);
setPaymentMethodAction();
return false;
},
selectPaymentMethodBrandCode: function() {
......@@ -151,6 +164,9 @@ define(
}),
isPaymentMethodSelectionOnAdyen: function() {
return window.checkoutConfig.payment.adyenHpp.isPaymentMethodSelectionOnAdyen;
},
validate: function () {
return true;
}
});
}
......
......@@ -25,9 +25,10 @@ define(
[
'ko',
'Magento_Checkout/js/view/payment/default',
'Adyen_Payment/js/action/set-payment-method'
'Adyen_Payment/js/action/set-payment-method',
'Magento_Checkout/js/model/payment/additional-validators'
],
function (ko, Component, setPaymentMethodAction) {
function (ko, Component, setPaymentMethodAction, additionalValidators) {
'use strict';
var brandCode = ko.observable(null);
var paymentMethod = ko.observable(null);
......@@ -46,13 +47,18 @@ define(
},
/** Redirect to adyen */
continueToAdyen: function () {
//update payment method information if additional data was changed
this.selectPaymentMethod();
setPaymentMethodAction();
return false;
if (this.validate() && additionalValidators.validate()) {
//update payment method information if additional data was changed
this.selectPaymentMethod();
setPaymentMethodAction();
return false;
}
},
showLogo: function() {
return window.checkoutConfig.payment.adyen.showLogo;
},
validate: function () {
return true;
}
});
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment