Skip to content

Commit

Permalink
Automatic refund option support fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartosz Sosnowski committed Dec 12, 2024
1 parent 467a667 commit 41dde2d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/Controller/Admin/OrderList.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidSolutionCatalysts\AmazonPay\Core\Config;
use OxidSolutionCatalysts\AmazonPay\Core\Constants;
use OxidSolutionCatalysts\AmazonPay\Core\Logger;
use OxidSolutionCatalysts\AmazonPay\Core\Provider\OxidServiceProvider;
Expand All @@ -35,6 +36,13 @@ public function cancelOrder()
return;
}

$config = new Config();
if (!$config->automatedRefundActivated()) {
parent::cancelOrder();

return;
}

$oOrder = oxNew(Order::class);
if (!$oOrder->load($sOxId)) {
return;
Expand Down
3 changes: 2 additions & 1 deletion src/Core/AmazonService.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@ public function createRefund(string $orderId, float $refundAmount, LoggerInterfa
/** @var string $orderCurrencyName */
$orderCurrencyName = $order->getOrderCurrency()->name;

if ($refundAmount < 0 || $refundAmount > $this->getMaximalRefundAmount($orderId)) {
//amounts needs to be cast with same precision level or else even if numbers looks the same the compare will be wrong
if ($refundAmount < 0 || round($refundAmount, 2) > round($this->getMaximalRefundAmount($orderId), 2)) {
Registry::getUtilsView()->addErrorToDisplay(
Registry::getLang()->translateString(
"OSC_AMAZONPAY_REFUND_ANNOTATION"
Expand Down

0 comments on commit 41dde2d

Please sign in to comment.