-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PAYOSWXP-156: webhooks: add sort-order for handlers to prevent wrong …
…order
- Loading branch information
1 parent
54d0593
commit 7f10d49
Showing
3 changed files
with
55 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PayonePayment\Payone\Webhook\Handler; | ||
|
||
use PayonePayment\Components\AutomaticCaptureService\AutomaticCaptureServiceInterface; | ||
use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface; | ||
use PayonePayment\Struct\PaymentTransaction; | ||
use Shopware\Core\System\SalesChannel\SalesChannelContext; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
class AutoCaptureStatusHandler implements WebhookHandlerInterface | ||
{ | ||
public function __construct( | ||
private readonly TransactionDataHandlerInterface $transactionDataHandler, | ||
private readonly AutomaticCaptureServiceInterface $automaticCaptureService | ||
) { | ||
} | ||
|
||
public function process(SalesChannelContext $salesChannelContext, Request $request): void | ||
{ | ||
$paymentTransaction = $this->transactionDataHandler->getPaymentTransactionByPayoneTransactionId( | ||
$salesChannelContext->getContext(), | ||
$request->request->getInt('txid') | ||
); | ||
|
||
if (!$paymentTransaction instanceof PaymentTransaction) { | ||
return; | ||
} | ||
|
||
$this->automaticCaptureService->captureIfPossible($paymentTransaction, $salesChannelContext); | ||
} | ||
|
||
public function supports(SalesChannelContext $salesChannelContext, array $data): bool | ||
{ | ||
return isset($data['txid']) && ($data['txaction'] ?? null) === 'appointed'; | ||
} | ||
} |
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