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 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 @@
*
* Author: Adyen <magento@adyen.com>
*/
/*browser:true*/
/*global define*/
define(
[
'underscore',
'jquery',
'Magento_Checkout/js/model/quote',
'Magento_Payment/js/view/payment/cc-form',
'Adyen_Payment/js/action/place-order',
'mage/translate',
'Magento_Checkout/js/model/payment/additional-validators'
'Magento_Payment/js/view/payment/cc-form'
],
function (_, $, quote, Component, placeOrderAction, $t, additionalValidators) {
function (_, $, quote, Component) {
'use strict';
var billingAddress = quote.billingAddress();
return Component.extend({
......@@ -51,16 +47,16 @@ define(
]);
return this;
},
setPlaceOrderHandler: function(handler) {
setPlaceOrderHandler: function (handler) {
this.placeOrderHandler = handler;
},
setValidateHandler: function(handler) {
setValidateHandler: function (handler) {
this.validateHandler = handler;
},
getCode: function() {
getCode: function () {
return 'adyen_boleto';
},
getData: function() {
getData: function () {
return {
'method': this.item.method,
'additional_data': {
......@@ -71,56 +67,34 @@ define(
}
};
},
isActive: function() {
isActive: function () {
return true;
},
/**
* @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() {
getControllerName: function () {
return window.checkoutConfig.payment.iframe.controllerName[this.getCode()];
},
getPlaceOrderUrl: function() {
getPlaceOrderUrl: function () {
return window.checkoutConfig.payment.iframe.placeOrderUrl[this.getCode()];
},
context: function() {
context: function () {
return this;
},
validate: function () {
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 true;
},
showLogo: function() {
showLogo: function () {
return window.checkoutConfig.payment.adyen.showLogo;
},
getBoletoTypes: function() {
return _.map(window.checkoutConfig.payment.adyenBoleto.boletoTypes, function(value, key) {
getBoletoTypes: function () {
return _.map(window.checkoutConfig.payment.adyenBoleto.boletoTypes, function (value, key) {
return {
'key': value.value,
'value': value.label
......
......@@ -19,23 +19,17 @@
*
* Author: Adyen <magento@adyen.com>
*/
/*browser:true*/
/*global define*/
define(
[
'underscore',
'jquery',
'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_Payment/js/model/credit-card-validation/credit-card-data',
'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';
var cvcLength = ko.observable(4);
......@@ -150,8 +144,7 @@ define(
if (event) {
event.preventDefault();
}
var options = {};
var cseInstance = adyen.createEncryption(options);
var generationtime = self.getGenerationTime();
......@@ -168,16 +161,8 @@ define(
var data = cseInstance.encrypt(cardData);
self.encryptedData(data);
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;
// rest is default placeOrder logic
return self._super();
},
getControllerName: function () {
return window.checkoutConfig.payment.iframe.controllerName[this.getCode()];
......
......@@ -19,22 +19,18 @@
*
* Author: Adyen <magento@adyen.com>
*/
/*browser:true*/
/*global define*/
define(
[
'ko',
'underscore',
'jquery',
'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/model/quote',
'Magento_Checkout/js/checkout-data'
],
function (ko, _, $, Component, placeOrderAction, $t, additionalValidators, selectPaymentMethodAction, quote, checkoutData) {
function (ko, _, $, Component, selectPaymentMethodAction, quote, checkoutData) {
'use strict';
var updatedExpiryDate = false;
var recurringDetailReference = ko.observable(null);
......@@ -55,10 +51,6 @@ define(
]);
return this;
},
initialize: function () {
var self = this;
this._super();
},
placeOrderHandler: null,
validateHandler: null,
setPlaceOrderHandler: function (handler) {
......@@ -117,16 +109,8 @@ define(
data.additional_data.number_of_installments = self.installment;
}
if (this.validate() && additionalValidators.validate()) {
//this.isPlaceOrderActionAllowed(false);
placeOrder = placeOrderAction(data, this.redirectAfterPlaceOrder);
$.when(placeOrder).fail(function (response) {
//self.isPlaceOrderActionAllowed(true);
});
return true;
}
return false;
// rest is default placeOrder logic
return self._super();
},
getControllerName: function () {
return window.checkoutConfig.payment.iframe.controllerName[this.getCode()];
......
......@@ -19,8 +19,7 @@
*
* Author: Adyen <magento@adyen.com>
*/
/*browser:true*/
/*global define*/
define(
[
'ko',
......@@ -30,19 +29,14 @@ define(
],
function (ko, Component, setPaymentMethodAction, additionalValidators) {
'use strict';
var brandCode = ko.observable(null);
var paymentMethod = ko.observable(null);
return Component.extend({
self: this,
defaults: {
template: 'Adyen_Payment/payment/pos-form',
brandCode: ''
template: 'Adyen_Payment/payment/pos-form'
},
initObservable: function () {
this._super()
.observe([
]);
.observe([]);
return this;
},
/** Redirect to adyen */
......@@ -54,7 +48,7 @@ define(
return false;
}
},
showLogo: function() {
showLogo: function () {
return window.checkoutConfig.payment.adyen.showLogo;
},
validate: function () {
......
......@@ -19,19 +19,15 @@
*
* Author: Adyen <magento@adyen.com>
*/
/*browser:true*/
/*global define*/
define(
[
'underscore',
'jquery',
'Magento_Checkout/js/model/quote',
'Magento_Payment/js/view/payment/cc-form',
'Adyen_Payment/js/action/place-order',
'mage/translate',
'Magento_Checkout/js/model/payment/additional-validators'
'Magento_Payment/js/view/payment/cc-form'
],
function (_, $, quote, Component, placeOrderAction, $t, additionalValidators) {
function (_, $, quote, Component) {
'use strict';
var billingAddress = quote.billingAddress();
return Component.extend({
......@@ -56,16 +52,16 @@ define(
isShowLegend: function () {
return true;
},
setPlaceOrderHandler: function(handler) {
setPlaceOrderHandler: function (handler) {
this.placeOrderHandler = handler;
},
setValidateHandler: function(handler) {
setValidateHandler: function (handler) {
this.validateHandler = handler;
},
getCode: function() {
getCode: function () {
return 'adyen_sepa';
},
getData: function() {
getData: function () {
return {
'method': this.item.method,
'additional_data': {
......@@ -76,56 +72,34 @@ define(
}
};
},
isActive: function() {
isActive: function () {
return true;
},
/**
* @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() {
getControllerName: function () {
return window.checkoutConfig.payment.iframe.controllerName[this.getCode()];
},
getPlaceOrderUrl: function() {
getPlaceOrderUrl: function () {
return window.checkoutConfig.payment.iframe.placeOrderUrl[this.getCode()];
},
context: function() {
context: function () {
return this;
},
validate: function () {
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 true;
},
showLogo: function() {
showLogo: function () {
return window.checkoutConfig.payment.adyen.showLogo;
},
getCountries: function() {
return _.map(window.checkoutConfig.payment.adyenSepa.countries, function(value, key) {
getCountries: function () {
return _.map(window.checkoutConfig.payment.adyenSepa.countries, function (value, key) {
return {
'key': key,
'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