Skip to content

Commit

Permalink
Merge branch 'improvement/prevent-multiple-captured-amount-notificati…
Browse files Browse the repository at this point in the history
…ons-when-completed' into release-week-31
  • Loading branch information
michielgerritsen committed Aug 7, 2024
2 parents d39572f + d5ab67f commit dc93269
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 6 additions & 4 deletions Model/Client/Orders/Processors/SuccessfulPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ public function __construct(
}

/**
* @param OrderInterface|\Magento\Sales\Model\Order $order
* @param OrderInterface|MagentoOrder $order
* @param MollieOrder $mollieOrder
* @param string $type
* @param ProcessTransactionResponse $response
* @throws \Magento\Framework\Exception\LocalizedException
* @return ProcessTransactionResponse|null
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function process(OrderInterface $order, Order $mollieOrder, string $type, ProcessTransactionResponse $response): ?ProcessTransactionResponse
{
Expand Down Expand Up @@ -173,7 +173,9 @@ private function handleWebhookCall(OrderInterface $order, MollieOrder $mollieOrd
$payment->setTransactionId($paymentId);
$payment->setCurrencyCode($order->getBaseCurrencyCode());

if ($order->getState() != \Magento\Sales\Model\Order::STATE_PROCESSING && $mollieOrder->isPaid()) {
if (!in_array($order->getState(), [MagentoOrder::STATE_PROCESSING, MagentoOrder::STATE_COMPLETE]) &&
$mollieOrder->isPaid()
) {
$payment->setIsTransactionClosed(true);
$payment->registerCaptureNotification($order->getBaseGrandTotal(), true);
}
Expand Down Expand Up @@ -230,7 +232,7 @@ public function checkCheckoutSession(
}

/**
* @param OrderInterface|\Magento\Sales\Model\Order $order
* @param OrderInterface|MagentoOrder $order
*/
protected function sendOrderEmails(OrderInterface $order): void
{
Expand Down
4 changes: 3 additions & 1 deletion Model/Client/Payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,9 @@ public function processTransaction(Order $order, $mollieApi, $type = 'webhook',
);
}

$payment->registerCaptureNotification($order->getBaseGrandTotal(), true);
if (!in_array($order->getState(), [Order::STATE_PROCESSING, Order::STATE_COMPLETE])) {
$payment->registerCaptureNotification($order->getBaseGrandTotal(), true);
}
}

$order->setState(Order::STATE_PROCESSING);
Expand Down

0 comments on commit dc93269

Please sign in to comment.