escapeHtml($block->getMethod()->getTitle()) ?>
diff --git a/view/frontend/templates/info/payment_method.phtml b/view/frontend/templates/info/payment_method.phtml
index 02480eea1..1cbbf2f3d 100644
--- a/view/frontend/templates/info/payment_method.phtml
+++ b/view/frontend/templates/info/payment_method.phtml
@@ -18,7 +18,13 @@
* @license https://tldrlegal.com/license/mit-license
*/
?>
-escapeHtml($block->getMethod()->buckarooPaymentMethodCode); ?>
+getMethod() instanceof \Magento\Payment\Model\Method\Adapter) {
+ $bpePaymentCode = $block->escapeHtml($block->getMethod()->getCode());
+} else {
+ $bpePaymentCode = $block->escapeHtml($block->getMethod()->buckarooPaymentMethodCode);
+} ?>
getGiftCards()) {
diff --git a/view/frontend/templates/sales/order/totals.phtml b/view/frontend/templates/sales/order/totals.phtml
index 92dbb1d4e..e9c19dff7 100644
--- a/view/frontend/templates/sales/order/totals.phtml
+++ b/view/frontend/templates/sales/order/totals.phtml
@@ -16,14 +16,15 @@
getChildHtml($_total->getBlockName(), false); ?>
- getLabelProperties()?> scope="row">
+ | getLabelProperties()?>>
getStrong()):?>
escapeHtml($_total->getLabel());?>
escapeHtml($_total->getLabel());?>
|
- getValueProperties()?> data-th="escapeHtml($_total->getLabel());?>">
+ | getValueProperties()?>
+ data-th="escapeHtml($_total->getLabel());?>">
getStrong()):?>
formatValue($_total) ?>
diff --git a/view/frontend/web/css/styles.css b/view/frontend/web/css/styles.css
index 60e7df017..464dc4c12 100644
--- a/view/frontend/web/css/styles.css
+++ b/view/frontend/web/css/styles.css
@@ -9,12 +9,30 @@
margin-right:10px;
align-items: center;
display: flex;
+ align-items: center;
+}
+
+.bk-mode-and-img {
+ display: flex;
+ align-items: stretch;
}
.bk-radio-wrap {
flex: auto;
display: flex;
align-items: center;
}
+.bk-test-mode {
+ background-color:#ff6200;
+ border-radius: 5px;
+ margin-right: 10px;
+ display: flex;
+ align-items: center;
+}
+.bk-test-text {
+ text-transform: uppercase;
+ color: #fff;
+ padding: 0 10px;
+}
.bk-description {
margin:0;
color:#757575;
@@ -133,15 +151,15 @@
margin-top: 20px;
}
-.payment-method-second-col input::placeholder {
+.payment-method-second-col input::placeholder {
color: #c0c0c0;
- opacity: 1;
+ opacity: 1;
}
-
+
.payment-method-second-col input:-ms-input-placeholder {
color: #c0c0c0;
}
-
+
.payment-method-second-col input::-ms-input-placeholder {
color: #c0c0c0;
}
@@ -164,7 +182,6 @@
}
.buckaroo_magento2_ideal .payment-method-second-col,
- .buckaroo_magento2_idealprocessing .payment-method-second-col,
.buckaroo_magento2_creditcard .payment-method-second-col,
.buckaroo_magento2_creditcards .payment-method-second-col,
.buckaroo_magento2_transfer .payment-method-second-col,
@@ -178,7 +195,6 @@
.buckaroo_magento2_klarna .payment-method-second-col,
.buckaroo_magento2_klarnakp .payment-method-second-col,
.buckaroo_magento2_klarnain .payment-method-second-col,
- .buckaroo_magento2_emandate .payment-method-second-col,
.buckaroo_magento2_applepay .payment-method-second-col,
.buckaroo_magento2_capayablein3 .payment-method-second-col,
.buckaroo_magento2_capayablepostpay .payment-method-second-col,
@@ -196,7 +212,6 @@
}
.buckaroo_magento2_ideal .payment-method-billing-address,
- .buckaroo_magento2_idealprocessing .payment-method-billing-address,
.buckaroo_magento2_creditcard .payment-method-billing-address,
.buckaroo_magento2_creditcards .payment-method-billing-address,
.buckaroo_magento2_transfer .payment-method-billing-address,
@@ -210,7 +225,6 @@
.buckaroo_magento2_klarna .payment-method-billing-address,
.buckaroo_magento2_klarnakp .payment-method-billing-address,
.buckaroo_magento2_klarnain .payment-method-billing-address,
- .buckaroo_magento2_emandate .payment-method-billing-address,
.buckaroo_magento2_applepay .payment-method-billing-address,
.buckaroo_magento2_capayablein3 .payment-method-billing-address,
.buckaroo_magento2_capayablepostpay .payment-method-billing-address,
@@ -232,7 +246,6 @@
@media screen and (min-width: 768px){
.magento-blank .buckaroo_magento2_ideal .fieldset > .field:not(.choice) > .label,
- .magento-blank .buckaroo_magento2_idealprocessing .fieldset > .field:not(.choice) > .label,
.magento-blank .buckaroo_magento2_creditcard .fieldset > .field:not(.choice) > .label,
.magento-blank .buckaroo_magento2_creditcards .fieldset > .field:not(.choice) > .label,
.magento-blank .buckaroo_magento2_transfer .fieldset > .field:not(.choice) > .label,
@@ -246,7 +259,6 @@
.magento-blank .buckaroo_magento2_klarna .fieldset > .field:not(.choice) > .label,
.magento-blank .buckaroo_magento2_klarnakp .fieldset > .field:not(.choice) > .label,
.magento-blank .buckaroo_magento2_klarnain .fieldset > .field:not(.choice) > .label,
- .magento-blank .buckaroo_magento2_emandate .fieldset > .field:not(.choice) > .label,
.magento-blank .buckaroo_magento2_applepay .fieldset > .field:not(.choice) > .label,
.magento-blank .buckaroo_magento2_capayablein3 .fieldset > .field:not(.choice) > .label,
.magento-blank .buckaroo_magento2_capayablepostpay .fieldset > .field:not(.choice) > .label
@@ -258,8 +270,7 @@
float: left !important;
}
- .magento-blank .buckaroo_magento2_ideal di.fieldset > .field:not(.choice) > .control,
- .magento-blank .buckaroo_magento2_idealprocessing .fieldset > .field:not(.choice) > .control,
+ .magento-blank .buckaroo_magento2_ideal .fieldset > .field:not(.choice) > .control,
.magento-blank .buckaroo_magento2_creditcard .fieldset > .field:not(.choice) > .control,
.magento-blank .buckaroo_magento2_creditcards .fieldset > .field:not(.choice) > .control,
.magento-blank .buckaroo_magento2_transfer .fieldset > .field:not(.choice) > .control,
@@ -273,7 +284,6 @@
.magento-blank .buckaroo_magento2_klarna .fieldset > .field:not(.choice) > .control,
.magento-blank .buckaroo_magento2_klarnakp .fieldset > .field:not(.choice) > .control,
.magento-blank .buckaroo_magento2_klarnain .fieldset > .field:not(.choice) > .control,
- .magento-blank .buckaroo_magento2_emandate .fieldset > .field:not(.choice) > .control,
.magento-blank .buckaroo_magento2_applepay .fieldset > .field:not(.choice) > .control,
.magento-blank .buckaroo_magento2_capayablein3 .fieldset > .field:not(.choice) > .control,
.magento-blank .buckaroo_magento2_capayablepostpay .fieldset > .field:not(.choice) > .control
@@ -284,7 +294,6 @@
}
.magento-blank .buckaroo_magento2_ideal .fieldset > .field.choice:before,
- .magento-blank .buckaroo_magento2_idealprocessing .fieldset > .field.choice:before,
.magento-blank .buckaroo_magento2_creditcard .fieldset > .field.choice:before,
.magento-blank .buckaroo_magento2_creditcards .fieldset > .field.choice:before,
.magento-blank .buckaroo_magento2_transfer .fieldset > .field.choice:before,
@@ -298,7 +307,6 @@
.magento-blank .buckaroo_magento2_klarna .fieldset > .field.choice:before,
.magento-blank .buckaroo_magento2_klarnakp .fieldset > .field.choice:before,
.magento-blank .buckaroo_magento2_klarnain .fieldset > .field.choice:before,
- .magento-blank .buckaroo_magento2_emandate .fieldset > .field.choice:before,
.magento-blank .buckaroo_magento2_applepay .fieldset > .field.choice:before,
.magento-blank .buckaroo_magento2_capayablein3 .fieldset > .field.choice:before,
.magento-blank .buckaroo_magento2_capayablepostpay .fieldset > .field.choice:before
@@ -318,19 +326,29 @@
content: '*';
}
/* ===================== iDeal ================================ */
-.buckaroo_magento2_ideal .payment-method-second-col .bank-types,
-.buckaroo_magento2_emandate .payment-method-second-col .bank-types,
-.buckaroo_magento2_idealprocessing .payment-method-second-col .bank-types {
+.buckaroo_magento2_ideal .payment-method-second-col .bank-types {
display: flex;
align-items: center;
margin-top: 10px;
+ flex:1 1 100%;
}
-.buckaroo_magento2_ideal .payment-method-second-col .bank-types-img,
-.buckaroo_magento2_emandate .payment-method-second-col .bank-types-img,
-.buckaroo_magento2_idealprocessing .payment-method-second-col .bank-types-img {
+.buckaroo_magento2_ideal .payment-method-second-col .bank-types-img {
margin-right:10px;
}
+.fieldset > .field .bk-issuer-list.addon {
+ display: flex;
+ flex-wrap: wrap;
+}
+
+.buckaroo_magento2_ideal .payment-method-second-col .bank-types input {
+ flex: 0;
+ order: 0;
+ margin: 0;
+ padding: 0;
+ margin-right: 5px;
+}
+
/* ===================== Credit Card =========================== */
.buckaroo_magento2_creditcards .payment-method-second-col .card-types,
@@ -475,7 +493,7 @@
line-height: 20px;
color: #757575;
content: '\e604';
- font-family: 'luma-icons';
+ font-family: 'luma-icons', sans-serif;
vertical-align: middle;
display: inline-block;
font-weight: normal;
@@ -583,6 +601,11 @@
align-items: center;
cursor: pointer;
}
+
+.hidden-fieldset-legend {
+ display: none;
+}
+
@media screen and (max-width: 768px) {
.buckaroo_magento2_paybybank .billing-address-form
{
@@ -640,7 +663,7 @@
padding: 10px 20px;
}
- .fieldset > .field .addon .bk-paybybank-selector .bank-method-input {
- display:none;
+ .bk-paybybank-selector .bank-method-input {
+ visibility: hidden;
}
}
\ No newline at end of file
diff --git a/view/frontend/web/images/buckaroo_magento2_creditclick_title.png b/view/frontend/web/images/buckaroo_magento2_creditclick_title.png
new file mode 100644
index 000000000..888b27d3d
Binary files /dev/null and b/view/frontend/web/images/buckaroo_magento2_creditclick_title.png differ
diff --git a/view/frontend/web/images/emandate.png b/view/frontend/web/images/emandate.png
deleted file mode 100644
index e69de29bb..000000000
diff --git a/view/frontend/web/images/giftcards/vouchers.svg b/view/frontend/web/images/giftcards/vouchers.svg
new file mode 100644
index 000000000..412bad1b0
--- /dev/null
+++ b/view/frontend/web/images/giftcards/vouchers.svg
@@ -0,0 +1,77 @@
+
+
+
diff --git a/view/frontend/web/images/idin.svg b/view/frontend/web/images/idin.svg
deleted file mode 100644
index e69de29bb..000000000
diff --git a/view/frontend/web/js/action/amasty-place-order-mixin.js b/view/frontend/web/js/action/amasty-place-order-mixin.js
index 49aa74b50..7f0c98b26 100644
--- a/view/frontend/web/js/action/amasty-place-order-mixin.js
+++ b/view/frontend/web/js/action/amasty-place-order-mixin.js
@@ -4,36 +4,36 @@ define([
], function ($, wrapper) {
'use strict';
- let getAmastyPromise = function() {
+ let getAmastyPromise = function () {
let requestDeferred = $.Deferred();
- if(window.checkoutConfig.amOrderAttribute !== undefined) {
+ if (window.checkoutConfig.amOrderAttribute !== undefined) {
require([
'Amasty_Orderattr/js/model/attribute-sets/payment-attributes',
'Amasty_Orderattr/js/model/validate-and-save'
- ], function (attributesForm, validateAndSave) {
- requestDeferred.resolve(validateAndSave(attributesForm));
- })
+ ], function (attributesForm, validateAndSave) {
+ requestDeferred.resolve(validateAndSave(attributesForm));
+ })
} else {
- requestDeferred.resolve($.when());
+ requestDeferred.resolve($.when());
}
- return requestDeferred.promise().then(function(resp) {
- return resp;
+ return requestDeferred.promise().then(function (resp) {
+ return resp;
});
}
return function (placeOrderAction) {
return wrapper.wrap(placeOrderAction, function (originalAction, paymentData, redirectOnSuccess, messageContainer) {
var result = $.Deferred();
- getAmastyPromise().done(
- function() {
+ getAmastyPromise().done(
+ function () {
$.when(
originalAction(paymentData, redirectOnSuccess, messageContainer)
).fail(
- function() {
+ function () {
result.reject.apply(this, arguments);
}
).done(
- function() {
+ function () {
result.resolve.apply(this, arguments);
}
);
diff --git a/view/frontend/web/js/action/paypal-express.js b/view/frontend/web/js/action/paypal-express.js
new file mode 100644
index 000000000..312a6aa38
--- /dev/null
+++ b/view/frontend/web/js/action/paypal-express.js
@@ -0,0 +1,144 @@
+define([], function () {
+ "use strict";
+ let checkoutUrl = "https://checkout.buckaroo.nl";
+ let payPalClientId =
+ "ATv1oKfBmc76Zzl8rAMai_OwpXIp9CsDTMzEceayY7X2Sy8t6bQT2rm7DIC7LYbfkch9m9S3R3amkeyU";
+ let buttonStyle = {
+ color: "gold",
+ shape: "rect",
+ };
+ let amount = 0.01;
+ let currency = "EUR";
+ /**
+ * Load the paypal sdk
+ */
+ const requirePayPal = function (url, callback) {
+ const e = document.createElement("script");
+ e.src = url;
+ e.setAttribute("data-partner-attribution-id", "NL_BUCKAROO_PPCP");
+ e.type = "text/javascript";
+ e.addEventListener("load", callback);
+ document.getElementsByTagName("head")[0].appendChild(e);
+ };
+
+ /**
+ * Set mode test
+ */
+ const setTestMode = function () {
+ checkoutUrl = "https://testcheckout.buckaroo.nl";
+ payPalClientId =
+ "AfHztAEfaf3f76tNy8j_Z86w5y-fGbqbBt04PXppVFtJatje79gVSB27DwBENnyFgfhFvKzgJbegNpHv";
+ };
+
+ const setAmount = function (newAmount) {
+ amount = newAmount;
+ };
+
+ const setCurrency = function (newCurrency) {
+ currency = newCurrency;
+ };
+
+ /**
+ * Initiate de button display
+ */
+ const initiate = function (options) {
+ const style = options.style || {};
+ if (options.isTestMode) {
+ setTestMode();
+ }
+
+ if (options.amount) {
+ amount = options.amount;
+ }
+
+ if (options.currency) {
+ currency = options.currency;
+ }
+
+ requirePayPal(
+ "https://www.paypal.com/sdk/js?client-id=" +
+ payPalClientId +
+ "&merchant-id=" +
+ options.paypalMerchantId +
+ "¤cy=" +
+ currency +
+ "&disable-funding=credit,card,bancontact,blik,eps,giropay,ideal,mercadopago,mybank,p24,sepa,sofort,venmo&enable-funding=paylater",
+ function () {
+ paypal
+ .Buttons({
+ style: Object.assign(buttonStyle, style),
+ createOrder: function () {
+ var createOrderUrl =
+ checkoutUrl +
+ "/api/paypal/createOrder?buckarooWebsiteKey=" +
+ options.buckarooWebsiteKey +
+ "¤cy=" +
+ currency +
+ "&initialAmount=" +
+ amount;
+ // Optional - Add InvoiceId when available.
+ if (
+ options.invoiceId !== undefined &&
+ options.invoiceId !== null
+ ) {
+ createOrderUrl += "&invoiceId=" + options.invoiceId;
+ }
+ return fetch(createOrderUrl, {
+ method: "post",
+ })
+ .then(function (res) {
+ return res.json();
+ })
+ .then(function (orderData) {
+ console.log(orderData);
+ return orderData.PaypalOrderId;
+ });
+ },
+ onApprove: function (data) {
+ return options.createPaymentHandler(data).then(
+ function () {
+ options.onSuccessCallback();
+ },
+ function (reason) {
+ if (options.onErrorCallback !== undefined) {
+ options.onErrorCallback(reason);
+ }
+ }
+ );
+ },
+ onShippingChange: function (data, actions) {
+ if (options.onShippingChangeHandler !== undefined) {
+ return options.onShippingChangeHandler(data, actions);
+ }
+ },
+ onCancel: function () {
+ if (options.onCancelCallback !== undefined) {
+ options.onCancelCallback();
+ }
+ },
+ onError: function (reason) {
+ if (options.onErrorCallback !== undefined) {
+ options.onErrorCallback(reason);
+ }
+ },
+ onInit: function () {
+ if (options.onInitCallback !== undefined) {
+ options.onInitCallback();
+ }
+ },
+ onClick: function () {
+ if (options.onClickCallback !== undefined) {
+ options.onClickCallback();
+ }
+ },
+ })
+ .render(options.containerSelector);
+ }
+ );
+ };
+ return {
+ initiate,
+ setAmount,
+ setCurrency,
+ };
+});
diff --git a/view/frontend/web/js/action/place-order.js b/view/frontend/web/js/action/place-order.js
index bd673cb74..f8763b9b4 100644
--- a/view/frontend/web/js/action/place-order.js
+++ b/view/frontend/web/js/action/place-order.js
@@ -111,8 +111,8 @@ define(
title: $t('Error'),
content: $t(jsonResponse.limitReachedMessage),
buttons: [{
- text: $t('Close'),
- class: 'action primary accept',
+ text: $t('Close'),
+ class: 'action primary accept',
click: function () {
this.closeModal(true);
}
@@ -137,7 +137,6 @@ define(
window.scroll(0, y);
}
}, 2000);
-
}
}
);
diff --git a/view/frontend/web/js/view/checkout/applepay/catalog-product-view.js b/view/frontend/web/js/view/checkout/applepay/catalog-product-view.js
index 02e6e5b99..0a20f019c 100644
--- a/view/frontend/web/js/view/checkout/applepay/catalog-product-view.js
+++ b/view/frontend/web/js/view/checkout/applepay/catalog-product-view.js
@@ -34,10 +34,8 @@ define(
return Component.extend({
showPayButton: function () {
if (window.checkoutConfig.payment
- &&
- window.checkoutConfig.payment.buckaroo.applepay.availableButtons
- &&
- (window.checkoutConfig.payment.buckaroo.applepay.availableButtons.indexOf('Product') !== -1)
+ && window.checkoutConfig.payment.buckaroo.buckaroo_magento2_applepay.availableButtons
+ && (window.checkoutConfig.payment.buckaroo.buckaroo_magento2_applepay.availableButtons.indexOf('Product') !== -1)
) {
//console.log('==============applepaydebug/catalog-product-view/4');
applepayPay.setQuote(quote);
diff --git a/view/frontend/web/js/view/checkout/applepay/handlers/billing-handler.js b/view/frontend/web/js/view/checkout/applepay/handlers/billing-handler.js
index 45bc574d5..07daa1304 100644
--- a/view/frontend/web/js/view/checkout/applepay/handlers/billing-handler.js
+++ b/view/frontend/web/js/view/checkout/applepay/handlers/billing-handler.js
@@ -76,10 +76,7 @@ define(
var url = resourceUrlManager.getUrl(urls, params);
payload.paymentMethod = {
- method: 'buckaroo_magento2_applepay',
- additional_data: {
- buckaroo_skip_validation: true
- }
+ method: 'buckaroo_magento2_applepay'
};
payload.billingAddress = quote.billingAddress();
payload.shippingAddress = quote.shippingAddress();
diff --git a/view/frontend/web/js/view/checkout/applepay/pay.js b/view/frontend/web/js/view/checkout/applepay/pay.js
index 700db28ca..49667ddd7 100644
--- a/view/frontend/web/js/view/checkout/applepay/pay.js
+++ b/view/frontend/web/js/view/checkout/applepay/pay.js
@@ -66,7 +66,7 @@ define(
this.setIsOnCheckout(true);
}
- BuckarooSdk.ApplePay.checkApplePaySupport(window.checkoutConfig.payment.buckaroo.applepay.guid).then(
+ BuckarooSdk.ApplePay.checkApplePaySupport(window.checkoutConfig.payment.buckaroo.buckaroo_magento2_applepay.guid).then(
function (applePaySupported) {
this.devLog('==============applepaydebug/8',[
applePaySupported,
@@ -84,9 +84,10 @@ define(
this.payment = new BuckarooSdk.ApplePay.ApplePayPayment('#apple-pay-wrapper', this.applepayOptions);
this.payment.showPayButton(
- window.checkoutConfig.payment.buckaroo.applepay.buttonStyle ?
- window.checkoutConfig.payment.buckaroo.applepay.buttonStyle : 'black',
- 'buy');
+ window.checkoutConfig.payment.buckaroo.buckaroo_magento2_applepay.buttonStyle ?
+ window.checkoutConfig.payment.buckaroo.buckaroo_magento2_applepay.buttonStyle : 'black',
+ 'buy'
+ );
if (this.payMode == 'product') {
this.payment.button.off("click");
var self = this;
@@ -118,7 +119,7 @@ define(
canShowApplePay:function () {
//ZAK
//return true;
- BuckarooSdk.ApplePay.checkApplePaySupport(window.checkoutConfig.payment.buckaroo.applepay.guid).then(
+ BuckarooSdk.ApplePay.checkApplePaySupport(window.checkoutConfig.payment.buckaroo.buckaroo_magento2_applepay.guid).then(
function (applePaySupported) {
this.canShowMethod(applePaySupported);
}.bind(this)
@@ -147,10 +148,10 @@ define(
var shippingMethods = self.availableShippingMethodInformation();
var shippingContactCallback = self.onSelectedShippingContact.bind(this);
var shipmentMethodCallback = self.onSelectedShipmentMethod.bind(this);
- var requiredBillingContactFields = ["name", "postalAddress", "phone"];
- var requiredShippingContactFields = ["name", "postalAddress", "phone"];
+ var requiredBillingContactFields = ["postalAddress", "name", "phone", "email"];
+ var requiredShippingContactFields = ["postalAddress", "name", "phone", "email"];
- var country = window.checkoutConfig.payment.buckaroo.applepay.country;
+ var country = window.checkoutConfig.payment.buckaroo.buckaroo_magento2_applepay.country;
this.devLog('==============applepaydebug/11', this.quote);
if (this.quote && (null !== this.quote.shippingAddress())) {
country = this.quote.shippingAddress().countryId;
@@ -168,7 +169,7 @@ define(
shipmentMethodCallback = null;
requiredBillingContactFields = ["postalAddress"];
requiredShippingContactFields = [];
- if (window.checkoutConfig.payment.buckaroo.applepay.dontAskBillingInfoInCheckout) {
+ if (window.checkoutConfig.payment.buckaroo.buckaroo_magento2_applepay.dontAskBillingInfoInCheckout) {
requiredBillingContactFields = [];
}
}
@@ -176,11 +177,11 @@ define(
this.devLog('==============applepaydebug/13', [country, requiredBillingContactFields, requiredShippingContactFields]);
this.applepayOptions = new BuckarooSdk.ApplePay.ApplePayOptions(
- window.checkoutConfig.payment.buckaroo.applepay.storeName,
+ window.checkoutConfig.payment.buckaroo.buckaroo_magento2_applepay.storeName,
country,
- window.checkoutConfig.payment.buckaroo.applepay.currency,
- window.checkoutConfig.payment.buckaroo.applepay.cultureCode,
- window.checkoutConfig.payment.buckaroo.applepay.guid,
+ window.checkoutConfig.payment.buckaroo.buckaroo_magento2_applepay.currency,
+ window.checkoutConfig.payment.buckaroo.buckaroo_magento2_applepay.cultureCode,
+ window.checkoutConfig.payment.buckaroo.buckaroo_magento2_applepay.guid,
self.processLineItems(lineItemsType),
self.processTotalLineItems(lineItemsType),
"shipping",
@@ -228,13 +229,15 @@ define(
*/
processTotalLineItems: function (type = 'final', directTotals = false) {
var grandTotal = '0.00';
- var storeName = window.checkoutConfig.payment.buckaroo.applepay.storeName;
+ var storeName = window.checkoutConfig.payment.buckaroo.buckaroo_magento2_applepay.storeName;
var totals = directTotals ? directTotals : this.getQuoteTotals();
if ('grand_total' in totals) {
grandTotal = parseFloat(totals['grand_total']).toFixed(2);
}
- if (isNaN(grandTotal)) grandTotal = 0;
+ if (isNaN(grandTotal)) {
+ grandTotal = 0;
+ }
return {label: storeName, amount: grandTotal, type: type};
},
@@ -291,13 +294,14 @@ define(
this.devLog('==============applepaydebug/38', url);
/** Set Timeout to prevent Safari from crashing and reload window to show error in Magento. */
setTimeout(
- function() {
+ function () {
if (url) {
window.location.href = url;
} else {
window.location.reload();
}
- }, 1500
+ },
+ 1500
)
},
@@ -316,10 +320,9 @@ define(
global: false,
dataType: 'json',
async: false,
- dataFilter: function(data, type) {
+ dataFilter: function (data, type) {
var result = JSON.parse(data);
if (result.success == 'true') {
-
var authorizationResult = {
newTotal: this.processTotalLineItems('final', result.data.totals),
newLineItems: this.processLineItems('final', result.data.totals)
@@ -333,14 +336,12 @@ define(
}
}.bind(this),
})
- .fail(function() {
+ .fail(function () {
this.timeoutRedirect();
}.bind(this));
return update;
-
} else {
-
var newShippingMethod = this.shippingGroups[event.identifier];
this.updateQuoteRate(newShippingMethod);
@@ -357,7 +358,6 @@ define(
this.devLog('==============applepaydebug/28');
if (this.payMode == 'product') {
-
var update = $.ajax({
url: urlBuilder.build('buckaroo/applepay/add'),
type: 'POST',
@@ -368,10 +368,9 @@ define(
global: false,
dataType: 'json',
async: false,
- dataFilter: function(data, type) {
+ dataFilter: function (data, type) {
var result = JSON.parse(data);
if (result.success == 'true') {
-
this.shippingGroups = {};
$.each(result.data.shipping_methods, function (index, rate) {
this.shippingGroups[rate['method_code']] = rate;
@@ -392,13 +391,12 @@ define(
}
}.bind(this),
})
- .fail(function() {
+ .fail(function () {
this.timeoutRedirect();
}.bind(this));
return update;
} else if (this.payMode == 'cart') {
-
var update = $.ajax({
url: urlBuilder.build('buckaroo/applepay/getShippingMethods'),
type: 'POST',
@@ -408,10 +406,9 @@ define(
global: false,
dataType: 'json',
async: false,
- dataFilter: function(data, type) {
+ dataFilter: function (data, type) {
var result = JSON.parse(data);
if (result.success == 'true') {
-
this.shippingGroups = {};
$.each(result.data.shipping_methods, function (index, rate) {
this.shippingGroups[rate['method_code']] = rate;
@@ -432,7 +429,7 @@ define(
}
}.bind(this),
})
- .fail(function() {
+ .fail(function () {
this.timeoutRedirect();
}.bind(this));
@@ -516,7 +513,6 @@ define(
};
if ((this.payMode == 'product') || (this.payMode == 'cart')) {
-
var authorizationFailedResult = {
status: ApplePaySession.STATUS_FAILURE,
errors: []
@@ -533,7 +529,7 @@ define(
global: false,
dataType: 'json',
async: false,
- dataFilter: function(data, type) {
+ dataFilter: function (data, type) {
var result = JSON.parse(data);
if (result.success == 'true') {
if (result.data && result.data.RequiredAction !== undefined && result.data.RequiredAction.RedirectURL !== undefined) {
@@ -548,14 +544,12 @@ define(
}
}.bind(this),
})
- .fail(function() {
+ .fail(function () {
this.timeoutRedirect();
}.bind(this));
return update;
-
} else {
-
this.transactionResult(payment);
return Promise.resolve(authorizationResult);
@@ -611,19 +605,19 @@ define(
this.productSelected.qty = $('#qty').val();
var self = this;
- $('#qty').change(function() {
+ $('#qty').change(function () {
self.productSelected.qty = $(this).val();
});
- $('.product-options-wrapper div').click(function() {
+ $('.product-options-wrapper div').click(function () {
var selected_options = {};
- $('div.swatch-attribute').each(function(k,v){
+ $('div.swatch-attribute').each(function (k,v) {
var attribute_id = $(v).attr('attribute-id');
var option_selected = $(v).attr('option-selected');
- if(!attribute_id || !option_selected) {
+ if (!attribute_id || !option_selected) {
attribute_id = $(v).attr('data-attribute-id');
option_selected = $(v).attr('data-option-selected');
- if(!attribute_id || !option_selected) {
+ if (!attribute_id || !option_selected) {
return;
}
}
diff --git a/view/frontend/web/js/view/checkout/common.js b/view/frontend/web/js/view/checkout/common.js
index 45577514d..62f809666 100644
--- a/view/frontend/web/js/view/checkout/common.js
+++ b/view/frontend/web/js/view/checkout/common.js
@@ -29,31 +29,14 @@ define(
if (response.RequiredAction !== undefined && response.RequiredAction.RedirectURL !== undefined) {
if (window.location.hash && (window.location.hash == '#payment')) {
window.history.pushState(
- null, null, `${window.location.pathname}${window.location.hash}`
+ null,
+ null,
+ `${window.location.pathname}${window.location.hash}`
);
}
window.location.replace(response.RequiredAction.RedirectURL);
}
- },
- getSubtextStyle: function(paymentCode) {
- let config = window.checkoutConfig.payment.buckaroo[paymentCode];
- if(config === undefined) {
- return;
- }
- let subtextColor = config.subtext_color || '#757575';
- let subtextStyle = config.subtext_style || 'regular';
-
- let style = { color: subtextColor }
- if(subtextStyle == 'bold') {
- style.fontWeight = 'bold';
- }
-
- if(subtextStyle == 'italic') {
- style.fontStyle = 'italic';
- }
- return style;
- }
-
+ }
};
}
);
diff --git a/view/frontend/web/js/view/checkout/idin/idin-step-view.js b/view/frontend/web/js/view/checkout/idin/idin-step-view.js
index 06e3ef501..7a5c344b6 100644
--- a/view/frontend/web/js/view/checkout/idin/idin-step-view.js
+++ b/view/frontend/web/js/view/checkout/idin/idin-step-view.js
@@ -30,15 +30,17 @@ define([
], function ($, ko, Component, _, uiRegistry, stepNavigator, alert, $t, quote, url) {
'use strict';
- function isOsc() {
+ function isOsc()
+ {
return window.checkoutConfig && window.checkoutConfig.buckarooIdin && window.checkoutConfig.buckarooIdin.isOscEnabled;
}
- function isOscMagePlaza() {
+ function isOscMagePlaza()
+ {
return window.checkoutConfig && window.checkoutConfig.oscConfig;
}
- window.onhashchange = function(){
+ window.onhashchange = function () {
if (!isOscMagePlaza() && !isOsc()) {
if (window.checkoutConfig.buckarooIdin.active > 0 && window.location.hash.replace('#', '') != 'step_idin') {
window.location.replace('#step_idin');
@@ -68,7 +70,7 @@ define([
initialize: function () {
this._super();
- if(window.checkoutConfig.buckarooIdin.active > 0){
+ if (window.checkoutConfig.buckarooIdin.active > 0) {
this.isVisible(true);
if (isOscMagePlaza() || isOsc()) {
if (!window.checkoutConfig.buckarooIdin.verified) {
@@ -88,7 +90,7 @@ define([
window.location.replace('#step_idin');
}
}
- }else{
+ } else {
if (isOscMagePlaza() || isOsc()) {
this.hideIdinBlock = true;
}
@@ -138,7 +140,7 @@ define([
return this;
},
- setSelectedBankDropDown: function() {
+ setSelectedBankDropDown: function () {
return true;
},
@@ -147,32 +149,32 @@ define([
var issuer = el.options[el.selectedIndex].value;
self = this;
- if(!issuer){
- alert({
- title: $t('Error'),
- content: $t('Select your bank'),
- actions: {always: function(){} }
+ if (!issuer) {
+ alert({
+ title: $t('Error'),
+ content: $t('Select your bank'),
+ actions: {always: function (){} }
});
- return ;
- }
+ return ;
+ }
$.ajax({
url: url.build("buckaroo/checkout/idin"),
type: 'POST',
dataType: 'json',
- showLoader: true, //use for display loader
+ showLoader: true, //use for display loader
data: {
issuer: issuer,
}
- }).done(function (response) {
+ }).done(function (response) {
if (response.RequiredAction !== undefined && response.RequiredAction.RedirectURL !== undefined) {
window.location.replace(response.RequiredAction.RedirectURL);
- }else{
+ } else {
alert({
title: $t('Error'),
content: $t('Unfortunately iDIN not verified!'),
- actions: {always: function(){} }
- });
+ actions: {always: function (){} }
+ });
}
});
diff --git a/view/frontend/web/js/view/checkout/mrcash/pay.js b/view/frontend/web/js/view/checkout/mrcash/pay.js
index de34fc128..9157ba6dd 100644
--- a/view/frontend/web/js/view/checkout/mrcash/pay.js
+++ b/view/frontend/web/js/view/checkout/mrcash/pay.js
@@ -24,7 +24,7 @@ define(
'mage/translate',
'BuckarooSDK'
],
- function(
+ function (
$,
utils,
url
@@ -34,11 +34,11 @@ define(
return {
transactionKey : null,
- setTransactionKey: function(newKey) {
+ setTransactionKey: function (newKey) {
this.transactionKey = newKey;
},
- showQrCode: function() {
+ showQrCode: function () {
if (/iPhone|iPad|iPod|Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
$('#buckaroo_magento2_mrcash_url').show();
}
@@ -46,7 +46,7 @@ define(
"#buckaroo_magento2_mrcash_qr",
"#buckaroo_magento2_mrcash_url",
this.transactionKey,
- function(status, params) {
+ function (status, params) {
if (status === 'SUCCESS') {
$('#buckaroo_magento2_mrcash_cancel').hide();
}
@@ -56,7 +56,7 @@ define(
);
},
- cancelPayment: function() {
+ cancelPayment: function () {
var cancelText = $.mage.__('You have canceled the order. We kindly ask you to not complete the payment in the Bancontact app - Your order will not be processed. Place the order again if you still want to make the payment.');
$('#buckaroo_magento2_mrcash_title').hide();
$('#buckaroo_magento2_mrcash_cancel').hide();
diff --git a/view/frontend/web/js/view/checkout/payconiq/pay.js b/view/frontend/web/js/view/checkout/payconiq/pay.js
index c7cb6318f..250dbbdfd 100644
--- a/view/frontend/web/js/view/checkout/payconiq/pay.js
+++ b/view/frontend/web/js/view/checkout/payconiq/pay.js
@@ -24,7 +24,7 @@ define(
'mage/translate',
'BuckarooSDK'
],
- function(
+ function (
$,
utils,
url
@@ -34,15 +34,15 @@ define(
return {
transactionKey : null,
- setTransactionKey: function(newKey) {
+ setTransactionKey: function (newKey) {
this.transactionKey = newKey;
},
- showQrCode: function() {
+ showQrCode: function () {
BuckarooSdk.Payconiq.initiate(
"#buckaroo_magento2_payconiq_qr",
this.transactionKey,
- function(status, params) {
+ function (status, params) {
if (status === 'SUCCESS') {
$('#buckaroo_magento2_payconiq_cancel').hide();
}
@@ -52,7 +52,7 @@ define(
);
},
- cancelPayment: function() {
+ cancelPayment: function () {
var cancelText = $.mage.__('You have canceled the order. We kindly ask you to not complete the payment in the Payconiq app - Your order will not be processed. Place the order again if you still want to make the payment.');
$('#buckaroo_magento2_payconiq_qr').html(cancelText);
diff --git a/view/frontend/web/js/view/checkout/paypal-express/button.js b/view/frontend/web/js/view/checkout/paypal-express/button.js
index 272068af1..23d76f51d 100644
--- a/view/frontend/web/js/view/checkout/paypal-express/button.js
+++ b/view/frontend/web/js/view/checkout/paypal-express/button.js
@@ -16,7 +16,7 @@
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/
- define(
+define(
[
'uiComponent',
'buckaroo/paypal-express/pay',
diff --git a/view/frontend/web/js/view/checkout/paypal-express/pay.js b/view/frontend/web/js/view/checkout/paypal-express/pay.js
index d200e1b63..fdab3c536 100644
--- a/view/frontend/web/js/view/checkout/paypal-express/pay.js
+++ b/view/frontend/web/js/view/checkout/paypal-express/pay.js
@@ -21,7 +21,7 @@ define([
"ko",
"mage/url",
"Magento_Customer/js/customer-data",
- "BuckarooSDK",
+ "Buckaroo_Magento2/js/action/paypal-express",
'mage/translate',
], function ($, ko, urlBuilder, customerData, sdk, $t) {
// 'use strict';
@@ -111,25 +111,25 @@ define([
}
},
- onErrorCallback(reason) {
- // custom error behavior
- this.displayErrorMessage(reason);
- },
- onInitCallback() {
- },
- onCancelCallback() {
+ onErrorCallback(reason) {
+ // custom error behavior
+ this.displayErrorMessage(reason);
+ },
+ onInitCallback() {
+ },
+ onCancelCallback() {
this.displayErrorMessage($t("You have canceled the payment request."));
- },
- onClickCallback() {
- //reset any previous payment response;
- this.result = null;
- },
- /**
- * Init class
- */
- init() {
- BuckarooSdk.PayPal.initiate(this.options);
- },
+ },
+ onClickCallback() {
+ //reset any previous payment response;
+ this.result = null;
+ },
+ /**
+ * Init class
+ */
+ init() {
+ sdk.initiate(this.options);
+ },
/**
* Create order and do payment
@@ -172,7 +172,7 @@ define([
getOrderData() {
let form = $("#product_addtocart_form");
if (this.page === 'product') {
- return form.serialize();
+ return form.serialize();
}
},
/**
diff --git a/view/frontend/web/js/view/checkout/summary/grand-total.js b/view/frontend/web/js/view/checkout/summary/grand-total.js
index 078ed2898..449787d42 100644
--- a/view/frontend/web/js/view/checkout/summary/grand-total.js
+++ b/view/frontend/web/js/view/checkout/summary/grand-total.js
@@ -39,7 +39,7 @@ define([
if (this.totals()) {
price = totals.getSegment('grand_total').value;
- if(!isNaN(parseFloat(this.getAlreadyPayTotal()))){
+ if (!isNaN(parseFloat(this.getAlreadyPayTotal()))) {
price = parseFloat(price) - parseFloat(this.getAlreadyPayTotal());
}
}
diff --git a/view/frontend/web/js/view/payment/buckaroo-payments.js b/view/frontend/web/js/view/payment/buckaroo-payments.js
index a6c5484f1..46c1684b1 100644
--- a/view/frontend/web/js/view/payment/buckaroo-payments.js
+++ b/view/frontend/web/js/view/payment/buckaroo-payments.js
@@ -43,151 +43,178 @@ define(
rendererList.push(
{
type: 'buckaroo_magento2_ideal',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/ideal'
- },
- {
- type: 'buckaroo_magento2_idealprocessing',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/idealprocessing'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/ideal',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_ideal}
},
{
type: 'buckaroo_magento2_afterpay',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/afterpay'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/afterpay',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_afterpay}
},
{
type: 'buckaroo_magento2_afterpay2',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/afterpay2'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/afterpay',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_afterpay2}
},
{
- type: 'buckaroo_magento2_afterpay20',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/afterpay20'
+ type: 'buckaroo_magento2_afterpay20',
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/afterpay20',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_afterpay20}
},
{
- type: 'buckaroo_magento2_billink',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/billink'
+ type: 'buckaroo_magento2_billink',
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/billink',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_billink}
},
{
type: 'buckaroo_magento2_payperemail',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/payperemail'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/payperemail',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_payperemail}
},
{
type: 'buckaroo_magento2_sepadirectdebit',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/sepadirectdebit'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/sepadirectdebit',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_sepadirectdebit}
},
{
type: 'buckaroo_magento2_paypal',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/paypal'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/default',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_paypal}
},
{
type: 'buckaroo_magento2_payconiq',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/payconiq'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/payconiq',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_payconiq}
},
{
type: 'buckaroo_magento2_creditcard',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/creditcard'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/creditcard',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_creditcard}
},
{
type: 'buckaroo_magento2_creditcards',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/creditcards'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/creditcards',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_creditcards}
},
{
type: 'buckaroo_magento2_transfer',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/transfer'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/transfer',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_transfer}
},
{
type: 'buckaroo_magento2_giropay',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/giropay'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/default',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_giropay}
},
{
type: 'buckaroo_magento2_mrcash',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/mrcash'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/mrcash',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_mrcash}
},
{
type: 'buckaroo_magento2_sofortbanking',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/sofortbanking'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/default',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_sofortbanking}
},
{
type: 'buckaroo_magento2_belfius',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/belfius'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/default',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_belfius}
},
{
type: 'buckaroo_magento2_eps',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/eps'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/default',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_eps}
},
{
type: 'buckaroo_magento2_giftcards',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/giftcards'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/giftcards',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_giftcards}
},
{
type: 'buckaroo_magento2_kbc',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/kbc'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/default',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_kbc}
},
{
type: 'buckaroo_magento2_klarna',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/klarna'
- },
- {
- type: 'buckaroo_magento2_klarnakp',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/klarnakp'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/klarna',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_klarna}
},
{
type: 'buckaroo_magento2_klarnain',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/klarnain'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/klarna',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_klarnain}
},
{
- type: 'buckaroo_magento2_emandate',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/emandate'
+ type: 'buckaroo_magento2_klarnakp',
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/klarnakp',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_klarnakp}
},
{
type: 'buckaroo_magento2_applepay',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/applepay'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/applepay',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_applepay}
},
{
type: 'buckaroo_magento2_capayablein3',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/capayablein3'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/capayablein3',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_capayablein3}
},
{
type: 'buckaroo_magento2_capayablepostpay',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/capayablepostpay'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/capayablepostpay',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_capayablepostpay}
},
{
type: 'buckaroo_magento2_alipay',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/alipay'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/default',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_alipay}
},
{
type: 'buckaroo_magento2_wechatpay',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/wechatpay'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/default',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_wechatpay}
},
{
type: 'buckaroo_magento2_p24',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/p24'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/default',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_p24}
},
{
type: 'buckaroo_magento2_trustly',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/trustly'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/default',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_trustly}
},
{
type: 'buckaroo_magento2_pospayment',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/pospayment'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/pospayment',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_pospayment}
},
{
type: 'buckaroo_magento2_voucher',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/voucher'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/voucher',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_voucher}
},
{
type: 'buckaroo_magento2_paybybank',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/paybybank'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/paybybank',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_paybybank}
},
{
type: 'buckaroo_magento2_multibanco',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/multibanco'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/default',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_multibanco}
},
{
type: 'buckaroo_magento2_mbway',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/mbway'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/default',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_mbway}
},
{
type: 'buckaroo_magento2_knaken',
- component: 'Buckaroo_Magento2/js/view/payment/method-renderer/knaken'
+ component: 'Buckaroo_Magento2/js/view/payment/method-renderer/default',
+ config: {buckaroo: window.checkoutConfig.payment.buckaroo.buckaroo_magento2_knaken}
}
);
/**
diff --git a/view/frontend/web/js/view/payment/method-renderer/afterpay.js b/view/frontend/web/js/view/payment/method-renderer/afterpay.js
index 6c05d76ca..59e13a251 100644
--- a/view/frontend/web/js/view/payment/method-renderer/afterpay.js
+++ b/view/frontend/web/js/view/payment/method-renderer/afterpay.js
@@ -21,29 +21,17 @@
define(
[
'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
+ 'buckaroo/checkout/payment/default',
'Magento_Checkout/js/model/quote',
'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common',
'buckaroo/checkout/datepicker',
'Magento_Ui/js/lib/knockout/bindings/datepicker'
- /*,
- 'jquery/validate'*/
],
function (
$,
Component,
- additionalValidators,
- placeOrderAction,
quote,
ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon,
datePicker
) {
'use strict';
@@ -89,7 +77,7 @@ define(
$.validator.addMethod(
'IBAN',
function (value) {
- var patternIBAN = new RegExp('^[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]?){0,16}$');
+ var patternIBAN = new RegExp('^[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]{1,16})$');
return (patternIBAN.test(value) && isValidIBAN(value));
},
$.mage.__('Enter Valid IBAN')
@@ -103,15 +91,16 @@ define(
value.substr(6, 4),
value.substr(3, 2) - 1,
value.substr(0, 2),
- 0, 0, 0
+ 0,
+ 0,
+ 0
);
return ~~((Date.now() - birthday) / (31557600000)) >= 18;
}
}
return false;
},
- $.mage.__('You should be at least 18 years old.')
- );
+ $.mage.__('You should be at least 18 years old.'));
return Component.extend(
{
@@ -125,32 +114,11 @@ define(
companyName:null,
bankAccountNumber: '',
termsUrl: 'https://www.afterpay.nl/nl/klantenservice/betalingsvoorwaarden/',
- termsValidate: true,
+ termsSelected: true,
value:"",
- validationState: {
- 'buckaroo_magento2_afterpay_TermsCondition': true
- }
},
redirectAfterPlaceOrder : true,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.afterpay.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.afterpay.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('afterpay'),
-
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
dp: datePicker,
- businessMethod : window.checkoutConfig.payment.buckaroo.afterpay.businessMethod,
- paymentMethod : window.checkoutConfig.payment.buckaroo.afterpay.paymentMethod,
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
initObservable: function () {
this._super().observe(
@@ -161,9 +129,8 @@ define(
'cocNumber',
'companyName',
'bankAccountNumber',
- 'termsValidate',
- 'value',
- 'validationState'
+ 'termsSelected',
+ 'value'
]
);
@@ -171,7 +138,7 @@ define(
function () {
return quote.billingAddress() !== null &&
quote.billingAddress().countryId == 'NL' &&
- window.checkoutConfig.payment.buckaroo.afterpay.showFinancialWarning
+ this.buckaroo.showFinancialWarning
},
this
);
@@ -179,16 +146,14 @@ define(
this.termsUrl = ko.computed(
function () {
- if(quote.billingAddress() !== null) {
+ if (quote.billingAddress() !== null) {
return this.getTos(quote.billingAddress().countryId);
}
},
this
);
- /**
- * Check if TelephoneNumber is filled in. If not - show field
- */
+
this.hasTelephoneNumber = ko.computed(
function () {
var telephone = quote.billingAddress() ? quote.billingAddress().telephone : null;
@@ -209,128 +174,13 @@ define(
*/
this.bankAccountNumber.extend({ uppercase: true });
- this.dateValidate.subscribe(function() {
- const dobId = 'buckaroo_magento2_afterpay_DoB';
- const isValid = $(`#${dobId}`).valid();
- let state = this.validationState();
- state[dobId] = isValid;
- this.validationState(state);
- }, this);
-
- this.buttoncheck = ko.computed(
- function () {
- const state = this.validationState();
- const valid = this.getActiveValidationFields().map((field) => {
- if(state[field] !== undefined) {
- return state[field];
- }
- return false;
- }).reduce(
- function(prev, cur) {
- return prev && cur
- },
- true
- )
- return valid;
- },
- this
- );
-
return this;
},
- validateField(data, event) {
- const isValid = $(event.target).valid();
- let state = this.validationState();
- state[event.target.id] = isValid;
- this.validationState(state);
- },
-
- getActiveValidationFields() {
- let fields = [
- 'buckaroo_magento2_afterpay_TermsCondition',
- ];
- if(!this.hasTelephoneNumber()) {
- fields.push('buckaroo_magento2_afterpay_Telephone')
- }
-
- if (this.businessMethod == BUSINESS_METHOD_B2C
- || (
- this.businessMethod == BUSINESS_METHOD_BOTH &&
- this.selectedBusiness() == BUSINESS_METHOD_B2C
- )
- ) {
- fields.push('buckaroo_magento2_afterpay_DoB')
- if(this.paymentMethod == PAYMENT_METHOD_ACCEPTGIRO) {
- fields.push('buckaroo_magento2_afterpay_IBAN')
- }
- } else {
- fields = fields.concat(
- [
- 'buckaroo_magento2_afterpay_COCNumber',
- 'buckaroo_magento2_afterpay_CompanyName'
- ]
- )
- }
-
- return fields;
- },
-
- /**
- * Place order.
- *
- * @todo To override the script used for placeOrderAction, we need to override the placeOrder method
- * on our parent class (Magento_Checkout/js/view/payment/default) so we can
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own
- * version (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
-
- return true;
- },
-
- /**
- * Run validation function
- */
-
- validate: function () {
- return $('.' + this.getCode() + ' .payment-method-second-col form').valid();
- },
+
+
getData: function () {
- var business = this.businessMethod;
+ var business = this.buckaroo.businessMethod;
if (business == BUSINESS_METHOD_BOTH) {
business = this.selectedBusiness();
@@ -343,7 +193,7 @@ define(
"customer_telephone" : this.telephoneNumber(),
"customer_DoB" : this.dateValidate(),
"customer_iban": this.bankAccountNumber(),
- "termsCondition" : this.termsValidate(),
+ "termsCondition" : this.termsSelected(),
"companyName" : this.companyName(),
"cOCNumber" : this.cocNumber(),
"selectedBusiness" : business
@@ -356,11 +206,11 @@ define(
let url = 'https://documents.riverty.com/terms_conditions/payment_methods/invoice';
const cc = country.toLowerCase()
- if (businessMethod == BUSINESS_METHOD_B2C || this.paymentMethod == PAYMENT_METHOD_DIGIACCEPT) {
+ if (businessMethod == BUSINESS_METHOD_B2C || this.buckaroo.paymentMethod == PAYMENT_METHOD_DIGIACCEPT) {
if (country === 'BE') {
lang = 'be_nl';
}
-
+
if (['NL','DE'].indexOf(country) !== -1) {
lang = `${cc}_${cc}`;
}
@@ -370,7 +220,7 @@ define(
lang = `${cc}_en`;
}
}
-
+
if (businessMethod == BUSINESS_METHOD_B2B && ['NL', 'DE', 'AT', 'CH'].indexOf(country) !== -1) {
url = 'https://documents.riverty.com/terms_conditions/payment_methods/b2b_invoice';
if (['NL', 'DE'].indexOf(country) !== -1) {
@@ -391,11 +241,11 @@ define(
.replace('%s', 'https://documents.riverty.com/terms_conditions/payment_methods/invoice/be_fr/');
},
- getBusinessMethod : function() {
+ getBusinessMethod : function () {
var businessMethod = BUSINESS_METHOD_B2C;
- if (this.businessMethod == BUSINESS_METHOD_B2B
- || (this.businessMethod == BUSINESS_METHOD_BOTH && this.selectedBusiness() == BUSINESS_METHOD_B2B)
+ if (this.buckaroo.businessMethod == BUSINESS_METHOD_B2B
+ || (this.buckaroo.businessMethod == BUSINESS_METHOD_BOTH && this.selectedBusiness() == BUSINESS_METHOD_B2B)
) {
businessMethod = BUSINESS_METHOD_B2B;
}
diff --git a/view/frontend/web/js/view/payment/method-renderer/afterpay2.js b/view/frontend/web/js/view/payment/method-renderer/afterpay2.js
deleted file mode 100644
index 34837f31d..000000000
--- a/view/frontend/web/js/view/payment/method-renderer/afterpay2.js
+++ /dev/null
@@ -1,406 +0,0 @@
-/**
- * NOTICE OF LICENSE
- *
- * This source file is subject to the MIT License
- * It is available through the world-wide-web at this URL:
- * https://tldrlegal.com/license/mit-license
- * If you are unable to obtain it through the world-wide-web, please send an email
- * to support@buckaroo.nl so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this module to newer
- * versions in the future. If you wish to customize this module for your
- * needs please contact support@buckaroo.nl for more information.
- *
- * @copyright Copyright (c) Buckaroo B.V.
- * @license https://tldrlegal.com/license/mit-license
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'Magento_Checkout/js/model/quote',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common',
- 'buckaroo/checkout/datepicker',
- 'Magento_Ui/js/lib/knockout/bindings/datepicker'
- /*,
- 'jquery/validate'*/
- ],
- function (
- $,
- Component,
- additionalValidators,
- placeOrderAction,
- quote,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon,
- datePicker
- ) {
- 'use strict';
-
-
- /**
- * constants for backend settings
- */
- var BUSINESS_METHOD_B2C = 1;
- var BUSINESS_METHOD_B2B = 2;
- var BUSINESS_METHOD_BOTH = 3;
-
- var PAYMENT_METHOD_ACCEPTGIRO = 1;
- var PAYMENT_METHOD_DIGIACCEPT = 2;
-
-
- /**
- * Validate IBAN and BIC number
- * This function check if the checksum if correct
- */
- function isValidIBAN($v)
- {
- $v = $v.replace(/^(.{4})(.*)$/,"$2$1"); //Move the first 4 chars from left to the right
- //Convert A-Z to 10-25
- $v = $v.replace(
- /[A-Z]/g,
- function ($e) {
- return $e.charCodeAt(0) - 'A'.charCodeAt(0) + 10;
- }
- );
- var $sum = 0;
- var $ei = 1; //First exponent
- for (var $i = $v.length - 1; $i >= 0; $i--) {
- $sum += $ei * parseInt($v.charAt($i),10); //multiply the digit by it's exponent
- $ei = ($ei * 10) % 97; //compute next base 10 exponent in modulus 97
- }
- return $sum % 97 == 1;
- }
-
- /**
- * Add validation methods
- */
- $.validator.addMethod(
- 'IBAN',
- function (value) {
- var patternIBAN = new RegExp('^[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]?){0,16}$');
- return (patternIBAN.test(value) && isValidIBAN(value));
- },
- $.mage.__('Enter Valid IBAN')
- );
-
- $.validator.addMethod('validateAge', function (value) {
- if (value && (value.length > 0)) {
- var dateReg = /^\d{2}[./-]\d{2}[./-]\d{4}$/;
- if (value.match(dateReg)) {
- var birthday = +new Date(
- value.substr(6, 4),
- value.substr(3, 2) - 1,
- value.substr(0, 2),
- 0, 0, 0
- );
- return ~~((Date.now() - birthday) / (31557600000)) >= 18;
- }
- }
- return false;
- },
- $.mage.__('You should be at least 18 years old.')
- );
-
- return Component.extend(
- {
- defaults : {
- template : 'Buckaroo_Magento2/payment/buckaroo_magento2_afterpay2',
- telephoneNumber: null,
- selectedBusiness: 1,
- country: '',
- dateValidate: null,
- cocNumber: null,
- companyName:null,
- bankAccountNumber: '',
- termsUrl: 'https://www.afterpay.nl/nl/klantenservice/betalingsvoorwaarden/',
- termsValidate: true,
- value:"",
- validationState: {
- 'buckaroo_magento2_afterpay2_TermsCondition': true
- }
- },
- redirectAfterPlaceOrder : true,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.afterpay2.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.afterpay2.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('afterpay2'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
- dp: datePicker,
- businessMethod : window.checkoutConfig.payment.buckaroo.afterpay2.businessMethod,
- paymentMethod : window.checkoutConfig.payment.buckaroo.afterpay2.paymentMethod,
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- initObservable: function () {
- this._super().observe(
- [
- 'telephoneNumber',
- 'selectedBusiness',
- 'dateValidate',
- 'cocNumber',
- 'companyName',
- 'bankAccountNumber',
- 'termsValidate',
- 'value',
- 'validationState'
- ]
- );
-
- this.showFinancialWarning = ko.computed(
- function () {
- return quote.billingAddress() !== null &&
- quote.billingAddress().countryId == 'NL' &&
- window.checkoutConfig.payment.buckaroo.afterpay2.showFinancialWarning
- },
- this
- );
-
- this.termsUrl = ko.computed(
- function () {
- if(quote.billingAddress() !== null) {
- return this.getTos(quote.billingAddress().countryId);
- }
- },
- this
- );
-
- /**
- * Check if TelephoneNumber is filled in. If not - show field
- */
- this.hasTelephoneNumber = ko.computed(
- function () {
- var telephone = quote.billingAddress() ? quote.billingAddress().telephone : null;
- return telephone != '' && telephone != '-';
- }
- );
-
- this.showFrenchTos = ko.computed(
- function () {
- return quote.billingAddress() !== null &&
- quote.billingAddress().countryId === 'BE'
- },
- this
- );
-
- /**
- * Repair IBAN value to uppercase
- */
- this.bankAccountNumber.extend({ uppercase: true });
-
- this.dateValidate.subscribe(function() {
- const dobId = 'buckaroo_magento2_afterpay2_DoB';
- const isValid = $(`#${dobId}`).valid();
- let state = this.validationState();
- state[dobId] = isValid;
- this.validationState(state);
- }, this);
-
- this.buttoncheck = ko.computed(
- function () {
- const state = this.validationState();
- const valid = this.getActiveValidationFields().map((field) => {
- if(state[field] !== undefined) {
- return state[field];
- }
- return false;
- }).reduce(
- function(prev, cur) {
- return prev && cur
- },
- true
- )
- return valid;
- },
- this
- );
-
- return this;
- },
- validateField(data, event) {
- const isValid = $(event.target).valid();
- let state = this.validationState();
- state[event.target.id] = isValid;
- this.validationState(state);
- },
-
- getActiveValidationFields() {
- let fields = [
- 'buckaroo_magento2_afterpay2_TermsCondition',
- ];
- if(!this.hasTelephoneNumber()) {
- fields.push('buckaroo_magento2_afterpay2_Telephone')
- }
-
- if (this.businessMethod == BUSINESS_METHOD_B2C
- || (
- this.businessMethod == BUSINESS_METHOD_BOTH &&
- this.selectedBusiness() == BUSINESS_METHOD_B2C
- )
- ) {
- fields.push('buckaroo_magento2_afterpay2_DoB')
- if(this.paymentMethod == PAYMENT_METHOD_ACCEPTGIRO) {
- fields.push('buckaroo_magento2_afterpay2_IBAN')
- }
- } else {
- fields = fields.concat(
- [
- 'buckaroo_magento2_afterpay2_COCNumber',
- 'buckaroo_magento2_afterpay2_CompanyName'
- ]
- )
- }
-
- return fields;
- },
-
- /**
- * Place order.
- *
- * @todo To override the script used for placeOrderAction, we need to override the placeOrder method
- * on our parent class (Magento_Checkout/js/view/payment/default) so we can
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own
- * version (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
-
- return true;
- },
-
- /**
- * Run validation function
- */
-
- validate: function () {
- return $('.' + this.getCode() + ' .payment-method-second-col form').valid();
- },
-
- getData: function () {
- var business = this.businessMethod;
-
- if (business == BUSINESS_METHOD_BOTH) {
- business = this.selectedBusiness();
- }
-
- return {
- "method": this.item.method,
- "po_number": null,
- "additional_data": {
- "customer_telephone" : this.telephoneNumber(),
- "customer_DoB" : this.dateValidate(),
- "customer_iban": this.bankAccountNumber(),
- "termsCondition" : this.termsValidate(),
- "companyName" : this.companyName(),
- "cOCNumber" : this.cocNumber(),
- "selectedBusiness" : business
- }
- };
- },
- getTos :function(country) {
- const businessMethod = this.getBusinessMethod();
- let lang = 'nl_nl';
- let url = 'https://documents.riverty.com/terms_conditions/payment_methods/invoice';
- const cc = country.toLowerCase()
-
- if (businessMethod == BUSINESS_METHOD_B2C || this.paymentMethod == PAYMENT_METHOD_DIGIACCEPT) {
- if (country === 'BE') {
- lang = 'be_nl';
- }
-
- if (['NL','DE'].indexOf(country) !== -1) {
- lang = `${cc}_${cc}`;
- }
-
- if (['AT','DK', 'FI', 'SE', 'CH', 'NO'].indexOf(country) !== -1) {
- const cc = country.toLowerCase()
- lang = `${cc}_en`;
- }
- }
-
- if (businessMethod == BUSINESS_METHOD_B2B && ['NL', 'DE', 'AT', 'CH'].indexOf(country) !== -1) {
- url = 'https://documents.riverty.com/terms_conditions/payment_methods/b2b_invoice';
- if (['NL', 'DE'].indexOf(country) !== -1) {
- lang = `${cc}_${cc}`;
- }
-
- if (['AT', 'CH'].indexOf(country) !== -1) {
- lang = `${cc}_en`;
- }
- }
-
- return `${url}/${lang}/`;
- },
-
- getFrenchTos: function () {
- return $.mage
- .__('(Or click here for the French translation: terms and condition.)')
- .replace('%s', 'https://documents.riverty.com/terms_conditions/payment_methods/invoice/be_fr/');
- },
-
- getBusinessMethod : function() {
- var businessMethod = BUSINESS_METHOD_B2C;
-
- if (this.businessMethod == BUSINESS_METHOD_B2B
- || (this.businessMethod == BUSINESS_METHOD_BOTH && this.selectedBusiness() == BUSINESS_METHOD_B2B)
- ) {
- businessMethod = BUSINESS_METHOD_B2B;
- }
-
- return businessMethod;
- }
- }
- );
- }
-);
diff --git a/view/frontend/web/js/view/payment/method-renderer/afterpay20.js b/view/frontend/web/js/view/payment/method-renderer/afterpay20.js
index 7e33d0263..f6986f1f8 100644
--- a/view/frontend/web/js/view/payment/method-renderer/afterpay20.js
+++ b/view/frontend/web/js/view/payment/method-renderer/afterpay20.js
@@ -22,14 +22,11 @@ define(
[
'jquery',
'mage/translate',
- 'Magento_Checkout/js/view/payment/default',
+ 'buckaroo/checkout/payment/default',
'Magento_Checkout/js/model/payment/additional-validators',
'Buckaroo_Magento2/js/action/place-order',
'Magento_Checkout/js/model/quote',
'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common',
'buckaroo/checkout/datepicker',
'Magento_Customer/js/model/customer',
'Magento_Ui/js/lib/knockout/bindings/datepicker',
@@ -44,9 +41,6 @@ define(
placeOrderAction,
quote,
ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon,
datePicker,
customer,
selectBillingAddress,
@@ -64,8 +58,7 @@ define(
return value.length <= 8;
},
- $.mage.__('Invalid COC number')
- );
+ $.mage.__('Invalid COC number'));
const bkIsPhoneValid = function (value) {
if (quote.billingAddress() === null) {
@@ -90,8 +83,8 @@ define(
return false;
}
- value = value.replace(/^\+|(00)/, '');
- value = value.replace(/\(0\)|\s|-/g, '');
+ value = value.replace(/^(\+|00)/, '');
+ value = value.replace(/(\(0\)|\s|-)/g, '');
if (value.match(/\+/)) {
return false;
@@ -127,15 +120,16 @@ define(
value.substr(6, 4),
value.substr(3, 2) - 1,
value.substr(0, 2),
- 0, 0, 0
+ 0,
+ 0,
+ 0
);
return ~~((Date.now() - birthday) / (31557600000)) >= 18;
}
}
return false;
},
- $.mage.__('You should be at least 18 years old.')
- );
+ $.mage.__('You should be at least 18 years old.'));
return Component.extend(
{
@@ -144,82 +138,64 @@ define(
activeAddress: null,
identificationNumber: null,
country: '',
- customerCoc:'',
+ customerCoc: '',
dateValidate: null,
- termsValidate: true,
+ termsSelected: true,
identificationValidate: null,
phone: null,
showIdentification: false,
showCOC: false,
- value:"",
- buttoncheck: false,
- validationState: {'TermsCondition':true},
+ value: "",
},
- redirectAfterPlaceOrder : true,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.afterpay20.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.afterpay20.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('afterpay20'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
+ redirectAfterPlaceOrder: true,
isCustomerLoggedIn: customer.isLoggedIn,
- isB2B: window.checkoutConfig.payment.buckaroo.afterpay20.is_b2b,
dp: datePicker,
- /**
- * @override
- */
- initialize: function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
- return this._super(options);
- },
initObservable: function () {
this._super().observe(
[
'dateValidate',
- 'termsValidate',
+ 'termsSelected',
'identificationValidate',
'phone',
'customerCoc',
- 'value',
- 'validationState'
+ 'value'
]
);
this.showFinancialWarning = ko.computed(
function () {
return quote.billingAddress() !== null &&
- quote.billingAddress().countryId == 'NL' &&
- window.checkoutConfig.payment.buckaroo.afterpay20.showFinancialWarning
+ quote.billingAddress().countryId == 'NL' &&
+ this.buckaroo.showFinancialWarning
},
this
);
this.activeAddress = ko.computed(
- function() {
- if(quote.billingAddress()) {
+ function () {
+ if (quote.billingAddress()) {
return quote.billingAddress();
}
return quote.shippingAddress();
}
);
-
+
this.country = ko.computed(
- function() {
+ function () {
return this.activeAddress().countryId;
},
this
);
this.showCOC = ko.computed(
- function() {
+ function () {
let shipping = quote.shippingAddress();
let billing = quote.billingAddress();
- return this.isB2B && (
+ return this.buckaroo.is_b2b && (
(shipping && shipping.countryId == 'NL' && shipping.company && shipping.company.trim().length > 0) ||
(billing && billing.countryId == 'NL' && billing.company && billing.company.trim().length > 0)
)
@@ -227,21 +203,21 @@ define(
this
);
+
this.showPhone = ko.computed(function () {
- return (!this.isCustomerLoggedIn() && this.isOsc()) ||
+ return (!this.isCustomerLoggedIn() && this.isOsc()) ||
quote.billingAddress() === null ||
- (['NL','BE'].indexOf(quote.billingAddress().countryId) !== -1 && !bkIsPhoneValid( quote.billingAddress().telephone))
- },
- this
- );
+ (['NL', 'BE'].indexOf(quote.billingAddress().countryId) !== -1 && !bkIsPhoneValid(quote.billingAddress().telephone))
+ },
+ this);
this.showNLBEFields = ko.computed(
function () {
return !this.showCOC() &&
- (
- ['NL','BE', 'DE'].indexOf(this.country()) != -1 ||
- (!this.isCustomerLoggedIn() && this.isOsc())
- );
+ (
+ ['NL', 'BE', 'DE'].indexOf(this.country()) != -1 ||
+ (!this.isCustomerLoggedIn() && this.isOsc())
+ );
},
this
);
@@ -267,79 +243,15 @@ define(
this
);
- this.buttoncheck = ko.computed(
- function() {
- const state = this.validationState();
- const valid = this.getActiveValidationFields().map((field) => {
- if(state[field] !== undefined) {
- return state[field];
- }
- return false;
- }).reduce(
- function(prev, cur) {
- return prev && cur
- },
- true
- )
- return valid;
- },
- this
- )
-
- this.dateValidate.subscribe(function() {
- this.validateField('DoB');
- }, this);
- this.customerCoc.subscribe(function() {
- this.validateField('coc');
- }, this);
- this.termsValidate.subscribe(function() {
- this.validateField('TermsCondition');
- }, this);
- this.identificationValidate.subscribe(function() {
- this.validateField('Identificationnumber');
- }, this);
- this.phone.subscribe(function() {
- this.validateField('Telephone');
- }, this);
-
return this;
},
- getActiveValidationFields() {
- let fields = ['TermsCondition'];
- if(this.showPhone()) {
- fields.push('Telephone')
- }
-
- if(this.showIdentification()) {
- fields.push('Identificationnumber')
- }
-
- if(this.showCOC()) {
- fields.push('coc')
- }
-
- if(this.showNLBEFields()) {
- fields.push('DoB')
- }
- return fields;
- },
-
-
- validateField: function(id) {
- this.messageContainer.clear();
- const isValid = $(`#buckaroo_magento2_afterpay20_${id}`).valid();
- let state = this.validationState();
- state[id] = isValid;
- this.validationState(state);
- return isValid;
- },
/**
* Place order.
*
* @todo To override the script used for placeOrderAction, we need to override the placeOrder method
- * on our parent class (Magento_Checkout/js/view/payment/default) so we can
+ * on our parent class (buckaroo/checkout/payment/default) so we can
*
* placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own
* version (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
@@ -366,7 +278,7 @@ define(
'dpd-selected-parcelshop-city',
'dpd-selected-parcelshop-country'
];
- dpdCookies.forEach(function(item) {
+ dpdCookies.forEach(function (item) {
var value = $.mage.cookies.get(item);
if (value) {
$.mage.cookies.clear(item);
@@ -392,28 +304,6 @@ define(
return false;
},
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- /**
- * Run validation function
- */
-
- validate: function () {
- return $('.' + this.getCode() + ' .payment-method-second-col form').valid();
- },
-
getData: function () {
return {
"method": this.item.method,
@@ -422,7 +312,7 @@ define(
"customer_telephone": this.phone(),
"customer_identificationNumber": this.identificationValidate(),
"customer_DoB": this.dateValidate(),
- "termsCondition": this.termsValidate(),
+ "termsCondition": this.termsSelected(),
"customer_coc": this.customerCoc(),
}
};
@@ -433,26 +323,26 @@ define(
let url = 'https://documents.riverty.com/terms_conditions/payment_methods/invoice';
const cc = country.toLowerCase()
- if ( b2b === false ) {
+ if (b2b === false) {
if (country === 'BE') {
lang = 'be_nl';
}
-
- if (['NL','DE'].indexOf(country) !== -1) {
+
+ if (['NL', 'DE'].indexOf(country) !== -1) {
lang = `${cc}_${cc}`;
}
- if (['AT','DK', 'FI', 'SE', 'CH', 'NO'].indexOf(country) !== -1) {
+ if (['AT', 'DK', 'FI', 'SE', 'CH', 'NO'].indexOf(country) !== -1) {
const cc = country.toLowerCase()
lang = `${cc}_en`;
}
} else {
url = 'https://documents.riverty.com/terms_conditions/payment_methods/b2b_invoice';
- if (['NL','DE'].indexOf(country) !== -1) {
+ if (['NL', 'DE'].indexOf(country) !== -1) {
lang = `${cc}_${cc}`;
}
- if (['AT','CH'].indexOf(country) !== -1) {
+ if (['AT', 'CH'].indexOf(country) !== -1) {
lang = `${cc}_en`;
}
}
@@ -461,9 +351,9 @@ define(
},
getFrenchTos: function () {
- return $.mage
- .__('(Or click here for the French translation: terms and condition.)')
- .replace('%s', 'https://documents.riverty.com/terms_conditions/payment_methods/invoice/be_fr/');
+ return $.mage
+ .__('(Or click here for the French translation: terms and condition.)')
+ .replace('%s', 'https://documents.riverty.com/terms_conditions/payment_methods/invoice/be_fr/');
},
isOsc: function () {
diff --git a/view/frontend/web/js/view/payment/method-renderer/applepay.js b/view/frontend/web/js/view/payment/method-renderer/applepay.js
index 8479b7da9..dc0f0f3ca 100644
--- a/view/frontend/web/js/view/payment/method-renderer/applepay.js
+++ b/view/frontend/web/js/view/payment/method-renderer/applepay.js
@@ -21,16 +21,12 @@
define(
[
'jquery',
- 'Magento_Checkout/js/view/payment/default',
+ 'buckaroo/checkout/payment/default',
'Magento_Checkout/js/model/payment/additional-validators',
'Buckaroo_Magento2/js/action/place-order',
'Magento_Checkout/js/model/quote',
'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/applepay/pay',
- 'buckaroo/checkout/common',
- 'BuckarooSDK'
+ 'buckaroo/applepay/pay'
],
function (
$,
@@ -39,10 +35,7 @@ define(
placeOrderAction,
quote,
ko,
- checkoutData,
- selectPaymentMethodAction,
applepayPay,
- checkoutCommon
) {
'use strict';
@@ -51,21 +44,14 @@ define(
defaults: {
template: 'Buckaroo_Magento2/payment/buckaroo_magento2_applepay'
},
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
- subtext : window.checkoutConfig.payment.buckaroo.applepay.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('applepay'),
- submit: false,
-
- /**
- * @override
- */
- initialize : function (options) {
- return this._super(options);
- },
+ submit: false,
+
initObservable: function () {
this._super().observe([]);
+ this.canShowPaymentMethod = ko.computed(function () {
+ return applepayPay.canShowApplePay();
+ }),
applepayPay.transactionResult.subscribe(
function () {
@@ -93,10 +79,6 @@ define(
return this;
},
- canShowPaymentMethod: ko.computed(function () {
- return applepayPay.canShowApplePay();
- }),
-
/**
* Place order.
*
@@ -149,22 +131,7 @@ define(
return false;
},
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- applepayPay.devLog('==========applepaydebug/14');
- response = $.parseJSON(response);
- if (response.RequiredAction !== undefined && response.RequiredAction.RedirectURL !== undefined) {
- window.location.replace(response.RequiredAction.RedirectURL);
- }
- },
-
- selectPaymentMethod: function () {
- applepayPay.devLog('==========applepaydebug/71');
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
showPayButton: function () {
applepayPay.devLog('==========applepaydebug/66');
@@ -173,17 +140,6 @@ define(
applepayPay.showPayButton();
},
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.applepay.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- },
getData: function () {
var transactionResult = applepayPay.transactionResult();
@@ -193,8 +149,8 @@ define(
"method": this.item.method,
"po_number": null,
"additional_data": {
- "applepayTransaction" : transactionData,
- "billingContact" : transactionResult && transactionResult.billingContact ?
+ "applepayTransaction": transactionData,
+ "billingContact": transactionResult && transactionResult.billingContact ?
JSON.stringify(transactionResult.billingContact) : ''
}
};
diff --git a/view/frontend/web/js/view/payment/method-renderer/belfius.js b/view/frontend/web/js/view/payment/method-renderer/belfius.js
deleted file mode 100644
index b8eec73b8..000000000
--- a/view/frontend/web/js/view/payment/method-renderer/belfius.js
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * NOTICE OF LICENSE
- *
- * This source file is subject to the MIT License
- * It is available through the world-wide-web at this URL:
- * https://tldrlegal.com/license/mit-license
- * If you are unable to obtain it through the world-wide-web, please send an email
- * to support@buckaroo.nl so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this module to newer
- * versions in the future. If you wish to customize this module for your
- * needs please contact support@buckaroo.nl for more information.
- *
- * @copyright Copyright (c) Buckaroo B.V.
- * @license https://tldrlegal.com/license/mit-license
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
- ],
- function (
- $,
- Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
- ) {
- 'use strict';
-
- return Component.extend(
- {
- defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_belfius'
- },
- redirectAfterPlaceOrder: false,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.belfius.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.belfius.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('belfius'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.belfius.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
- }
- );
- }
-);
-
-
-
-
-
-
-
-
diff --git a/view/frontend/web/js/view/payment/method-renderer/billink.js b/view/frontend/web/js/view/payment/method-renderer/billink.js
index af46f6cd0..9ff285588 100644
--- a/view/frontend/web/js/view/payment/method-renderer/billink.js
+++ b/view/frontend/web/js/view/payment/method-renderer/billink.js
@@ -21,29 +21,17 @@
define(
[
'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
+ 'buckaroo/checkout/payment/default',
'Magento_Checkout/js/model/quote',
'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common',
'buckaroo/checkout/datepicker',
'Magento_Ui/js/lib/knockout/bindings/datepicker'
- /*,
- 'jquery/validate'*/
],
function (
$,
Component,
- additionalValidators,
- placeOrderAction,
quote,
ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon,
datePicker
) {
'use strict';
@@ -56,15 +44,16 @@ define(
value.substr(6, 4),
value.substr(3, 2) - 1,
value.substr(0, 2),
- 0, 0, 0
+ 0,
+ 0,
+ 0
);
return ~~((Date.now() - birthday) / (31557600000)) >= 18;
}
}
return false;
},
- $.mage.__('You should be at least 18 years old.')
- );
+ $.mage.__('You should be at least 18 years old.'));
const validPhone = function (value) {
if (quote.billingAddress() === null) {
@@ -89,8 +78,8 @@ define(
return false;
}
- value = value.replace(/^\+|(00)/, '');
- value = value.replace(/\(0\)|\s|-/g, '');
+ value = value.replace(/^(\+|00)/, '');
+ value = value.replace(/(\(0\)|\s|-)/g, '');
if (value.match(/\+/)) {
return false;
@@ -111,7 +100,9 @@ define(
return true;
};
- $.validator.addMethod('phoneValidation', validPhone ,
+ $.validator.addMethod(
+ 'phoneValidation',
+ validPhone ,
$.mage.__('Phone number should be correct.')
);
@@ -130,32 +121,10 @@ define(
tos: true,
showPhone: false,
showFrenchTosValue: null,
- validationState:{
- 'buckaroo_magento2_billink_TermsCondition': true
- },
value: ""
},
redirectAfterPlaceOrder : true,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.billink.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.billink.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('billink'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
- currentCustomerAddressId : null,
- genderList: window.checkoutConfig.payment.buckaroo.billink.genderList,
dp: datePicker,
- isB2B: window.checkoutConfig.payment.buckaroo.billink.b2b == true,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
initObservable: function () {
this._super().observe(
@@ -167,7 +136,6 @@ define(
'tos',
'dob',
'showFrenchTosValue',
- 'validationState',
'value'
]
);
@@ -176,147 +144,52 @@ define(
function () {
return quote.billingAddress() !== null &&
quote.billingAddress().countryId == 'NL' &&
- window.checkoutConfig.payment.buckaroo.billink.showFinancialWarning
+ this.buckaroo.showFinancialWarning
},
this
);
this.billingName = ko.computed(
function () {
- if(this.isB2B && quote.billingAddress() !== null) {
+ if ((this.buckaroo.b2b == true) && quote.billingAddress() !== null) {
return quote.billingAddress().company;
}
- if(quote.billingAddress() !== null) {
+ if (quote.billingAddress() !== null) {
return quote.billingAddress().firstname + " " + quote.billingAddress().lastname;
}
},
this
);
- this.showFrenchTos = ko.computed(
- function () {
- return quote.billingAddress() !== null && quote.billingAddress().countryId == 'BE'
- },
- this
- );
-
this.showPhone = ko.computed(
function () {
return (
quote.billingAddress() === null ||
!validPhone(quote.billingAddress().telephone)
- ) && !this.isB2B;
+ ) && this.buckaroo.b2b != true;
},
this
);
-
- this.dob.subscribe(function() {
- const dobId = 'buckaroo_magento2_billink_DoB';
- const isValid = $(`#${dobId}`).valid();
- let state = this.validationState();
- state[dobId] = isValid;
- this.validationState(state);
- }, this);
- this.buttoncheck = ko.computed(
+ this.showB2B = ko.computed(
function () {
- const state = this.validationState();
- const valid = this.getActiveValidationFields().map((field) => {
- if(state[field] !== undefined) {
- return state[field];
- }
- return false;
- }).reduce(
- function(prev, cur) {
- return prev && cur
- },
- true
+
+ let shipping = quote.shippingAddress();
+ let billing = quote.billingAddress();
+
+ return this.buckaroo.b2b == true && (
+ (shipping && shipping.company && shipping.company.trim().length > 0) ||
+ (billing && billing.company && billing.company.trim().length > 0)
)
- return valid;
},
this
);
return this;
},
- validateField(data, event) {
- const isValid = $(event.target).valid();
- let state = this.validationState();
- state[event.target.id] = isValid;
- this.validationState(state);
- },
-
- getActiveValidationFields() {
- let fields = [
- 'buckaroo_magento2_billink_TermsCondition',
- ];
- if(this.showPhone()) {
- fields.push('buckaroo_magento2_billink_Telephone')
- }
-
- if(this.isB2B) {
- fields.push('buckaroo_magento2_billink_chamberOfCommerce')
- } else {
- fields = fields.concat([
- 'buckaroo_magento2_billink_DoB',
- 'buckaroo_magento2_bilink_genderSelect'
- ]);
- }
-
- return fields;
- },
- validate: function () {
- return $('.' + this.getCode() + ' .payment-method-second-col form').valid();
- },
-
- /**
- * Place order.
- *
- * @todo To override the script used for placeOrderAction, we need to override the placeOrder method
- * on our parent class (Magento_Checkout/js/view/payment/default) so we can
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own
- * version (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
-
- return true;
- },
getData: function () {
let phone = this.phone();
- if(!this.showPhone() && quote.billingAddress() !== null) {
+ if (!this.showPhone() && quote.billingAddress() !== null) {
phone = quote.billingAddress().telephone;
}
diff --git a/view/frontend/web/js/view/payment/method-renderer/capayablein3.js b/view/frontend/web/js/view/payment/method-renderer/capayablein3.js
index 64165a54e..4064cc5ec 100644
--- a/view/frontend/web/js/view/payment/method-renderer/capayablein3.js
+++ b/view/frontend/web/js/view/payment/method-renderer/capayablein3.js
@@ -21,26 +21,16 @@
define(
[
'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
+ 'buckaroo/checkout/payment/default',
'Magento_Checkout/js/model/quote',
'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common',
'buckaroo/checkout/datepicker'
],
function (
$,
Component,
- additionalValidators,
- placeOrderAction,
quote,
ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon,
datePicker
) {
'use strict';
@@ -68,8 +58,8 @@ define(
return false;
}
- value = value.replace(/^\+|(00)/, '');
- value = value.replace(/\(0\)|\s|-/g, '');
+ value = value.replace(/^(\+|00)/, '');
+ value = value.replace(/(\(0\)|\s|-)/g, '');
if (value.match(/\+/)) {
return false;
@@ -90,9 +80,11 @@ define(
return true;
};
- $.validator.addMethod('in3phoneValidation', validPhone ,
- $.mage.__('Phone number should be correct.')
- );
+ $.validator.addMethod(
+ 'in3phoneValidation',
+ validPhone ,
+ $.mage.__('Phone number should be correct.')
+ );
return Component.extend(
{
@@ -102,42 +94,24 @@ define(
dateValidate : '',
value: '',
phone: null,
- validationState : {},
},
redirectAfterPlaceOrder: false,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.capayablein3.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.capayablein3.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('capayablein3'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
- logo: window.checkoutConfig.payment.buckaroo.capayablein3.logo,
dp: datePicker,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
+
initObservable: function () {
this._super().observe([
'billingName',
'dateValidate',
'value',
- 'phone',
- 'validationState'
+ 'phone'
]);
this.showFinancialWarning = ko.computed(
function () {
return quote.billingAddress() !== null &&
quote.billingAddress().countryId == 'NL' &&
- window.checkoutConfig.payment.buckaroo.capayablein3.showFinancialWarning
+ this.buckaroo.showFinancialWarning
},
this
);
@@ -153,7 +127,7 @@ define(
this.billingName = ko.computed(
function () {
- if(quote.billingAddress() !== null) {
+ if (quote.billingAddress() !== null) {
return quote.billingAddress().firstname + " " + quote.billingAddress().lastname
}
return '';
@@ -162,111 +136,10 @@ define(
);
- /** Check used to see form is valid **/
- this.buttoncheck = ko.computed(
- function () {
- const state = this.validationState();
- const valid =this.getActiveFields().map((field) => {
- if(state[field] !== undefined) {
- return state[field];
- }
- return false;
- }).reduce(
- function(prev, cur) {
- return prev && cur
- },
- true
- )
- return valid;
- },
- this
- );
-
- this.dateValidate.subscribe(function() {
- const id = 'buckaroo_magento2_capayablein3_DoB';
- const isValid = $(`#${id}`).valid();
- let state = this.validationState();
- state[id] = isValid;
- this.validationState(state);
- }, this);
-
return this;
},
- getActiveFields() {
- let fields = [
- 'buckaroo_magento2_capayablein3_DoB',
- ];
- if(this.showPhone()) {
- fields.push('buckaroo_magento2_capayablein3_Telephone');
- }
- return fields;
- },
-
- validateField(data, event) {
- const isValid = $(event.target).valid();
- let state = this.validationState();
- state[event.target.id] = isValid;
- this.validationState(state);
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.capayablein3.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- },
-
- validate: function () {
- return $('.' + this.getCode() + ' .payment-method-second-col form').valid();
- },
- getData : function() {
+ getData : function () {
let telephone = quote.billingAddress().telephone;
if (validPhone(this.phone())) {
telephone = this.phone();
diff --git a/view/frontend/web/js/view/payment/method-renderer/capayablepostpay.js b/view/frontend/web/js/view/payment/method-renderer/capayablepostpay.js
index 81a64e4e3..6e80412fa 100644
--- a/view/frontend/web/js/view/payment/method-renderer/capayablepostpay.js
+++ b/view/frontend/web/js/view/payment/method-renderer/capayablepostpay.js
@@ -20,27 +20,15 @@
/*global define*/
define(
[
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
+ 'buckaroo/checkout/payment/default',
'Magento_Checkout/js/model/quote',
'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common',
'buckaroo/checkout/datepicker'
],
function (
- $,
Component,
- additionalValidators,
- placeOrderAction,
quote,
ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon,
datePicker
) {
'use strict';
@@ -62,23 +50,8 @@ define(
value:''
},
redirectAfterPlaceOrder: true,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.capayablepostpay.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.capayablepostpay.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('capayablepostpay'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
dp: datePicker,
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
initObservable: function () {
this._super().observe([
@@ -99,7 +72,7 @@ define(
function () {
return quote.billingAddress() !== null &&
quote.billingAddress().countryId == 'NL' &&
- window.checkoutConfig.payment.buckaroo.capayablepostpay.showFinancialWarning
+ this.buckaroo.showFinancialWarning
},
this
);
@@ -115,7 +88,7 @@ define(
/**
* Observe customer first & lastname and bind them together, so they could appear in the frontend
*/
- this.updateBillingName = function(firstname, lastname) {
+ this.updateBillingName = function (firstname, lastname) {
this.firstName = firstname;
this.lastName = lastname;
@@ -134,7 +107,7 @@ define(
}
quote.billingAddress.subscribe(
- function(newAddress) {
+ function (newAddress) {
if (this.getCode() === this.isChecked() &&
newAddress &&
newAddress.getKey() &&
@@ -145,98 +118,11 @@ define(
}.bind(this)
);
- /**
- * Validation on the input fields
- */
- var runValidation = function () {
- $('.' + this.getCode() + ' .payment [data-validate]').filter(':not([name*="agreement"])').valid();
- };
-
- this.genderValidate.subscribe(runValidation,this);
- this.dateValidate.subscribe(runValidation,this);
- this.CocNumber.subscribe(runValidation,this);
- this.CompanyName.subscribe(runValidation,this);
-
- this.buttoncheck = ko.computed(function () {
- var validation = this.selectedGender() !== null &&
- this.genderValidate() !== null &&
- this.BillingName() !== null &&
- this.dateValidate() !== null;
-
- if (this.selectedOrderAs() == 2 || this.selectedOrderAs() == 3) {
- validation = validation && this.CocNumber() !== null && this.CompanyName() !== null;
- }
-
- return (validation && this.validate());
- }, this);
return this;
},
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
-
- if (quote.billingAddress()) {
- this.updateBillingName(quote.billingAddress().firstname, quote.billingAddress().lastname);
- }
-
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.capayablepostpay.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- },
-
- validate: function () {
- return $('.' + this.getCode() + ' .payment [data-validate]:not([name*="agreement"])').valid();
- },
-
- getData : function() {
+ getData : function () {
return {
"method" : this.item.method,
"additional_data": {
diff --git a/view/frontend/web/js/view/payment/method-renderer/creditcard.js b/view/frontend/web/js/view/payment/method-renderer/creditcard.js
index 4a98227f4..8603d8c7b 100644
--- a/view/frontend/web/js/view/payment/method-renderer/creditcard.js
+++ b/view/frontend/web/js/view/payment/method-renderer/creditcard.js
@@ -20,191 +20,35 @@
/*global define*/
define(
[
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'mage/translate',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
+ 'buckaroo/checkout/payment/default',
],
function (
- $,
Component,
- additionalValidators,
- placeOrderAction,
- ko,
- $t,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
) {
'use strict';
return Component.extend(
{
defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_creditcard'
+ template: 'Buckaroo_Magento2/payment/buckaroo_magento2_creditcard',
+ selectedCard: null
},
- creditcards: [],
- groupCreditcards: false,
redirectAfterPlaceOrder: false,
- creditcardIssuer: null,
- selectedBank: null,
- selectedBankDropDown: null,
- selectionType: null,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.creditcard.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.creditcard.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('creditcard'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
- paymentFlow : window.checkoutConfig.payment.buckaroo.creditcard.paymentFlow,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
- return this._super(options);
- },
-
initObservable: function () {
- this._super().observe(['selectedCard', 'creditcards', 'selectionType']);
-
- this.creditcards = ko.observableArray(window.checkoutConfig.payment.buckaroo.creditcard.cards);
-
- this.selectionType = window.checkoutConfig.payment.buckaroo.creditcard.selectionType;
-
- /**
- * observe radio buttons
- * check if selected
- */
- var self = this;
- this.setSelectedCard = function (value) {
- self.selectedCard(value);
- return true;
- };
-
- /**
- * Check if the required fields are filled. If so: enable place order button (true) | ifnot: disable place order button (false)
- */
- this.buttoncheck = ko.computed(
- function () {
- return this.selectedCard();
- },
- this
- );
-
- $('.iosc-place-order-button').on('click', function(e){
- if(self.selectedCard() == null){
- self.messageContainer.addErrorMessage({'message': $t('You need select a card')});
- }
- });
-
+ this._super().observe(['selectedCard']);
return this;
},
- setSelectedBankDropDown: function() {
- var el = document.getElementById("buckaroo_magento2_creditcard_issuer");
- this.selectedCard(el.options[el.selectedIndex].value);
- return true;
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- isCheckedCreditCardPaymentMethod: function (code) {
- return ((this.creditcardIssuer !== undefined) && this.creditcardIssuer == code);
- },
-
- selectCreditCardPaymentMethod: function (code) {
- this.setSelectedCard(code);
- this.item.method = 'buckaroo_magento2_creditcard';
- this.paymentMethod = this.item.method;
- this.selectPaymentMethod();
- return true;
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- isCredicardGroupMode: function () {
- return window.checkoutConfig.payment.buckaroo.creditcard.groupCreditcards === '1';
- },
getData: function () {
- var selectedCardCode = null;
- if (this.selectedCard()) {
- selectedCardCode = typeof this.selectedCard() === 'object' ?
- this.selectedCard().code :
- this.selectedCard();
- }
-
- if(this.creditcardIssuer){
- selectedCardCode = this.creditcardIssuer;
- }
-
return {
"method": this.item.method,
"po_number": null,
"additional_data": {
- "card_type" : selectedCardCode
+ "card_type": this.selectedCard()
}
};
},
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.creditcard.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
-
}
);
}
diff --git a/view/frontend/web/js/view/payment/method-renderer/creditcards.js b/view/frontend/web/js/view/payment/method-renderer/creditcards.js
index 09b647898..0837cec47 100644
--- a/view/frontend/web/js/view/payment/method-renderer/creditcards.js
+++ b/view/frontend/web/js/view/payment/method-renderer/creditcards.js
@@ -21,13 +21,10 @@
define(
[
'jquery',
- 'Magento_Checkout/js/view/payment/default',
+ 'buckaroo/checkout/payment/default',
'Magento_Checkout/js/model/payment/additional-validators',
'Buckaroo_Magento2/js/action/place-order',
'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common',
'BuckarooClientSideEncryption'
],
function (
@@ -36,56 +33,48 @@ define(
additionalValidators,
placeOrderAction,
ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
) {
'use strict';
-
+
/**
* Add validation methods
*/
$.validator.addMethod('validateCardNumber', function (value) {
return BuckarooClientSideEncryption.V001.validateCardNumber(value.replace(/\s+/g, ''));
- },
- $.mage.__('Please enter a valid creditcard number.')
- );
+ },
+ $.mage.__('Please enter a valid creditcard number.'));
$.validator.addMethod('validateCvc', function (value) {
return BuckarooClientSideEncryption.V001.validateCvc(
- value,
+ value,
$('#buckaroo_magento2_creditcards_issuer').val()
);
- },
- $.mage.__('Please enter a valid Cvc number.')
- );
+ },
+ $.mage.__('Please enter a valid Cvc number.'));
$.validator.addMethod('validateCardHolderName', function (value) {
return BuckarooClientSideEncryption.V001.validateCardholderName(value);
- },
- $.mage.__('Please enter a valid card holder name.')
- );
+ },
+ $.mage.__('Please enter a valid card holder name.'));
$.validator.addMethod('bkValidateYear', function (value) {
- if(value.length === 0) {
- return false;
- }
+ if (value.length === 0) {
+ return false;
+ }
const parts = value.split("/");
return BuckarooClientSideEncryption.V001.validateYear(parts[1]);
- },
- $.mage.__('Enter a valid year number.')
- );
+ },
+ $.mage.__('Enter a valid year number.'));
$.validator.addMethod('bkValidateMonth', function (value) {
- if(value.length === 0) {
- return false;
- }
+ if (value.length === 0) {
+ return false;
+ }
const parts = value.split("/");
return BuckarooClientSideEncryption.V001.validateMonth(parts[0]);
- },
- $.mage.__('Enter a valid month number.')
- );
+ },
+ $.mage.__('Enter a valid month number.'));
return Component.extend(
{
@@ -97,27 +86,6 @@ define(
expireDate : '',
encryptedCardData : null,
cardIssuer : null,
- validationState : {},
- issuerImage : window.checkoutConfig.payment.buckaroo.creditcards.defaultCardImage
- },
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.creditcards.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.creditcards.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('creditcards'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
- creditcards : window.checkoutConfig.payment.buckaroo.creditcards.creditcards,
- defaultCardImage : window.checkoutConfig.payment.buckaroo.creditcards.defaultCardImage,
- isTestMode: window.checkoutConfig.payment.buckaroo.creditcards.isTestMode,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
},
initObservable: function () {
@@ -128,8 +96,7 @@ define(
'cvc',
'cardHolderName',
'expireDate',
- 'cardIssuer',
- 'validationState'
+ 'cardIssuer'
]
);
@@ -137,7 +104,7 @@ define(
this.formatedCardNumber = ko.computed({
read: function () {
let cardNumber = this.cardNumber();
- if(cardNumber.length) {
+ if (cardNumber.length) {
return this.cardNumber().match(new RegExp('.{1,4}', 'g')).join(" ");
}
return '';
@@ -151,22 +118,29 @@ define(
this.formatedExpirationDate = ko.computed({
read: function () {
let expireDate = this.expireDate();
- if(expireDate.length) {
+ if (expireDate.length) {
return expireDate.replace(
- /^([1-9]\/|[2-9])$/g, '0$1/' // 3 > 03/
- ).replace(
- /^(0[1-9]|1[0-2])$/g, '$1/' // 11 > 11/
- ).replace(
- /^([0-1])([3-9])$/g, '0$1/$2' // 13 > 01/3
- ).replace(
- /^(0?[1-9]|1[0-2])([0-9]{2})$/g, '$1/$2' // 141 > 01/41
- ).replace(
- /^([0]+)\/|[0]+$/g, '0' // 0/ > 0 and 00 > 0
- ).replace(
- /[^\d\/]|^[\/]*$/g, '' // To allow only digits and `/`
- ).replace(
- /\/\//g, '/' // Prevent entering more than 1 `/`
- );
+ /^([1-9]\/|[2-9])$/g,
+ '0$1/' // 3 > 03/
+ ).replace(
+ /^(0[1-9]|1[0-2])$/g,
+ '$1/' // 11 > 11/
+ ).replace(
+ /^([0-1])([3-9])$/g,
+ '0$1/$2' // 13 > 01/3
+ ).replace(
+ /^(0?[1-9]|1[0-2])([0-9]{2})$/g,
+ '$1/$2' // 141 > 01/41
+ ).replace(
+ /^(0+\/|0+)$/g,
+ '0' // 0/ > 0 and 00 > 0
+ ).replace(
+ /[^\d\/]|^[\/]*$/g,
+ '' // To allow only digits and `/`
+ ).replace(
+ /\/\//g,
+ '/' // Prevent entering more than 1 `/`
+ );
}
return '';
},
@@ -175,18 +149,18 @@ define(
},
owner: this
});
-
+
this.issuerImage = ko.computed(
function () {
- var cardLogo = this.defaultCardImage;
+ var cardLogo = this.buckaroo.defaultCardImage;
- var issuer = this.creditcards.find(o => o.code === this.cardIssuer());
+ var issuer = this.buckaroo.creditcards.find(o => o.code === this.cardIssuer());
if (issuer) {
cardLogo = issuer.img;
}
- return cardLogo;
+ return cardLogo;
},
this
);
@@ -194,6 +168,31 @@ define(
return this;
},
+ placeOrder: function (data, event) {
+ var self = this,
+ placeOrder;
+
+ if (event) {
+ event.preventDefault();
+ }
+
+ if (this.validate() && additionalValidators.validate()) {
+ this.isPlaceOrderActionAllowed(false);
+ this.encryptCardData().then(function() {
+ console.log('here');
+ placeOrder = placeOrderAction(self.getData(), self.redirectAfterPlaceOrder, self.messageContainer);
+
+ $.when(placeOrder).fail(
+ function () {
+ self.isPlaceOrderActionAllowed(true);
+ }
+ ).done(self.afterPlaceOrder.bind(self));
+ })
+ return true;
+ }
+ return false;
+ },
+
validateCardNumber(data, event) {
this.validateField(data, event);
@@ -204,17 +203,11 @@ define(
)
//validate the cvc if exists
- if(this.cvc().length) {
+ if (this.cvc().length) {
$('#buckaroo_magento2_creditcards_cvc').valid();
}
},
- validateField(data, event) {
- const isValid = $(event.target).valid();
- let state = this.validationState();
- state[event.target.id] = isValid;
- this.validationState(state);
- },
/** Get the card issuer based on the creditcard number **/
determineIssuer: function (cardNumber) {
@@ -254,67 +247,6 @@ define(
return false;
},
- validate: function () {
- return $('.' + this.getCode() + ' .payment-method-second-col form').valid();
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.creditcards.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- placeOrder: function (data, event) {
- var self = this,
- placeOrder;
-
- if (event) {
- event.preventDefault();
- }
-
- if (this.validate() && additionalValidators.validate()) {
- this.isPlaceOrderActionAllowed(false);
- this.encryptCardData().then(function() {
- placeOrder = placeOrderAction(self.getData(), self.redirectAfterPlaceOrder, self.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(self.afterPlaceOrder.bind(self));
- })
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
getData: function() {
let cardIssuer = this.cardIssuer();
@@ -332,7 +264,7 @@ define(
},
encryptCardData: function () {
- return new Promise(function(resolve) {
+ return new Promise(function (resolve) {
const parts = this.expireDate().split("/");
const month = parts[0];
const year = parts[1];
@@ -343,14 +275,15 @@ define(
month,
this.cvc(),
this.cardHolderName(),
- function(encryptedCardData) {
+ function (encryptedCardData) {
this.encryptedCardData = encryptedCardData;
resolve()
}.bind(this));
}.bind(this))
},
+
setTestParameters() {
- if (this.isTestMode) {
+ if (this.buckaroo.isTestMode) {
this.cardNumber('4563550000000005')
this.cardIssuer('visa')
this.cardHolderName('Test Acceptation')
diff --git a/view/frontend/web/js/view/payment/method-renderer/alipay.js b/view/frontend/web/js/view/payment/method-renderer/default.js
similarity index 74%
rename from view/frontend/web/js/view/payment/method-renderer/alipay.js
rename to view/frontend/web/js/view/payment/method-renderer/default.js
index ecab04dfd..fb8027263 100644
--- a/view/frontend/web/js/view/payment/method-renderer/alipay.js
+++ b/view/frontend/web/js/view/payment/method-renderer/default.js
@@ -24,7 +24,6 @@ define(
'Magento_Checkout/js/view/payment/default',
'Magento_Checkout/js/model/payment/additional-validators',
'Buckaroo_Magento2/js/action/place-order',
- 'ko',
'Magento_Checkout/js/checkout-data',
'Magento_Checkout/js/action/select-payment-method',
'buckaroo/checkout/common'
@@ -34,7 +33,6 @@ define(
Component,
additionalValidators,
placeOrderAction,
- ko,
checkoutData,
selectPaymentMethodAction,
checkoutCommon
@@ -44,14 +42,11 @@ define(
return Component.extend(
{
defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_alipay'
+ template: 'Buckaroo_Magento2/payment/default'
},
- redirectAfterPlaceOrder: false,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.alipay.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.alipay.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('alipay'),
currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
+ config: null,
/**
* @override
@@ -61,7 +56,9 @@ define(
window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
}
- return this._super(options);
+ const init = this._super(options);
+
+ return init;
},
/**
@@ -107,7 +104,7 @@ define(
},
payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.alipay.allowedCurrencies;
+ var allowedCurrencies = this.buckaroo.allowedCurrencies;
return allowedCurrencies.indexOf(this.currencyCode) < 0;
},
@@ -116,16 +113,40 @@ define(
var text = $.mage.__('The transaction will be processed using %s.');
return text.replace('%s', this.baseCurrencyCode);
+ },
+
+ validate: function () {
+ const form = $('.' + this.getCode() + ' .payment-method-second-col form');
+ if (form.length) {
+ return form.valid();
+ }
+ return true;
+ },
+
+ validateField(data, event) {
+ $(event.target).valid();
+ },
+
+ getSubtextStyle: function () {
+ let config = this.buckaroo;
+ if (config === undefined) {
+ return;
+ }
+ let subtextColor = config.subtext_color || '#757575';
+ let subtextStyle = config.subtext_style || 'regular';
+
+ let style = { color: subtextColor }
+ if (subtextStyle == 'bold') {
+ style.fontWeight = 'bold';
+ }
+
+ if (subtextStyle == 'italic') {
+ style.fontStyle = 'italic';
+ }
+ return style;
}
+
}
);
}
);
-
-
-
-
-
-
-
-
diff --git a/view/frontend/web/js/view/payment/method-renderer/emandate.js b/view/frontend/web/js/view/payment/method-renderer/emandate.js
deleted file mode 100644
index c4d0dc68a..000000000
--- a/view/frontend/web/js/view/payment/method-renderer/emandate.js
+++ /dev/null
@@ -1,166 +0,0 @@
-/**
- * NOTICE OF LICENSE
- *
- * This source file is subject to the MIT License
- * It is available through the world-wide-web at this URL:
- * https://tldrlegal.com/license/mit-license
- * If you are unable to obtain it through the world-wide-web, please send an email
- * to support@buckaroo.nl so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this module to newer
- * versions in the future. If you wish to customize this module for your
- * needs please contact support@buckaroo.nl for more information.
- *
- * @copyright Copyright (c) Buckaroo B.V.
- * @license https://tldrlegal.com/license/mit-license
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
- ],
- function (
- $,
- Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
- ) {
- 'use strict';
-
- return Component.extend(
- {
- defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_emandate'
- },
- banktypes: [],
- redirectAfterPlaceOrder: false,
- selectedBank: null,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.emandate.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.emandate.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('emandate'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- initObservable: function () {
- this._super().observe(['selectedBank', 'banktypes']);
-
- this.banktypes = ko.observableArray(window.checkoutConfig.payment.buckaroo.emandate.banks);
-
- /** observe radio buttons, check if they're selected */
- var self = this;
- this.setSelectedBank = function (value) {
- self.selectedBank(value);
- return true;
- };
-
- /** Check if the required fields are filled.
- * If so: enable place order button (true) | if not: disable place order button (false)
- */
- this.buttoncheck = ko.computed(
- function () {
- return this.selectedBank() !== null;
- },
- this
- );
-
- return this;
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- getData: function () {
- var selectedBankCode = null;
- if (this.selectedBank()) {
- selectedBankCode = this.selectedBank().code;
- }
-
- return {
- "method": this.item.method,
- "po_number": null,
- "additional_data": {
- "issuer" : selectedBankCode
- }
- };
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.emandate.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
-
- }
- );
- }
-);
diff --git a/view/frontend/web/js/view/payment/method-renderer/eps.js b/view/frontend/web/js/view/payment/method-renderer/eps.js
deleted file mode 100644
index 98233a62c..000000000
--- a/view/frontend/web/js/view/payment/method-renderer/eps.js
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * NOTICE OF LICENSE
- *
- * This source file is subject to the MIT License
- * It is available through the world-wide-web at this URL:
- * https://tldrlegal.com/license/mit-license
- * If you are unable to obtain it through the world-wide-web, please send an email
- * to support@buckaroo.nl so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this module to newer
- * versions in the future. If you wish to customize this module for your
- * needs please contact support@buckaroo.nl for more information.
- *
- * @copyright Copyright (c) Buckaroo B.V.
- * @license https://tldrlegal.com/license/mit-license
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
- ],
- function (
- $,
- Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
- ) {
- 'use strict';
-
- return Component.extend(
- {
- defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_eps'
- },
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.eps.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.eps.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('eps'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.eps.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
-
- }
- );
- }
-);
-
-
-
-
-
-
-
-
diff --git a/view/frontend/web/js/view/payment/method-renderer/giftcards.js b/view/frontend/web/js/view/payment/method-renderer/giftcards.js
index 71323ce8f..806cc193a 100644
--- a/view/frontend/web/js/view/payment/method-renderer/giftcards.js
+++ b/view/frontend/web/js/view/payment/method-renderer/giftcards.js
@@ -21,21 +21,13 @@
define(
[
'jquery',
- 'Magento_Checkout/js/view/payment/default',
+ 'buckaroo/checkout/payment/default',
'Magento_Checkout/js/model/payment/additional-validators',
'Buckaroo_Magento2/js/action/place-order',
'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'Magento_Checkout/js/model/quote',
- 'Magento_Ui/js/model/messageList',
'mage/translate',
'mage/url',
- 'Magento_Checkout/js/action/get-totals',
- 'Magento_Customer/js/customer-data',
- 'Magento_Checkout/js/model/payment-service',
'Magento_Ui/js/modal/alert',
- 'buckaroo/checkout/common'
],
function (
$,
@@ -43,32 +35,26 @@ define(
additionalValidators,
placeOrderAction,
ko,
- checkoutData,
- selectPaymentMethodAction,
- quote,
- globalMessageList,
$t,
url,
- getTotalsAction,
- customerData,
- paymentService,
alert,
- checkoutCommon
) {
'use strict';
- function checkLabels(){
- $.each($('.buckaroo_magento2_image_title span'), function(key, item){
+ function checkLabels()
+ {
+ $.each($('.buckaroo_magento2_image_title span'), function (key, item) {
var label = $(item).html(),
label_part = label.split(' + ');
$(item).html(label_part[0]);
});
}
- function checkPayments(){
- var p = ["billink","klarnakp","capayableinstallments","sofortbanking","giropay","transfer","sepadirectdebit","capayablein3","creditcard","mrcash","payperemail","emandate"];
- p.forEach(function(item) {
- $('.buckaroo_magento2_'+item).remove();
+ function checkPayments()
+ {
+ var p = ["billink","klarnakp","capayableinstallments","sofortbanking","giropay","transfer","sepadirectdebit","capayablein3","creditcard","mrcash","payperemail"];
+ p.forEach(function (item) {
+ $('.buckaroo_magento2_' + item).remove();
});
$('.buckaroo_magento2_flow_authorize').remove();
checkLabels();
@@ -77,78 +63,27 @@ define(
return Component.extend(
{
defaults: {
- alreadyFullPayed : null,
- CardNumber: null,
- Pin: null,
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_giftcards'
+ template: 'Buckaroo_Magento2/payment/buckaroo_magento2_giftcards',
+ alreadyFullPayed : false,
+ cardNumber: null,
+ pin: null,
+ currentGiftcard: null
},
- giftcards: [],
- allgiftcards: [],
redirectAfterPlaceOrder: false,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.giftcards.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.giftcards.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('giftcards'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
- currentGiftcard : false,
- alreadyPayed : false,
- isTestMode: window.checkoutConfig.payment.buckaroo.giftcards.isTestMode,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
initObservable: function () {
- this._super().observe(['alreadyFullPayed','CardNumber','Pin','allgiftcards']);
-
- this.allgiftcards = ko.observableArray(window.checkoutConfig.payment.buckaroo.avaibleGiftcards);
-
- var self = this;
- this.setCurrentGiftcard = function (value) {
- self.currentGiftcard = value;
- this.setTestParameters(value)
- return true;
- };
-
-/* quote.totals._latestValue.total_segments.forEach(function(item) {
- if(item.code == 'buckaroo_already_paid' && quote.totals._latestValue.grand_total == 0.001){
- self.alreadyPayed = true;
- self.alreadyFullPayed(true);
- }
- });
-*/
- /** Check used to see if input is valid **/
- this.buttoncheck = ko.computed(
- function () {
- return (
- this.alreadyFullPayed() !== null
- );
- },
- this
- );
+ this._super().observe(['alreadyFullPayed','cardNumber','pin', 'currentGiftcard']);
return this;
},
- getGiftcardType: ko.observable(function () {
- return this.currentGiftcard;
- }),
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
+ /**
+ * Place order.
+ *
+ * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
+ * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
+ */
placeOrder: function (data, event) {
-
var self = this,
placeOrder;
@@ -157,7 +92,6 @@ define(
}
if (this.validate() && additionalValidators.validate()) {
-
//mageplaza only check
if (document.querySelector('#checkoutSteps.opc.one-step-checkout-container .place-order-primary button.checkout')) {
if (data || event) {
@@ -179,75 +113,39 @@ define(
},
afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
-
- if(this.alreadyPayed){
+ this._super();
+ if (this.alreadyFullPayed()) {
window.location.replace(url.build('checkout/onepage/success/'));
}
-
- },
-
- isCheckedGiftCardPaymentMethod: function (code) {
- return ((this.currentGiftcard !== undefined) && this.currentGiftcard == code);
- },
-
- selectGiftCardPaymentMethod: function (code) {
- this.setCurrentGiftcard(code);
- this.getGiftcardType(code);
- this.item.method = 'buckaroo_magento2_giftcards';
- this.paymentMethod = this.item.method;
- window.checkoutConfig.buckarooFee.title('Fee');
- selectPaymentMethodAction({
- "method": this.item.method,
- "additional_data": {
- "giftcard_method" : code
- }
- });
- checkoutData.setSelectedPaymentMethod(this.item.method);
- this.checkValidness();
- return true;
},
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
+ validate: function() {
+ return this.alreadyFullPayed() === true || this.buckaroo.groupGiftcards === true;
},
- isGiftcardsRedirectMode: function () {
- return window.checkoutConfig.payment.buckaroo.groupGiftcards !== undefined && window.checkoutConfig.payment.buckaroo.groupGiftcards == 1 ? true : false;
+ validateForm: function () {
+ return $('.buckaroo_magento2_' + this.currentGiftcard() + ' .payment-method-second-col form').valid();
},
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.giftcards.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
+ selectGiftCardPaymentMethod: function (code) {
+ this.selectPaymentMethod();
+ this.setTestParameters(code);
},
-
+
getData: function () {
return {
"method": this.item.method,
"po_number": null,
"additional_data": {
- "giftcard_method" : (this.currentGiftcard !== undefined) ? this.currentGiftcard : null
+ "giftcard_method" : this.currentGiftcard()
}
};
},
- alreadyFullPayed: function (state = false) {
- return state;
- },
-
- applyGiftcard: function (data, event) {
+ applyGiftcard: function () {
+ if (!this.validateForm()) {
+ return;
+ }
self = this;
$.ajax({
@@ -257,111 +155,64 @@ define(
showLoader: true, //use for display loader
data: {
card: self.currentGiftcard,
- cardNumber: self.CardNumber._latestValue,
- pin: self.Pin._latestValue
+ cardNumber: self.cardNumber(),
+ pin: self.pin()
}
- }).done(function (data) {
+ }).done(function (data) {
+ self.cardNumber('');
+ self.pin('');
- $('.buckaroo_magento2_giftcards_input').val('');
- self.CardNumber('');
- self.Pin('');
- self.checkValidness();
-
- if(data.alreadyPaid){
- if(data.RemainderAmount == 0){
- self.alreadyPayed = true;
+ if (data.alreadyPaid) {
+ if (data.RemainderAmount == 0) {
self.alreadyFullPayed(true);
self.placeOrder(null, null);
}
-
- /* Totals summary reloading */
- // var deferred = $.Deferred();
- // getTotalsAction([], deferred);
- $('.buckaroo_magento2_'+self.currentGiftcard+' input[name="payment[method]"]').click();
-
checkPayments();
}
- if(data.error){
+ if (data.error) {
alert({
title: $t('Error'),
content: $t(data.error),
- actions: {always: function(){} }
+ actions: {always: function (){} }
});
- self.messageContainer.addErrorMessage({'message': $t(data.error)});
- }else{
- if(data.RemainderAmount != 0){
+ self.messageContainer.addErrorMessage({'message': $t(data.error)});
+ } else {
+ if (data.RemainderAmount != 0) {
+ checkPayments();
alert({
title: $t('Success'),
content: $t(data.message),
- actions: {always: function(){} },
+ actions: {always: function (){} },
buttons: [{
- text: $t(data.PayRemainingAmountButton),
- class: 'action primary accept',
+ text: $t(data.PayRemainingAmountButton),
+ class: 'action primary accept',
click: function () {
this.closeModal(true);
}
}]
});
}
- self.messageContainer.addSuccessMessage({'message': $t(data.message)});
+ self.messageContainer.addSuccessMessage({'message': $t(data.message)});
}
-
- $('.buckaroo_magento2_'+self.currentGiftcard+' input[name="payment[method]"]').click();
-
});
},
- checkForPayments: function () {
- setTimeout(function() {
- quote.totals._latestValue.total_segments.forEach(function(item) {
- if(item.code == 'buckaroo_already_paid' && Math.abs(Math.round(item.value)) > 0){
- checkPayments();
- }
- });
- }, 500);
- },
- checkValidness: function () {
- var pfx = 'buckaroo_magento2_giftcards_';
- var currentCode;
- if (this.currentGiftcard) {
- currentCode = this.currentGiftcard;
- } else {
- currentCode = this.code;
- }
- var submitBtn = document.getElementById(pfx+ 'submit_' + currentCode);
-
- if (
- document.getElementById(pfx+ 'cardnumber_' + currentCode)
- &&
- document.getElementById(pfx+ 'cardnumber_' + currentCode).value
- &&
- document.getElementById(pfx+ 'pin_' + currentCode)
- &&
- document.getElementById(pfx+ 'pin_' + currentCode).value
- ) {
- if (submitBtn) {
- submitBtn.classList.remove("disabled");
- }
- return true;
- } else {
- if (submitBtn) {
- submitBtn.classList.add("disabled");
- }
- return false;
- }
- },
setTestParameters(giftcardCode) {
- if (this.isTestMode && !this.isGiftcardsRedirectMode()) {
+ let cardNumber =''
+ let pin = '';
+ if (this.buckaroo.isTestMode && !this.buckaroo.groupGiftcards) {
if (["boekenbon","vvvgiftcard","yourgift","customgiftcard","customgiftcard1","customgiftcard2"].indexOf(giftcardCode) !== -1) {
- this.CardNumber('0000000000000000001')
- this.Pin('1000')
+ cardNumber = '0000000000000000001';
+ pin = '1000';
}
if (giftcardCode === 'fashioncheque') {
- this.CardNumber('1000001000')
- this.Pin('2000')
+ cardNumber = '1000001000';
+ pin = '2000';
}
}
+ this.cardNumber(cardNumber);
+ this.pin(pin);
}
}
);
diff --git a/view/frontend/web/js/view/payment/method-renderer/giropay.js b/view/frontend/web/js/view/payment/method-renderer/giropay.js
deleted file mode 100644
index 6546e87ed..000000000
--- a/view/frontend/web/js/view/payment/method-renderer/giropay.js
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * NOTICE OF LICENSE
- *
- * This source file is subject to the MIT License
- * It is available through the world-wide-web at this URL:
- * https://tldrlegal.com/license/mit-license
- * If you are unable to obtain it through the world-wide-web, please send an email
- * to support@buckaroo.nl so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this module to newer
- * versions in the future. If you wish to customize this module for your
- * needs please contact support@buckaroo.nl for more information.
- *
- * @copyright Copyright (c) Buckaroo B.V.
- * @license https://tldrlegal.com/license/mit-license
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
- ],
- function (
- $,
- Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
- ) {
- 'use strict';
-
- return Component.extend(
- {
- defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_giropay'
- },
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.giropay.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.giropay.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('giropay'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.giropay.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
- }
- );
- }
-);
diff --git a/view/frontend/web/js/view/payment/method-renderer/ideal.js b/view/frontend/web/js/view/payment/method-renderer/ideal.js
index 050951b52..3ae24f2d0 100644
--- a/view/frontend/web/js/view/payment/method-renderer/ideal.js
+++ b/view/frontend/web/js/view/payment/method-renderer/ideal.js
@@ -20,172 +20,36 @@
/*global define*/
define(
[
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'mage/translate',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
+ 'buckaroo/checkout/payment/default',
],
function (
- $,
Component,
- additionalValidators,
- placeOrderAction,
- ko,
- $t,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
) {
'use strict';
return Component.extend(
{
defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_ideal'
+ template: 'Buckaroo_Magento2/payment/buckaroo_magento2_ideal',
+ selectedBank: null,
},
- banktypes: [],
redirectAfterPlaceOrder: false,
- idealIssuer: null,
- selectedBank: null,
- selectedBankDropDown: null,
- selectionType: null,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.ideal.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.ideal.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('ideal'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
- showIssuers : window.checkoutConfig.payment.buckaroo.ideal.showIssuers,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
initObservable: function () {
- this._super().observe(['selectedBank', 'banktypes', 'selectionType']);
-
- this.banktypes = ko.observableArray(window.checkoutConfig.payment.buckaroo.ideal.banks);
-
- this.selectionType = window.checkoutConfig.payment.buckaroo.ideal.selectionType;
-
- /**
- * observe radio buttons
- * check if selected
- */
- var self = this;
- this.setSelectedBank = function (value) {
- self.selectedBank(value);
- return true;
- };
-
- /**
- * Check if the required fields are filled. If so: enable place order button (true) | ifnot: disable place order button (false)
- */
- this.buttoncheck = ko.computed(
- function () {
- return this.selectedBank() !== null || !this.showIssuers;
- },
- this
- );
-
- $('.iosc-place-order-button').on('click', function(e){
- if(self.selectedBank() == null){
- self.messageContainer.addErrorMessage({'message': $t('You need select a bank')});
- }
- });
-
+ this._super().observe(['selectedBank']);
return this;
},
- setSelectedBankDropDown: function() {
- var el = document.getElementById("buckaroo_magento2_ideal_issuer");
- this.selectedBank(el.options[el.selectedIndex].value);
- return true;
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
getData: function () {
- var selectedBankCode = null;
- if (this.selectedBank()) {
- selectedBankCode = this.selectedBank().code;
- }
-
- if(this.idealIssuer){
- selectedBankCode = this.idealIssuer;
- }
-
return {
"method": this.item.method,
"po_number": null,
"additional_data": {
- "issuer" : selectedBankCode
+ "issuer": this.selectedBank()
}
};
},
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.ideal.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
}
);
}
diff --git a/view/frontend/web/js/view/payment/method-renderer/idealprocessing.js b/view/frontend/web/js/view/payment/method-renderer/idealprocessing.js
deleted file mode 100644
index 287b7fe3d..000000000
--- a/view/frontend/web/js/view/payment/method-renderer/idealprocessing.js
+++ /dev/null
@@ -1,191 +0,0 @@
-/**
- * NOTICE OF LICENSE
- *
- * This source file is subject to the MIT License
- * It is available through the world-wide-web at this URL:
- * https://tldrlegal.com/license/mit-license
- * If you are unable to obtain it through the world-wide-web, please send an email
- * to support@buckaroo.nl so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this module to newer
- * versions in the future. If you wish to customize this module for your
- * needs please contact support@buckaroo.nl for more information.
- *
- * @copyright Copyright (c) Buckaroo B.V.
- * @license https://tldrlegal.com/license/mit-license
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'mage/translate',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
- ],
- function (
- $,
- Component,
- additionalValidators,
- placeOrderAction,
- ko,
- $t,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
- ) {
- 'use strict';
-
- return Component.extend(
- {
- defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_idealprocessing'
- },
- banktypes: [],
- redirectAfterPlaceOrder: false,
- idealIssuer: null,
- selectedBank: null,
- selectedBankDropDown: null,
- selectionType: null,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.idealprocessing.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.idealprocessing.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('idealprocessing'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
- showIssuers : window.checkoutConfig.payment.buckaroo.idealprocessing.showIssuers,
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- initObservable: function () {
- this._super().observe(['selectedBank', 'banktypes', 'selectionType']);
-
- this.banktypes = ko.observableArray(window.checkoutConfig.payment.buckaroo.idealprocessing.banks);
-
- this.selectionType = window.checkoutConfig.payment.buckaroo.idealprocessing.selectionType;
-
- /**
- * observe radio buttons
- * check if selected
- */
- var self = this;
- this.setSelectedBank = function (value) {
- self.selectedBank(value);
- return true;
- };
-
- /**
- * Check if the required fields are filled. If so: enable place order button (true) | ifnot: disable place order button (false)
- */
- this.buttoncheck = ko.computed(
- function () {
- return this.selectedBank() !== null || !this.showIssuers;
- },
- this
- );
-
- $('.iosc-place-order-button').on('click', function(e){
- if(self.selectedBank() == null){
- self.messageContainer.addErrorMessage({'message': $t('You need select a bank')});
- }
- });
-
- return this;
- },
-
- setSelectedBankDropDown: function() {
- var el = document.getElementById("buckaroo_magento2_idealp_issuer");
- this.selectedBank(el.options[el.selectedIndex].valu);
- return true;
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- getData: function () {
- var selectedBankCode = null;
- if (this.selectedBank()) {
- selectedBankCode = this.selectedBank().code;
- }
-
- if(this.idealIssuer){
- selectedBankCode = this.idealIssuer;
- }
-
- return {
- "method": this.item.method,
- "po_number": null,
- "additional_data": {
- "issuer" : selectedBankCode
- }
- };
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.idealprocessing.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
- }
- );
- }
-);
diff --git a/view/frontend/web/js/view/payment/method-renderer/kbc.js b/view/frontend/web/js/view/payment/method-renderer/kbc.js
deleted file mode 100644
index 9f006f951..000000000
--- a/view/frontend/web/js/view/payment/method-renderer/kbc.js
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * NOTICE OF LICENSE
- *
- * This source file is subject to the MIT License
- * It is available through the world-wide-web at this URL:
- * https://tldrlegal.com/license/mit-license
- * If you are unable to obtain it through the world-wide-web, please send an email
- * to support@buckaroo.nl so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this module to newer
- * versions in the future. If you wish to customize this module for your
- * needs please contact support@buckaroo.nl for more information.
- *
- * @copyright Copyright (c) Buckaroo B.V.
- * @license https://tldrlegal.com/license/mit-license
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
- ],
- function (
- $,
- Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
- ) {
- 'use strict';
-
- return Component.extend(
- {
- defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_kbc'
- },
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.kbc.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.kbc.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('kbc'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.kbc.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
- }
- );
- }
-);
diff --git a/view/frontend/web/js/view/payment/method-renderer/klarna.js b/view/frontend/web/js/view/payment/method-renderer/klarna.js
index 44a019a89..417b4617d 100644
--- a/view/frontend/web/js/view/payment/method-renderer/klarna.js
+++ b/view/frontend/web/js/view/payment/method-renderer/klarna.js
@@ -20,25 +20,13 @@
/*global define*/
define(
[
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
+ 'buckaroo/checkout/payment/default',
'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common',
'Magento_Checkout/js/model/quote'
],
function (
- $,
Component,
- additionalValidators,
- placeOrderAction,
ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon,
quote
) {
'use strict';
@@ -49,111 +37,23 @@ define(
template: 'Buckaroo_Magento2/payment/buckaroo_magento2_klarna',
selectedGender: null,
},
- redirectAfterPlaceOrder: true,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.klarna.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.klarna.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('klarna'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
- genderList: window.checkoutConfig.payment.buckaroo.klarna.genderList,
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
+
initObservable: function () {
- this._super().observe(
- [
- 'selectedGender',
- 'genderList'
- ]
- );
-
+ this._super().observe(['selectedGender']);
+
this.showFinancialWarning = ko.computed(
function () {
return quote.billingAddress() !== null &&
quote.billingAddress().countryId == 'NL' &&
- window.checkoutConfig.payment.buckaroo.klarna.showFinancialWarning
- },
- this
- );
-
- /**
- * Check if the required fields are filled. If so: enable place order button (true) | if not: disable place order button (false)
- */
- this.buttoncheck = ko.computed(
- function () {
- return this.selectedGender() != null;
+ this.buckaroo.showFinancialWarning
},
this
);
return this;
},
- validateField(data, event) {
- $(event.target).valid();
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.klarna.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- },
-
+
getData: function () {
return {
"method": this.item.method,
diff --git a/view/frontend/web/js/view/payment/method-renderer/klarnain.js b/view/frontend/web/js/view/payment/method-renderer/klarnain.js
deleted file mode 100644
index 5047f23e7..000000000
--- a/view/frontend/web/js/view/payment/method-renderer/klarnain.js
+++ /dev/null
@@ -1,170 +0,0 @@
-/**
- * NOTICE OF LICENSE
- *
- * This source file is subject to the MIT License
- * It is available through the world-wide-web at this URL:
- * https://tldrlegal.com/license/mit-license
- * If you are unable to obtain it through the world-wide-web, please send an email
- * to support@buckaroo.nl so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this module to newer
- * versions in the future. If you wish to customize this module for your
- * needs please contact support@buckaroo.nl for more information.
- *
- * @copyright Copyright (c) Buckaroo B.V.
- * @license https://tldrlegal.com/license/mit-license
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common',
- 'Magento_Checkout/js/model/quote'
- ],
- function (
- $,
- Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon,
- quote
- ) {
- 'use strict';
-
- return Component.extend(
- {
- defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_klarnain',
- selectedGender: null,
- },
- redirectAfterPlaceOrder: false,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.klarnain.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.klarnain.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('klarnain'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
- genderList: window.checkoutConfig.payment.buckaroo.klarnain.genderList,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- initObservable: function () {
- this._super().observe(
- [
- 'selectedGender',
- ]
- );
-
- this.showFinancialWarning = ko.computed(
- function () {
- return quote.billingAddress() !== null &&
- quote.billingAddress().countryId == 'NL' &&
- window.checkoutConfig.payment.buckaroo.klarnain.showFinancialWarning
- },
- this
- );
-
- /**
- * Check if the required fields are filled. If so: enable place order button (true) | if not: disable place order button (false)
- */
- this.buttoncheck = ko.computed(
- function () {
- return this.selectedGender() != null;
- },
- this
- );
-
- return this;
- },
- validateField(data, event) {
- $(event.target).valid();
- },
-
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.klarnain.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- },
-
- getData: function () {
- return {
- "method": this.item.method,
- "po_number": null,
- "additional_data": {
- "customer_gender" : this.selectedGender()
- }
- };
- }
- }
- );
- }
-);
\ No newline at end of file
diff --git a/view/frontend/web/js/view/payment/method-renderer/klarnakp.js b/view/frontend/web/js/view/payment/method-renderer/klarnakp.js
index 4e25aee50..adbb82017 100644
--- a/view/frontend/web/js/view/payment/method-renderer/klarnakp.js
+++ b/view/frontend/web/js/view/payment/method-renderer/klarnakp.js
@@ -20,25 +20,13 @@
/*global define*/
define(
[
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
+ 'buckaroo/checkout/payment/default',
'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common',
'Magento_Checkout/js/model/quote'
],
function (
- $,
Component,
- additionalValidators,
- placeOrderAction,
ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon,
quote
) {
'use strict';
@@ -49,12 +37,6 @@ define(
template: 'Buckaroo_Magento2/payment/buckaroo_magento2_klarnakp'
},
redirectAfterPlaceOrder: false,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.klarnakp.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.klarnakp.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('klarnakp'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
- showFinancialWarning: window.checkoutConfig.payment.buckaroo.klarnakp.showFinancialWarning || true,
initObservable: function () {
this._super();
@@ -62,77 +44,14 @@ define(
function () {
return quote.billingAddress() !== null &&
quote.billingAddress().countryId == 'NL' &&
- window.checkoutConfig.payment.buckaroo.klarnakp.showFinancialWarning
+ this.buckaroo.showFinancialWarning
},
this
);
return this;
},
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.klarnakp.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
+
}
);
}
diff --git a/view/frontend/web/js/view/payment/method-renderer/knaken.js b/view/frontend/web/js/view/payment/method-renderer/knaken.js
deleted file mode 100644
index da6b47fa0..000000000
--- a/view/frontend/web/js/view/payment/method-renderer/knaken.js
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * NOTICE OF LICENSE
- *
- * This source file is subject to the MIT License
- * It is available through the world-wide-web at this URL:
- * https://tldrlegal.com/license/mit-license
- * If you are unable to obtain it through the world-wide-web, please send an email
- * to support@buckaroo.nl so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this module to newer
- * versions in the future. If you wish to customize this module for your
- * needs please contact support@buckaroo.nl for more information.
- *
- * @copyright Copyright (c) Buckaroo B.V.
- * @license https://tldrlegal.com/license/mit-license
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
- ],
- function (
- $,
- Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
- ) {
- 'use strict';
-
- return Component.extend(
- {
- defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_knaken'
- },
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.knaken.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.knaken.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('knaken'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.knaken.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
- }
- );
- }
-);
diff --git a/view/frontend/web/js/view/payment/method-renderer/mbway.js b/view/frontend/web/js/view/payment/method-renderer/mbway.js
deleted file mode 100644
index d559e1e9d..000000000
--- a/view/frontend/web/js/view/payment/method-renderer/mbway.js
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * NOTICE OF LICENSE
- *
- * This source file is subject to the MIT License
- * It is available through the world-wide-web at this URL:
- * https://tldrlegal.com/license/mit-license
- * If you are unable to obtain it through the world-wide-web, please send an email
- * to support@buckaroo.nl so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this module to newer
- * versions in the future. If you wish to customize this module for your
- * needs please contact support@buckaroo.nl for more information.
- *
- * @copyright Copyright (c) Buckaroo B.V.
- * @license https://tldrlegal.com/license/mit-license
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
- ],
- function (
- $,
- Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
- ) {
- 'use strict';
-
- return Component.extend(
- {
- defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_mbway'
- },
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.mbway.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.mbway.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('mbway'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.mbway.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
- }
- );
- }
-);
diff --git a/view/frontend/web/js/view/payment/method-renderer/mrcash.js b/view/frontend/web/js/view/payment/method-renderer/mrcash.js
index 227cacc90..349a10254 100644
--- a/view/frontend/web/js/view/payment/method-renderer/mrcash.js
+++ b/view/frontend/web/js/view/payment/method-renderer/mrcash.js
@@ -21,14 +21,11 @@
define(
[
'jquery',
- 'Magento_Checkout/js/view/payment/default',
+ 'buckaroo/checkout/payment/default',
'Magento_Checkout/js/model/payment/additional-validators',
'Buckaroo_Magento2/js/action/place-order',
'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
'mageUtils',
- 'buckaroo/checkout/common',
'BuckarooClientSideEncryption'
],
function (
@@ -37,10 +34,7 @@ define(
additionalValidators,
placeOrderAction,
ko,
- checkoutData,
- selectPaymentMethodAction,
- utils,
- checkoutCommon
+ utils
) {
'use strict';
@@ -49,33 +43,29 @@ define(
*/
$.validator.addMethod('validateCardNumber', function (value) {
return BuckarooClientSideEncryption.V001.validateCardNumber(value.replace(/\s+/g, ''));
- },
- $.mage.__('Please enter a valid creditcard number.')
- );
+ },
+ $.mage.__('Please enter a valid creditcard number.'));
$.validator.addMethod('validateCardHolderName', function (value) {
return BuckarooClientSideEncryption.V001.validateCardholderName(value);
- },
- $.mage.__('Please enter a valid card holder name.')
- );
+ },
+ $.mage.__('Please enter a valid card holder name.'));
$.validator.addMethod('bkValidateYear', function (value) {
- if(value.length === 0) {
- return false;
- }
+ if (value.length === 0) {
+ return false;
+ }
const parts = value.split("/");
return BuckarooClientSideEncryption.V001.validateYear(parts[1]);
- },
- $.mage.__('Enter a valid year number.')
- );
+ },
+ $.mage.__('Enter a valid year number.'));
$.validator.addMethod('bkValidateMonth', function (value) {
- if(value.length === 0) {
- return false;
- }
+ if (value.length === 0) {
+ return false;
+ }
const parts = value.split("/");
return BuckarooClientSideEncryption.V001.validateMonth(parts[0]);
- },
- $.mage.__('Enter a valid month number.')
- );
+ },
+ $.mage.__('Enter a valid month number.'));
return Component.extend(
{
@@ -84,34 +74,11 @@ define(
cardNumber : '',
cardHolderName : null,
expireDate : '',
- validationState : {},
clientSideMode : 'cc',
isMobileMode : false,
encryptedCardData : null
},
redirectAfterPlaceOrder: false,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.mrcash.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.mrcash.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('mrcash'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
- useClientSide : window.checkoutConfig.payment.buckaroo.mrcash.useClientSide,
- isTestMode: window.checkoutConfig.payment.buckaroo.mrcash.isTestMode,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
-
-
- },
-
-
initObservable: function () {
/** Observed fields **/
@@ -120,14 +87,13 @@ define(
'cardNumber',
'cardHolderName',
'expireDate',
- 'validationState',
'clientSideMode'
]
);
this.setTestParameters()
this.isMobileMode = ko.computed(
function () {
- return this.useClientSide && this.clientSideMode() == 'mobile';
+ return this.buckaroo.useClientSide && this.clientSideMode() == 'mobile';
},
this
);
@@ -135,7 +101,7 @@ define(
this.formatedCardNumber = ko.computed({
read: function () {
let cardNumber = this.cardNumber();
- if(cardNumber.length) {
+ if (cardNumber.length) {
return this.cardNumber().match(new RegExp('.{1,4}', 'g')).join(" ");
}
return '';
@@ -149,22 +115,29 @@ define(
this.formatedExpirationDate = ko.computed({
read: function () {
let expireDate = this.expireDate();
- if(expireDate.length) {
+ if (expireDate.length) {
return expireDate.replace(
- /^([1-9]\/|[2-9])$/g, '0$1/' // 3 > 03/
- ).replace(
- /^(0[1-9]|1[0-2])$/g, '$1/' // 11 > 11/
- ).replace(
- /^([0-1])([3-9])$/g, '0$1/$2' // 13 > 01/3
- ).replace(
- /^(0?[1-9]|1[0-2])([0-9]{2})$/g, '$1/$2' // 141 > 01/41
- ).replace(
- /^([0]+)\/|[0]+$/g, '0' // 0/ > 0 and 00 > 0
- ).replace(
- /[^\d\/]|^[\/]*$/g, '' // To allow only digits and `/`
- ).replace(
- /\/\//g, '/' // Prevent entering more than 1 `/`
- );
+ /^([1-9]\/|[2-9])$/g,
+ '0$1/' // 3 > 03/
+ ).replace(
+ /^(0[1-9]|1[0-2])$/g,
+ '$1/' // 11 > 11/
+ ).replace(
+ /^([0-1])([3-9])$/g,
+ '0$1/$2' // 13 > 01/3
+ ).replace(
+ /^(0?[1-9]|1[0-2])([0-9]{2})$/g,
+ '$1/$2' // 141 > 01/41
+ ).replace(
+ /^(0+\/|0+)$/g,
+ '0' // 0/ > 0 and 00 > 0
+ ).replace(
+ /[^\d\/]|^[\/]*$/g,
+ '' // To allow only digits and `/`
+ ).replace(
+ /\/\//g,
+ '/' // Prevent entering more than 1 `/`
+ );
}
return '';
},
@@ -177,14 +150,32 @@ define(
return this;
},
+ placeOrder: function (data, event) {
+ var self = this,
+ placeOrder;
- validateField(data, event) {
- const isValid = $(event.target).valid();
- let state = this.validationState();
- state[event.target.id] = isValid;
- this.validationState(state);
+ if (event) {
+ event.preventDefault();
+ }
+
+ if (this.validate() && additionalValidators.validate()) {
+ this.isPlaceOrderActionAllowed(false);
+ this.encryptCardData().then(function() {
+ placeOrder = placeOrderAction(self.getData(), self.redirectAfterPlaceOrder, self.messageContainer);
+
+ $.when(placeOrder).fail(
+ function () {
+ self.isPlaceOrderActionAllowed(true);
+ }
+ ).done(self.afterPlaceOrder.bind(self));
+ })
+ return true;
+ }
+ return false;
},
+
+
getData: function () {
return {
"method": this.item.method,
@@ -197,7 +188,7 @@ define(
},
encryptCardData: function () {
- return new Promise(function(resolve) {
+ return new Promise(function (resolve) {
const parts = this.expireDate().split("/");
const month = parts[0];
const year = parts[1];
@@ -208,60 +199,20 @@ define(
month,
'',
this.cardHolderName(),
- function(encryptedCardData) {
+ function (encryptedCardData) {
this.encryptedCardData = encryptedCardData;
resolve()
}.bind(this));
}.bind(this))
},
- setClientSideMode: function (mode) {
- this.clientSideMode(mode)
- },
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- placeOrder: function (data, event) {
- var self = this,
- placeOrder;
-
- if (event) {
- event.preventDefault();
- }
-
- if (this.validate() && additionalValidators.validate()) {
- this.isPlaceOrderActionAllowed(false);
- this.encryptCardData().then(function() {
- placeOrder = placeOrderAction(self.getData(), self.redirectAfterPlaceOrder, self.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(self.afterPlaceOrder.bind(self));
- })
- return true;
- }
- return false;
- },
-
- validate: function () {
- return this.isMobileMode() || this.useClientSide == false || $('.' + this.getCode() + ' .payment-method-second-col form').valid();
- },
-
afterPlaceOrder: function () {
var response = window.checkoutConfig.payment.buckaroo.response;
response = $.parseJSON(response);
if (response.RequiredAction !== undefined && response.RequiredAction.RedirectURL !== undefined) {
if (this.isMobileMode()) {
- var data = {};
- data['transaction_key'] = response.key;
-
utils.submit({
- url: window.checkoutConfig.payment.buckaroo.mrcash.redirecturl,
+ url: this.buckaroo.redirecturl,
data: response
});
} else {
@@ -270,30 +221,8 @@ define(
}
},
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction({
- "method": this.item.method,
- "po_number": null,
- });
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.mrcash.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- },
setTestParameters() {
- if (this.useClientSide && this.isTestMode) {
+ if (this.buckaroo.useClientSide && this.buckaroo.isTestMode) {
this.cardNumber('67034200554565015')
this.cardHolderName('Test Acceptation')
this.expireDate('01/' + (new Date(new Date().setFullYear(new Date().getFullYear() + 1)).getFullYear().toString().substr(-2)))
diff --git a/view/frontend/web/js/view/payment/method-renderer/multibanco.js b/view/frontend/web/js/view/payment/method-renderer/multibanco.js
deleted file mode 100644
index 2ed8f9aab..000000000
--- a/view/frontend/web/js/view/payment/method-renderer/multibanco.js
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * NOTICE OF LICENSE
- *
- * This source file is subject to the MIT License
- * It is available through the world-wide-web at this URL:
- * https://tldrlegal.com/license/mit-license
- * If you are unable to obtain it through the world-wide-web, please send an email
- * to support@buckaroo.nl so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this module to newer
- * versions in the future. If you wish to customize this module for your
- * needs please contact support@buckaroo.nl for more information.
- *
- * @copyright Copyright (c) Buckaroo B.V.
- * @license https://tldrlegal.com/license/mit-license
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
- ],
- function (
- $,
- Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
- ) {
- 'use strict';
-
- return Component.extend(
- {
- defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_multibanco'
- },
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.multibanco.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.multibanco.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('multibanco'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.multibanco.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
- }
- );
- }
-);
diff --git a/view/frontend/web/js/view/payment/method-renderer/p24.js b/view/frontend/web/js/view/payment/method-renderer/p24.js
deleted file mode 100644
index d5e28b13b..000000000
--- a/view/frontend/web/js/view/payment/method-renderer/p24.js
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * NOTICE OF LICENSE
- *
- * This source file is subject to the MIT License
- * It is available through the world-wide-web at this URL:
- * https://tldrlegal.com/license/mit-license
- * If you are unable to obtain it through the world-wide-web, please send an email
- * to support@buckaroo.nl so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this module to newer
- * versions in the future. If you wish to customize this module for your
- * needs please contact support@buckaroo.nl for more information.
- *
- * @copyright Copyright (c) Buckaroo B.V.
- * @license https://tldrlegal.com/license/mit-license
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
- ],
- function (
- $,
- Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
- ) {
- 'use strict';
-
- return Component.extend(
- {
- defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_p24'
- },
- redirectAfterPlaceOrder: false,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.p24.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.p24.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('p24'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.p24.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
- }
- );
- }
-);
-
-
-
-
-
-
-
-
diff --git a/view/frontend/web/js/view/payment/method-renderer/paybybank.js b/view/frontend/web/js/view/payment/method-renderer/paybybank.js
index e566f09de..0955d262d 100644
--- a/view/frontend/web/js/view/payment/method-renderer/paybybank.js
+++ b/view/frontend/web/js/view/payment/method-renderer/paybybank.js
@@ -20,199 +20,95 @@
/*global define*/
define([
"jquery",
- "Magento_Checkout/js/view/payment/default",
- "Magento_Checkout/js/model/payment/additional-validators",
- "Buckaroo_Magento2/js/action/place-order",
- "ko",
- "mage/translate",
- "Magento_Checkout/js/checkout-data",
- "Magento_Checkout/js/action/select-payment-method",
- "buckaroo/checkout/common",
+ "buckaroo/checkout/payment/default",
+ "ko"
], function (
- $,
- Component,
- additionalValidators,
- placeOrderAction,
- ko,
- $t,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
+ $,
+ Component,
+ ko,
) {
- "use strict";
-
- return Component.extend({
- defaults: {
- template: "Buckaroo_Magento2/payment/buckaroo_magento2_paybybank",
- selectedBank: "",
- validationState: {},
- showAll: false,
- bankTypes: window.checkoutConfig.payment.buckaroo.paybybank.banks,
- isMobile: $(window).width() < 768,
- logo: require.toUrl('Buckaroo_Magento2/images/paybybank.gif')
- },
- redirectAfterPlaceOrder: false,
- selectionType:
- window.checkoutConfig.payment.buckaroo.paybybank.selectionType,
- subtext: window.checkoutConfig.payment.buckaroo.paybybank.subtext,
- subTextStyle: checkoutCommon.getSubtextStyle("paybybank"),
- currencyCode: window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode: window.checkoutConfig.quoteData.base_currency_code,
- internalBanks: window.checkoutConfig.payment.buckaroo.paybybank.banks,
- /**
- * @override
- */
- initialize: function (options) {
- return this._super(options);
- },
-
- initObservable: function () {
- this._super().observe(["selectedBank", "validationState", "showAll", "isMobile"]);
- this.initialSelected();
- const self = this;
- $(window).resize(function () {
- const width = $(window).width();
- if(width < 768 && self.isMobile() === false) {
- self.isMobile(true);
- } else if (width >= 768) {
- self.isMobile(false);
- }
- });
+ "use strict";
+
+ return Component.extend({
+ defaults: {
+ template: "Buckaroo_Magento2/payment/buckaroo_magento2_paybybank",
+ selectedBank: "",
+ showAll: false,
+ isMobile: $(window).width() < 768
+ },
+ redirectAfterPlaceOrder: false,
+ /**
+ * @override
+ */
+ initialize: function (options) {
+ return this._super(options);
+ },
- this.bankTypes = ko.computed(function () {
- const issuers = window.checkoutConfig.payment.buckaroo.paybybank.banks;
- if (this.showAll() === false && !this.isMobile()) {
- if (this.selectedBank() !== "") {
- return issuers.filter(function (bank) {
- return bank.code === this.selectedBank();
+ initObservable: function () {
+ this._super().observe(["selectedBank", "showAll", "isMobile"]);
+ this.initialSelected();
+ const self = this;
+ $(window).resize(function () {
+ const width = $(window).width();
+ if (width < 768 && self.isMobile() === false) {
+ self.isMobile(true);
+ } else if (width >= 768) {
+ self.isMobile(false);
+ }
+ });
+
+ this.bankTypes = ko.computed(function () {
+ const issuers = this.buckaroo.banks;
+ if (this.showAll() === false && !this.isMobile()) {
+ if (this.selectedBank() !== "") {
+ return issuers.filter(function (bank) {
+ return bank.code === this.selectedBank();
+ }, this);
+ }
+ return issuers.slice(0, 4);
+ }
+ return issuers;
}, this);
- }
- return issuers.slice(0, 4);
- }
- return issuers;
- }, this);
- /** Check used to see form is valid **/
- this.buttoncheck = ko.computed(function () {
- const state = this.validationState();
- const valid = ["issuer"]
- .map((field) => {
- if (state[field] !== undefined) {
- return state[field];
- }
- return false;
- })
- .reduce(function (prev, cur) {
- return prev && cur;
- }, true);
- return valid;
- }, this);
- this.logo = ko.computed(function () {
- let found = this.internalBanks.find(function (bank) {
- return bank.code === this.selectedBank();
- }, this);
+ this.logo = ko.computed(function () {
+ let found = this.buckaroo.banks.find(function (bank) {
+ return bank.code === this.selectedBank();
+ }, this);
- if (found !== undefined) {
- return found.img;
- }
- return require.toUrl('Buckaroo_Magento2/images/paybybank.gif')
- }, this);
- return this;
- },
-
-
- initialSelected() {
- let found = this.internalBanks.find(function (bank) {
- return bank.selected === true;
- });
-
- if (found !== undefined) {
- this.selectedBank(found.code);
- this.updateFormState(true);
- }
- },
-
- validateField(data, event) {
- this.updateFormState(
- $(event.target).valid()
- );
- },
-
- updateFormState(isValid) {
- let state = this.validationState();
- state["issuer"] = isValid;
- this.validationState(state);
- },
-
- toggleShow: function () {
- this.showAll(!this.showAll());
- },
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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,
- this.messageContainer
- );
-
- $.when(placeOrder)
- .fail(function () {
- self.isPlaceOrderActionAllowed(true);
- })
- .done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
+ if (found !== undefined) {
+ return found.img;
+ }
+ return this.buckaroo.logo
+ }, this);
+ return this;
+ },
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
- selectPaymentMethod: function () {
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
+ initialSelected() {
+ let found = this.buckaroo.banks.find(function (bank) {
+ return bank.selected === true;
+ });
- getData: function () {
- return {
- method: this.item.method,
- po_number: null,
- additional_data: {
- issuer: this.selectedBank(),
+ if (found !== undefined) {
+ this.selectedBank(found.code);
+ }
},
- };
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies =
- window.checkoutConfig.payment.buckaroo.paybybank.allowedCurrencies;
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
+ toggleShow: function () {
+ this.showAll(!this.showAll());
+ },
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__("The transaction will be processed using %s.");
+ getData: function () {
+ return {
+ method: this.item.method,
+ po_number: null,
+ additional_data: {
+ issuer: this.selectedBank(),
+ },
+ };
+ },
- return text.replace("%s", this.baseCurrencyCode);
- },
- });
+
+ });
});
diff --git a/view/frontend/web/js/view/payment/method-renderer/payconiq.js b/view/frontend/web/js/view/payment/method-renderer/payconiq.js
index 2bad304c8..707df90c1 100644
--- a/view/frontend/web/js/view/payment/method-renderer/payconiq.js
+++ b/view/frontend/web/js/view/payment/method-renderer/payconiq.js
@@ -21,80 +21,24 @@
define(
[
'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
+ 'buckaroo/checkout/payment/default',
'mageUtils',
'mage/url',
- 'buckaroo/checkout/common'
],
function (
$,
Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
utils,
url,
- checkoutCommon
) {
'use strict';
return Component.extend(
{
defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_payconiq'
+ template: 'Buckaroo_Magento2/payment/default'
},
redirectAfterPlaceOrder: false,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.payconiq.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.payconiq.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('payconiq'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
afterPlaceOrder: function () {
var response = window.checkoutConfig.payment.buckaroo.response;
@@ -106,35 +50,17 @@ define(
null,
url.build('/buckaroo/payconiq/process/?cancel=1&form_key=' + formKey + '&transaction_key=' + response.Key)
);
- var data = {};
+ var data = {};
data['transaction_key'] = response.key;
utils.submit({
- url: window.checkoutConfig.payment.buckaroo.payconiq.redirecturl,
+ url: this.buckaroo.redirecturl,
data: response
});
}
},
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.payconiq.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
- return text.replace('%s', this.baseCurrencyCode);
- }
}
);
}
diff --git a/view/frontend/web/js/view/payment/method-renderer/paypal.js b/view/frontend/web/js/view/payment/method-renderer/paypal.js
deleted file mode 100644
index eaeca5023..000000000
--- a/view/frontend/web/js/view/payment/method-renderer/paypal.js
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * NOTICE OF LICENSE
- *
- * This source file is subject to the MIT License
- * It is available through the world-wide-web at this URL:
- * https://tldrlegal.com/license/mit-license
- * If you are unable to obtain it through the world-wide-web, please send an email
- * to support@buckaroo.nl so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this module to newer
- * versions in the future. If you wish to customize this module for your
- * needs please contact support@buckaroo.nl for more information.
- *
- * @copyright Copyright (c) Buckaroo B.V.
- * @license https://tldrlegal.com/license/mit-license
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
- ],
- function (
- $,
- Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
- ) {
- 'use strict';
-
- return Component.extend(
- {
- defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_paypal'
- },
- redirectAfterPlaceOrder: false,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.paypal.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.paypal.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('paypal'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.paypal.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
- }
- );
- }
-);
-
-
-
-
-
-
-
-
diff --git a/view/frontend/web/js/view/payment/method-renderer/payperemail.js b/view/frontend/web/js/view/payment/method-renderer/payperemail.js
index 88b4cee98..6534fa393 100644
--- a/view/frontend/web/js/view/payment/method-renderer/payperemail.js
+++ b/view/frontend/web/js/view/payment/method-renderer/payperemail.js
@@ -20,26 +20,12 @@
/*global define*/
define(
[
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
+ 'buckaroo/checkout/payment/default',
'Magento_Checkout/js/model/quote',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
],
function (
- $,
Component,
- additionalValidators,
- placeOrderAction,
quote,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
) {
'use strict';
@@ -51,27 +37,11 @@ define(
firstName: null,
middleName: null,
lastName: null,
- email: null,
- validationState : {}
+ email: null
},
redirectAfterPlaceOrder: true,
- paymentFeeLabel: window.checkoutConfig.payment.buckaroo.payperemail.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.payperemail.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('payperemail'),
- currencyCode: window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode: window.checkoutConfig.quoteData.base_currency_code,
- genderList: window.checkoutConfig.payment.buckaroo.payperemail.genderList,
- /**
- * @override
- */
- initialize: function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
+
initObservable: function () {
this._super().observe(
[
@@ -84,132 +54,27 @@ define(
]
);
quote.billingAddress.subscribe(function (address) {
- if(address !== null) {
+ if (address !== null) {
this.firstName(address.firstname || '');
this.lastName(address.lastname || '');
this.middleName(address.middlename || '');
-
- this.updateState(
- 'buckaroo_magento2_payperemail_BillingFirstName',
- address.firstname && address.firstname.length > 0
- );
- this.updateState(
- 'buckaroo_magento2_payperemail_BillingLastName',
- address.lastname && address.lastname.length > 0
- );
}
}, this);
if (typeof customerData === 'object' && customerData.hasOwnProperty('email')) {
this.email(customerData.email);
- this.updateState(
- 'buckaroo_magento2_payperemail_Email',
- customerData.email.length > 0
- );
+
}
- if(quote.guestEmail) {
+ if (quote.guestEmail) {
this.email(quote.guestEmail);
- this.updateState(
- 'buckaroo_magento2_payperemail_Email',
- quote.guestEmail.length > 0
- );
}
- /** Check used to see form is valid **/
- this.buttoncheck = ko.computed(
- function () {
- const state = this.validationState();
- const valid =[
- "buckaroo_magento2_payperemail_genderSelect",
- "buckaroo_magento2_payperemail_BillingFirstName",
- "buckaroo_magento2_payperemail_BillingLastName",
- "buckaroo_magento2_payperemail_Email"
- ].map((field) => {
- if(state[field] !== undefined) {
- return state[field];
- }
- return false;
- }).reduce(
- function(prev, cur) {
- return prev && cur
- },
- true
- )
- return valid;
- },
- this
- );
+
return this;
},
- validateField(data, event) {
- const isValid = $(event.target).valid();
- let state = this.validationState();
- state[event.target.id] = isValid;
- this.validationState(state);
- },
-
-
- updateState(id, isValid) {
- let state = this.validationState();
- state[id] = isValid;
- this.validationState(state);
- },
-
- /**
- * Place order.
- *
- * @todo To override the script used for placeOrderAction, we need to override the placeOrder method
- * on our parent class (Magento_Checkout/js/view/payment/default) so we can
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own
- * version (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- /**
- * Run validation function
- */
-
- validate: function () {
- return $('.' + this.getCode() + ' .payment-method-second-col form').valid();
- },
-
+
getData: function () {
return {
"method": this.item.method,
@@ -223,18 +88,6 @@ define(
}
};
},
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.payperemail.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
}
);
}
diff --git a/view/frontend/web/js/view/payment/method-renderer/pospayment.js b/view/frontend/web/js/view/payment/method-renderer/pospayment.js
index f84e98619..e5e7ca3b1 100644
--- a/view/frontend/web/js/view/payment/method-renderer/pospayment.js
+++ b/view/frontend/web/js/view/payment/method-renderer/pospayment.js
@@ -21,13 +21,7 @@
define(
[
'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'mage/storage',
+ 'buckaroo/checkout/payment/default',
'mage/url',
'mage/translate',
'Magento_Ui/js/modal/alert',
@@ -36,12 +30,6 @@ define(
function (
$,
Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- storage,
urlBuilder,
$t,
alert,
@@ -49,8 +37,8 @@ define(
) {
'use strict';
- function checkOrderState(orderId, interval) {
- //console.log('==================31', orderId);
+ function checkOrderState(orderId, interval)
+ {
$.ajax({
url: urlBuilder.build('buckaroo/pos/checkOrderStatus'),
type: 'POST',
@@ -70,51 +58,7 @@ define(
return Component.extend(
{
defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_pospayment'
- },
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.pospayment.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.pospayment.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('pospayment'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- placeOrder: function (data, event) {
- var self = this,
- placeOrder;
-
- if (event) {
- event.preventDefault();
- }
-
- if (this.validate() && additionalValidators.validate()) {
- this.isPlaceOrderActionAllowed(false);
- placeOrder = placeOrderAction(this.getData(), false, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
+ template: 'Buckaroo_Magento2/payment/default'
},
afterPlaceOrder: function () {
@@ -125,14 +69,7 @@ define(
alert({
title: $t('Follow the instructions on the payment terminal'),
content: $t('Your order will be completed as soon as payment has been made'),
- actions: {always: function(){} }/*,
- buttons: [{
- text: $t(333),
- class: 'action primary accept',
- click: function () {
- this.closeModal(true);
- }
- }]*/
+ actions: {always: function (){} }
});
var interval = setInterval(function () {
checkOrderState(response.Order, interval);
@@ -140,25 +77,6 @@ define(
}
},
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.pospayment.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
}
);
}
diff --git a/view/frontend/web/js/view/payment/method-renderer/sepadirectdebit.js b/view/frontend/web/js/view/payment/method-renderer/sepadirectdebit.js
index 5164f56fc..ba90226c2 100644
--- a/view/frontend/web/js/view/payment/method-renderer/sepadirectdebit.js
+++ b/view/frontend/web/js/view/payment/method-renderer/sepadirectdebit.js
@@ -21,25 +21,15 @@
define(
[
'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
+ 'buckaroo/checkout/payment/default',
'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
'Magento_Checkout/js/model/quote',
- 'buckaroo/checkout/common'
],
function (
$,
Component,
- additionalValidators,
- placeOrderAction,
ko,
- checkoutData,
- selectPaymentMethodAction,
quote,
- checkoutCommon
) {
'use strict';
@@ -48,9 +38,8 @@ define(
* This function check if the checksum if correct
*/
- function isValidIBAN($v)
- {
- $v = $v.replace(/^(.{4})(.*)$/,"$2$1"); //Move the first 4 chars from left to the right
+ function isValidIBAN($v) {
+ $v = $v.replace(/^(.{4})(.*)$/, "$2$1"); //Move the first 4 chars from left to the right
//Convert A-Z to 10-25
$v = $v.replace(
/[A-Z]/g,
@@ -61,7 +50,7 @@ define(
var $sum = 0;
var $ei = 1; //First exponent
for (var $i = $v.length - 1; $i >= 0; $i--) {
- $sum += $ei * parseInt($v.charAt($i),10); //multiply the digit by it's exponent
+ $sum += $ei * parseInt($v.charAt($i), 10); //multiply the digit by it's exponent
$ei = ($ei * 10) % 97; //compute next base 10 exponent in modulus 97
}
return $sum % 97 == 1;
@@ -74,7 +63,7 @@ define(
$.validator.addMethod(
'IBAN',
function (value) {
- var patternIBAN = new RegExp('^[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]?){0,16}$');
+ var patternIBAN = new RegExp('^[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]{1,16})$');
return (patternIBAN.test(value) && isValidIBAN(value));
},
$.mage.__('Enter Valid IBAN')
@@ -103,101 +92,27 @@ define(
template: 'Buckaroo_Magento2/payment/buckaroo_magento2_sepadirectdebit',
bankaccountholder: '',
bankaccountnumber: '',
- bicnumber: '',
- isnl: false,
- validationState : {},
- },
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.sepadirectdebit.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.sepadirectdebit.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('sepadirectdebit'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
-
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
+ bicnumber: ''
},
initObservable: function () {
this._super().observe([
- 'bankaccountholder',
+ 'bankaccountholder',
'bankaccountnumber',
- 'bicnumber',
- 'validationState'
+ 'bicnumber'
]);
this.isnl = ko.computed(function () {
- return quote.billingAddress() !== null && quote.billingAddress().countryId == 'NL'
+ return quote.billingAddress() !== null && quote.billingAddress().countryId == 'NL'
}, this);
-
/**
* Repair IBAN value to uppercase
*/
this.bankaccountnumber.extend({ uppercase: true });
- /** Check used to see form is valid **/
- this.buttoncheck = ko.computed(
- function () {
- const state = this.validationState();
- const valid =this.getActiveFields().map((field) => {
- if(state[field] !== undefined) {
- return state[field];
- }
- return false;
- }).reduce(
- function(prev, cur) {
- return prev && cur
- },
- true
- )
- return valid;
- },
- this
- );
-
return this;
},
-
- getActiveFields() {
- let fields = [
- 'bankaccountholder',
- 'bankaccountnumber',
- ];
- if(!this.isnl()) {
- fields.push('bicnumber');
- }
- return fields;
- },
- validateField(data, event) {
- const isValid = $(event.target).valid();
- let state = this.validationState();
- state[event.target.id] = isValid;
- this.validationState(state);
- },
- /**
- * Run function
- */
-
- validate: function () {
- return $('.' + this.getCode() + ' .payment-method-second-col form').valid();
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
getData: function () {
return {
"method": this.item.method,
@@ -209,18 +124,6 @@ define(
}
};
},
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.sepadirectdebit.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
}
);
}
diff --git a/view/frontend/web/js/view/payment/method-renderer/sofortbanking.js b/view/frontend/web/js/view/payment/method-renderer/sofortbanking.js
deleted file mode 100644
index fc2d995ee..000000000
--- a/view/frontend/web/js/view/payment/method-renderer/sofortbanking.js
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * NOTICE OF LICENSE
- *
- * This source file is subject to the MIT License
- * It is available through the world-wide-web at this URL:
- * https://tldrlegal.com/license/mit-license
- * If you are unable to obtain it through the world-wide-web, please send an email
- * to support@buckaroo.nl so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this module to newer
- * versions in the future. If you wish to customize this module for your
- * needs please contact support@buckaroo.nl for more information.
- *
- * @copyright Copyright (c) Buckaroo B.V.
- * @license https://tldrlegal.com/license/mit-license
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
- ],
- function (
- $,
- Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
- ) {
- 'use strict';
-
- return Component.extend(
- {
- defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_sofortbanking'
- },
- redirectAfterPlaceOrder: false,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.sofortbanking.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.sofortbanking.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('sofortbanking'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.sofortbanking.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
- }
- );
- }
-);
-
-
-
-
-
-
-
-
diff --git a/view/frontend/web/js/view/payment/method-renderer/transfer.js b/view/frontend/web/js/view/payment/method-renderer/transfer.js
index de4cd1290..11690a5d7 100644
--- a/view/frontend/web/js/view/payment/method-renderer/transfer.js
+++ b/view/frontend/web/js/view/payment/method-renderer/transfer.js
@@ -20,68 +20,18 @@
/*global define*/
define(
[
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
+ 'buckaroo/checkout/payment/default',
],
function (
- $,
Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
+
) {
'use strict';
-
return Component.extend(
{
defaults: {
template: 'Buckaroo_Magento2/payment/buckaroo_magento2_transfer'
},
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.transfer.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.transfer.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('transfer'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.transfer.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
}
);
diff --git a/view/frontend/web/js/view/payment/method-renderer/trustly.js b/view/frontend/web/js/view/payment/method-renderer/trustly.js
deleted file mode 100644
index dc60e239b..000000000
--- a/view/frontend/web/js/view/payment/method-renderer/trustly.js
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * NOTICE OF LICENSE
- *
- * This source file is subject to the MIT License
- * It is available through the world-wide-web at this URL:
- * https://tldrlegal.com/license/mit-license
- * If you are unable to obtain it through the world-wide-web, please send an email
- * to support@buckaroo.nl so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this module to newer
- * versions in the future. If you wish to customize this module for your
- * needs please contact support@buckaroo.nl for more information.
- *
- * @copyright Copyright (c) Buckaroo B.V.
- * @license https://tldrlegal.com/license/mit-license
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
- ],
- function (
- $,
- Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
- ) {
- 'use strict';
-
- return Component.extend(
- {
- defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_trustly'
- },
- redirectAfterPlaceOrder: false,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.trustly.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.trustly.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('trustly'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.trustly.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
- }
- );
- }
-);
-
-
-
-
-
-
-
-
diff --git a/view/frontend/web/js/view/payment/method-renderer/voucher.js b/view/frontend/web/js/view/payment/method-renderer/voucher.js
index 06aec1b65..9f59d2547 100644
--- a/view/frontend/web/js/view/payment/method-renderer/voucher.js
+++ b/view/frontend/web/js/view/payment/method-renderer/voucher.js
@@ -21,29 +21,17 @@
define(
[
'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
+ 'buckaroo/checkout/payment/default',
'Magento_Ui/js/modal/alert',
'mage/url',
'mage/translate',
- 'buckaroo/checkout/common'
],
function (
$,
Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
alert,
url,
$t,
- checkoutCommon
) {
'use strict';
@@ -52,50 +40,36 @@ define(
defaults: {
template: 'Buckaroo_Magento2/payment/buckaroo_magento2_voucher',
code: '',
- isFormValid: false
- },
- paymentFeeLabel: window.checkoutConfig.payment.buckaroo.voucher.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.voucher.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('voucher'),
- currencyCode: window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode: window.checkoutConfig.quoteData.base_currency_code,
-
-
- /**
- * @override
- */
- initialize: function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
- return this._super(options);
+ isSubmitting: false
},
initObservable: function () {
- this._super().observe(['code', 'isFormValid']);
+ this._super().observe(['code', 'isSubmitting']);
- this.code.subscribe(function (code) {
- this.isFormValid($('.' + this.getCode() + ' .payment [data-validate]').valid());
- }.bind(this))
return this;
},
+ validateForm: function() {
+ return $('.' + this.getCode() + ' .payment [data-validate]').valid();
+ },
applyVoucher: function () {
- if (this.isFormValid()) {
+ if (this.validateForm()) {
+ this.isSubmitting(true);
const voucherCode = this.code();
let self = this;
$.ajax({
url: url.build(`rest/V1/buckaroo/voucher/apply`),
type: 'POST',
dataType: 'json',
- showLoader: true, //use for display loader
- data: { voucherCode: voucherCode }
+ showLoader: true, //use for display loader
+ data: {voucherCode: voucherCode}
}).done(function (data) {
self.code(null);
if (data.remainder_amount == 0) {
self.placeOrder(null, null);
}
+ this.isSubmitting(false);
if (data.error) {
self.displayErrorModal(self, data.error);
@@ -117,6 +91,7 @@ define(
self.messageContainer.addSuccessMessage({ 'message': $t(data.message) });
}
}).fail((err) => {
+ this.isSubmitting(false);
if (err.responseJSON && err.responseJSON.message) {
self.displayErrorModal(self, err.responseJSON.message);
}
@@ -131,28 +106,7 @@ define(
actions: { always: function () { } }
});
self.messageContainer.addErrorMessage({ 'message': $t(message) });
- },
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.voucher.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
}
-
}
);
}
diff --git a/view/frontend/web/js/view/payment/method-renderer/wechatpay.js b/view/frontend/web/js/view/payment/method-renderer/wechatpay.js
deleted file mode 100644
index 6968e65da..000000000
--- a/view/frontend/web/js/view/payment/method-renderer/wechatpay.js
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * NOTICE OF LICENSE
- *
- * This source file is subject to the MIT License
- * It is available through the world-wide-web at this URL:
- * https://tldrlegal.com/license/mit-license
- * If you are unable to obtain it through the world-wide-web, please send an email
- * to support@buckaroo.nl so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this module to newer
- * versions in the future. If you wish to customize this module for your
- * needs please contact support@buckaroo.nl for more information.
- *
- * @copyright Copyright (c) Buckaroo B.V.
- * @license https://tldrlegal.com/license/mit-license
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'Magento_Checkout/js/view/payment/default',
- 'Magento_Checkout/js/model/payment/additional-validators',
- 'Buckaroo_Magento2/js/action/place-order',
- 'ko',
- 'Magento_Checkout/js/checkout-data',
- 'Magento_Checkout/js/action/select-payment-method',
- 'buckaroo/checkout/common'
- ],
- function (
- $,
- Component,
- additionalValidators,
- placeOrderAction,
- ko,
- checkoutData,
- selectPaymentMethodAction,
- checkoutCommon
- ) {
- 'use strict';
-
- return Component.extend(
- {
- defaults: {
- template: 'Buckaroo_Magento2/payment/buckaroo_magento2_wechatpay'
- },
- redirectAfterPlaceOrder: false,
- paymentFeeLabel : window.checkoutConfig.payment.buckaroo.wechatpay.paymentFeeLabel,
- subtext : window.checkoutConfig.payment.buckaroo.wechatpay.subtext,
- subTextStyle : checkoutCommon.getSubtextStyle('wechatpay'),
- currencyCode : window.checkoutConfig.quoteData.quote_currency_code,
- baseCurrencyCode : window.checkoutConfig.quoteData.base_currency_code,
-
- /**
- * @override
- */
- initialize : function (options) {
- if (checkoutData.getSelectedPaymentMethod() == options.index) {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
- }
-
- return this._super(options);
- },
-
- /**
- * Place order.
- *
- * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version
- * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response.
- */
- 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, this.messageContainer);
-
- $.when(placeOrder).fail(
- function () {
- self.isPlaceOrderActionAllowed(true);
- }
- ).done(this.afterPlaceOrder.bind(this));
- return true;
- }
- return false;
- },
-
- afterPlaceOrder: function () {
- var response = window.checkoutConfig.payment.buckaroo.response;
- response = $.parseJSON(response);
- checkoutCommon.redirectHandle(response);
- },
-
- selectPaymentMethod: function () {
- window.checkoutConfig.buckarooFee.title(this.paymentFeeLabel);
-
- selectPaymentMethodAction(this.getData());
- checkoutData.setSelectedPaymentMethod(this.item.method);
- return true;
- },
-
- payWithBaseCurrency: function () {
- var allowedCurrencies = window.checkoutConfig.payment.buckaroo.wechatpay.allowedCurrencies;
-
- return allowedCurrencies.indexOf(this.currencyCode) < 0;
- },
-
- getPayWithBaseCurrencyText: function () {
- var text = $.mage.__('The transaction will be processed using %s.');
-
- return text.replace('%s', this.baseCurrencyCode);
- }
- }
- );
- }
-);
-
-
-
-
-
-
-
-
diff --git a/view/frontend/web/js/view/summary/totals.js b/view/frontend/web/js/view/summary/totals.js
index ff06a4a2e..5c5d80dcd 100644
--- a/view/frontend/web/js/view/summary/totals.js
+++ b/view/frontend/web/js/view/summary/totals.js
@@ -169,45 +169,43 @@ define(
removeGiftcard: function (transaction_id, servicecode, amount) {
self = this;
if (confirm('Are you sure you want to remove?')) {
+ $.ajax({
+ url: url.build("buckaroo/checkout/giftcard"),
+ type: 'POST',
+ dataType: 'json',
+ showLoader: true, //use for display loader
+ data: {
+ refund: transaction_id,
+ card: servicecode,
+ amount: amount,
+ }
+ }).done(function (data) {
+ if (data.error) {
+ alert({
+ title: $t('Error'),
+ content: $t(data.error),
+ actions: {always: function (){} }
+ });
+ } else {
+ alert({
+ title: $t('Success'),
+ content: $t(data.message),
+ actions: {always: function (){} },
+ buttons: [{
+ text: $t(data.message),
+ class: 'action primary accept',
+ click: function () {
+ this.closeModal(true);
+ }
+ }]
+ });
+ }
- $.ajax({
- url: url.build("buckaroo/checkout/giftcard"),
- type: 'POST',
- dataType: 'json',
- showLoader: true, //use for display loader
- data: {
- refund: transaction_id,
- card: servicecode,
- amount: amount,
- }
- }).done(function (data) {
- if(data.error){
- alert({
- title: $t('Error'),
- content: $t(data.error),
- actions: {always: function(){} }
- });
- }else{
- alert({
- title: $t('Success'),
- content: $t(data.message),
- actions: {always: function(){} },
- buttons: [{
- text: $t(data.message),
- class: 'action primary accept',
- click: function () {
- this.closeModal(true);
- }
- }]
- });
- }
-
- var deferred = $.Deferred();
- getTotalsAction([], deferred);
+ var deferred = $.Deferred();
+ getTotalsAction([], deferred);
// $('.buckaroo_magento2_'+self.currentGiftcard+' input[name="payment[method]"]').click();
-
- });
+ });
} else {
console.log('no');
}
diff --git a/view/frontend/web/template/cart/totals/buckaroo_fee.html b/view/frontend/web/template/cart/totals/buckaroo_fee.html
index bd9e933f9..64b9c83b7 100644
--- a/view/frontend/web/template/cart/totals/buckaroo_fee.html
+++ b/view/frontend/web/template/cart/totals/buckaroo_fee.html
@@ -1,13 +1,13 @@
|