Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gateway/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class Config extends BaseConfig
{
const CODE = 'fintecture';
const VERSION = '3.5.0';
const VERSION = '3.5.1';

const KEY_SHOP_NAME = 'general/store_information/name';
const KEY_ACTIVE = 'active';
Expand Down
10 changes: 6 additions & 4 deletions Gateway/HandlePayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Fintecture\Payment\Helper\Fintecture as FintectureHelper;
use Fintecture\Payment\Logger\Logger;
use Magento\Framework\DB\Transaction;
use Magento\Sales\Api\Data\TransactionInterface;
use Magento\Sales\Api\InvoiceRepositoryInterface;
use Magento\Sales\Api\OrderManagementInterface;
use Magento\Sales\Api\OrderPaymentRepositoryInterface;
Expand Down Expand Up @@ -140,6 +139,8 @@ public function create(
$payment->setAmountPaid($paidAmount);
$payment->setBaseAmountPaid($basePaidAmount);

$payment->setTransactionId($params['sessionId']);

$this->paymentRepository->save($payment);

$transaction = $this->transactionBuilder->setPayment($payment)
Expand All @@ -153,7 +154,7 @@ public function create(
'type' => $params['type'],
]])
->setFailSafe(true)
->build(TransactionInterface::TYPE_CAPTURE);
->build(Payment\Transaction::TYPE_CAPTURE);

$this->transactionRepository->save($transaction);

Expand Down Expand Up @@ -208,14 +209,15 @@ public function sendInvoice(Order $order, array $params): void
if ($this->fintectureHelper->isStatusAlreadyFinal($order)
&& $order->canInvoice() && $this->config->isInvoicingActive()) {
$invoice = $this->invoiceService->prepareInvoice($order);
$invoice->setRequestedCaptureCase(Order\Invoice::CAPTURE_ONLINE);
$invoice->setTransactionId($params['sessionId']);
$invoice->register();
$invoice->pay();
$this->invoiceRepository->save($invoice);
$transactionSave = $this->transaction
$transaction = $this->transaction
->addObject($invoice)
->addObject($invoice->getOrder());
$transactionSave->save();
$transaction->save();
// Send Invoice mail to customer
$this->invoiceSender->send($invoice);

Expand Down
11 changes: 10 additions & 1 deletion Gateway/HandleRefund.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,16 @@ public function applyWithoutCreditmemo(Order $order, float $amount): bool

// Create a credit memo only for a full refund
if ($isFullRefund) {
$creditmemo = $this->creditmemoFactory->createByOrder($order);
$invoice = $this->fintectureHelper->getInvoiceByOrder($order);
if (!$invoice) {
$this->fintectureLogger->error('Apply refund', [
'message' => 'No invoice found',
'orderIncrementId' => $order->getIncrementId(),
]);

return false;
}
$creditmemo = $this->creditmemoFactory->createByInvoice($invoice);

return $this->apply($order, $creditmemo, $amount);
}
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Http/DummyTransferFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(
*/
public function create(array $request)
{
return $this->transferBuilder // ignored...
return $this->transferBuilder
->setBody($request)
->setMethod('POST')
->build();
Expand Down
14 changes: 14 additions & 0 deletions Helper/Fintecture.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Magento\Sales\Api\TransactionRepositoryInterface;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\Creditmemo;
use Magento\Sales\Model\Order\Invoice;
use Magento\Sales\Model\Order\Payment\Transaction;
use Magento\Sales\Model\Order\Status\History;
use Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory;
Expand Down Expand Up @@ -134,6 +135,19 @@ public function getSessionIdByOrderId(string $orderId): ?string
return null;
}

public function getInvoiceByOrder(Order $order): ?Invoice
{
$invoices = $order->getInvoiceCollection();
if ($invoices->count() === 0) {
return null;
}

/** @var Invoice $invoice */
$invoice = $invoices->getLastItem();

return $invoice;
}

public function getCreditmemoByTransactionId(OrderInterface $order, string $creditmemoTransactionId): ?Creditmemo
{
try {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"email": "[email protected]"
},
"type": "magento2-module",
"version": "3.5.0",
"version": "3.5.1",
"license": [
"GPL-3.0"
],
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Fintecture_Payment" setup_version="3.5.0">
<module name="Fintecture_Payment" setup_version="3.5.1">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Payment"/>
Expand Down