diff --git a/app/code/community/Mollie/Mpm/Model/Client/Orders.php b/app/code/community/Mollie/Mpm/Model/Client/Orders.php index b5cddb8..5dd31af 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. @@ -660,6 +663,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; @@ -668,11 +678,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()); diff --git a/app/code/community/Mollie/Mpm/etc/config.xml b/app/code/community/Mollie/Mpm/etc/config.xml index a8199da..4bf55bc 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