diff --git a/controllers/admin/AdminRefundController.php b/controllers/admin/AdminRefundController.php index 746188eb..eecade97 100644 --- a/controllers/admin/AdminRefundController.php +++ b/controllers/admin/AdminRefundController.php @@ -21,6 +21,7 @@ use Buckaroo\PrestaShop\Src\Refund\Request\Handler as RefundRequestHandler; use Buckaroo\PrestaShop\Src\Refund\Request\QuantityBasedBuilder; use Buckaroo\PrestaShop\Src\Refund\Request\Response\Handler as RefundResponseHandler; +use Buckaroo\PrestaShop\Src\Refund\Settings; use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; use Symfony\Component\HttpFoundation\JsonResponse; @@ -140,14 +141,18 @@ private function sentRefundRequest(\Order $order, \OrderPayment $payment, float } $body = $this->refundBuilder->create($order, $payment, $refundAmount); - $this->responseHandler->parse( - $this->refundHandler->refund( + + + if (\Configuration::get(Settings::LABEL_REFUND_CONF)){ + $this->responseHandler->parse( + $this->refundHandler->refund( + $body, + $payment->payment_method + ), $body, - $payment->payment_method - ), - $body, - $order->id - ); + $order->id + ); + } return $maxRefundAmount; } diff --git a/src/Refund/Request/Handler.php b/src/Refund/Request/Handler.php index 7e0f2911..1d8caa0b 100644 --- a/src/Refund/Request/Handler.php +++ b/src/Refund/Request/Handler.php @@ -20,6 +20,7 @@ use Buckaroo\BuckarooClient; use Buckaroo\PrestaShop\Classes\Config; use Buckaroo\PrestaShop\Src\Refund\Settings; +use Buckaroo\Transaction\Response\TransactionResponse; if (!defined('_PS_VERSION_')) { exit; @@ -33,13 +34,12 @@ class Handler * @param array $body * @param string $method * + * @return TransactionResponse */ - public function refund(array $body, string $method) + public function refund(array $body, string $method): TransactionResponse { - if (\Configuration::get(Settings::LABEL_REFUND_CONF)){ - $buckaroo = $this->getClient($method); - return $buckaroo->method($method)->refund($body); - } + $buckaroo = $this->getClient($method); + return $buckaroo->method($method)->refund($body); } /**