Skip to content

Commit

Permalink
NTR: fix broken refund composition after metadata change
Browse files Browse the repository at this point in the history
  • Loading branch information
boxblinkracer committed Sep 22, 2023
1 parent b378a90 commit 0d095b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/Components/RefundManager/Builder/RefundDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,13 @@ private function getRefundedQuantity(string $mollieLineItemId, \Mollie\Api\Resou
continue;
}

$metadata = RefundMetadata::fromArray($refund['metadata']);
$meta = $refund['metadata'];

if (is_string($meta)) {
$meta = json_decode($meta, true);
}

$metadata = RefundMetadata::fromArray($meta);

# if we do have a FULL item refund then
# we must NOT substract our item again.
Expand Down
6 changes: 3 additions & 3 deletions src/Hydrator/RefundHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public function hydrate(Refund $refund, OrderEntity $order): array
];
}

$metaData = '';
$metaData = [];

if (property_exists($refund, 'metadata')) {
$metaData = (string)json_encode($refund->metadata);
$metaData = $refund->metadata;
}

$internalDescription = null;
Expand Down Expand Up @@ -70,7 +70,7 @@ public function hydrate(Refund $refund, OrderEntity $order): array
'isProcessing' => $refund->isProcessing(),
'isQueued' => $refund->isQueued(),
'isTransferred' => $refund->isTransferred(),
'metadata' => json_decode($metaData, true),
'metadata' => $metaData,
];
}
}

0 comments on commit 0d095b4

Please sign in to comment.