diff --git a/Controller/Checkout/Exchange.php b/Controller/Checkout/Exchange.php index f3759cde..aa21adce 100644 --- a/Controller/Checkout/Exchange.php +++ b/Controller/Checkout/Exchange.php @@ -172,9 +172,8 @@ public function execute() } if ($action == 'capture') { $payment = $order->getPayment(); - if(!empty($payment) && $payment->getAdditionalInformation('manual_capture')){ + if (!empty($payment) && $payment->getAdditionalInformation('manual_capture')) { $this->logger->debug('Already captured.'); - return $this->result->setContents('TRUE| Already captured.'); } } @@ -182,8 +181,10 @@ public function execute() if ($transaction->isPaid() || $transaction->isAuthorized()) { return $this->processPaidOrder($transaction, $order); } elseif ($transaction->isCanceled()) { - if ($order->isCanceled()) { - return $this->result->setContents("TRUE| ALLREADY CANCELED"); + if ($order->getState() == Order::STATE_PROCESSING) { + return $this->result->setContents("TRUE| Ignoring cancel, order is `processing`"); + } elseif ($order->isCanceled()) { + return $this->result->setContents("TRUE| Already canceled"); } else { return $this->cancelOrder($order); } @@ -330,14 +331,11 @@ private function processPaidOrder(Transaction $transaction, Order $order) } } - # Make the invoice and send it to the customer if ($transaction->isAuthorized()) { - $paidAmount = $transaction->getCurrencyAmount(); - $payment->registerAuthorizationNotification($paidAmount); + $authAmount = $this->config->useMagOrderAmountForAuth() ? $order->getBaseGrandTotal() : $transaction->getCurrencyAmount(); + $payment->registerAuthorizationNotification($authAmount); } else { - $payment->registerCaptureNotification( - $paidAmount, $this->config->isSkipFraudDetection() - ); + $payment->registerCaptureNotification($paidAmount, $this->config->isSkipFraudDetection()); } $this->orderRepository->save($order); diff --git a/Model/Config.php b/Model/Config.php index 02fac8c1..8cdddda0 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -99,6 +99,11 @@ public function isAlwaysBaseCurrency() return $this->store->getConfig('payment/paynl/always_base_currency') == 1; } + public function useMagOrderAmountForAuth() + { + return $this->store->getConfig('payment/paynl/use_magorder_for_auth') == 1; + } + public function getLanguage() { $language = $this->store->getConfig('payment/paynl/language'); @@ -130,7 +135,7 @@ public function ignoreB2BInvoice($methodCode) { return $this->store->getConfig('payment/' . $methodCode . '/turn_off_invoices_b2b') == 1; } - + public function autoCaptureEnabled() { return $this->store->getConfig('payment/paynl/auto_capture') == 1; diff --git a/composer.json b/composer.json index d907ce42..d08c706f 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.7.4", + "version": "1.7.5", "require": { "magento/module-sales": "100 - 103", "magento/module-payment": "100 - 103", diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index c34f10e4..8e4051d3 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -48,12 +48,16 @@ This can be used if uncancelling the order in case of a second chance payment produces errors. WARNING! Orders will never be cancelled automaticly]]> Magento\Config\Model\Config\Source\Yesno - + Magento\Config\Model\Config\Source\Yesno + + + + Magento\Config\Model\Config\Source\Yesno + 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 4cc63291..7eca6668 100755 --- a/view/frontend/web/js/view/payment/method-renderer/default.js +++ b/view/frontend/web/js/view/payment/method-renderer/default.js @@ -21,8 +21,8 @@ define( dateofbirth: null, billink_agree: null, initialize: function () { - this._super(); - if(!quote.paymentMethod() && window.checkoutConfig.payment.defaultpaymentoption[this.item.method]){ + this._super(); + if (!quote.paymentMethod() && window.checkoutConfig.payment.defaultpaymentoption[this.item.method]) { this.selectPaymentMethod(); } return this; @@ -38,10 +38,10 @@ define( return false; } } - if(this.getforCompany() == 1 && this.getCompany().length != 0){ + if (this.getforCompany() == 1 && this.getCompany().length != 0) { return false; } - if(this.getforCompany() == 2 && this.getCompany().length == 0){ + if (this.getforCompany() == 2 && this.getCompany().length == 0) { return false; } if (!this.currentIpIsValid()) { @@ -60,16 +60,16 @@ define( }, getDisallowedShipping: function () { return window.checkoutConfig.payment.disallowedshipping[this.item.method]; - }, - getCompany: function () { + }, + getCompany: function () { if (typeof quote.billingAddress._latestValue.company !== 'undefined' && quote.billingAddress._latestValue.company !== null) { return quote.billingAddress._latestValue.company; } - return ''; - }, + return ''; + }, getforCompany : function () { return window.checkoutConfig.payment.showforcompany[this.item.method]; - }, + }, getInstructions: function () { return window.checkoutConfig.payment.instructions[this.item.method]; }, @@ -80,23 +80,23 @@ define( return this.getKVK() > 0; }, getKVK: function () { - return window.checkoutConfig.payment.showkvk[this.item.method]; + return (typeof window.checkoutConfig.payment.showkvk !== 'undefined') ? window.checkoutConfig.payment.showkvk[this.item.method] : ''; }, showDOB: function () { return this.getDOB() > 0; }, getDOB: function () { - return window.checkoutConfig.payment.showdob[this.item.method]; + return (typeof window.checkoutConfig.payment.showdob !== 'undefined') ? 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]; },