From 157295534c3225366b7d9591156005c84fa62a59 Mon Sep 17 00:00:00 2001 From: "k.verschoor@pay.nl" Date: Mon, 16 Nov 2020 09:12:17 +0100 Subject: [PATCH 01/19] Remove duplicate code from JS --- .../view/payment/method-renderer/billink.js | 72 +++++++------------ .../view/payment/method-renderer/default.js | 1 - .../js/view/payment/method-renderer/ideal.js | 35 +-------- 3 files changed, 28 insertions(+), 80 deletions(-) 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 4427da01..145b62cb 100644 --- a/view/frontend/web/js/view/payment/method-renderer/billink.js +++ b/view/frontend/web/js/view/payment/method-renderer/billink.js @@ -3,12 +3,12 @@ define( [ 'jquery', - 'Magento_Checkout/js/view/payment/default', + 'Paynl_Payment/js/view/payment/method-renderer/default', 'mage/url', 'Magento_Checkout/js/action/place-order', - 'Magento_Checkout/js/model/quote' + 'Magento_Ui/js/modal/alert' ], - function ($, Component, url, placeOrderAction, quote) { + function ($, Component, url, placeOrderAction, alert) { 'use strict'; return Component.extend({ defaults: { @@ -35,35 +35,6 @@ define( getKVKDOB: function () { return (this.getDOB() > 0 && this.getKVK() > 0); }, - isVisible:function(){ - var currentShippingMethod = quote.shippingMethod().carrier_code+'_'+quote.shippingMethod().method_code; - var disallowedShippingMethods = []; - if(this.getDisallowedShipping()){ - disallowedShippingMethods = this.getDisallowedShipping().split(','); - } - if(disallowedShippingMethods.includes(currentShippingMethod)){ - return false; - } - if(this.getforCompany() == 1 && this.getCompany().length != 0){ - return false; - } - if(this.getforCompany() == 2 && this.getCompany().length == 0){ - return false; - } - return true; - }, - getDisallowedShipping: function () { - return window.checkoutConfig.payment.disallowedshipping[this.item.method]; - }, - getCompany: function () { - if (typeof quote.billingAddress._latestValue.company !== 'undefined') { - return quote.billingAddress._latestValue.company; - } - return ''; - }, - getforCompany : function () { - return window.checkoutConfig.payment.showforcompany[this.item.method]; - }, /** * Get payment method data */ @@ -93,29 +64,41 @@ define( } }; }, - getInstructions: function () { - return window.checkoutConfig.payment.instructions[this.item.method]; - }, - getPaymentIcon: function () { - return window.checkoutConfig.payment.icon[this.item.method]; - }, placeOrder: function (data, event) { var placeOrder; var showingKVK = this.getKVK() == 2; var showingDOB = this.getDOB() == 2; if (showingKVK) { - if (this.billink_agree != true) { - alert('U dient eerst akkoord te gaan met de betalingsvoorwaarden van Billink.'); + if (this.billink_agree != true) { + alert({ + title: $.mage.__('Betalingsvoorwaarden'), + content: $.mage.__('U dient eerst akkoord te gaan met de betalingsvoorwaarden van Billink.'), + actions: { + always: function(){} + } + }); return false; } if (this.kvknummer == null || this.kvknummer.length < 8) { - alert('Voer een geldig KVK nummer in.'); + alert({ + title: $.mage.__('Ongeldig KVK nummer'), + content: $.mage.__('Voer een geldig KVK nummer in.'), + actions: { + always: function(){} + } + }); return false; } } if (showingDOB) { - if (this.dateofbirth == null || this.dateofbirth.length < 1) { - alert('Voer een geldig geboortedatum in.'); + if (this.dateofbirth == null || this.dateofbirth.length < 1) { + alert({ + title: $.mage.__('Ongeldig geboortedatum'), + content: $.mage.__('Voer een geldig geboortedatum in.'), + actions: { + always: function(){} + } + }); return false; } } @@ -135,9 +118,6 @@ define( return true; }, - afterPlaceOrder: function () { - window.location.replace(url.build('/paynl/checkout/redirect?nocache=' + (new Date().getTime()))); - }, }); } ); diff --git a/view/frontend/web/js/view/payment/method-renderer/default.js b/view/frontend/web/js/view/payment/method-renderer/default.js index 4f2410f5..a0f648e8 100644 --- a/view/frontend/web/js/view/payment/method-renderer/default.js +++ b/view/frontend/web/js/view/payment/method-renderer/default.js @@ -12,7 +12,6 @@ define( 'use strict'; return Component.extend({ redirectAfterPlaceOrder: false, - defaults: { template: 'Paynl_Payment/payment/default' }, 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 36987328..fd10171b 100644 --- a/view/frontend/web/js/view/payment/method-renderer/ideal.js +++ b/view/frontend/web/js/view/payment/method-renderer/ideal.js @@ -4,16 +4,14 @@ define( [ 'jquery', 'Paynl_Payment/js/view/payment/method-renderer/default', - 'mage/url', - 'Magento_Checkout/js/model/quote' + 'mage/url' ], - function ($, Component, url, quote) { + function ($, Component, url) { 'use strict'; return Component.extend({ defaults: { template: 'Paynl_Payment/payment/ideal' }, - selectedBank: null, getBanks: function(){ return window.checkoutConfig.payment.banks[this.item.method]; @@ -21,35 +19,6 @@ define( showBanks: function(){ return window.checkoutConfig.payment.banks[this.item.method].length > 0; }, - isVisible:function(){ - var currentShippingMethod = quote.shippingMethod().carrier_code+'_'+quote.shippingMethod().method_code; - var disallowedShippingMethods = []; - if(this.getDisallowedShipping()){ - disallowedShippingMethods = this.getDisallowedShipping().split(','); - } - if(disallowedShippingMethods.includes(currentShippingMethod)){ - return false; - } - if(this.getforCompany() == 1 && this.getCompany().length != 0){ - return false; - } - if(this.getforCompany() == 2 && this.getCompany().length == 0){ - return false; - } - return true; - }, - getDisallowedShipping: function () { - return window.checkoutConfig.payment.disallowedshipping[this.item.method]; - }, - getCompany: function () { - if (typeof quote.billingAddress._latestValue.company !== 'undefined') { - return quote.billingAddress._latestValue.company; - } - return ''; - }, - getforCompany : function () { - return window.checkoutConfig.payment.showforcompany[this.item.method]; - }, /** * Get payment method data */ From 0d09c4433fd4d2692d38ee5ad7a159a2d8ce40c9 Mon Sep 17 00:00:00 2001 From: "k.verschoor@pay.nl" Date: Wed, 18 Nov 2020 12:12:26 +0100 Subject: [PATCH 02/19] Turn both JS and HTML into 1 file. --- .../web/js/view/payment/method-renderer.js | 16 +-- .../view/payment/method-renderer/billink.js | 123 ------------------ .../view/payment/method-renderer/default.js | 107 ++++++++++++++- .../js/view/payment/method-renderer/ideal.js | 36 ----- .../web/template/payment/billink.html | 56 -------- .../web/template/payment/default.html | 21 ++- view/frontend/web/template/payment/ideal.html | 43 ------ 7 files changed, 129 insertions(+), 273 deletions(-) delete mode 100644 view/frontend/web/js/view/payment/method-renderer/billink.js delete mode 100644 view/frontend/web/js/view/payment/method-renderer/ideal.js delete mode 100644 view/frontend/web/template/payment/billink.html delete mode 100644 view/frontend/web/template/payment/ideal.html diff --git a/view/frontend/web/js/view/payment/method-renderer.js b/view/frontend/web/js/view/payment/method-renderer.js index 0c0763f0..1fe5efbd 100644 --- a/view/frontend/web/js/view/payment/method-renderer.js +++ b/view/frontend/web/js/view/payment/method-renderer.js @@ -9,15 +9,13 @@ define( rendererList) { 'use strict'; - var defaultComponent = 'Paynl_Payment/js/view/payment/method-renderer/default'; - var idealComponent = 'Paynl_Payment/js/view/payment/method-renderer/ideal'; - var billinkComponent = 'Paynl_Payment/js/view/payment/method-renderer/billink'; + var defaultComponent = 'Paynl_Payment/js/view/payment/method-renderer/default'; var methods = [ {type: 'paynl_payment_afterpay', component: defaultComponent}, {type: 'paynl_payment_alipay', component: defaultComponent}, {type: 'paynl_payment_amex', component: defaultComponent}, - {type: 'paynl_payment_billink', component: billinkComponent}, + {type: 'paynl_payment_billink', component: defaultComponent}, {type: 'paynl_payment_capayable', component: defaultComponent}, {type: 'paynl_payment_capayable_gespreid', component: defaultComponent}, {type: 'paynl_payment_cartasi', component: defaultComponent}, @@ -26,7 +24,7 @@ define( {type: 'paynl_payment_clickandbuy', component: defaultComponent}, {type: 'paynl_payment_creditclick', component: defaultComponent}, {type: 'paynl_payment_dankort', component: defaultComponent}, - {type: 'paynl_payment_decadeaukaart', component: defaultComponent}, + {type: 'paynl_payrendererListment_decadeaukaart', component: defaultComponent}, {type: 'paynl_payment_eps', component: defaultComponent}, {type: 'paynl_payment_fashioncheque', component: defaultComponent}, {type: 'paynl_payment_fashiongiftcard', component: defaultComponent}, @@ -35,10 +33,10 @@ define( {type: 'paynl_payment_giropay', component: defaultComponent}, {type: 'paynl_payment_givacard', component: defaultComponent}, {type: 'paynl_payment_huisentuincadeau', component: defaultComponent}, - {type: 'paynl_payment_ideal', component: idealComponent}, - {type: 'paynl_payment_instore', component: idealComponent}, - {type: 'paynl_payment_klarna', component: idealComponent}, - {type: 'paynl_payment_klarnakp', component: idealComponent}, + {type: 'paynl_payment_ideal', component: defaultComponent}, + {type: 'paynl_payment_instore', component: defaultComponent}, + {type: 'paynl_payment_klarna', component: defaultComponent}, + {type: 'paynl_payment_klarnakp', component: defaultComponent}, {type: 'paynl_payment_maestro', component: defaultComponent}, {type: 'paynl_payment_mistercash', component: defaultComponent}, {type: 'paynl_payment_multibanco', component: defaultComponent}, diff --git a/view/frontend/web/js/view/payment/method-renderer/billink.js b/view/frontend/web/js/view/payment/method-renderer/billink.js deleted file mode 100644 index 145b62cb..00000000 --- a/view/frontend/web/js/view/payment/method-renderer/billink.js +++ /dev/null @@ -1,123 +0,0 @@ -/*browser:true*/ -/*global define*/ -define( - [ - 'jquery', - 'Paynl_Payment/js/view/payment/method-renderer/default', - 'mage/url', - 'Magento_Checkout/js/action/place-order', - 'Magento_Ui/js/modal/alert' - ], - function ($, Component, url, placeOrderAction, alert) { - 'use strict'; - return Component.extend({ - defaults: { - template: 'Paynl_Payment/payment/billink' - }, - kvknummer: null, - dateofbirth: null, - billink_agree: null, - showKVK: function () { - return this.getKVK() > 0; - }, - getKVK: function () { - return window.checkoutConfig.payment.showkvk[this.item.method]; - }, - showDOB: function () { - return this.getDOB() > 0; - }, - getDOB: function () { - return window.checkoutConfig.payment.showdob[this.item.method]; - }, - showKVKDOB: function () { - return this.getDOB() > 0; - }, - getKVKDOB: function () { - return (this.getDOB() > 0 && this.getKVK() > 0); - }, - /** - * Get payment method data - */ - getData: function () { - - var dob = new Date(this.dateofbirth); - - var dd = dob.getDate(); - var mm = dob.getMonth() + 1; - - var yyyy = dob.getFullYear(); - if (dd < 10) { - dd = '0' + dd; - } - if (mm < 10) { - mm = '0' + mm; - } - var dob_format = dd + '-' + mm + '-' + yyyy; - - return { - 'method': this.item.method, - 'po_number': null, - 'additional_data': { - "kvknummer": this.kvknummer, - "dob": dob_format, - "billink_agree": this.billink_agree - } - }; - }, - placeOrder: function (data, event) { - var placeOrder; - var showingKVK = this.getKVK() == 2; - var showingDOB = this.getDOB() == 2; - if (showingKVK) { - if (this.billink_agree != true) { - alert({ - title: $.mage.__('Betalingsvoorwaarden'), - content: $.mage.__('U dient eerst akkoord te gaan met de betalingsvoorwaarden van Billink.'), - actions: { - always: function(){} - } - }); - return false; - } - if (this.kvknummer == null || this.kvknummer.length < 8) { - alert({ - title: $.mage.__('Ongeldig KVK nummer'), - content: $.mage.__('Voer een geldig KVK nummer in.'), - actions: { - always: function(){} - } - }); - return false; - } - } - if (showingDOB) { - if (this.dateofbirth == null || this.dateofbirth.length < 1) { - alert({ - title: $.mage.__('Ongeldig geboortedatum'), - content: $.mage.__('Voer een geldig geboortedatum in.'), - actions: { - always: function(){} - } - }); - return false; - } - } - - if (event) { - event.preventDefault(); - } - - $('#billink-button').html('Processing').attr('disabled','disabled'); - - this.isPlaceOrderActionAllowed(false); - placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder); - - $.when(placeOrder).fail(function () { - this.isPlaceOrderActionAllowed(true); - }.bind(this)).done(this.afterPlaceOrder.bind(this)); - - return true; - }, - }); - } -); diff --git a/view/frontend/web/js/view/payment/method-renderer/default.js b/view/frontend/web/js/view/payment/method-renderer/default.js index a0f648e8..e05df7f5 100644 --- a/view/frontend/web/js/view/payment/method-renderer/default.js +++ b/view/frontend/web/js/view/payment/method-renderer/default.js @@ -6,15 +6,20 @@ define( 'Magento_Checkout/js/view/payment/default', 'mage/url', 'Magento_Checkout/js/action/place-order', - 'Magento_Checkout/js/model/quote' + 'Magento_Checkout/js/model/quote', + 'Magento_Ui/js/modal/alert' ], - function ($, Component, url, placeOrderAction, quote) { + function ($, Component, url, placeOrderAction, quote, alert) { 'use strict'; return Component.extend({ redirectAfterPlaceOrder: false, defaults: { template: 'Paynl_Payment/payment/default' }, + selectedBank: null, + kvknummer: null, + dateofbirth: null, + billink_agree: null, isVisible:function(){ var currentShippingMethod = quote.shippingMethod().carrier_code+'_'+quote.shippingMethod().method_code; var disallowedShippingMethods = []; @@ -50,11 +55,105 @@ define( getPaymentIcon: function () { return window.checkoutConfig.payment.icon[this.item.method]; }, - + showKVK: function () { + return this.getKVK() > 0; + }, + getKVK: function () { + return window.checkoutConfig.payment.showkvk[this.item.method]; + }, + showDOB: function () { + return this.getDOB() > 0; + }, + getDOB: function () { + return window.checkoutConfig.payment.showdob[this.item.method]; + }, + showKVKDOB: function () { + return this.getKVKDOB() > 0; + }, + getKVKDOB: function () { + return (this.getDOB() > 0 && this.getKVK() > 0); + }, + showBanks: function(){ + return window.checkoutConfig.payment.banks[this.item.method].length > 0; + }, + getBanks: function(){ + return window.checkoutConfig.payment.banks[this.item.method]; + }, afterPlaceOrder: function () { window.location.replace(url.build('/paynl/checkout/redirect?nocache='+ (new Date().getTime()))); }, - + getData: function () { + var dob = new Date(this.dateofbirth); + var dd = dob.getDate(); + var mm = dob.getMonth() + 1; + var yyyy = dob.getFullYear(); + if (dd < 10) { + dd = '0' + dd; + } + if (mm < 10) { + mm = '0' + mm; + } + var dob_format = dd + '-' + mm + '-' + yyyy; + return { + 'method': this.item.method, + 'po_number': null, + 'additional_data': { + "kvknummer": this.kvknummer, + "dob": dob_format, + "billink_agree": this.billink_agree, + "bank_id": this.selectedBank + } + }; + }, + placeOrder: function (data, event) { + var placeOrder; + var showingKVK = this.getKVK() == 2; + var showingDOB = this.getDOB() == 2; + if (showingKVK) { + if (this.billink_agree != true) { + alert({ + title: $.mage.__('Betalingsvoorwaarden'), + content: $.mage.__('U dient eerst akkoord te gaan met de betalingsvoorwaarden.'), + actions: { + always: function(){} + } + }); + return false; + } + if (this.kvknummer == null || this.kvknummer.length < 8) { + alert({ + title: $.mage.__('Ongeldig KVK nummer'), + content: $.mage.__('Voer een geldig KVK nummer in.'), + actions: { + always: function(){} + } + }); + return false; + } + } + if (showingDOB) { + if (this.dateofbirth == null || this.dateofbirth.length < 1) { + alert({ + title: $.mage.__('Ongeldig geboortedatum'), + content: $.mage.__('Voer een geldig geboortedatum in.'), + actions: { + always: function(){} + } + }); + return false; + } + } + if (event) { + event.preventDefault(); + } + $('#payment-button').html('Processing').attr('disabled','disabled'); + this.isPlaceOrderActionAllowed(false); + placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder); + $.when(placeOrder).fail(function () { + this.isPlaceOrderActionAllowed(true); + }.bind(this)).done(this.afterPlaceOrder.bind(this)); + return true; + }, }); } ); \ No newline at end of file diff --git a/view/frontend/web/js/view/payment/method-renderer/ideal.js b/view/frontend/web/js/view/payment/method-renderer/ideal.js deleted file mode 100644 index fd10171b..00000000 --- a/view/frontend/web/js/view/payment/method-renderer/ideal.js +++ /dev/null @@ -1,36 +0,0 @@ -/*browser:true*/ -/*global define*/ -define( - [ - 'jquery', - 'Paynl_Payment/js/view/payment/method-renderer/default', - 'mage/url' - ], - function ($, Component, url) { - 'use strict'; - return Component.extend({ - defaults: { - template: 'Paynl_Payment/payment/ideal' - }, - selectedBank: null, - getBanks: function(){ - return window.checkoutConfig.payment.banks[this.item.method]; - }, - showBanks: function(){ - return window.checkoutConfig.payment.banks[this.item.method].length > 0; - }, - /** - * Get payment method data - */ - getData: function () { - return { - 'method': this.item.method, - 'po_number': null, - 'additional_data': { - "bank_id": this.selectedBank - } - }; - } - }); - } -); \ No newline at end of file diff --git a/view/frontend/web/template/payment/billink.html b/view/frontend/web/template/payment/billink.html deleted file mode 100644 index c1c7fb4c..00000000 --- a/view/frontend/web/template/payment/billink.html +++ /dev/null @@ -1,56 +0,0 @@ -
-
- - -
-
-
- - - - -
-
- - - -
-

-
- - -
-
-
-
-
- - -
- - betalingsvoorwaarden -
-
- -
-
- -
-
-
-
\ No newline at end of file diff --git a/view/frontend/web/template/payment/default.html b/view/frontend/web/template/payment/default.html index 228bc953..4d7f6704 100644 --- a/view/frontend/web/template/payment/default.html +++ b/view/frontend/web/template/payment/default.html @@ -20,11 +20,28 @@ -

+
+ +
+
+ + +
+
+
+
+
+ + +
+ + betalingsvoorwaarden +
+
- -
-
- - \ No newline at end of file From acb5a0ee3799ee3359f18b679f2068424ca917d2 Mon Sep 17 00:00:00 2001 From: "k.verschoor@pay.nl" Date: Fri, 20 Nov 2020 09:17:04 +0100 Subject: [PATCH 03/19] update3 --- .../web/js/view/payment/method-renderer.js | 2 +- .../js/view/payment/method-renderer/default.js | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/view/frontend/web/js/view/payment/method-renderer.js b/view/frontend/web/js/view/payment/method-renderer.js index 1fe5efbd..fcb6a74c 100644 --- a/view/frontend/web/js/view/payment/method-renderer.js +++ b/view/frontend/web/js/view/payment/method-renderer.js @@ -24,7 +24,7 @@ define( {type: 'paynl_payment_clickandbuy', component: defaultComponent}, {type: 'paynl_payment_creditclick', component: defaultComponent}, {type: 'paynl_payment_dankort', component: defaultComponent}, - {type: 'paynl_payrendererListment_decadeaukaart', component: defaultComponent}, + {type: 'paynl_payment_decadeaukaart', component: defaultComponent}, {type: 'paynl_payment_eps', component: defaultComponent}, {type: 'paynl_payment_fashioncheque', component: defaultComponent}, {type: 'paynl_payment_fashiongiftcard', component: defaultComponent}, diff --git a/view/frontend/web/js/view/payment/method-renderer/default.js b/view/frontend/web/js/view/payment/method-renderer/default.js index e05df7f5..4e4d98ec 100644 --- a/view/frontend/web/js/view/payment/method-renderer/default.js +++ b/view/frontend/web/js/view/payment/method-renderer/default.js @@ -21,13 +21,15 @@ define( dateofbirth: null, billink_agree: null, isVisible:function(){ - var currentShippingMethod = quote.shippingMethod().carrier_code+'_'+quote.shippingMethod().method_code; - var disallowedShippingMethods = []; - if(this.getDisallowedShipping()){ - disallowedShippingMethods = this.getDisallowedShipping().split(','); - } - if(disallowedShippingMethods.includes(currentShippingMethod)){ - return false; + var disallowedShippingMethods = this.getDisallowedShipping(); + if (disallowedShippingMethods) { + var carrier_code = typeof quote.shippingMethod().carrier_code !== 'undefined' ? quote.shippingMethod().carrier_code + '_' : ''; + var method_code = typeof quote.shippingMethod().method_code !== 'undefined' ? quote.shippingMethod().method_code : ''; + var currentShippingMethod = carrier_code + method_code; + var disallowedShippingMethodsSplitted = disallowedShippingMethods.split(','); + if (disallowedShippingMethodsSplitted.includes(currentShippingMethod) && currentShippingMethod.length > 0) { + return false; + } } if(this.getforCompany() == 1 && this.getCompany().length != 0){ return false; From 608cc3c158abfd696ab1890fe63bb7e7bbbe3d8f Mon Sep 17 00:00:00 2001 From: woutse Date: Tue, 8 Dec 2020 12:37:47 +0100 Subject: [PATCH 04/19] Added check on cancel exchange --- Controller/Checkout/Exchange.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Controller/Checkout/Exchange.php b/Controller/Checkout/Exchange.php index b35e5efd..4e20e35b 100644 --- a/Controller/Checkout/Exchange.php +++ b/Controller/Checkout/Exchange.php @@ -159,11 +159,15 @@ public function execute() if ($transaction->isPaid() || $transaction->isAuthorized()) { return $this->processPaidOrder($transaction, $order); - } elseif ($transaction->isCanceled()) { - return $this->cancelOrder($order); + if ($order->isCanceled()) { + $returnMessage = "TRUE| ALLREADY CANCELED"; + } else { + return $this->cancelOrder($order); + } } + return $this->result->setContents($returnMessage); } private function cancelOrder(Order $order) From 4a77c3e4811115f9f9a6a0e7c624c97530e46581 Mon Sep 17 00:00:00 2001 From: woutse Date: Tue, 8 Dec 2020 22:16:48 +0100 Subject: [PATCH 05/19] Added check on cancel exchange --- Controller/Checkout/Exchange.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Controller/Checkout/Exchange.php b/Controller/Checkout/Exchange.php index 4e20e35b..83930ca5 100644 --- a/Controller/Checkout/Exchange.php +++ b/Controller/Checkout/Exchange.php @@ -166,8 +166,7 @@ public function execute() return $this->cancelOrder($order); } } - - return $this->result->setContents($returnMessage); + } private function cancelOrder(Order $order) From 92137bc6d5648ed49989412edc42cc9754655d85 Mon Sep 17 00:00:00 2001 From: woutse Date: Tue, 8 Dec 2020 22:17:44 +0100 Subject: [PATCH 06/19] Added check on cancel exchange --- Controller/Checkout/Exchange.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Controller/Checkout/Exchange.php b/Controller/Checkout/Exchange.php index 83930ca5..16c09f9d 100644 --- a/Controller/Checkout/Exchange.php +++ b/Controller/Checkout/Exchange.php @@ -161,12 +161,12 @@ public function execute() return $this->processPaidOrder($transaction, $order); } elseif ($transaction->isCanceled()) { if ($order->isCanceled()) { - $returnMessage = "TRUE| ALLREADY CANCELED"; + return $this->result->setContents("TRUE| ALLREADY CANCELED"); } else { return $this->cancelOrder($order); } } - + } private function cancelOrder(Order $order) From fefcf27d729389d97b1127ad79cc1a56b7e706f9 Mon Sep 17 00:00:00 2001 From: woutse Date: Wed, 9 Dec 2020 16:46:34 +0100 Subject: [PATCH 07/19] Added check on cancel exchange --- Controller/Checkout/Exchange.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Controller/Checkout/Exchange.php b/Controller/Checkout/Exchange.php index 16c09f9d..8a7e849a 100644 --- a/Controller/Checkout/Exchange.php +++ b/Controller/Checkout/Exchange.php @@ -115,6 +115,12 @@ public function execute() \Paynl\Config::setApiToken($this->config->getApiToken()); $params = $this->getRequest()->getParams(); + $action = !empty($params['action']) ? strtolower($params['action']) : ''; + + if ($action == 'pending') { + return $this->result->setContents('TRUE| Ignore pending'); + } + if (!isset($params['order_id'])) { $this->logger->critical('Exchange: order_id is not set in the request', $params); @@ -136,7 +142,7 @@ public function execute() } if ($transaction->isPending()) { - if (isset($params['action']) && $params['action'] == 'new_ppt') { + if ($action == 'new_ppt') { return $this->result->setContents("FALSE| Payment is pending"); } return $this->result->setContents("TRUE| Ignoring pending"); From b55ec143bd4a4c1324c85da2145260664d08a06f Mon Sep 17 00:00:00 2001 From: woutse Date: Wed, 9 Dec 2020 17:13:41 +0100 Subject: [PATCH 08/19] Added check on cancel exchange --- Controller/Checkout/Exchange.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Controller/Checkout/Exchange.php b/Controller/Checkout/Exchange.php index 8a7e849a..8ae28a43 100644 --- a/Controller/Checkout/Exchange.php +++ b/Controller/Checkout/Exchange.php @@ -158,9 +158,9 @@ public function execute() return $this->result->setContents('FALSE| Cannot load order'); } if ($order->getTotalDue() <= 0) { - $this->logger->debug('Total due <= 0, so iam not touching the status of the order: ' . $orderEntityId); + $this->logger->debug('Total due <= 0, so not touching the status of the order: ' . $orderEntityId); - return $this->result->setContents('TRUE| Total due <= 0, so iam not touching the status of the order'); + return $this->result->setContents('TRUE| Ignoring: order has been paid'); } if ($transaction->isPaid() || $transaction->isAuthorized()) { From bb14b3b7d91cfb92c5d3ca754dee782eff4926ca Mon Sep 17 00:00:00 2001 From: woutse Date: Wed, 9 Dec 2020 17:14:24 +0100 Subject: [PATCH 09/19] Added check on cancel exchange --- Controller/Checkout/Exchange.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/Checkout/Exchange.php b/Controller/Checkout/Exchange.php index 8ae28a43..61e825cd 100644 --- a/Controller/Checkout/Exchange.php +++ b/Controller/Checkout/Exchange.php @@ -160,7 +160,7 @@ public function execute() if ($order->getTotalDue() <= 0) { $this->logger->debug('Total due <= 0, so not touching the status of the order: ' . $orderEntityId); - return $this->result->setContents('TRUE| Ignoring: order has been paid'); + return $this->result->setContents('TRUE| Ignoring: order has already been paid'); } if ($transaction->isPaid() || $transaction->isAuthorized()) { From a19ff654b13a4c55a034b73a3c05202df6da3cd7 Mon Sep 17 00:00:00 2001 From: woutse Date: Wed, 9 Dec 2020 21:23:37 +0100 Subject: [PATCH 10/19] Added check on cancel exchange --- Controller/Checkout/Finish.php | 6 +++++- i18n/nl_NL.csv | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Controller/Checkout/Finish.php b/Controller/Checkout/Finish.php index d764c128..94988d66 100644 --- a/Controller/Checkout/Finish.php +++ b/Controller/Checkout/Finish.php @@ -126,7 +126,11 @@ public function execute() return $resultRedirect; } - $this->messageManager->addNoticeMessage(__('Payment canceled')); + $orderStatus = empty($params['orderStatusId']) ? null : $params['orderStatusId']; + + $cancelMessage = $orderStatus == -63 ? __('Payment denied') : __('Payment canceled'); + + $this->messageManager->addNoticeMessage($cancelMessage); $cancelURL = $this->config->getCancelURL(); $resultRedirect->setPath($cancelURL); diff --git a/i18n/nl_NL.csv b/i18n/nl_NL.csv index 9ff75fc4..489bde6c 100644 --- a/i18n/nl_NL.csv +++ b/i18n/nl_NL.csv @@ -6,6 +6,7 @@ "Invalid return, no transactionId specified","Ongeldige return, geen transactieId meegegeven" "There was an error checking the transaction status","Fout bij het controleren van de transactie status" "Payment canceled","Betaling geannuleerd" +"Payment denied","Betaling afgewezen" "Something went wrong, please try again later","Er is iet mis gegaan, probeer het later nogmaals" "Enter your API-token and ServiceId first","Voer eerst je API-token en Service Id in" "No","Nee" @@ -81,4 +82,4 @@ "Shipping & Handling","Verzendkosten" "Grand Total","Totaalbedrag" "Offline refund","Offline terugbetaling" -"This will create an offline refund. To create an online refund, open an invoice and create credit memo for it. Do you want to continue?","Dit zorgt voor een offline terugbetaling. Om een ​​online terugbetaling te creëren, opent u een factuur en maakt u er een creditnota voor aan. Wilt u doorgaan?" \ No newline at end of file +"This will create an offline refund. To create an online refund, open an invoice and create credit memo for it. Do you want to continue?","Dit zorgt voor een offline terugbetaling. Om een ​​online terugbetaling te creëren, opent u een factuur en maakt u er een creditnota voor aan. Wilt u doorgaan?" From cb576839d4770e732ff56224f05a7844c7ddbae0 Mon Sep 17 00:00:00 2001 From: woutse Date: Wed, 9 Dec 2020 21:26:33 +0100 Subject: [PATCH 11/19] Added check on cancel exchange --- i18n/nl_NL.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/nl_NL.csv b/i18n/nl_NL.csv index 489bde6c..65bd2c6b 100644 --- a/i18n/nl_NL.csv +++ b/i18n/nl_NL.csv @@ -82,4 +82,4 @@ "Shipping & Handling","Verzendkosten" "Grand Total","Totaalbedrag" "Offline refund","Offline terugbetaling" -"This will create an offline refund. To create an online refund, open an invoice and create credit memo for it. Do you want to continue?","Dit zorgt voor een offline terugbetaling. Om een ​​online terugbetaling te creëren, opent u een factuur en maakt u er een creditnota voor aan. Wilt u doorgaan?" +"This will create an offline refund. To create an online refund, open an invoice and create credit memo for it. Do you want to continue?","Dit zorgt voor een offline terugbetaling. Om een ​​online terugbetaling te creëren, opent u een factuur en maakt u er een creditnota voor aan. Wilt u doorgaan?" \ No newline at end of file From 7e27f292f8adf5e3f17748e5f16b0808272db9e6 Mon Sep 17 00:00:00 2001 From: woutse Date: Mon, 21 Dec 2020 14:43:54 +0100 Subject: [PATCH 12/19] Updated composer version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3f5e7257..5d53ad4a 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "paynl/magento2-plugin", "description": "PAY. Magento2 Payment methods", "type": "magento2-module", - "version": "1.6.8", + "version": "1.6.9", "require": { "magento/module-sales": "100 - 103", "magento/module-payment": "100 - 103", From 7e3b087a1a994db2ca5e05811f7641694c71e80d Mon Sep 17 00:00:00 2001 From: kevinverschoor <61683999+kevinverschoor@users.noreply.github.com> Date: Thu, 24 Dec 2020 16:53:03 +0100 Subject: [PATCH 13/19] Fix null error when logged in without setting company --- view/frontend/web/js/view/payment/method-renderer/default.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/view/frontend/web/js/view/payment/method-renderer/default.js b/view/frontend/web/js/view/payment/method-renderer/default.js index 4e4d98ec..4739e6fd 100644 --- a/view/frontend/web/js/view/payment/method-renderer/default.js +++ b/view/frontend/web/js/view/payment/method-renderer/default.js @@ -43,7 +43,7 @@ define( return window.checkoutConfig.payment.disallowedshipping[this.item.method]; }, getCompany: function () { - if (typeof quote.billingAddress._latestValue.company !== 'undefined') { + if (typeof quote.billingAddress._latestValue.company !== 'undefined' && quote.billingAddress._latestValue.company !== null) { return quote.billingAddress._latestValue.company; } return ''; @@ -158,4 +158,4 @@ define( }, }); } -); \ No newline at end of file +); From 81c6cd8949c7a4b17c360638d1770df0425ae06f Mon Sep 17 00:00:00 2001 From: "k.verschoor@pay.nl" Date: Mon, 28 Dec 2020 12:17:23 +0100 Subject: [PATCH 14/19] add default.js --- .../view/payment/method-renderer/default.js | 165 ++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 view/frontend/web/js/view/payment/method-renderer/default.js diff --git a/view/frontend/web/js/view/payment/method-renderer/default.js b/view/frontend/web/js/view/payment/method-renderer/default.js new file mode 100644 index 00000000..b6c59db0 --- /dev/null +++ b/view/frontend/web/js/view/payment/method-renderer/default.js @@ -0,0 +1,165 @@ +/*browser:true*/ +/*global define*/ +define( + [ + 'jquery', + 'Magento_Checkout/js/view/payment/default', + 'mage/url', + 'Magento_Checkout/js/action/place-order', + 'Magento_Checkout/js/model/quote', + 'Magento_Ui/js/modal/alert' + ], + function ($, Component, url, placeOrderAction, quote, alert) { + 'use strict'; + return Component.extend({ + redirectAfterPlaceOrder: false, + defaults: { + template: 'Paynl_Payment/payment/default' + }, + selectedBank: null, + kvknummer: null, + dateofbirth: null, + billink_agree: null, + isVisible:function(){ + var disallowedShippingMethods = this.getDisallowedShipping(); + if (disallowedShippingMethods) { + var carrier_code = typeof quote.shippingMethod().carrier_code !== 'undefined' ? quote.shippingMethod().carrier_code + '_' : ''; + var method_code = typeof quote.shippingMethod().method_code !== 'undefined' ? quote.shippingMethod().method_code : ''; + var currentShippingMethod = carrier_code + method_code; + var disallowedShippingMethodsSplitted = disallowedShippingMethods.split(','); + if (disallowedShippingMethodsSplitted.includes(currentShippingMethod) && currentShippingMethod.length > 0) { + return false; + } + } + if(this.getforCompany() == 1 && this.getCompany().length != 0){ + return false; + } + if(this.getforCompany() == 2 && this.getCompany().length == 0){ + return false; + } + return true; + }, + getDisallowedShipping: function () { + return window.checkoutConfig.payment.disallowedshipping[this.item.method]; + }, + getCompany: function () { + if (typeof quote.billingAddress._latestValue.company !== 'undefined' && quote.billingAddress._latestValue.company !== null) { + return quote.billingAddress._latestValue.company; + } + return ''; + }, + getforCompany : function () { + return window.checkoutConfig.payment.showforcompany[this.item.method]; + }, + getInstructions: function () { + return window.checkoutConfig.payment.instructions[this.item.method]; + }, + getPaymentIcon: function () { + return window.checkoutConfig.payment.icon[this.item.method]; + }, + showKVK: function () { + return this.getKVK() > 0; + }, + getKVK: function () { + return window.checkoutConfig.payment.showkvk[this.item.method]; + }, + showDOB: function () { + return this.getDOB() > 0; + }, + getDOB: function () { + return window.checkoutConfig.payment.showdob[this.item.method]; + }, + showKVKDOB: function () { + return this.getKVKDOB() > 0; + }, + getKVKDOB: function () { + return (this.getDOB() > 0 && this.getKVK() > 0); + }, + showBanks: function(){ + return window.checkoutConfig.payment.banks[this.item.method].length > 0; + }, + getBanks: function(){ + return window.checkoutConfig.payment.banks[this.item.method]; + }, + afterPlaceOrder: function () { + window.location.replace(url.build('/paynl/checkout/redirect?nocache='+ (new Date().getTime()))); + }, + getData: function () { + var dob = new Date(this.dateofbirth); + var dd = dob.getDate(); + var mm = dob.getMonth() + 1; + var yyyy = dob.getFullYear(); + if (dd < 10) { + dd = '0' + dd; + } + if (mm < 10) { + mm = '0' + mm; + } + var dob_format = dd + '-' + mm + '-' + yyyy; + return { + 'method': this.item.method, + 'po_number': null, + 'additional_data': { + "kvknummer": this.kvknummer, + "dob": dob_format, + "billink_agree": this.billink_agree, + "bank_id": this.selectedBank + } + }; + }, + placeOrder: function (data, event) { + var placeOrder; + var showingKVK = this.getKVK() == 2; + var showingDOB = this.getDOB() == 2; + if (showingKVK) { + if (this.billink_agree != true) { + alert({ + title: $.mage.__('Betalingsvoorwaarden'), + content: $.mage.__('U dient eerst akkoord te gaan met de betalingsvoorwaarden.'), + actions: { + always: function(){} + } + }); + return false; + } + if (this.kvknummer == null || this.kvknummer.length < 8) { + alert({ + title: $.mage.__('Ongeldig KVK nummer'), + content: $.mage.__('Voer een geldig KVK nummer in.'), + actions: { + always: function(){} + } + }); + return false; + } + } + if (showingDOB) { + if (this.dateofbirth == null || this.dateofbirth.length < 1) { + alert({ + title: $.mage.__('Ongeldig geboortedatum'), + content: $.mage.__('Voer een geldig geboortedatum in.'), + actions: { + always: function(){} + } + }); + return false; + } + } + if (event) { + event.preventDefault(); + } + $('#payment-button').html('Processing').attr('disabled','disabled'); + this.isPlaceOrderActionAllowed(false); + placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder); + $.when(placeOrder).fail(function () { + this.isPlaceOrderActionAllowed(true); + }.bind(this)).done(this.afterPlaceOrder.bind(this)); + return true; + }, + }); + } +); + + + + From 165fd163748ba6efe32efd00a5a21095c327560a Mon Sep 17 00:00:00 2001 From: bryantvdberg Date: Wed, 13 Jan 2021 16:52:50 +0100 Subject: [PATCH 15/19] Creditclick add settings. --- etc/adminhtml/paymentmethods/creditclick.xml | 54 +++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/etc/adminhtml/paymentmethods/creditclick.xml b/etc/adminhtml/paymentmethods/creditclick.xml index 3cef6bc4..0df4664a 100644 --- a/etc/adminhtml/paymentmethods/creditclick.xml +++ b/etc/adminhtml/paymentmethods/creditclick.xml @@ -17,7 +17,59 @@ 1 - + + + 1 + + payment/paynl_payment_creditclick/instructions + + + + payment/paynl_payment_creditclick/min_order_total + + 1 + + + + + payment/paynl_payment_creditclick/max_order_total + + 1 + + + + + validate-number + payment/paynl_payment_creditclick/sort_order + + 1 + + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/paynl_payment_creditclick/allowspecific + + 1 + + + + + Magento\Directory\Model\Config\Source\Country + 1 + payment/paynl_payment_creditclick/specificcountry + + 1 + 1 + + + Magento\Shipping\Model\Config\Source\Allmethods From b398a932ab00f2de017c8120633b4c28bb4f1ed6 Mon Sep 17 00:00:00 2001 From: bryantvdberg Date: Wed, 13 Jan 2021 16:57:06 +0100 Subject: [PATCH 16/19] place field tag on same line --- etc/adminhtml/paymentmethods/creditclick.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/etc/adminhtml/paymentmethods/creditclick.xml b/etc/adminhtml/paymentmethods/creditclick.xml index 0df4664a..3ad95111 100644 --- a/etc/adminhtml/paymentmethods/creditclick.xml +++ b/etc/adminhtml/paymentmethods/creditclick.xml @@ -69,8 +69,7 @@ 1 - + Magento\Shipping\Model\Config\Source\Allmethods 1 From 939274d9d80b0394aacb7b73cbf2228c612b0c14 Mon Sep 17 00:00:00 2001 From: bryantvdberg Date: Wed, 13 Jan 2021 16:59:21 +0100 Subject: [PATCH 17/19] place field tag on same line --- etc/adminhtml/paymentmethods/creditclick.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/etc/adminhtml/paymentmethods/creditclick.xml b/etc/adminhtml/paymentmethods/creditclick.xml index 3ad95111..0df4664a 100644 --- a/etc/adminhtml/paymentmethods/creditclick.xml +++ b/etc/adminhtml/paymentmethods/creditclick.xml @@ -69,7 +69,8 @@ 1 - + Magento\Shipping\Model\Config\Source\Allmethods 1 From ba5a4cfe1f8cbdbf7ae24601656b650280fc7fb6 Mon Sep 17 00:00:00 2001 From: "k.verschoor@pay.nl" Date: Thu, 14 Jan 2021 17:43:33 +0100 Subject: [PATCH 18/19] Fix to prevent double invoices after Capture via Magento2 --- Controller/Checkout/Exchange.php | 8 ++++++++ Model/Paymentmethod/PaymentMethod.php | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/Controller/Checkout/Exchange.php b/Controller/Checkout/Exchange.php index 61e825cd..1c9c7e32 100644 --- a/Controller/Checkout/Exchange.php +++ b/Controller/Checkout/Exchange.php @@ -162,6 +162,14 @@ public function execute() return $this->result->setContents('TRUE| Ignoring: order has already been paid'); } + if ($_REQUEST["action"] == 'capture') { + $payment = $order->getPayment(); + if ($payment->getAdditionalInformation('manual_capture')) { + $this->logger->debug('Already captured.'); + + return $this->result->setContents('TRUE| Already captured.'); + } + } if ($transaction->isPaid() || $transaction->isAuthorized()) { return $this->processPaidOrder($transaction, $order); diff --git a/Model/Paymentmethod/PaymentMethod.php b/Model/Paymentmethod/PaymentMethod.php index 4323c5a1..797992cf 100644 --- a/Model/Paymentmethod/PaymentMethod.php +++ b/Model/Paymentmethod/PaymentMethod.php @@ -183,6 +183,10 @@ public function capture(InfoInterface $payment, $amount) { $this->paynlConfig->configureSDK(); + $payment->setAdditionalInformation('manual_capture', 'true'); + $order = $payment->getOrder(); + $order->save(); + $transactionId = $payment->getParentTransactionId(); Transaction::capture($transactionId); From 006151e32b5bb16051addc0bed3d6775aa0a59bf Mon Sep 17 00:00:00 2001 From: "k.verschoor@pay.nl" Date: Thu, 14 Jan 2021 18:06:14 +0100 Subject: [PATCH 19/19] Check on var instead of and add empty check on payment --- Controller/Checkout/Exchange.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Controller/Checkout/Exchange.php b/Controller/Checkout/Exchange.php index 1c9c7e32..f9b213df 100644 --- a/Controller/Checkout/Exchange.php +++ b/Controller/Checkout/Exchange.php @@ -162,13 +162,13 @@ public function execute() return $this->result->setContents('TRUE| Ignoring: order has already been paid'); } - if ($_REQUEST["action"] == 'capture') { + if ($action == 'capture') { $payment = $order->getPayment(); - if ($payment->getAdditionalInformation('manual_capture')) { + if(!empty($payment) && $payment->getAdditionalInformation('manual_capture')){ $this->logger->debug('Already captured.'); return $this->result->setContents('TRUE| Already captured.'); - } + } } if ($transaction->isPaid() || $transaction->isAuthorized()) {