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 c0c23405 authored by Rik ter Beek's avatar Rik ter Beek

fixes and optimalizations for cc and oneclick

parent 4fbf8974
...@@ -138,31 +138,28 @@ define( ...@@ -138,31 +138,28 @@ define(
* @override * @override
*/ */
placeOrder: function (data, event) { placeOrder: function (data, event) {
var self = this,
placeOrder;
if (event) { if (event) {
event.preventDefault(); event.preventDefault();
} }
var options = {}; var options = {};
var cseInstance = adyen.createEncryption(options); var cseInstance = adyen.createEncryption(options);
var generationtime = self.getGenerationTime(); var generationtime = this.getGenerationTime();
var cardData = { var cardData = {
number: self.creditCardNumber(), number: this.creditCardNumber(),
cvc: self.creditCardVerificationNumber(), cvc: this.creditCardVerificationNumber(),
holderName: self.creditCardOwner(), holderName: this.creditCardOwner(),
expiryMonth: self.creditCardExpMonth(), expiryMonth: this.creditCardExpMonth(),
expiryYear: self.creditCardExpYear(), expiryYear: this.creditCardExpYear(),
generationtime: generationtime generationtime: generationtime
}; };
var data = cseInstance.encrypt(cardData); var data = cseInstance.encrypt(cardData);
self.encryptedData(data); this.encryptedData(data);
// rest is default placeOrder logic // rest is default placeOrder logic
return self._super(); return this._super();
}, },
getControllerName: function () { getControllerName: function () {
return window.checkoutConfig.payment.iframe.controllerName[this.getCode()]; return window.checkoutConfig.payment.iframe.controllerName[this.getCode()];
......
...@@ -26,19 +26,23 @@ define( ...@@ -26,19 +26,23 @@ define(
'jquery', 'jquery',
'Magento_Payment/js/view/payment/cc-form', 'Magento_Payment/js/view/payment/cc-form',
'Magento_Checkout/js/action/select-payment-method', 'Magento_Checkout/js/action/select-payment-method',
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/checkout-data' 'Magento_Checkout/js/checkout-data',
'Magento_Checkout/js/action/redirect-on-success'
], ],
function (ko, _, $, Component, selectPaymentMethodAction, quote, checkoutData) { function (ko, _, $, Component, selectPaymentMethodAction, additionalValidators, quote, checkoutData, redirectOnSuccessAction) {
'use strict'; 'use strict';
var updatedExpiryDate = false; var updatedExpiryDate = false;
var recurringDetailReference = ko.observable(null); var recurringDetailReference = ko.observable(null);
var variant = ko.observable(null);
var paymentMethod = ko.observable(null); var paymentMethod = ko.observable(null);
return Component.extend({ return Component.extend({
defaults: { defaults: {
template: 'Adyen_Payment/payment/oneclick-form', template: 'Adyen_Payment/payment/oneclick-form',
recurringDetailReference: '', recurringDetailReference: '',
encryptedData: '' encryptedData: '',
variant: ''
}, },
initObservable: function () { initObservable: function () {
this._super() this._super()
...@@ -46,7 +50,8 @@ define( ...@@ -46,7 +50,8 @@ define(
'recurringDetailReference', 'recurringDetailReference',
'creditCardType', 'creditCardType',
'creditCardVerificationNumber', 'creditCardVerificationNumber',
'encryptedData' 'encryptedData',
'variant'
]); ]);
return this; return this;
}, },
...@@ -68,8 +73,7 @@ define( ...@@ -68,8 +73,7 @@ define(
* @override * @override
*/ */
placeOrder: function (data, event) { placeOrder: function (data, event) {
var self = this, var self = this;
placeOrder;
if (event) { if (event) {
event.preventDefault(); event.preventDefault();
...@@ -103,13 +107,38 @@ define( ...@@ -103,13 +107,38 @@ define(
data.additional_data.encrypted_data = encryptedData; data.additional_data.encrypted_data = encryptedData;
} }
// set payment method to adyen_hpp // set payment method to adyen_hpp
data.additional_data.number_of_installments = self.installment; data.additional_data.number_of_installments = self.installment;
} }
// rest is default placeOrder logic // in different context so need custom place order logic
return self._super(); if (this.validate() && additionalValidators.validate()) {
self.isPlaceOrderActionAllowed(false);
this.getPlaceOrderDeferredObject()
.fail(
function () {
self.isPlaceOrderActionAllowed(true);
}
).done(
function () {
self.afterPlaceOrder();
redirectOnSuccessAction.execute();
}
);
return true;
}
return false;
},
getData: function () {
debugger;;
return {
"method": this.item.method,
"additional_data": {
variant: variant(),
recurring_detail_reference: recurringDetailReference()
}
};
}, },
getControllerName: function () { getControllerName: function () {
return window.checkoutConfig.payment.iframe.controllerName[this.getCode()]; return window.checkoutConfig.payment.iframe.controllerName[this.getCode()];
...@@ -167,6 +196,15 @@ define( ...@@ -167,6 +196,15 @@ define(
hasVerification: function () { hasVerification: function () {
return window.checkoutConfig.payment.adyenOneclick.hasCustomerInteraction; return window.checkoutConfig.payment.adyenOneclick.hasCustomerInteraction;
}, },
isPlaceOrderActionAllowed: function() {
return self.isPlaceOrderActionAllowed(); // needed for placeOrder method
},
afterPlaceOrder: function() {
return self.afterPlaceOrder(); // needed for placeOrder method
},
getPlaceOrderDeferredObject: function() {
return self.getPlaceOrderDeferredObject();
},
validate: function () { validate: function () {
var code = self.item.method; var code = self.item.method;
...@@ -226,6 +264,7 @@ define( ...@@ -226,6 +264,7 @@ define(
// set the brandCode // set the brandCode
recurringDetailReference(self.value); recurringDetailReference(self.value);
variant(self.agreement_data.variant);
// set payment method // set payment method
paymentMethod(self.method); paymentMethod(self.method);
......
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