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 c9a48fb
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions Helper/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,25 @@ 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;
}

/**
Expand Down Expand Up @@ -95,6 +87,8 @@ public function proceedAuthorize($order, $transactionId, $amount, $transData = [
* @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,14 +110,8 @@ 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;
}

/**
Expand Down

0 comments on commit c9a48fb

Please sign in to comment.