+
@@ -158,7 +195,7 @@
Magento\Config\Model\Config\Source\Yesno
-
+
diff --git a/etc/config.xml b/etc/config.xml
index 15b6f4a..7dd019f 100644
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -19,12 +19,21 @@
direct
full_page
0
+ 1
1
Alternative Payment Methods
PAYPAL-EXPRESS,GIROPAY-SSL
+
+ Wallets
+
+ 1
+ AMEX,VISA,DISCOVER,JCB,MASTERCARD
+ PAN_ONLY,CRYPTOGRAM_3DS
+
+
1
Moto
@@ -94,6 +103,14 @@
authorize
11
+
+ Wallets
+ Sapient\Worldpay\Model\PaymentMethods\Wallets
+ 1
+ 0
+ authorize
+ 11
+
MOTO
Sapient\Worldpay\Model\PaymentMethods\Moto
diff --git a/etc/cron_groups.xml b/etc/cron_groups.xml
index 4c7f08f..e089296 100644
--- a/etc/cron_groups.xml
+++ b/etc/cron_groups.xml
@@ -9,4 +9,13 @@
600
1
+
+ 1
+ 4
+ 2
+ 10
+ 60
+ 600
+ 1
+
\ No newline at end of file
diff --git a/etc/crontab.xml b/etc/crontab.xml
index a76b433..e0bad5b 100644
--- a/etc/crontab.xml
+++ b/etc/crontab.xml
@@ -5,4 +5,9 @@
* * * * *
+
+
+ * * * * *
+
+
\ No newline at end of file
diff --git a/etc/di.xml b/etc/di.xml
index d0636ff..be9a2b0 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -14,6 +14,12 @@
+
+
+
+
+
+
@@ -27,6 +33,7 @@
- worldpay_apm
- worldpay_moto
- worldpay_cc_vault
+ - worldpay_wallets
diff --git a/etc/paymentmethods.xml b/etc/paymentmethods.xml
index fba68a8..d351d6b 100644
--- a/etc/paymentmethods.xml
+++ b/etc/paymentmethods.xml
@@ -441,4 +441,144 @@
+
+ Wallets
+
+
+ Apple Pay
+
+ AU
+ AT
+ BE
+ BR
+ CA
+ CN
+ DK
+ EG
+ FI
+ FR
+ DE
+ GH
+ GR
+ HK
+ IN
+ ID
+ IE
+ IT
+ JP
+ MY
+ MX
+ NL
+ NZ
+ NG
+ NO
+ PH
+ PL
+ PT
+ RU
+ SG
+ ZA
+ KR
+ ES
+ SE
+ CH
+ TH
+ GB
+ US
+ VN
+
+ 1
+
+
+ Google Pay
+
+ AU
+ AT
+ BE
+ BR
+ CA
+ CN
+ DK
+ EG
+ FI
+ FR
+ DE
+ GH
+ GR
+ HK
+ IN
+ ID
+ IE
+ IT
+ JP
+ MY
+ MX
+ NL
+ NZ
+ NG
+ NO
+ PH
+ PL
+ PT
+ RU
+ SG
+ ZA
+ KR
+ ES
+ SE
+ CH
+ TH
+ GB
+ US
+ VN
+
+ 1
+
+
+ Samsung Pay
+
+ AU
+ AT
+ BE
+ BR
+ CA
+ CN
+ DK
+ EG
+ FI
+ FR
+ DE
+ GH
+ GR
+ HK
+ IN
+ ID
+ IE
+ IT
+ JP
+ MY
+ MX
+ NL
+ NZ
+ NG
+ NO
+ PH
+ PL
+ PT
+ RU
+ SG
+ ZA
+ KR
+ ES
+ SE
+ CH
+ TH
+ GB
+ US
+ VN
+
+ 1
+
+
+
diff --git a/view/frontend/layout/checkout_cart_index.xml b/view/frontend/layout/checkout_cart_index.xml
index d34e21f..adf8526 100644
--- a/view/frontend/layout/checkout_cart_index.xml
+++ b/view/frontend/layout/checkout_cart_index.xml
@@ -3,6 +3,13 @@
-
+
+
+
+
+ Sapient_Worldpay::onepage/link.phtml
+
+
+
\ No newline at end of file
diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml
index 2d22ab3..83a3649 100644
--- a/view/frontend/layout/checkout_index_index.xml
+++ b/view/frontend/layout/checkout_index_index.xml
@@ -29,6 +29,9 @@
-
- true
+ -
+
- true
+
diff --git a/view/frontend/layout/checkout_onepage_success.xml b/view/frontend/layout/checkout_onepage_success.xml
new file mode 100644
index 0000000..4526c2f
--- /dev/null
+++ b/view/frontend/layout/checkout_onepage_success.xml
@@ -0,0 +1,26 @@
+
+
+
+
+ Success Page
+
+
+
+
+
+ Thank you for your purchase!
+
+
+
+
+
+
+
+
+
+
diff --git a/view/frontend/layout/default.xml b/view/frontend/layout/default.xml
new file mode 100644
index 0000000..6ead6a9
--- /dev/null
+++ b/view/frontend/layout/default.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/view/frontend/requirejs-config.js b/view/frontend/requirejs-config.js
index 8ef686b..15e4529 100644
--- a/view/frontend/requirejs-config.js
+++ b/view/frontend/requirejs-config.js
@@ -1,7 +1,17 @@
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
var config = {
map: {
'*': {
worldpay: 'https://payments.worldpay.com/resources/cse/js/worldpay-cse-1.0.1.min.js',
+ googlePay: 'https://pay.google.com/gp/p/js/pay.js',
+ "Magento_Checkout/js/sidebar": "Sapient_Worldpay/js/sidebar",
+ "Magento_Checkout/js/proceed-to-checkout": "Sapient_Worldpay/js/proceed-to-checkout",
+ "Magento_Checkout/template/minicart/content.html":
+ "Sapient_Worldpay/template/minicart/content.html",
+ "Magento_Checkout/js/view/minicart": "Sapient_Worldpay/js/minicart"
}
}
};
diff --git a/view/frontend/templates/cart/minicart.phtml b/view/frontend/templates/cart/minicart.phtml
new file mode 100644
index 0000000..af63b15
--- /dev/null
+++ b/view/frontend/templates/cart/minicart.phtml
@@ -0,0 +1,62 @@
+
+
+
+
+
diff --git a/view/frontend/templates/onepage/link.phtml b/view/frontend/templates/onepage/link.phtml
new file mode 100644
index 0000000..0451451
--- /dev/null
+++ b/view/frontend/templates/onepage/link.phtml
@@ -0,0 +1,36 @@
+
+isPossibleOnepageCheckout()):?>
+
+
+
+
+
+
+
diff --git a/view/frontend/templates/success.phtml b/view/frontend/templates/success.phtml
new file mode 100644
index 0000000..0741f86
--- /dev/null
+++ b/view/frontend/templates/success.phtml
@@ -0,0 +1,38 @@
+
+
+
+
+
+ getOrderId()):?>
+ getCanViewOrder()) :?>
+
= __('Your order number is: %1.', sprintf('%s', $block->escapeHtml($block->getViewOrderUrl()), $block->escapeHtml($block->getOrderId()))) ?>
+
+
= __('Your order # is: %1.', $block->escapeHtml($block->getOrderId())) ?>
+
+
= /* @escapeNotVerified */ __('We\'ll email you an order confirmation with details and tracking info.') ?>
+
+
+ = $block->getAdditionalInfoHtml() ?>
+
+
+
diff --git a/view/frontend/templates/webpayment.phtml b/view/frontend/templates/webpayment.phtml
new file mode 100644
index 0000000..46387de
--- /dev/null
+++ b/view/frontend/templates/webpayment.phtml
@@ -0,0 +1,451 @@
+getRequest()->getParams();
+if (array_key_exists('chromepay', $param)) {
+ ?>
+
+
+ _messageManager->addError(__("Error occurred, please check your card details."));
+}
+
+$cusToken = 'Bearer ' . $block->getCustomerToken();
+
+/** @var $block \Sapient\Worldpay\Block\Webpayment */
+?>
+
+
+
+
diff --git a/view/frontend/web/images/cc/visa_debit-ssl.png b/view/frontend/web/images/cc/visa_debit-ssl.png
new file mode 100644
index 0000000..120f377
Binary files /dev/null and b/view/frontend/web/images/cc/visa_debit-ssl.png differ
diff --git a/view/frontend/web/js/minicart.js b/view/frontend/web/js/minicart.js
new file mode 100644
index 0000000..6616e0b
--- /dev/null
+++ b/view/frontend/web/js/minicart.js
@@ -0,0 +1,202 @@
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+define([
+ 'uiComponent',
+ 'Magento_Customer/js/customer-data',
+ 'jquery',
+ 'ko',
+ 'underscore',
+ 'sidebar',
+ 'mage/translate',
+ 'mage/dropdown'
+], function (Component, customerData, $, ko, _) {
+ 'use strict';
+
+ var sidebarInitialized = false,
+ addToCartCalls = 0,
+ miniCart;
+
+ miniCart = $('[data-block=\'minicart\']');
+
+ /**
+ * @return {Boolean}
+ */
+ function initSidebar() {
+ if (miniCart.data('mageSidebar')) {
+ miniCart.sidebar('update');
+ }
+
+ if (!$('[data-role=product-item]').length) {
+ return false;
+ }
+ miniCart.trigger('contentUpdated');
+
+ if (sidebarInitialized) {
+ return false;
+ }
+ sidebarInitialized = true;
+ miniCart.sidebar({
+ 'targetElement': 'div.block.block-minicart',
+ 'url': {
+ 'checkout': window.checkout.checkoutUrl,
+ 'update': window.checkout.updateItemQtyUrl,
+ 'remove': window.checkout.removeItemUrl,
+ 'loginUrl': window.checkout.customerLoginUrl,
+ 'isRedirectRequired': window.checkout.isRedirectRequired
+ },
+ 'button': {
+ 'checkout': '#top-cart-btn-checkout',
+ 'remove': '#mini-cart a.action.delete',
+ 'close': '#btn-minicart-close'
+ },
+ 'showcart': {
+ 'parent': 'span.counter',
+ 'qty': 'span.counter-number',
+ 'label': 'span.counter-label'
+ },
+ 'minicart': {
+ 'list': '#mini-cart',
+ 'content': '#minicart-content-wrapper',
+ 'qty': 'div.items-total',
+ 'subtotal': 'div.subtotal span.price',
+ 'maxItemsVisible': window.checkout.minicartMaxItemsVisible
+ },
+ 'item': {
+ 'qty': ':input.cart-item-qty',
+ 'button': ':button.update-cart-item'
+ },
+ 'confirmMessage': $.mage.__('Are you sure you would like to remove this item from the shopping cart?')
+ });
+ }
+
+ miniCart.on('dropdowndialogopen', function () {
+ initSidebar();
+ });
+
+
+ return Component.extend({
+ shoppingCartUrl: window.checkout.shoppingCartUrl,
+ maxItemsToDisplay: window.checkout.maxItemsToDisplay,
+ checkoutNowUrl: window.checkout.shoppingCartUrl+'?chromepay=1',
+ proceedToCheckoutUrl: window.checkout.checkoutUrl,
+
+ checkoutNowTitle: window.ChromepayButtonName,
+ chromepayEnabled: window.ChromepayEnabled,
+ chromePaymentMode: window.ChromePaymentMode,
+
+ cart: {},
+
+ /**
+ * @override
+ */
+ initialize: function () {
+ var self = this,
+ cartData = customerData.get('cart');
+
+ this.update(cartData());
+ cartData.subscribe(function (updatedCart) {
+ addToCartCalls--;
+ this.isLoading(addToCartCalls > 0);
+ sidebarInitialized = false;
+ this.update(updatedCart);
+ initSidebar();
+ }, this);
+ $('[data-block="minicart"]').on('contentLoading', function () {
+ addToCartCalls++;
+ self.isLoading(true);
+ });
+
+ if (cartData()['website_id'] !== window.checkout.websiteId) {
+ customerData.reload(['cart'], false);
+ }
+
+ return this._super();
+ },
+ isLoading: ko.observable(false),
+ initSidebar: initSidebar,
+
+ /**
+ * Close mini shopping cart.
+ */
+ closeMinicart: function () {
+ $('[data-block="minicart"]').find('[data-role="dropdownDialog"]').dropdownDialog('close');
+ },
+
+ /**
+ * @return {Boolean}
+ */
+ closeSidebar: function () {
+ var minicart = $('[data-block="minicart"]');
+
+ minicart.on('click', '[data-action="close"]', function (event) {
+ event.stopPropagation();
+ minicart.find('[data-role="dropdownDialog"]').dropdownDialog('close');
+ });
+
+ return true;
+ },
+
+ /**
+ * @param {String} productType
+ * @return {*|String}
+ */
+ getItemRenderer: function (productType) {
+ return this.itemRenderer[productType] || 'defaultRenderer';
+ },
+
+ /**
+ * Update mini shopping cart content.
+ *
+ * @param {Object} updatedCart
+ * @returns void
+ */
+ update: function (updatedCart) {
+ _.each(updatedCart, function (value, key) {
+ if (!this.cart.hasOwnProperty(key)) {
+ this.cart[key] = ko.observable();
+ }
+ this.cart[key](value);
+ }, this);
+ },
+
+ /**
+ * Get cart param by name.
+ * @param {String} name
+ * @returns {*}
+ */
+ getCartParam: function (name) {
+ if (!_.isUndefined(name)) {
+ if (!this.cart.hasOwnProperty(name)) {
+ this.cart[name] = ko.observable();
+ }
+ }
+
+ return this.cart[name]();
+ },
+
+ /**
+ * Returns array of cart items, limited by 'maxItemsToDisplay' setting
+ * @returns []
+ */
+ getCartItems: function () {
+ var items = this.getCartParam('items') || [];
+
+ items = items.slice(parseInt(-this.maxItemsToDisplay, 10));
+
+ return items;
+ },
+
+ /**
+ * Returns count of cart line items
+ * @returns {Number}
+ */
+ getCartLineItemsCount: function () {
+ var items = this.getCartParam('items') || [];
+
+ return parseInt(items.length, 10);
+ }
+ });
+});
diff --git a/view/frontend/web/js/proceed-to-checkout.js b/view/frontend/web/js/proceed-to-checkout.js
new file mode 100644
index 0000000..ad6bce5
--- /dev/null
+++ b/view/frontend/web/js/proceed-to-checkout.js
@@ -0,0 +1,37 @@
+define([
+ 'jquery',
+ 'Magento_Customer/js/model/authentication-popup',
+ 'Magento_Customer/js/customer-data'
+], function ($, authenticationPopup, customerData) {
+ 'use strict';
+
+ return function (config, element) {
+
+ $(element).click(function (event) {
+ var cart = customerData.get('cart'),
+ customer = customerData.get('customer');
+
+ event.preventDefault();
+ //
+ // if (!customer().firstname && cart().isGuestCheckoutAllowed === false) {
+ // authenticationPopup.showModal();
+ //
+ // return false;
+ // }
+
+ if(window.PaymentRequest && window.ChromepayEnabled == 1 && window.ChromePaymentMode == 'direct') {
+ var request = initPaymentRequest();
+ onBuyClicked(request);
+ request = initPaymentRequest();
+
+ console.log('got it 111');
+
+ console.log(request);
+ //window.location = "http://worldpay.localhost:81/webpayment";
+ } else {
+ location.href = this.options.url.checkout;
+ }
+ });
+
+ };
+});
\ No newline at end of file
diff --git a/view/frontend/web/js/sidebar.js b/view/frontend/web/js/sidebar.js
new file mode 100644
index 0000000..1926b77
--- /dev/null
+++ b/view/frontend/web/js/sidebar.js
@@ -0,0 +1,330 @@
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+define([
+ 'jquery',
+ 'Magento_Customer/js/model/authentication-popup',
+ 'Magento_Customer/js/customer-data',
+ 'Magento_Ui/js/modal/alert',
+ 'Magento_Ui/js/modal/confirm',
+ 'jquery/ui',
+ 'mage/decorate',
+ 'mage/collapsible',
+ 'mage/cookies'
+], function ($, authenticationPopup, customerData, alert, confirm) {
+ 'use strict';
+
+ $.widget('mage.sidebar', {
+ options: {
+ isRecursive: true,
+ minicart: {
+ maxItemsVisible: 3
+ }
+ },
+ scrollHeight: 0,
+
+ /**
+ * Create sidebar.
+ * @private
+ */
+ _create: function () {
+ this._initContent();
+ },
+
+ /**
+ * Update sidebar block.
+ */
+ update: function () {
+ $(this.options.targetElement).trigger('contentUpdated');
+ this._calcHeight();
+ this._isOverflowed();
+ },
+
+ /**
+ * @private
+ */
+ _initContent: function () {
+ var self = this,
+ events = {};
+
+ this.element.decorate('list', this.options.isRecursive);
+
+ /**
+ * @param {jQuery.Event} event
+ */
+ events['click ' + this.options.button.close] = function (event) {
+ event.stopPropagation();
+ $(self.options.targetElement).dropdownDialog('close');
+ };
+ events['click ' + this.options.button.checkout] = $.proxy(function () {
+ var cart = customerData.get('cart'),
+ customer = customerData.get('customer');
+
+ if (!customer().firstname && cart().isGuestCheckoutAllowed === false) {
+ // set URL for redirect on successful login/registration. It's postprocessed on backend.
+ $.cookie('login_redirect', this.options.url.checkout);
+
+ if (this.options.url.isRedirectRequired) {
+ location.href = this.options.url.loginUrl;
+ } else {
+ authenticationPopup.showModal();
+ }
+
+ return false;
+ }
+
+ if(window.PaymentRequest && window.ChromepayEnabled == 1 && window.ChromePaymentMode == 'direct') {
+ var request = initPaymentRequest();
+ onBuyClicked(request);
+ // request = initPaymentRequest();
+ } else {
+ location.href = this.options.url.checkout;
+ }
+ }, this);
+
+ /**
+ * @param {jQuery.Event} event
+ */
+ events['click ' + this.options.button.remove] = function (event) {
+ event.stopPropagation();
+ confirm({
+ content: self.options.confirmMessage,
+ actions: {
+ /** @inheritdoc */
+ confirm: function () {
+ self._removeItem($(event.currentTarget));
+ },
+
+ /** @inheritdoc */
+ always: function (e) {
+ e.stopImmediatePropagation();
+ }
+ }
+ });
+ };
+
+ /**
+ * @param {jQuery.Event} event
+ */
+ events['keyup ' + this.options.item.qty] = function (event) {
+ self._showItemButton($(event.target));
+ };
+
+ /**
+ * @param {jQuery.Event} event
+ */
+ events['click ' + this.options.item.button] = function (event) {
+ event.stopPropagation();
+ self._updateItemQty($(event.currentTarget));
+ };
+
+ /**
+ * @param {jQuery.Event} event
+ */
+ events['focusout ' + this.options.item.qty] = function (event) {
+ self._validateQty($(event.currentTarget));
+ };
+
+ this._on(this.element, events);
+ this._calcHeight();
+ this._isOverflowed();
+ },
+
+ /**
+ * Add 'overflowed' class to minicart items wrapper element
+ *
+ * @private
+ */
+ _isOverflowed: function () {
+ var list = $(this.options.minicart.list),
+ cssOverflowClass = 'overflowed';
+
+ if (this.scrollHeight > list.innerHeight()) {
+ list.parent().addClass(cssOverflowClass);
+ } else {
+ list.parent().removeClass(cssOverflowClass);
+ }
+ },
+
+ /**
+ * @param {HTMLElement} elem
+ * @private
+ */
+ _showItemButton: function (elem) {
+ var itemId = elem.data('cart-item'),
+ itemQty = elem.data('item-qty');
+
+ if (this._isValidQty(itemQty, elem.val())) {
+ $('#update-cart-item-' + itemId).show('fade', 300);
+ } else if (elem.val() == 0) { //eslint-disable-line eqeqeq
+ this._hideItemButton(elem);
+ } else {
+ this._hideItemButton(elem);
+ }
+ },
+
+ /**
+ * @param {*} origin - origin qty. 'data-item-qty' attribute.
+ * @param {*} changed - new qty.
+ * @returns {Boolean}
+ * @private
+ */
+ _isValidQty: function (origin, changed) {
+ return origin != changed && //eslint-disable-line eqeqeq
+ changed.length > 0 &&
+ changed - 0 == changed && //eslint-disable-line eqeqeq
+ changed - 0 > 0;
+ },
+
+ /**
+ * @param {Object} elem
+ * @private
+ */
+ _validateQty: function (elem) {
+ var itemQty = elem.data('item-qty');
+
+ if (!this._isValidQty(itemQty, elem.val())) {
+ elem.val(itemQty);
+ }
+ },
+
+ /**
+ * @param {HTMLElement} elem
+ * @private
+ */
+ _hideItemButton: function (elem) {
+ var itemId = elem.data('cart-item');
+
+ $('#update-cart-item-' + itemId).hide('fade', 300);
+ },
+
+ /**
+ * @param {HTMLElement} elem
+ * @private
+ */
+ _updateItemQty: function (elem) {
+ var itemId = elem.data('cart-item');
+
+ this._ajax(this.options.url.update, {
+ 'item_id': itemId,
+ 'item_qty': $('#cart-item-' + itemId + '-qty').val()
+ }, elem, this._updateItemQtyAfter);
+ },
+
+ /**
+ * Update content after update qty
+ *
+ * @param {HTMLElement} elem
+ */
+ _updateItemQtyAfter: function (elem) {
+ this._hideItemButton(elem);
+ },
+
+ /**
+ * @param {HTMLElement} elem
+ * @private
+ */
+ _removeItem: function (elem) {
+ var itemId = elem.data('cart-item');
+
+ this._ajax(this.options.url.remove, {
+ 'item_id': itemId
+ }, elem, this._removeItemAfter);
+ },
+
+ /**
+ * Update content after item remove
+ *
+ * @param {Object} elem
+ * @private
+ */
+ _removeItemAfter: function (elem) {
+ var productData = customerData.get('cart')().items.find(function (item) {
+ return Number(elem.data('cart-item')) === Number(item['item_id']);
+ });
+
+ $(document).trigger('ajax:removeFromCart', productData['product_sku']);
+ },
+
+ /**
+ * @param {String} url - ajax url
+ * @param {Object} data - post data for ajax call
+ * @param {Object} elem - element that initiated the event
+ * @param {Function} callback - callback method to execute after AJAX success
+ */
+ _ajax: function (url, data, elem, callback) {
+ $.extend(data, {
+ 'form_key': $.mage.cookies.get('form_key')
+ });
+
+ $.ajax({
+ url: url,
+ data: data,
+ type: 'post',
+ dataType: 'json',
+ context: this,
+
+ /** @inheritdoc */
+ beforeSend: function () {
+ elem.attr('disabled', 'disabled');
+ },
+
+ /** @inheritdoc */
+ complete: function () {
+ elem.attr('disabled', null);
+ }
+ })
+ .done(function (response) {
+ var msg;
+
+ if (response.success) {
+ callback.call(this, elem, response);
+ } else {
+ msg = response['error_message'];
+
+ if (msg) {
+ alert({
+ content: msg
+ });
+ }
+ }
+ })
+ .fail(function (error) {
+ console.log(JSON.stringify(error));
+ });
+ },
+
+ /**
+ * Calculate height of minicart list
+ *
+ * @private
+ */
+ _calcHeight: function () {
+ var self = this,
+ height = 0,
+ counter = this.options.minicart.maxItemsVisible,
+ target = $(this.options.minicart.list),
+ outerHeight;
+
+ self.scrollHeight = 0;
+ target.children().each(function () {
+
+ if ($(this).find('.options').length > 0) {
+ $(this).collapsible();
+ }
+ outerHeight = $(this).outerHeight();
+
+ if (counter-- > 0) {
+ height += outerHeight;
+ }
+ self.scrollHeight += outerHeight;
+ });
+
+ target.parent().height(height);
+ }
+ });
+
+ return $.mage.sidebar;
+});
diff --git a/view/frontend/web/js/view/payment/method-renderer/apm-method.js b/view/frontend/web/js/view/payment/method-renderer/apm-method.js
index 1e23157..0cd566b 100644
--- a/view/frontend/web/js/view/payment/method-renderer/apm-method.js
+++ b/view/frontend/web/js/view/payment/method-renderer/apm-method.js
@@ -74,35 +74,34 @@ define(
serviceUrl, JSON.stringify(payload)
).done(
function (apiresponse) {
- var response = JSON.parse(apiresponse);
- if(response.length){
- for (var responsekey in response) {
- var found = false;
- for(var key in ccavailabletypes) {
- if(response[responsekey] == key.toUpperCase()){
- found = true;
- cckey = key;
- ccvalue = ccavailabletypes[key];
- break;
- }
- }
-
- if(found){
- filtercclist[cckey] = ccvalue;
- }
+ var response = JSON.parse(apiresponse);
+ if(response.length){
+ $.each(response, function(responsekey, value){
+ var found = false;
+ $.each(ccavailabletypes, function(key, value){
+ if(response[responsekey] == key.toUpperCase()){
+ found = true;
+ cckey = key;
+ ccvalue = ccavailabletypes[key];
+ return false;
+ }
+ });
+ if(found){
+ filtercclist[cckey] = ccvalue;
}
- }else{
- filtercclist = ccavailabletypes;
- }
+ });
+ }else{
+ filtercclist = ccavailabletypes;
+ }
- var ccTypesArr1 = _.map(filtercclist, function (value, key) {
- return {
- 'ccValue': key,
- 'ccLabel': value
+ var ccTypesArr1 = _.map(filtercclist, function (value, key) {
+ return {
+ 'ccValue': key,
+ 'ccLabel': value
};
- });
+ });
- fullScreenLoader.stopLoader();
+ fullScreenLoader.stopLoader();
ccTypesArr(ccTypesArr1);
}
).fail(
@@ -213,5 +212,3 @@ define(
});
}
);
-
-
diff --git a/view/frontend/web/js/view/payment/method-renderer/cc-method.js b/view/frontend/web/js/view/payment/method-renderer/cc-method.js
index 2fb1cd6..f7b41fb 100644
--- a/view/frontend/web/js/view/payment/method-renderer/cc-method.js
+++ b/view/frontend/web/js/view/payment/method-renderer/cc-method.js
@@ -122,24 +122,27 @@ define(
function (apiresponse) {
var response = JSON.parse(apiresponse);
if(response.length){
- if(savedcardlists.length > 0){
- for (var key in savedcardlists) {
- var method = savedcardlists[key]['method'];
- var found = false;
- for (var responsekey in response) {
- if(method.toUpperCase() == response[responsekey]){
- found = true;
- break;
+ if (savedcardlists.length) {
+ $.each(savedcardlists, function(key, value){
+ var method = savedcardlists[key]['method'];
+ if (typeof method == 'undefined') {
+ return true;
}
- }
-
- if(found){
- filtercards.push(savedcardlists[key]);
- }
+ // commented for saved debit card access
+// var found = false;
+// $.each(response, function(responsekey, value){
+// if(method.toUpperCase() == response[responsekey]){
+// found = true;
+// return false;
+// }
+// });
+// if(found){
+ filtercards.push(savedcardlists[key]);
+ //}
+ });
}
- }
- for (var responsekey in response) {
+ for (var responsekey in response) {
var found = false;
for(var key in ccavailabletypes) {
if(key != 'savedcard'){
@@ -350,23 +353,27 @@ define(
}else if($form.validation() && $form.validation('isValid')){
//Direct form handle
this.saveMyCard = $('#' + this.getCode() + '_save_card').is(":checked");
- if (this.isClientSideEncryptionEnabled() && this.intigrationmode == 'direct') {
- var that = this;
- require(["https://payments.worldpay.com/resources/cse/js/worldpay-cse-1.0.1.min.js"], function(worldpay){
- worldpay.setPublicKey(that.getCsePublicKey());
- var cseData = {
- cvc: that.creditCardVerificationNumber(),
- cardHolderName: $('#' + that.getCode() + '_cc_name').val(),
- cardNumber: that.creditCardNumber(),
- expiryMonth: that.creditCardExpMonth(),
- expiryYear: that.creditCardExpYear()
- };
- var encryptedData = worldpay.encrypt(cseData);
- that.cseData = encryptedData;
- //place order with direct CSE method
- self.placeOrder();
- });
- } else if(this.intigrationmode == 'redirect'){
+ if (this.intigrationmode == 'direct') {
+ var that = this;
+ if(this.isClientSideEncryptionEnabled()){
+ require(["https://payments.worldpay.com/resources/cse/js/worldpay-cse-1.0.1.min.js"], function (worldpay) {
+ worldpay.setPublicKey(that.getCsePublicKey());
+ var cseData = {
+ cvc: that.creditCardVerificationNumber(),
+ cardHolderName: $('#' + that.getCode() + '_cc_name').val(),
+ cardNumber: that.creditCardNumber(),
+ expiryMonth: that.creditCardExpMonth(),
+ expiryYear: that.creditCardExpYear()
+ };
+ var encryptedData = worldpay.encrypt(cseData);
+ that.cseData = encryptedData;
+ //place order with direct CSE method
+ self.placeOrder();
+ });
+ } else{
+ self.placeOrder();
+ }
+ }else if(this.intigrationmode == 'redirect'){
//place order with Redirect CSE Method
self.placeOrder();
}
@@ -385,4 +392,4 @@ define(
}
});
}
-);
+);
\ No newline at end of file
diff --git a/view/frontend/web/js/view/payment/method-renderer/wallets-method.js b/view/frontend/web/js/view/payment/method-renderer/wallets-method.js
new file mode 100644
index 0000000..83862cf
--- /dev/null
+++ b/view/frontend/web/js/view/payment/method-renderer/wallets-method.js
@@ -0,0 +1,239 @@
+/*browser:true*/
+/*global define*/
+define(
+ [
+ 'Magento_Payment/js/view/payment/cc-form',
+ 'jquery',
+ 'Magento_Checkout/js/model/quote',
+ 'Magento_Customer/js/model/customer',
+ 'Magento_Payment/js/model/credit-card-validation/validator',
+ 'mage/url',
+ 'Magento_Checkout/js/action/place-order',
+ 'Magento_Checkout/js/action/redirect-on-success',
+ 'ko',
+ 'Magento_Checkout/js/action/set-payment-information',
+ 'Magento_Checkout/js/model/error-processor',
+ 'Magento_Checkout/js/model/url-builder',
+ 'mage/storage',
+ 'Magento_Checkout/js/model/full-screen-loader',
+ 'googlePay'
+ ],
+ function (Component, $, quote, customer,validator, url, placeOrderAction, redirectOnSuccessAction,ko, setPaymentInformationAction, errorProcessor, urlBuilder, storage, fullScreenLoader, googlePay) {
+ 'use strict';
+ var ccTypesArr = ko.observableArray([]);
+ var paymentService = false;
+ var billingAddressCountryId = "";
+ var googleResponse = "";
+
+ /***** Google pay Elements Started */
+ const baseRequest = {apiVersion: 2, apiVersionMinor: 0 };
+ const allowedCardNetworks = window.checkoutConfig.payment.ccform.googlePaymentMethods.split(",");
+ const allowedCardAuthMethods = window.checkoutConfig.payment.ccform.googleAuthMethods.split(",");
+ const tokenizationSpecification = {
+ type: 'PAYMENT_GATEWAY',
+ parameters: {
+ 'gateway': window.checkoutConfig.payment.ccform.googleGatewayMerchantname,
+ 'gatewayMerchantId': window.checkoutConfig.payment.ccform.googleGatewayMerchantid
+ }
+ };
+
+ const baseCardPaymentMethod = {
+ type: 'CARD',
+ parameters: {
+ allowedAuthMethods: allowedCardAuthMethods,
+ allowedCardNetworks: allowedCardNetworks
+ }
+ };
+ const cardPaymentMethod = Object.assign(
+ {},
+ baseCardPaymentMethod,
+ {
+ tokenizationSpecification: tokenizationSpecification
+ }
+ );
+
+ var paymentDataRequest = null;
+ var paymentsClient = null;
+ /***** Google pay Elements End */
+
+ if (quote.billingAddress()) {
+ billingAddressCountryId = quote.billingAddress._latestValue.countryId;
+ }
+
+ function getGooglePaymentDataRequest(){
+ const paymentDataRequest = Object.assign({}, baseRequest);
+ paymentDataRequest.allowedPaymentMethods = [cardPaymentMethod];
+ paymentDataRequest.transactionInfo = getGoogleTransactionInfo();
+ paymentDataRequest.merchantInfo = {
+ // @todo a merchant ID is available for a production environment after approval by Google
+ // See {@link https://developers.google.com/pay/api/web/guides/test-and-deploy/integration-checklist|Integration checklist}
+
+ merchantId: 'b21b1d14ba43077',
+ merchantName: window.checkoutConfig.payment.ccform.googleGatewayMerchantname
+ };
+ return paymentDataRequest;
+ }
+ function getGoogleTransactionInfo(){
+ return {
+ currencyCode: window.checkoutConfig.totalsData.base_currency_code,
+ totalPriceStatus: 'FINAL',
+ // set to cart total
+ totalPrice: parseFloat(window.checkoutConfig.totalsData.base_grand_total).toFixed(2)
+ };
+ }
+ function getGooglePaymentsClient() {
+ if ( paymentsClient === null ) {
+ paymentsClient = new google.payments.api.PaymentsClient({environment: window.checkoutConfig.payment.general.environmentMode});
+ }
+ return paymentsClient;
+ }
+
+ return Component.extend({
+ defaults: {
+ redirectAfterPlaceOrder: false,
+ direcTemplate: 'Sapient_Worldpay/payment/wallets',
+ cardHolderName:'',
+ SavedcreditCardVerificationNumber:'',
+ cseData:null
+ },
+
+ initialize: function () {
+ this._super();
+ this.selectedCCType(null);
+ if(paymentService == false) {
+ this.filterwalletajax(1);
+ }
+
+ },
+ initObservable: function () {
+ var that = this;
+ this._super();
+ quote.billingAddress.subscribe(function (newAddress) {
+ if (quote.billingAddress._latestValue != null && quote.billingAddress._latestValue.countryId != billingAddressCountryId) {
+ billingAddressCountryId = quote.billingAddress._latestValue.countryId;
+ that.filterwalletajax(1);
+ paymentService = true;
+ }
+ });
+ return this;
+ },
+ filterwalletajax: function(statusCheck = null){
+ if(!statusCheck){
+ return;
+ }
+ if (quote.billingAddress._latestValue == null) {
+ return;
+ }
+ var ccavailabletypes = this.getCcAvailableTypes();
+ var filtercclist = {};
+
+ fullScreenLoader.startLoader();
+
+ filtercclist = ccavailabletypes;
+
+ var ccTypesArr1 = _.map(filtercclist, function (value, key) {
+ return {
+ 'ccValue': key,
+ 'ccLabel': value
+ };
+ });
+ fullScreenLoader.stopLoader();
+ ccTypesArr(ccTypesArr1);
+ //filtersavedcardLists(filtercards);
+ },
+
+ getCcAvailableTypesValues : function(){
+ return ccTypesArr;
+ },
+
+ availableCCTypes : function(){
+ return ccTypesArr;
+ },
+ selectedCCType : ko.observable(),
+ //paymentToken:ko.observable(),
+
+ getCode: function() {
+ return 'worldpay_wallets';
+ },
+
+ getTemplate: function(){
+ return this.direcTemplate;
+ },
+
+ /**
+ * Get payment icons
+ * @param {String} type
+ * @returns {Boolean}
+ */
+ getIcons: function (type) {
+ return window.checkoutConfig.payment.ccform.wpicons.hasOwnProperty(type) ?
+ window.checkoutConfig.payment.ccform.wpicons[type]
+ : false;
+ },
+
+ getTitle: function() {
+ return window.checkoutConfig.payment.ccform.walletstitle ;
+ },
+ isActive: function() {
+ return true;
+ },
+ paymentMethodSelection: function() {
+ return window.checkoutConfig.payment.ccform.paymentMethodSelection;
+ },
+ getselectedCCType : function(){
+ if(this.paymentMethodSelection()=='radio'){
+ return $("input[name='wallets_type']:checked").val();
+ } else{
+ return this.selectedCCType();
+ }
+ },
+
+ /**
+ * @override
+ */
+ getData: function () {
+ return {
+ 'method': "worldpay_wallets",
+ 'additional_data': {
+ 'cc_type': this.getselectedCCType(),
+ 'walletResponse' : googleResponse
+ }
+ };
+ },
+ preparePayment:function() {
+ var self = this;
+ var $form = $('#' + this.getCode() + '-form');
+ if(this.getselectedCCType()== undefined){
+ $('.mage-error').css({'display' : 'block','margin-bottom': '7px'});
+ $('.mage-error').html('Please select one of the options.');
+ return false;
+ }
+ if (this.getselectedCCType()=='PAYWITHGOOGLE-SSL') {
+ const paymentsClient = getGooglePaymentsClient();
+ const paymentDataRequest = getGooglePaymentDataRequest();
+ paymentDataRequest.transactionInfo = getGoogleTransactionInfo();
+ paymentsClient.loadPaymentData(paymentDataRequest)
+ .then(function(paymentData) {
+ googleResponse = JSON.stringify(paymentData);
+ if($form.validation() && $form.validation('isValid')){
+ self.placeOrder();
+ }else {
+ return $form.validation() && $form.validation('isValid');
+ }
+ })
+ .catch(function(err) {
+ // show error in developer console for debugging
+ console.log('payment client resposnse else condition');
+ console.error(err);
+ return false;
+ });
+ }
+
+ },
+ afterPlaceOrder: function (data, event) {
+ window.location.replace(url.build('worldpay/wallets/success'));
+ }
+
+ });
+ }
+);
diff --git a/view/frontend/web/js/view/payment/methodrenderer.js b/view/frontend/web/js/view/payment/methodrenderer.js
index 72f83f9..e0be796 100644
--- a/view/frontend/web/js/view/payment/methodrenderer.js
+++ b/view/frontend/web/js/view/payment/methodrenderer.js
@@ -18,10 +18,12 @@ define(
'use strict';
var CCcomponent = 'Sapient_Worldpay/js/view/payment/method-renderer/cc-method';
var APMcomponent = 'Sapient_Worldpay/js/view/payment/method-renderer/apm-method';
+ var Walletscomponent = 'Sapient_Worldpay/js/view/payment/method-renderer/wallets-method';
var methods = [
{type: 'worldpay_cc', component: CCcomponent},
- {type: 'worldpay_apm', component: APMcomponent}
+ {type: 'worldpay_apm', component: APMcomponent},
+ {type: 'worldpay_wallets', component: Walletscomponent}
];
$.each(methods, function (k, method) {
diff --git a/view/frontend/web/template/minicart/content.html b/view/frontend/web/template/minicart/content.html
new file mode 100644
index 0000000..7c6fb39
--- /dev/null
+++ b/view/frontend/web/template/minicart/content.html
@@ -0,0 +1,114 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/view/frontend/web/template/payment/wallets.html b/view/frontend/web/template/payment/wallets.html
new file mode 100644
index 0000000..3a33592
--- /dev/null
+++ b/view/frontend/web/template/payment/wallets.html
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+