Skip to content

Commit

Permalink
Merge pull request #113 from paynl/feature/PLUG-280
Browse files Browse the repository at this point in the history
Fix to prevent double invoices after capture via Magento2
  • Loading branch information
woutse authored Jan 16, 2021
2 parents 7e27f29 + 006151e commit bba9517
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Controller/Checkout/Exchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ public function execute()

return $this->result->setContents('TRUE| Ignoring: order has already been paid');
}
if ($action == 'capture') {
$payment = $order->getPayment();
if(!empty($payment) && $payment->getAdditionalInformation('manual_capture')){
$this->logger->debug('Already captured.');

return $this->result->setContents('TRUE| Already captured.');
}
}

if ($transaction->isPaid() || $transaction->isAuthorized()) {
return $this->processPaidOrder($transaction, $order);
Expand Down
4 changes: 4 additions & 0 deletions Model/Paymentmethod/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ public function capture(InfoInterface $payment, $amount)
{
$this->paynlConfig->configureSDK();

$payment->setAdditionalInformation('manual_capture', 'true');
$order = $payment->getOrder();
$order->save();

$transactionId = $payment->getParentTransactionId();

Transaction::capture($transactionId);
Expand Down

0 comments on commit bba9517

Please sign in to comment.