Skip to content

Commit

Permalink
Merge pull request #182 from mollie/5.6.1
Browse files Browse the repository at this point in the history
5.6.1
  • Loading branch information
Marvin-Magmodules authored Jul 7, 2020
2 parents cd4fe56 + 0e2ae4d commit e42f505
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions app/code/community/Mollie/Mpm/Model/Client/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Mollie/Mpm/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<config>
<modules>
<Mollie_Mpm>
<version>5.6.0</version>
<version>5.6.1</version>
</Mollie_Mpm>
</modules>
<global>
Expand Down

0 comments on commit e42f505

Please sign in to comment.