Skip to content

Commit b20bece

Browse files
update: prevent duplicate orders by checking if payment is in transit before restoring quote
1 parent 152823c commit b20bece

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Model/Method/AbstractMethod.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,8 @@ public function order(InfoInterface $payment, $amount)
834834

835835
if (!(isset($response[0]->RequiredAction->Type) && $response[0]->RequiredAction->Type === 'Redirect')) {
836836
$this->setPaymentInTransit($payment, false);
837+
$this->helper->setRestoreQuoteLastOrder($order->getId());
837838
}
838-
$this->helper->setRestoreQuoteLastOrder($order->getId());
839839

840840
$this->eventManager->dispatch('buckaroo_order_after', ['order' => $order]);
841841

Observer/RestoreQuote.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
namespace Buckaroo\Magento2\Observer;
2323

2424
use Buckaroo\Magento2\Helper\Data;
25+
use Buckaroo\Magento2\Model\Method\AbstractMethod;
2526
use Magento\Checkout\Model\Session;
2627
use Buckaroo\Magento2\Model\Service\Order;
2728
use Buckaroo\Magento2\Model\Method\Payconiq;
@@ -154,6 +155,11 @@ private function processShippingAddress($quote)
154155
*/
155156
private function shouldRestoreQuote($lastRealOrder, $payment)
156157
{
158+
if ($payment->getAdditionalInformation(AbstractMethod::BUCKAROO_PAYMENT_IN_TRANSIT) === true) {
159+
$this->helper->addDebug(__METHOD__ . '|Payment in transit, not restoring quote to prevent duplicate orders');
160+
return false;
161+
}
162+
157163
return (
158164
($this->helper->getRestoreQuoteLastOrder() &&
159165
($lastRealOrder->getData('state') === 'new') &&

0 commit comments

Comments
 (0)