-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bugfix/prevent-double-credit-restore' into release-week-15
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
Plugin/CustomerBalance/Observer/PreventDoubleCreditRevert.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mollie\Payment\Plugin\CustomerBalance\Observer; | ||
|
||
use Magento\Framework\Event\Observer; | ||
use Magento\Sales\Api\Data\OrderInterface; | ||
|
||
class PreventDoubleCreditRevert | ||
{ | ||
public function aroundExecute($subject, callable $proceed, Observer $observer) | ||
{ | ||
$order = $observer->getData('order'); | ||
if (!$order || | ||
!$order instanceof OrderInterface || | ||
!$order->getPayment() | ||
) { | ||
return $proceed($observer); | ||
} | ||
|
||
if ($observer->getEvent()->getName() == 'restore_quote' && | ||
$this->isMollieOrder($order) | ||
) { | ||
return $subject; | ||
} | ||
|
||
return $proceed($observer); | ||
} | ||
|
||
private function isMollieOrder(OrderInterface $order): bool | ||
{ | ||
$payment = $order->getPayment(); | ||
|
||
return strstr($payment->getMethod(), 'mollie_methods_') !== false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters