-
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 pull request #639 from mollie/release/2.25.0
Release/2.25.0
- Loading branch information
Showing
40 changed files
with
867 additions
and
30 deletions.
There are no files selected for viewing
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
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
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
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,66 @@ | ||
<?php | ||
|
||
namespace Mollie\Payment\Model\Client\Orders\Processors; | ||
|
||
use Magento\Sales\Api\Data\OrderInterface; | ||
use Mollie\Api\Resources\Order; | ||
use Mollie\Payment\Model\Client\OrderProcessorInterface; | ||
use Mollie\Payment\Model\Client\ProcessTransactionResponse; | ||
use Mollie\Payment\Model\Client\ProcessTransactionResponseFactory; | ||
use Mollie\Payment\Service\Order\ExpiredOrderToTransaction; | ||
|
||
class ExpiredProcessor implements OrderProcessorInterface | ||
{ | ||
/** | ||
* @var CancelledProcessor | ||
*/ | ||
private $cancelledProcessor; | ||
|
||
/** | ||
* @var ProcessTransactionResponseFactory | ||
*/ | ||
private $processTransactionResponseFactory; | ||
|
||
/** | ||
* @var ExpiredOrderToTransaction | ||
*/ | ||
private $expiredOrderToTransaction; | ||
|
||
public function __construct( | ||
CancelledProcessor $cancelledProcessor, | ||
ExpiredOrderToTransaction $expiredOrderToTransaction, | ||
ProcessTransactionResponseFactory $processTransactionResponseFactory | ||
) { | ||
$this->cancelledProcessor = $cancelledProcessor; | ||
$this->processTransactionResponseFactory = $processTransactionResponseFactory; | ||
$this->expiredOrderToTransaction = $expiredOrderToTransaction; | ||
} | ||
|
||
public function process( | ||
OrderInterface $magentoOrder, | ||
Order $mollieOrder, | ||
string $type, | ||
ProcessTransactionResponse $response | ||
): ?ProcessTransactionResponse { | ||
if ($this->shouldCancelProcessing($magentoOrder)) { | ||
return $this->processTransactionResponseFactory->create([ | ||
'success' => false, | ||
'status' => $mollieOrder->status, | ||
'order_id' => $magentoOrder->getEntityId(), | ||
'type' => $type | ||
]); | ||
} | ||
|
||
return $this->cancelledProcessor->process($magentoOrder, $mollieOrder, $type, $response); | ||
} | ||
|
||
private function shouldCancelProcessing(OrderInterface $order): bool | ||
{ | ||
if (!$this->expiredOrderToTransaction->hasMultipleTransactions($order)) { | ||
return false; | ||
} | ||
|
||
$this->expiredOrderToTransaction->markTransactionAsSkipped($order->getMollieTransactionId()); | ||
return true; | ||
} | ||
} |
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
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
64 changes: 64 additions & 0 deletions
64
Model/Client/Payments/Processors/ExpiredStatusProcessor.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,64 @@ | ||
<?php | ||
|
||
namespace Mollie\Payment\Model\Client\Payments\Processors; | ||
|
||
use Magento\Sales\Api\Data\OrderInterface; | ||
use Mollie\Api\Resources\Payment; | ||
use Mollie\Payment\Model\Client\PaymentProcessorInterface; | ||
use Mollie\Payment\Model\Client\ProcessTransactionResponse; | ||
use Mollie\Payment\Model\Client\ProcessTransactionResponseFactory; | ||
use Mollie\Payment\Service\Order\ExpiredOrderToTransaction; | ||
|
||
class ExpiredStatusProcessor implements PaymentProcessorInterface | ||
{ | ||
/** | ||
* @var ExpiredOrderToTransaction | ||
*/ | ||
private $expiredOrderToTransaction; | ||
/** | ||
* @var FailedStatusProcessor | ||
*/ | ||
private $failedStatusProcessor; | ||
/** | ||
* @var ProcessTransactionResponseFactory | ||
*/ | ||
private $processTransactionResponseFactory; | ||
|
||
public function __construct( | ||
ExpiredOrderToTransaction $expiredOrderToTransaction, | ||
FailedStatusProcessor $failedStatusProcessor, | ||
ProcessTransactionResponseFactory $processTransactionResponseFactory | ||
) { | ||
$this->expiredOrderToTransaction = $expiredOrderToTransaction; | ||
$this->failedStatusProcessor = $failedStatusProcessor; | ||
$this->processTransactionResponseFactory = $processTransactionResponseFactory; | ||
} | ||
|
||
public function process( | ||
OrderInterface $magentoOrder, | ||
Payment $molliePayment, | ||
string $type, | ||
ProcessTransactionResponse $response | ||
): ?ProcessTransactionResponse { | ||
if ($this->shouldCancelProcessing($magentoOrder)) { | ||
return $this->processTransactionResponseFactory->create([ | ||
'success' => false, | ||
'status' => $molliePayment->status, | ||
'order_id' => $magentoOrder->getEntityId(), | ||
'type' => $type | ||
]); | ||
} | ||
|
||
return $this->failedStatusProcessor->process($magentoOrder, $molliePayment, $type, $response); | ||
} | ||
|
||
private function shouldCancelProcessing(OrderInterface $order): bool | ||
{ | ||
if (!$this->expiredOrderToTransaction->hasMultipleTransactions($order)) { | ||
return false; | ||
} | ||
|
||
$this->expiredOrderToTransaction->markTransactionAsSkipped($order->getMollieTransactionId()); | ||
return true; | ||
} | ||
} |
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
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
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
Oops, something went wrong.