Skip to content

Commit

Permalink
Change return value to OrderPaymentInterface.
Browse files Browse the repository at this point in the history
  • Loading branch information
sekulich-mygento committed Oct 23, 2024
1 parent a56d77b commit 80d5eaa
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions Helper/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,34 @@ class Transaction extends \Magento\Framework\App\Helper\AbstractHelper
*/
private $orderRepository;

/**
* @var \Magento\Sales\Model\Order\Email\Sender\InvoiceSender
*/
private $invoiceSender;

/**
* @param \Mygento\Payment\Helper\Data $helper
* @param \Magento\Sales\Model\Order\Payment\Transaction\ManagerInterface $transactionManager
* @param \Magento\Sales\Api\TransactionRepositoryInterface $transactionRepo
* @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
* @param \Magento\Sales\Model\Order\Email\Sender\InvoiceSender $invoiceSender
* @param \Magento\Framework\App\Helper\Context $context
*/
public function __construct(
\Mygento\Payment\Helper\Data $helper,
\Magento\Sales\Model\Order\Payment\Transaction\ManagerInterface $transactionManager,
\Magento\Sales\Api\TransactionRepositoryInterface $transactionRepo,
\Magento\Sales\Api\OrderRepositoryInterface $orderRepository,
\Magento\Sales\Model\Order\Email\Sender\InvoiceSender $invoiceSender,
\Magento\Framework\App\Helper\Context $context
) {
parent::__construct($context);
$this->helper = $helper;
$this->transactionRepo = $transactionRepo;
$this->transactionManager = $transactionManager;
$this->orderRepository = $orderRepository;
$this->invoiceSender = $invoiceSender;
}

/**
* @param \Magento\Sales\Api\Data\OrderInterface $order
* @param string $transactionId
* @param float $amount
* @param array $transData
*
* @return \Magento\Sales\Api\Data\OrderPaymentInterface
*/
public function proceedAuthorize($order, $transactionId, $amount, $transData = [])
{
Expand All @@ -88,13 +82,17 @@ public function proceedAuthorize($order, $transactionId, $amount, $transData = [
$transData
);
}

return $payment;
}

/**
* @param \Magento\Sales\Api\Data\OrderInterface $order
* @param string $transactionId
* @param float $amount
* @param array $transData
*
* @return \Magento\Sales\Api\Data\OrderPaymentInterface
*/
public function proceedCapture($order, $transactionId, $amount, $transData = [])
{
Expand All @@ -116,21 +114,17 @@ public function proceedCapture($order, $transactionId, $amount, $transData = [])
$transData
);
}
$invoice = $payment->getCreatedInvoice();
if ($invoice && !$invoice->getEmailSent()) {
$this->invoiceSender->send($invoice);
$order->addStatusHistoryComment(
__('You notified customer about invoice #%1.', $invoice->getIncrementId())
)
->save();
}

return $payment;
}

/**
* @param \Magento\Sales\Api\Data\OrderInterface $order
* @param string $transactionId
* @param string $parentTransactionId
* @param float $amount
*
* @return \Magento\Sales\Api\Data\OrderPaymentInterface
*/
public function proceedRefund($order, $transactionId, $parentTransactionId, $amount)
{
Expand All @@ -144,13 +138,17 @@ public function proceedRefund($order, $transactionId, $parentTransactionId, $amo
$payment->registerRefundNotification($amount);

$this->orderRepository->save($order);

return $payment;
}

/**
* @param \Magento\Sales\Api\Data\OrderInterface $order
* @param string $transactionId
* @param string $parentTransactionId
* @param float $amount
*
* @return \Magento\Sales\Api\Data\OrderPaymentInterface
*/
public function proceedVoid($order, $transactionId, $parentTransactionId, $amount)
{
Expand All @@ -160,13 +158,17 @@ public function proceedVoid($order, $transactionId, $parentTransactionId, $amoun
$payment->registerVoidNotification($amount);

$this->orderRepository->save($order);

return $payment;
}

/**
* @param \Magento\Sales\Api\Data\OrderInterface $order
* @param string $transactionId
* @param string $parentTransactionId
* @param mixed $transData
*
* @return \Magento\Sales\Api\Data\OrderPaymentInterface
*/
public function proceedReceipt($order, $transactionId, $parentTransactionId, $transData)
{
Expand Down Expand Up @@ -205,13 +207,17 @@ public function proceedReceipt($order, $transactionId, $parentTransactionId, $tr
);

$this->orderRepository->save($order);

return $payment;
}

/**
* @param \Magento\Sales\Api\Data\OrderInterface $order
* @param string $transactionId
* @param string $parentTransactionId
* @param mixed $transData
*
* @return \Magento\Sales\Api\Data\OrderPaymentInterface
*/
public function proceedRefundReceipt($order, $transactionId, $parentTransactionId, $transData)
{
Expand Down Expand Up @@ -250,6 +256,8 @@ public function proceedRefundReceipt($order, $transactionId, $parentTransactionI
);

$this->orderRepository->save($order);

return $payment;
}

/**
Expand Down

0 comments on commit 80d5eaa

Please sign in to comment.