Skip to content

Commit

Permalink
fix calculate rabatt
Browse files Browse the repository at this point in the history
  • Loading branch information
mariolorenz committed Sep 29, 2023
1 parent efbb2fc commit 61013d4
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/Core/PatchRequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,26 +134,27 @@ protected function getAmountPatch(): void
$basket = $this->basket;
$currency = $this->basket->getBasketCurrency();

$total = PriceToMoney::convert($this->basket->getPriceForPayment(), $currency);

//Total amount
$amount = new AmountWithBreakdown();
$amount->value = $total->value;
$amount->currency_code = $total->currency_code;

//Cost breakdown
$breakdown = $amount->breakdown = new AmountBreakdown();

//Discount
$discount = $basket->getPayPalCheckoutDiscount();
//Item total cost
$itemTotal = $basket->getPayPalCheckoutItems();

// possible price surcharge
if ($discount < 0) {
$itemTotal += $discount;
$itemTotal -= $discount;
$discount = 0;
}
$total = $itemTotal - $discount;

$total = PriceToMoney::convert($total, $currency);

//Total amount
$amount = new AmountWithBreakdown();
$amount->value = $total->value;
$amount->currency_code = $total->currency_code;

//Cost breakdown
$breakdown = $amount->breakdown = new AmountBreakdown();

if ($discount) {
$breakdown->discount = PriceToMoney::convert($discount, $currency);
Expand Down

0 comments on commit 61013d4

Please sign in to comment.