From 487c143d266a263d599ab57e17f554aff77e54c1 Mon Sep 17 00:00:00 2001 From: "g.prenaj" Date: Tue, 28 Apr 2026 15:39:52 +0200 Subject: [PATCH] fix builder for refunds issue --- src/Refund/Request/Builder.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Refund/Request/Builder.php b/src/Refund/Request/Builder.php index 50d35a7a5..2532fcc29 100644 --- a/src/Refund/Request/Builder.php +++ b/src/Refund/Request/Builder.php @@ -63,20 +63,23 @@ private function buildArticles(OrderRefundSummary $refundSummary, string $paymen continue; } - $amount = $this->round((float) $productRefund['amount']); - if ($amount <= 0) { + $lineTotal = $this->round((float) $productRefund['amount']); + if ($lineTotal <= 0) { continue; } + $quantity = (int) $productRefund['quantity']; + $unitPrice = $quantity > 0 ? $this->round($lineTotal / $quantity) : $lineTotal; + $total += $this->round($unitPrice * $quantity); + $orderDetail = $refundSummary->getOrderDetailById($orderDetailId); - $total += $amount; $articles[] = [ 'refundType' => 'Return', 'identifier' => $orderDetail->product_id, 'description' => $orderDetail->product_name, - 'quantity' => $productRefund['quantity'], - 'price' => $amount, + 'quantity' => $quantity, + 'price' => $unitPrice, 'vatPercentage' => $this->getVatPercentage($orderDetail), ]; }