diff --git a/CHANGELOG.md b/CHANGELOG.md index 8132b1496..49ec17819 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - [0007719](https://bugs.oxid-esales.com/view.php?id=7719): Tracking code also be stored in standard DB field for backwards compatibility - add possibility to ignore cached tokens. It helps e.g. for webhook registration - use PayPal-Client v2.0.17 +- [0007744](https://bugs.oxid-esales.com/view.php?id=7744): : When using vouchers shop jumps back to payment selection ### NEW @@ -49,7 +50,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - [0007675](https://bugs.oxid-esales.com/view.php?id=7675): fix the possibility to finish order without redirect and login to Paypal - [0007676](https://bugs.oxid-esales.com/view.php?id=7676): If we have a corrupted generated_services.yaml and try to deactivate the module via the admin, we will display a more understandable error message about what happened. - introduce ActionHash to make the PayPal-Request-ID more unique -- [0007695](https://bugs.oxid-esales.com/view.php?id=7695): Fix: if DeliverySet is set in Frontend, then do not add any PseudoDeliveryCosts for PPExpress ### NEW - PayPal-Request-Id based on serialized body, no extra PayPal-Request-Id necessary anymore diff --git a/src/Core/PatchRequestFactory.php b/src/Core/PatchRequestFactory.php index 3bdad79dc..028d89493 100644 --- a/src/Core/PatchRequestFactory.php +++ b/src/Core/PatchRequestFactory.php @@ -67,50 +67,36 @@ public function getRequest( protected function getShippingAddressPatch(): void { - $addressObj = false; - $address = new AddressPortable(); - $session = Registry::getSession(); + $deliveryId = Registry::getSession()->getVariable("deladrid"); + $deliveryAddress = oxNew(Address::class); - $deliveryId = $session->getVariable("deladrid"); + if ($deliveryId && $deliveryAddress->load($deliveryId)) { + $patch = new Patch(); + $patch->op = Patch::OP_REPLACE; + $patch->path = "/purchase_units/@reference_id=='" + . Constants::PAYPAL_ORDER_REFERENCE_ID + . "'/shipping/address"; - if ($deliveryId) { - $deliveryAddress = oxNew(Address::class); - if ($deliveryAddress->load($deliveryId)) { - $addressObj = $deliveryAddress; - } - } - else { - $user = $this->basket->getUser(); - if ($user) { - $addressObj = $user; - } - } + $address = new AddressPortable(); - if ($addressObj) { $state = oxNew(State::class); - $country = oxNew(Country::class); + $state->load($deliveryAddress->getFieldData('oxstateid')); - $state->load($addressObj->getFieldData('oxstateid')); - $country->load($addressObj->getFieldData('oxcountryid')); + $country = oxNew(Country::class); + $country->load($deliveryAddress->getFieldData('oxcountryid')); $addressLine = - $addressObj->getFieldData('oxstreet') . " " . $addressObj->getFieldData('oxstreetnr'); + $deliveryAddress->getFieldData('oxstreet') . " " . $deliveryAddress->getFieldData('oxstreetnr'); $address->address_line_1 = $addressLine; - $addinfoLine = $addressObj->getFieldData('oxcompany') . " " . - $addressObj->getFieldData('oxaddinfo'); + $addinfoLine = $deliveryAddress->getFieldData('oxcompany') . " " . + $deliveryAddress->getFieldData('oxaddinfo'); $address->address_line_2 = $addinfoLine; $address->admin_area_1 = $state->getFieldData('oxtitle'); - $address->admin_area_2 = $addressObj->getFieldData('oxcity'); + $address->admin_area_2 = $deliveryAddress->getFieldData('oxcity'); $address->country_code = $country->oxcountry__oxisoalpha2->value; - $address->postal_code = $addressObj->getFieldData('oxzip'); - - $patch = new Patch(); - $patch->op = Patch::OP_REPLACE; - $patch->path = "/purchase_units/@reference_id=='" - . Constants::PAYPAL_ORDER_REFERENCE_ID - . "'/shipping/address"; + $address->postal_code = $deliveryAddress->getFieldData('oxzip'); $patch->value = $address; diff --git a/src/Core/PayPalRequestAmountFactory.php b/src/Core/PayPalRequestAmountFactory.php index 5894ab380..dac1ce348 100644 --- a/src/Core/PayPalRequestAmountFactory.php +++ b/src/Core/PayPalRequestAmountFactory.php @@ -47,18 +47,16 @@ public function getAmount(Basket $basket): AmountWithBreakdown } if ($netMode) { - $total = $brutBasketTotal - $shipping; + $total = $itemTotal - $shipping; } else { $total = $itemTotal - $discount + $itemTotalAdditionalCosts; } - $total_with_shipping = $total + $shipping; $total = PriceToMoney::convert($total, $currency); - $total_with_shipping = PriceToMoney::convert($total_with_shipping, $currency); //Total amount $amount = new AmountWithBreakdown(); - $amount->value = $total_with_shipping->value; + $amount->value = $brutBasketTotal; $amount->currency_code = $total->currency_code; //Cost breakdown @@ -68,7 +66,8 @@ public function getAmount(Basket $basket): AmountWithBreakdown $breakdown->discount = PriceToMoney::convert($netMode ? $brutDiscountValue : $discount, $currency); } - $breakdown->item_total = PriceToMoney::convert($total->value, $currency); + $breakDownItemTotal = $netMode ? $total->value : $itemTotal; + $breakdown->item_total = PriceToMoney::convert($breakDownItemTotal, $currency); //Item tax sum - we use 0% and calculate with brutto to avoid rounding errors $breakdown->tax_total = PriceToMoney::convert(0, $currency); diff --git a/src/Model/Order.php b/src/Model/Order.php index 6be99c5f9..49a43025a 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -663,7 +663,6 @@ public function setPayPalTracking(string $trackingCarrier, string $trackingCode) 'oxtrackcode' => $trackingCode ] ); - $this->save(); $payPalOrder = $this->getPayPalRepository(); $payPalOrder->setTrackingCode($trackingCode); $payPalOrder->setTrackingCarrier($trackingCarrier);