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

Remove place-order and use core code

parent 3281c8ab
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
define(
[
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/url-builder',
'mage/storage',
'mage/url',
'Magento_Checkout/js/model/error-processor',
'Magento_Customer/js/model/customer',
'Magento_Checkout/js/model/full-screen-loader'
],
function (quote, urlBuilder, storage, url, errorProcessor, customer, fullScreenLoader) {
'use strict';
return function (paymentData, redirectOnSuccess) {
var serviceUrl,
payload;
//redirectOnSuccess = redirectOnSuccess !== false;
redirectOnSuccess = redirectOnSuccess === false ? false : true;
/** Checkout for guest and registered customer. */
if (!customer.isLoggedIn()) {
serviceUrl = urlBuilder.createUrl('/guest-carts/:quoteId/payment-information', {
quoteId: quote.getQuoteId()
});
payload = {
cartId: quote.getQuoteId(),
email: quote.guestEmail,
paymentMethod: paymentData,
billingAddress: quote.billingAddress()
};
} else {
serviceUrl = urlBuilder.createUrl('/carts/mine/payment-information', {});
payload = {
cartId: quote.getQuoteId(),
paymentMethod: paymentData,
billingAddress: quote.billingAddress()
};
}
fullScreenLoader.startLoader();
return storage.post(
serviceUrl, JSON.stringify(payload)
).done(
function () {
if (redirectOnSuccess) {
window.location.replace(url.build(window.checkoutConfig.payment[quote.paymentMethod().method].redirectUrl));
}
}
).fail(
function (response) {
errorProcessor.process(response);
fullScreenLoader.stopLoader();
}
);
};
}
);
...@@ -19,19 +19,15 @@ ...@@ -19,19 +19,15 @@
* *
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
/*browser:true*/
/*global define*/
define( define(
[ [
'underscore', 'underscore',
'jquery', 'jquery',
'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/quote',
'Magento_Payment/js/view/payment/cc-form', 'Magento_Payment/js/view/payment/cc-form'
'Adyen_Payment/js/action/place-order',
'mage/translate',
'Magento_Checkout/js/model/payment/additional-validators'
], ],
function (_, $, quote, Component, placeOrderAction, $t, additionalValidators) { function (_, $, quote, Component) {
'use strict'; 'use strict';
var billingAddress = quote.billingAddress(); var billingAddress = quote.billingAddress();
return Component.extend({ return Component.extend({
...@@ -51,16 +47,16 @@ define( ...@@ -51,16 +47,16 @@ define(
]); ]);
return this; return this;
}, },
setPlaceOrderHandler: function(handler) { setPlaceOrderHandler: function (handler) {
this.placeOrderHandler = handler; this.placeOrderHandler = handler;
}, },
setValidateHandler: function(handler) { setValidateHandler: function (handler) {
this.validateHandler = handler; this.validateHandler = handler;
}, },
getCode: function() { getCode: function () {
return 'adyen_boleto'; return 'adyen_boleto';
}, },
getData: function() { getData: function () {
return { return {
'method': this.item.method, 'method': this.item.method,
'additional_data': { 'additional_data': {
...@@ -71,56 +67,34 @@ define( ...@@ -71,56 +67,34 @@ define(
} }
}; };
}, },
isActive: function() { isActive: function () {
return true; return true;
}, },
/** getControllerName: function () {
* @override
*/
placeOrder: function(data, event) {
var self = this,
placeOrder;
if (event) {
event.preventDefault();
}
if (this.validate() && additionalValidators.validate()) {
this.isPlaceOrderActionAllowed(false);
placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
$.when(placeOrder).fail(function(response) {
self.isPlaceOrderActionAllowed(true);
});
return true;
}
return false;
},
getControllerName: function() {
return window.checkoutConfig.payment.iframe.controllerName[this.getCode()]; return window.checkoutConfig.payment.iframe.controllerName[this.getCode()];
}, },
getPlaceOrderUrl: function() { getPlaceOrderUrl: function () {
return window.checkoutConfig.payment.iframe.placeOrderUrl[this.getCode()]; return window.checkoutConfig.payment.iframe.placeOrderUrl[this.getCode()];
}, },
context: function() { context: function () {
return this; return this;
}, },
validate: function () { validate: function () {
var form = 'form[data-role=adyen-boleto-form]'; var form = 'form[data-role=adyen-boleto-form]';
var validate = $(form).validation() && $(form).validation('isValid'); var validate = $(form).validation() && $(form).validation('isValid');
if(!validate) { if (!validate) {
return false; return false;
} }
return true; return true;
}, },
showLogo: function() { showLogo: function () {
return window.checkoutConfig.payment.adyen.showLogo; return window.checkoutConfig.payment.adyen.showLogo;
}, },
getBoletoTypes: function() { getBoletoTypes: function () {
return _.map(window.checkoutConfig.payment.adyenBoleto.boletoTypes, function(value, key) { return _.map(window.checkoutConfig.payment.adyenBoleto.boletoTypes, function (value, key) {
return { return {
'key': value.value, 'key': value.value,
'value': value.label 'value': value.label
......
...@@ -19,23 +19,17 @@ ...@@ -19,23 +19,17 @@
* *
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
/*browser:true*/
/*global define*/
define( define(
[ [
'underscore',
'jquery', 'jquery',
'Magento_Payment/js/view/payment/cc-form', 'Magento_Payment/js/view/payment/cc-form',
'Adyen_Payment/js/action/place-order',
'mage/translate',
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Customer/js/model/customer', 'Magento_Customer/js/model/customer',
'Magento_Payment/js/model/credit-card-validation/credit-card-data', 'Magento_Payment/js/model/credit-card-validation/credit-card-data',
'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/quote',
'ko', 'Adyen_Payment/js/model/installments'
'Adyen_Payment/js/model/installments',
], ],
function (_, $, Component, placeOrderAction, $t, additionalValidators, customer, creditCardData, quote, ko, installments) { function ($, Component, customer, creditCardData, quote, installments) {
'use strict'; 'use strict';
var cvcLength = ko.observable(4); var cvcLength = ko.observable(4);
...@@ -150,8 +144,7 @@ define( ...@@ -150,8 +144,7 @@ define(
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 = self.getGenerationTime();
...@@ -168,16 +161,8 @@ define( ...@@ -168,16 +161,8 @@ define(
var data = cseInstance.encrypt(cardData); var data = cseInstance.encrypt(cardData);
self.encryptedData(data); self.encryptedData(data);
if (this.validate() && additionalValidators.validate()) { // rest is default placeOrder logic
this.isPlaceOrderActionAllowed(false); return self._super();
placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
$.when(placeOrder).fail(function (response) {
self.isPlaceOrderActionAllowed(true);
});
return true;
}
return false;
}, },
getControllerName: function () { getControllerName: function () {
return window.checkoutConfig.payment.iframe.controllerName[this.getCode()]; return window.checkoutConfig.payment.iframe.controllerName[this.getCode()];
......
...@@ -19,22 +19,18 @@ ...@@ -19,22 +19,18 @@
* *
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
/*browser:true*/
/*global define*/
define( define(
[ [
'ko', 'ko',
'underscore', 'underscore',
'jquery', 'jquery',
'Magento_Payment/js/view/payment/cc-form', 'Magento_Payment/js/view/payment/cc-form',
'Adyen_Payment/js/action/place-order',
'mage/translate',
'Magento_Checkout/js/model/payment/additional-validators',
'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'
], ],
function (ko, _, $, Component, placeOrderAction, $t, additionalValidators, selectPaymentMethodAction, quote, checkoutData) { function (ko, _, $, Component, selectPaymentMethodAction, quote, checkoutData) {
'use strict'; 'use strict';
var updatedExpiryDate = false; var updatedExpiryDate = false;
var recurringDetailReference = ko.observable(null); var recurringDetailReference = ko.observable(null);
...@@ -55,10 +51,6 @@ define( ...@@ -55,10 +51,6 @@ define(
]); ]);
return this; return this;
}, },
initialize: function () {
var self = this;
this._super();
},
placeOrderHandler: null, placeOrderHandler: null,
validateHandler: null, validateHandler: null,
setPlaceOrderHandler: function (handler) { setPlaceOrderHandler: function (handler) {
...@@ -117,16 +109,8 @@ define( ...@@ -117,16 +109,8 @@ define(
data.additional_data.number_of_installments = self.installment; data.additional_data.number_of_installments = self.installment;
} }
if (this.validate() && additionalValidators.validate()) { // rest is default placeOrder logic
//this.isPlaceOrderActionAllowed(false); return self._super();
placeOrder = placeOrderAction(data, this.redirectAfterPlaceOrder);
$.when(placeOrder).fail(function (response) {
//self.isPlaceOrderActionAllowed(true);
});
return true;
}
return false;
}, },
getControllerName: function () { getControllerName: function () {
return window.checkoutConfig.payment.iframe.controllerName[this.getCode()]; return window.checkoutConfig.payment.iframe.controllerName[this.getCode()];
......
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
* *
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
/*browser:true*/
/*global define*/
define( define(
[ [
'ko', 'ko',
...@@ -30,19 +29,14 @@ define( ...@@ -30,19 +29,14 @@ define(
], ],
function (ko, Component, setPaymentMethodAction, additionalValidators) { function (ko, Component, setPaymentMethodAction, additionalValidators) {
'use strict'; 'use strict';
var brandCode = ko.observable(null);
var paymentMethod = ko.observable(null);
return Component.extend({ return Component.extend({
self: this, self: this,
defaults: { defaults: {
template: 'Adyen_Payment/payment/pos-form', template: 'Adyen_Payment/payment/pos-form'
brandCode: ''
}, },
initObservable: function () { initObservable: function () {
this._super() this._super()
.observe([ .observe([]);
]);
return this; return this;
}, },
/** Redirect to adyen */ /** Redirect to adyen */
...@@ -54,7 +48,7 @@ define( ...@@ -54,7 +48,7 @@ define(
return false; return false;
} }
}, },
showLogo: function() { showLogo: function () {
return window.checkoutConfig.payment.adyen.showLogo; return window.checkoutConfig.payment.adyen.showLogo;
}, },
validate: function () { validate: function () {
......
...@@ -19,19 +19,15 @@ ...@@ -19,19 +19,15 @@
* *
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
/*browser:true*/
/*global define*/
define( define(
[ [
'underscore', 'underscore',
'jquery', 'jquery',
'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/quote',
'Magento_Payment/js/view/payment/cc-form', 'Magento_Payment/js/view/payment/cc-form'
'Adyen_Payment/js/action/place-order',
'mage/translate',
'Magento_Checkout/js/model/payment/additional-validators'
], ],
function (_, $, quote, Component, placeOrderAction, $t, additionalValidators) { function (_, $, quote, Component) {
'use strict'; 'use strict';
var billingAddress = quote.billingAddress(); var billingAddress = quote.billingAddress();
return Component.extend({ return Component.extend({
...@@ -56,16 +52,16 @@ define( ...@@ -56,16 +52,16 @@ define(
isShowLegend: function () { isShowLegend: function () {
return true; return true;
}, },
setPlaceOrderHandler: function(handler) { setPlaceOrderHandler: function (handler) {
this.placeOrderHandler = handler; this.placeOrderHandler = handler;
}, },
setValidateHandler: function(handler) { setValidateHandler: function (handler) {
this.validateHandler = handler; this.validateHandler = handler;
}, },
getCode: function() { getCode: function () {
return 'adyen_sepa'; return 'adyen_sepa';
}, },
getData: function() { getData: function () {
return { return {
'method': this.item.method, 'method': this.item.method,
'additional_data': { 'additional_data': {
...@@ -76,56 +72,34 @@ define( ...@@ -76,56 +72,34 @@ define(
} }
}; };
}, },
isActive: function() { isActive: function () {
return true; return true;
}, },
/** getControllerName: function () {
* @override
*/
placeOrder: function(data, event) {
var self = this,
placeOrder;
if (event) {
event.preventDefault();
}
if (this.validate() && additionalValidators.validate()) {
this.isPlaceOrderActionAllowed(false);
placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
$.when(placeOrder).fail(function(response) {
self.isPlaceOrderActionAllowed(true);
});
return true;
}
return false;
},
getControllerName: function() {
return window.checkoutConfig.payment.iframe.controllerName[this.getCode()]; return window.checkoutConfig.payment.iframe.controllerName[this.getCode()];
}, },
getPlaceOrderUrl: function() { getPlaceOrderUrl: function () {
return window.checkoutConfig.payment.iframe.placeOrderUrl[this.getCode()]; return window.checkoutConfig.payment.iframe.placeOrderUrl[this.getCode()];
}, },
context: function() { context: function () {
return this; return this;
}, },
validate: function () { validate: function () {
var form = 'form[data-role=adyen-sepa-form]'; var form = 'form[data-role=adyen-sepa-form]';
var validate = $(form).validation() && $(form).validation('isValid'); var validate = $(form).validation() && $(form).validation('isValid');
if(!validate) { if (!validate) {
return false; return false;
} }
return true; return true;
}, },
showLogo: function() { showLogo: function () {
return window.checkoutConfig.payment.adyen.showLogo; return window.checkoutConfig.payment.adyen.showLogo;
}, },
getCountries: function() { getCountries: function () {
return _.map(window.checkoutConfig.payment.adyenSepa.countries, function(value, key) { return _.map(window.checkoutConfig.payment.adyenSepa.countries, function (value, key) {
return { return {
'key': key, 'key': key,
'value': value 'value': value
......
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