Skip to content

Commit

Permalink
add config for refund and validate if setting is on or off when doing…
Browse files Browse the repository at this point in the history
… refunds
  • Loading branch information
gentiprenaj committed Sep 3, 2024
1 parent 62fe747 commit 4f5c27c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
19 changes: 12 additions & 7 deletions controllers/admin/AdminRefundController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Refund/Request/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

/**
Expand Down

0 comments on commit 4f5c27c

Please sign in to comment.