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/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(), 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); + } } 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