Skip to content

Commit

Permalink
MOL-674 Fix refund functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Feb 11, 2022
1 parent 562d621 commit 107a640
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Gateway/MolliePaymentGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public function __construct(
$this->method_description = $this->paymentMethod->getProperty(
'settingsDescription'
);
$this->supports = $this->paymentMethod->getProperty('supports');

// Load the settings.
$this->init_form_fields();
Expand Down
5 changes: 3 additions & 2 deletions src/Payment/MollieOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Psr\Log\LogLevel;
use stdClass;
use WC_Order;
use WP_Error;

class MollieOrder extends MollieObject
{
Expand Down Expand Up @@ -564,7 +565,7 @@ public function onWebhookExpired(WC_Order $order, $payment, $paymentMethodTitle)
* @param null $amount
* @param string $reason
*
* @return bool|\WP_Error
* @return bool|WP_Error
*/
public function refund(WC_Order $order, $orderId, $paymentObject, $amount = null, $reason = '')
{
Expand Down Expand Up @@ -614,7 +615,7 @@ public function refund(WC_Order $order, $orderId, $paymentObject, $amount = null
}

$totals = number_format(abs($totals), 2); // WooCommerce - sum of all refund items
$checkAmount = number_format($amount, 2); // WooCommerce - refund amount
$checkAmount = $amount? number_format((float)$amount, 2):0; // WooCommerce - refund amount

if ($checkAmount !== $totals) {
$errorMessage = "The sum of refunds for all order lines is not identical to the refund amount, so this refund will be processed as a payment amount refund, not an order line refund.";
Expand Down

0 comments on commit 107a640

Please sign in to comment.