diff --git a/view/frontend/web/css/ideal-fast-checkout.css b/view/frontend/web/css/ideal-fast-checkout.css
new file mode 100644
index 000000000..e107f91ac
--- /dev/null
+++ b/view/frontend/web/css/ideal-fast-checkout.css
@@ -0,0 +1,17 @@
+#fast-checkout-ideal-btn {
+ height: 45px;
+ padding: 0;
+ border: none;
+ background: none;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ margin: 20px 0;
+}
+
+#fast-checkout-ideal-btn img {
+ max-height: 100%;
+ max-width: 100%;
+ display: block;
+ margin: auto;
+}
diff --git a/view/frontend/web/js/view/checkout/applepay/checkout-cart.js b/view/frontend/web/js/view/checkout/applepay/checkout-cart.js
index 42e026c20..8823a1989 100644
--- a/view/frontend/web/js/view/checkout/applepay/checkout-cart.js
+++ b/view/frontend/web/js/view/checkout/applepay/checkout-cart.js
@@ -32,9 +32,9 @@ define(
'use strict';
return {
- showPayButton: function () {
+ showPayButton: function ($page) {
applepayPay.setQuote(quote);
- applepayPay.showPayButton('cart');
+ applepayPay.showPayButton($page);
applepayPay.transactionResult.subscribe(
function () {
diff --git a/view/frontend/web/js/view/checkout/applepay/pay.js b/view/frontend/web/js/view/checkout/applepay/pay.js
index 700db28ca..ae4efa01f 100644
--- a/view/frontend/web/js/view/checkout/applepay/pay.js
+++ b/view/frontend/web/js/view/checkout/applepay/pay.js
@@ -392,9 +392,9 @@ define(
}
}.bind(this),
})
- .fail(function() {
- this.timeoutRedirect();
- }.bind(this));
+ .fail(function() {
+ this.timeoutRedirect();
+ }.bind(this));
return update;
} else if (this.payMode == 'cart') {
@@ -432,9 +432,9 @@ define(
}
}.bind(this),
})
- .fail(function() {
- this.timeoutRedirect();
- }.bind(this));
+ .fail(function() {
+ this.timeoutRedirect();
+ }.bind(this));
return update;
} else {
@@ -548,9 +548,9 @@ define(
}
}.bind(this),
})
- .fail(function() {
- this.timeoutRedirect();
- }.bind(this));
+ .fail(function() {
+ this.timeoutRedirect();
+ }.bind(this));
return update;
@@ -607,10 +607,22 @@ define(
initProductViewWatchers: function () {
this.devLog('==============applepaydebug/initProductViewWatchers');
- this.productSelected.id = $('.price-box').attr('data-product-id');
- this.productSelected.qty = $('#qty').val();
- var self = this;
+ var productId = $('.price-box').attr('data-product-id');
+ var productQty = $('#qty').val();
+
+ if (!productId) {
+ console.error('Product ID not found on the page.');
+ return;
+ }
+
+ if (!productQty) {
+ productQty = 1;
+ }
+ this.productSelected.id = productId;
+ this.productSelected.qty = productQty;
+
+ var self = this;
$('#qty').change(function() {
self.productSelected.qty = $(this).val();
});
diff --git a/view/frontend/web/js/view/checkout/ideal-fast-checkout/pay.js b/view/frontend/web/js/view/checkout/ideal-fast-checkout/pay.js
index 5235ef3d0..272012621 100644
--- a/view/frontend/web/js/view/checkout/ideal-fast-checkout/pay.js
+++ b/view/frontend/web/js/view/checkout/ideal-fast-checkout/pay.js
@@ -1,23 +1,49 @@
define([
- 'jquery',
+ 'uiComponent',
'mage/url',
+ 'jquery',
'Magento_Customer/js/customer-data',
'mage/translate',
'mage/storage'
-], function ($, urlBuilder, customerData, $t, storage) {
+], function (Component, urlBuilder, $, customerData, $t, storage) {
'use strict';
- return {
- createQuoteAndPlaceOrder: function (productData) {
- this.showLoader();
+ return Component.extend({
+ page: null,
+ paymentData: null,
+
+ initialize: function (config) {
+ this._super();
- this.page = productData.page;
- productData.order_data = this.getOrderData();
+ this.page = config.page;
+ this.paymentData = config.paymentData;
var customerDataObject = customerData.get('customer');
customerDataObject.subscribe(function (updatedCustomer) {
}.bind(this));
+
+ $(document).on('click', '#fast-checkout-ideal-btn', function() {
+ this.onCheckout();
+ }.bind(this));
+ },
+
+ onCheckout: function () {
+ var qty = $("#qty").val();
+
+ var productData = {
+ qty: qty,
+ page: this.page,
+ paymentData: this.paymentData,
+ order_data: this.getOrderData()
+ };
+
+ this.createQuoteAndPlaceOrder(productData);
+ },
+
+ createQuoteAndPlaceOrder: function (productData) {
+ this.showLoader();
+
this.processOrderFlow(productData)
.then(this.onQuoteCreateSuccess.bind(this, productData))
.catch(this.onQuoteCreateFail.bind(this));
@@ -33,7 +59,7 @@ define([
getOrderData: function () {
let form = $("#product_addtocart_form");
- return this.page === 'product' ? form.serialize() : null;
+ return this.page === "product" ? form.serialize() : null;
},
onQuoteCreateSuccess: function (productData, quoteResponse) {
@@ -123,5 +149,5 @@ define([
hideLoader: function () {
$('body').loader('hide');
}
- };
+ });
});
diff --git a/view/frontend/web/js/view/checkout/summary/already-paid.js b/view/frontend/web/js/view/checkout/summary/already-paid.js
new file mode 100644
index 000000000..189a9e139
--- /dev/null
+++ b/view/frontend/web/js/view/checkout/summary/already-paid.js
@@ -0,0 +1,42 @@
+define([
+ 'Magento_Checkout/js/view/summary/abstract-total',
+ 'Magento_Checkout/js/model/quote',
+ 'Magento_Catalog/js/price-utils',
+ 'Magento_Checkout/js/model/totals'
+], function (Component, quote, priceUtils, totals) {
+ 'use strict';
+
+ return Component.extend({
+ defaults: {
+ template: 'Buckaroo_Magento2/checkout/summary/already-paid'
+ },
+ isDisplayed: function () {
+ return this.getAlreadyPaidTotal() > 0;
+ },
+ getValue: function () {
+ var alreadyPaid = this.getAlreadyPaidTotal();
+ return this.getFormattedPrice(alreadyPaid);
+ },
+ getAlreadyPaidTotal: function () {
+ var buckarooFeeSegment = totals.getSegment('buckaroo_already_paid');
+ try {
+ if (buckarooFeeSegment.title) {
+ var items = JSON.parse(buckarooFeeSegment.title);
+ var total = 0;
+ if ((typeof items === 'object') && (items.length > 0)) {
+ for (var i = 0; i < items.length; i++) {
+ total = parseFloat(total) + parseFloat(items[i].serviceamount);
+ }
+ return parseFloat(total).toFixed(2);
+ }
+ }
+ } catch (e) {
+ }
+
+ return parseFloat(buckarooFeeSegment.value).toFixed(2);
+ },
+ getFormattedPrice: function (price) {
+ return priceUtils.formatPrice(price, quote.getPriceFormat());
+ }
+ });
+});
diff --git a/view/frontend/web/js/view/checkout/summary/grand-total.js b/view/frontend/web/js/view/checkout/summary/grand-total.js
deleted file mode 100644
index 3c1c89431..000000000
--- a/view/frontend/web/js/view/checkout/summary/grand-total.js
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
-
-/**
- * @api
- */
-
-define([
- 'Magento_Checkout/js/view/summary/abstract-total',
- 'Magento_Checkout/js/model/quote',
- 'Magento_Catalog/js/price-utils',
- 'Magento_Checkout/js/model/totals'
-], function (Component, quote, priceUtils, totals) {
- 'use strict';
-
- return Component.extend({
- defaults: {
- isFullTaxSummaryDisplayed: window.checkoutConfig.isFullTaxSummaryDisplayed || false,
- template: 'Buckaroo_Magento2/checkout/summary/grand-total'
- },
- totals: quote.getTotals(),
- isTaxDisplayedInGrandTotal: window.checkoutConfig.includeTaxInGrandTotal || false,
-
- /**
- * @return {*}
- */
- isDisplayed: function () {
- return this.isFullMode();
- },
-
- /**
- * @return {*|String}
- */
- getValue: function () {
- var price = 0;
-
- if (this.totals()) {
- price = totals.getSegment('grand_total').value;
-
- if(!isNaN(parseFloat(this.getAlreadyPayTotal()))){
- price = parseFloat(price) - parseFloat(this.getAlreadyPayTotal());
- }
- }
-
- return this.getFormattedPrice(price);
- },
-
- /**
- * @return {*|String}
- */
- getBaseValue: function () {
- var price = 0;
-
- if (this.totals()) {
- price = this.totals()['base_grand_total'];
- }
-
- return priceUtils.formatPriceLocale(price, quote.getBasePriceFormat());
- },
-
- /**
- * @return {*}
- */
- getGrandTotalExclTax: function () {
- var total = this.totals(),
- amount;
-
- if (!total) {
- return 0;
- }
-
- amount = total['grand_total'] - total['tax_amount'];
-
- if (amount < 0) {
- amount = 0;
- }
-
- return this.getFormattedPrice(amount);
- },
-
- /**
- * @return {Boolean}
- */
- isBaseGrandTotalDisplayNeeded: function () {
- var total = this.totals();
-
- if (!total) {
- return false;
- }
-
- return total['base_currency_code'] != total['quote_currency_code']; //eslint-disable-line eqeqeq
- },
-
- getAlreadyPayTotal : function () {
- var buckarooFeeSegment = totals.getSegment('buckaroo_already_paid');
- try {
- if (buckarooFeeSegment.title) {
- var items = JSON.parse(buckarooFeeSegment.title);
- var total = 0;
- if ((typeof items === 'object') && (items.length > 0)) {
- for (var i = 0; i < items.length; i++) {
- total = parseFloat(total) + parseFloat(items[i].serviceamount);
- }
- return parseFloat(total).toFixed(2);
- }
- }
- } catch (e) {
- // console.log(e);
- }
-
- return parseFloat(buckarooFeeSegment.value).toFixed(2);
- }
- });
-});
diff --git a/view/frontend/web/js/view/checkout/summary/remaining-amount.js b/view/frontend/web/js/view/checkout/summary/remaining-amount.js
new file mode 100644
index 000000000..9a12ae4f2
--- /dev/null
+++ b/view/frontend/web/js/view/checkout/summary/remaining-amount.js
@@ -0,0 +1,37 @@
+define([
+ 'Magento_Checkout/js/view/summary/abstract-total',
+ 'Magento_Checkout/js/model/quote',
+ 'Magento_Catalog/js/price-utils',
+ 'Magento_Checkout/js/model/totals'
+], function (Component, quote, priceUtils, totals) {
+ 'use strict';
+
+ return Component.extend({
+ defaults: {
+ template: 'Buckaroo_Magento2/checkout/summary/remaining-amount'
+ },
+ isDisplayed: function () {
+ return this.getAlreadyPaidTotal() < 0;
+ },
+ getValue: function () {
+ var remainingAmount = 0;
+ if (totals.getSegment('remaining_amount')) {
+ remainingAmount = totals.getSegment('remaining_amount').value;
+ }
+ return this.getFormattedPrice(remainingAmount);
+ },
+ getAlreadyPaidTotal: function () {
+ var remainingAmount = 0;
+ if (totals.getSegment('buckaroo_already_paid')) {
+ remainingAmount = totals.getSegment('buckaroo_already_paid').value;
+ }
+ return remainingAmount;
+ },
+ getTitle: function () {
+ return this.title;
+ },
+ getFormattedPrice: function (price) {
+ return priceUtils.formatPrice(price, quote.getPriceFormat());
+ }
+ });
+});
diff --git a/view/frontend/web/template/checkout/summary/already-paid.html b/view/frontend/web/template/checkout/summary/already-paid.html
new file mode 100644
index 000000000..41d367b5b
--- /dev/null
+++ b/view/frontend/web/template/checkout/summary/already-paid.html
@@ -0,0 +1,11 @@
+
+
+
+
+
+ |
+
+
+ |
+
+
diff --git a/view/frontend/web/template/checkout/summary/grand-total.html b/view/frontend/web/template/checkout/summary/grand-total.html
deleted file mode 100644
index 5a324f922..000000000
--- a/view/frontend/web/template/checkout/summary/grand-total.html
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
- |
-
-
- |
-
-
-
-
- |
-
-
- |
-
-
-
-
-
-
- |
-
-
- |
-
-
-
-
- |
-
-
- |
-
-
diff --git a/view/frontend/web/template/checkout/summary/remaining-amount.html b/view/frontend/web/template/checkout/summary/remaining-amount.html
new file mode 100644
index 000000000..bcba4c746
--- /dev/null
+++ b/view/frontend/web/template/checkout/summary/remaining-amount.html
@@ -0,0 +1,10 @@
+
+
+
+
+ |
+
+
+ |
+
+