We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) 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( ...@@ -29,9 +29,10 @@ define(
'Adyen_Payment/js/action/set-payment-method', 'Adyen_Payment/js/action/set-payment-method',
'Magento_Checkout/js/action/select-payment-method', 'Magento_Checkout/js/action/select-payment-method',
'Magento_Checkout/js/model/quote', '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'; 'use strict';
var brandCode = ko.observable(null); var brandCode = ko.observable(null);
var paymentMethod = ko.observable(null); var paymentMethod = ko.observable(null);
...@@ -64,6 +65,9 @@ define( ...@@ -64,6 +65,9 @@ define(
'issuerId': ko.observable(null), 'issuerId': ko.observable(null),
getCode: function() { getCode: function() {
return self.item.method; return self.item.method;
},
validate: function () {
return self.validate();
} }
} }
} else { } else {
...@@ -73,6 +77,9 @@ define( ...@@ -73,6 +77,9 @@ define(
'method': self.item.method, 'method': self.item.method,
getCode: function() { getCode: function() {
return self.item.method; return self.item.method;
},
validate: function () {
return self.validate();
} }
} }
} }
...@@ -82,15 +89,19 @@ define( ...@@ -82,15 +89,19 @@ define(
}, },
/** Redirect to adyen */ /** Redirect to adyen */
continueToAdyen: function () { continueToAdyen: function () {
if (this.validate() && additionalValidators.validate()) {
//update payment method information if additional data was changed //update payment method information if additional data was changed
this.selectPaymentMethod(); this.selectPaymentMethod();
setPaymentMethodAction(); setPaymentMethodAction();
return false; return false;
}
}, },
continueToAdyenBrandCode: function() { continueToAdyenBrandCode: function() {
// set payment method to adyen_hpp // set payment method to adyen_hpp
var self = this; var self = this;
if (this.validate() && additionalValidators.validate()) {
// for ideal add brand_code in request // for ideal add brand_code in request
if(brandCode() == "ideal") { if(brandCode() == "ideal") {
var data = { var data = {
...@@ -113,6 +124,8 @@ define( ...@@ -113,6 +124,8 @@ define(
selectPaymentMethodAction(data); selectPaymentMethodAction(data);
setPaymentMethodAction(); setPaymentMethodAction();
}
return false; return false;
}, },
selectPaymentMethodBrandCode: function() { selectPaymentMethodBrandCode: function() {
...@@ -151,6 +164,9 @@ define( ...@@ -151,6 +164,9 @@ define(
}), }),
isPaymentMethodSelectionOnAdyen: function() { isPaymentMethodSelectionOnAdyen: function() {
return window.checkoutConfig.payment.adyenHpp.isPaymentMethodSelectionOnAdyen; return window.checkoutConfig.payment.adyenHpp.isPaymentMethodSelectionOnAdyen;
},
validate: function () {
return true;
} }
}); });
} }
......
...@@ -25,9 +25,10 @@ define( ...@@ -25,9 +25,10 @@ define(
[ [
'ko', 'ko',
'Magento_Checkout/js/view/payment/default', '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'; 'use strict';
var brandCode = ko.observable(null); var brandCode = ko.observable(null);
var paymentMethod = ko.observable(null); var paymentMethod = ko.observable(null);
...@@ -46,13 +47,18 @@ define( ...@@ -46,13 +47,18 @@ define(
}, },
/** Redirect to adyen */ /** Redirect to adyen */
continueToAdyen: function () { continueToAdyen: function () {
if (this.validate() && additionalValidators.validate()) {
//update payment method information if additional data was changed //update payment method information if additional data was changed
this.selectPaymentMethod(); this.selectPaymentMethod();
setPaymentMethodAction(); setPaymentMethodAction();
return false; return false;
}
}, },
showLogo: function() { showLogo: function() {
return window.checkoutConfig.payment.adyen.showLogo; 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