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,37 +89,43 @@ define( ...@@ -82,37 +89,43 @@ define(
}, },
/** Redirect to adyen */ /** Redirect to adyen */
continueToAdyen: function () { continueToAdyen: function () {
//update payment method information if additional data was changed if (this.validate() && additionalValidators.validate()) {
this.selectPaymentMethod(); //update payment method information if additional data was changed
setPaymentMethodAction(); this.selectPaymentMethod();
return false; setPaymentMethodAction();
return false;
}
}, },
continueToAdyenBrandCode: function() { continueToAdyenBrandCode: function() {
// set payment method to adyen_hpp // set payment method to adyen_hpp
var self = this; var self = this;
// for ideal add brand_code in request if (this.validate() && additionalValidators.validate()) {
if(brandCode() == "ideal") {
var data = { // for ideal add brand_code in request
"method": self.method, if(brandCode() == "ideal") {
"po_number": null, var data = {
"additional_data": { "method": self.method,
issuer_id: this.issuerId(), "po_number": null,
brand_code: self.value "additional_data": {
} issuer_id: this.issuerId(),
}; brand_code: self.value
} else { }
var data = { };
"method": self.method, } else {
"po_number": null, var data = {
"additional_data": { "method": self.method,
brand_code: self.value "po_number": null,
} "additional_data": {
}; brand_code: self.value
}
};
}
selectPaymentMethodAction(data);
setPaymentMethodAction();
} }
selectPaymentMethodAction(data);
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 () {
//update payment method information if additional data was changed if (this.validate() && additionalValidators.validate()) {
this.selectPaymentMethod(); //update payment method information if additional data was changed
setPaymentMethodAction(); this.selectPaymentMethod();
return false; setPaymentMethodAction();
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