From 7e74b4f06d21b7fe097958c7b7002bb5a63f9a4f Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 6 Jul 2020 14:53:58 +0200 Subject: [PATCH 1/3] Bugfix: Allow to enter a adjustment fee --- .../community/Mollie/Mpm/Model/Client/Orders.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/code/community/Mollie/Mpm/Model/Client/Orders.php b/app/code/community/Mollie/Mpm/Model/Client/Orders.php index 82dbf4b8..63d3d004 100644 --- a/app/code/community/Mollie/Mpm/Model/Client/Orders.php +++ b/app/code/community/Mollie/Mpm/Model/Client/Orders.php @@ -654,6 +654,13 @@ public function createOrderRefund(Mage_Sales_Model_Order_Creditmemo $creditmemo, $mollieOrder = $mollieApi->orders->get($order->getMollieTransactionId(), ['embed' => 'payments']); $payments = $mollieOrder->_embedded->payments; + $return = false; + $refundAmount = $creditmemo->getAdjustment(); + if ($creditmemo->getAdjustment() < 0.0) { + $return = true; + $refundAmount = $creditmemo->getBaseGrandTotal(); + } + try { $payment = new Payment($mollieApi); $payment->id = current($payments)->id; @@ -662,11 +669,15 @@ public function createOrderRefund(Mage_Sales_Model_Order_Creditmemo $creditmemo, 'amount' => [ 'currency' => $order->getOrderCurrencyCode(), 'value' => $this->mollieHelper->formatCurrencyValue( - $creditmemo->getAdjustment(), + $refundAmount, $order->getOrderCurrencyCode() ), ] ]); + + if ($return) { + return $this; + } } catch (\Exception $exception) { $this->mollieHelper->addTolog('error', $exception->getMessage()); Mage::throwException($exception->getMessage()); From dc69553cebe971f302667caa3ce9615d61ae753a Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 6 Jul 2020 14:56:55 +0200 Subject: [PATCH 2/3] Bugfix: The order details are not always available --- app/code/community/Mollie/Mpm/Model/Client/Orders.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/code/community/Mollie/Mpm/Model/Client/Orders.php b/app/code/community/Mollie/Mpm/Model/Client/Orders.php index b5cddb8f..078f886b 100644 --- a/app/code/community/Mollie/Mpm/Model/Client/Orders.php +++ b/app/code/community/Mollie/Mpm/Model/Client/Orders.php @@ -202,7 +202,10 @@ public function processTransaction(Mage_Sales_Model_Order $order, $type = 'webho $this->orderLines->updateOrderLinesByWebhook($mollieOrder->lines, $mollieOrder->isPaid()); - $order->getPayment()->setAdditionalInformation('details', json_encode($mollieOrder->_embedded->payments[0]->details))->save(); + if ($mollieOrder->_embedded->payments && isset($mollieOrder->_embedded->payments[0]->details)) { + $details = $mollieOrder->_embedded->payments[0]->details; + $order->getPayment()->setAdditionalInformation('details', json_encode($details))->save(); + } /** * Check if last payment was canceled, failed or expired and redirect customer to cart for retry. From 0e2ae4dbdb29b9899fd5629c3c4e563801896634 Mon Sep 17 00:00:00 2001 From: Marvin-Magmodules Date: Tue, 7 Jul 2020 19:53:11 +0200 Subject: [PATCH 3/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 a8199da3..4bf55bc3 100644 --- a/app/code/community/Mollie/Mpm/etc/config.xml +++ b/app/code/community/Mollie/Mpm/etc/config.xml @@ -33,7 +33,7 @@ - 5.6.0 + 5.6.1