From 7f8d3aa029d3671387ebc0dfed5dcabd6f849f77 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Wed, 6 Nov 2019 09:35:07 +0100 Subject: [PATCH 1/3] Call the method when cancelling an order --- app/code/community/Mollie/Mpm/Helper/Data.php | 11 +++++-- .../Mollie/Mpm/Test/Helper/DataTest.php | 30 +++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/app/code/community/Mollie/Mpm/Helper/Data.php b/app/code/community/Mollie/Mpm/Helper/Data.php index 8fe92340..1c8b9506 100644 --- a/app/code/community/Mollie/Mpm/Helper/Data.php +++ b/app/code/community/Mollie/Mpm/Helper/Data.php @@ -628,10 +628,11 @@ public function getStatusPending($storeId = null) /** * @param Mage_Sales_Model_Order $order - * @param null $status + * @param null $status * * @return bool * @throws Mage_Core_Exception + * @throws Exception */ public function registerCancellation(Mage_Sales_Model_Order $order, $status = null) { @@ -642,7 +643,13 @@ public function registerCancellation(Mage_Sales_Model_Order $order, $status = nu } $this->addTolog('info', $order->getIncrementId() . ' ' . $comment); - $order->registerCancellation($comment)->save(); + $order->cancel(); + + if ($status !== null) { + $order->addStatusHistoryComment($comment); + } + + $order->save(); return true; } diff --git a/app/code/community/Mollie/Mpm/Test/Helper/DataTest.php b/app/code/community/Mollie/Mpm/Test/Helper/DataTest.php index 5cd4aa53..943317da 100644 --- a/app/code/community/Mollie/Mpm/Test/Helper/DataTest.php +++ b/app/code/community/Mollie/Mpm/Test/Helper/DataTest.php @@ -288,4 +288,34 @@ public function testGetInvoiceMomentPaidStatusThrowsAnExceptionWhenAWrongMomentI $this->assertEquals('Invoice moment not supported: shipment', $exception->getMessage()); } } + + public function testRegisterCancellation() + { + $order = $this->createMock(Mage::getConfig()->getModelClassName('sales/order')); + $order->expects($this->once())->method('cancel'); + $order->expects($this->never())->method('addStatusHistoryComment'); + $order->method('getId')->willReturn(-999); + + /** @var Mollie_Mpm_Helper_data $instance */ + $instance = Mage::helper('mpm'); + + $instance->registerCancellation($order); + } + + public function testRegisterCancellationWithStatus() + { + $order = $this->createMock(Mage::getConfig()->getModelClassName('sales/order')); + $order->expects($this->once())->method('cancel'); + $order->method('getId')->willReturn(-999); + + /** @var Mollie_Mpm_Helper_data $instance */ + $instance = Mage::helper('mpm'); + + $status = 'my custom status'; + $order->expects($this->once())->method('addStatusHistoryComment')->with( + $instance->__('The order was canceled, reason: payment %s', $status) + ); + + $instance->registerCancellation($order, $status); + } } From 663a148dc386d5b4974dc73687c828c9687a25f9 Mon Sep 17 00:00:00 2001 From: Marvin-Magmodules Date: Fri, 29 Nov 2019 15:41:48 +0100 Subject: [PATCH 2/3] Version bump --- app/code/community/Mollie/Mpm/etc/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/community/Mollie/Mpm/etc/config.xml b/app/code/community/Mollie/Mpm/etc/config.xml index e603c91b..90f26fdc 100644 --- a/app/code/community/Mollie/Mpm/etc/config.xml +++ b/app/code/community/Mollie/Mpm/etc/config.xml @@ -33,7 +33,7 @@ - 5.5.3 + 5.5.4 From 7aa0c80a4acc0284c295a06be89b8082993f7b9b Mon Sep 17 00:00:00 2001 From: Marvin-Magmodules Date: Mon, 2 Dec 2019 19:31:53 +0100 Subject: [PATCH 3/3] Fixed display of zero payment fee in checkout on certain setups --- app/code/community/Mollie/Mpm/Model/Totals/PaymentFee/Quote.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/community/Mollie/Mpm/Model/Totals/PaymentFee/Quote.php b/app/code/community/Mollie/Mpm/Model/Totals/PaymentFee/Quote.php index 345e8fc8..35a388a9 100644 --- a/app/code/community/Mollie/Mpm/Model/Totals/PaymentFee/Quote.php +++ b/app/code/community/Mollie/Mpm/Model/Totals/PaymentFee/Quote.php @@ -45,7 +45,7 @@ public function collect(Mage_Sales_Model_Quote_Address $address) public function fetch(Mage_Sales_Model_Quote_Address $address) { $amount = $address->getMollieMpmPaymentFee(); - if ($amount) { + if (floatval($amount)) { $address->addTotal( array( 'code' => $this->getCode(),